1
0
mirror of https://gitlab.com/comunic/comunicmobile synced 2024-11-22 21:09:21 +00:00
comunicmobile/lib/models/comment.dart

50 lines
1.2 KiB
Dart
Raw Normal View History

2020-04-15 17:17:29 +00:00
import 'package:comunic/enums/likes_type.dart';
2020-04-16 12:07:21 +00:00
import 'package:comunic/models/displayed_content.dart';
2019-05-18 14:04:21 +00:00
import 'package:comunic/models/like_element.dart';
2019-05-18 14:48:19 +00:00
import 'package:comunic/utils/account_utils.dart' as account;
2020-04-16 12:07:21 +00:00
import 'package:meta/meta.dart';
2019-05-16 12:52:22 +00:00
/// Comments
///
/// Contains information about a single comment
///
/// @author Pierre HUBERT
2019-05-18 14:04:21 +00:00
class Comment implements LikeElement {
2019-05-16 12:52:22 +00:00
final int id;
final int userID;
final int postID;
final int timeSent;
2020-04-16 12:07:21 +00:00
DisplayedString content;
2019-05-16 12:52:22 +00:00
final String imageURL;
2019-05-18 13:54:10 +00:00
int likes;
bool userLike;
2019-05-16 12:52:22 +00:00
Comment({
@required this.id,
@required this.userID,
@required this.postID,
@required this.timeSent,
@required this.content,
@required this.imageURL,
@required this.likes,
@required this.userLike,
}) : assert(id != null),
assert(userID != null),
assert(postID != null),
assert(timeSent != null),
assert(content != null),
assert(likes != null),
assert(userLike != null);
2020-04-16 12:07:21 +00:00
bool get hasContent =>
content != null && !content.isNull && content.length > 0;
2019-05-16 12:52:22 +00:00
bool get hasImage => imageURL != null;
2019-05-18 14:48:19 +00:00
bool get isOwner => userID == account.userID();
2020-04-15 17:17:29 +00:00
@override
LikesType get likeType => LikesType.COMMENT;
2019-05-16 12:52:22 +00:00
}