1
0
mirror of https://gitlab.com/comunic/comunicmobile synced 2025-01-29 21:23:00 +00:00
comunicmobile/lib/models/group.dart

74 lines
2.0 KiB
Dart
Raw Normal View History

2019-06-10 09:47:02 +02:00
import 'package:meta/meta.dart';
/// Group information
///
/// @author Pierre HUBERT
enum GroupMembershipLevel {
ADMINISTRATOR,
MODERATOR,
MEMBER,
INVITED,
PENDING,
VISITOR
}
enum GroupVisibilityLevel { OPEN, PRIVATE, SECRETE }
enum GroupRegistrationLevel { OPEN, MODERATED, CLOSED }
enum GroupPostCreationLevel { MODERATORS, MEMBERS }
class Group {
final int id;
2020-05-01 15:39:54 +02:00
String name;
2020-04-15 12:04:19 +02:00
final String iconURL;
2019-06-10 09:47:02 +02:00
final int numberMembers;
2020-04-15 13:56:59 +02:00
GroupMembershipLevel membershipLevel;
2020-05-01 20:52:24 +02:00
GroupVisibilityLevel visibilityLevel;
2020-05-01 21:04:50 +02:00
GroupRegistrationLevel registrationLevel;
2020-05-01 21:13:31 +02:00
GroupPostCreationLevel postCreationLevel;
2020-05-01 20:10:25 +02:00
String virtualDirectory;
2020-04-15 18:39:07 +02:00
bool following;
2019-06-10 09:47:02 +02:00
Group({
@required this.id,
@required this.name,
2020-04-15 12:04:19 +02:00
@required this.iconURL,
2019-06-10 09:47:02 +02:00
@required this.numberMembers,
@required this.membershipLevel,
@required this.visibilityLevel,
@required this.registrationLevel,
@required this.postCreationLevel,
@required this.virtualDirectory,
@required this.following,
}) : assert(id != null),
assert(name != null),
2020-04-15 12:04:19 +02:00
assert(iconURL != null),
2019-06-10 09:47:02 +02:00
assert(numberMembers != null),
assert(membershipLevel != null),
assert(visibilityLevel != null),
assert(registrationLevel != null),
assert(postCreationLevel != null),
assert(following != null);
get displayName => this.name;
2020-04-15 18:06:20 +02:00
2020-04-15 18:39:07 +02:00
bool get isAtLeastMember =>
2020-04-15 18:06:20 +02:00
membershipLevel == GroupMembershipLevel.ADMINISTRATOR ||
membershipLevel == GroupMembershipLevel.MODERATOR ||
membershipLevel == GroupMembershipLevel.MEMBER;
2020-04-16 08:52:26 +02:00
2020-05-01 15:12:55 +02:00
bool get isAdmin => membershipLevel == GroupMembershipLevel.ADMINISTRATOR;
bool get isAtLeastModerator =>
membershipLevel == GroupMembershipLevel.ADMINISTRATOR ||
membershipLevel == GroupMembershipLevel.MODERATOR;
2020-04-16 08:52:26 +02:00
bool get canCreatePost =>
membershipLevel == GroupMembershipLevel.ADMINISTRATOR ||
membershipLevel == GroupMembershipLevel.MODERATOR ||
(membershipLevel == GroupMembershipLevel.MEMBER &&
postCreationLevel == GroupPostCreationLevel.MEMBERS);
2019-06-10 09:47:02 +02:00
}