1
0
mirror of https://gitlab.com/comunic/comunicmobile synced 2024-11-30 00:36:28 +00:00
comunicmobile/lib/models/group.dart

68 lines
1.8 KiB
Dart
Raw Normal View History

2019-06-10 07:47:02 +00: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;
final String name;
2020-04-15 10:04:19 +00:00
final String iconURL;
2019-06-10 07:47:02 +00:00
final int numberMembers;
2020-04-15 11:56:59 +00:00
GroupMembershipLevel membershipLevel;
2019-06-10 07:47:02 +00:00
final GroupVisibilityLevel visibilityLevel;
final GroupRegistrationLevel registrationLevel;
final GroupPostCreationLevel postCreationLevel;
final String virtualDirectory;
2020-04-15 16:39:07 +00:00
bool following;
2019-06-10 07:47:02 +00:00
Group({
@required this.id,
@required this.name,
2020-04-15 10:04:19 +00:00
@required this.iconURL,
2019-06-10 07:47:02 +00: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 10:04:19 +00:00
assert(iconURL != null),
2019-06-10 07:47:02 +00: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 16:06:20 +00:00
2020-04-15 16:39:07 +00:00
bool get isAtLeastMember =>
2020-04-15 16:06:20 +00:00
membershipLevel == GroupMembershipLevel.ADMINISTRATOR ||
membershipLevel == GroupMembershipLevel.MODERATOR ||
membershipLevel == GroupMembershipLevel.MEMBER;
2020-04-16 06:52:26 +00:00
bool get canCreatePost =>
membershipLevel == GroupMembershipLevel.ADMINISTRATOR ||
membershipLevel == GroupMembershipLevel.MODERATOR ||
(membershipLevel == GroupMembershipLevel.MEMBER &&
postCreationLevel == GroupPostCreationLevel.MEMBERS);
2019-06-10 07:47:02 +00:00
}