mirror of
https://gitlab.com/mysocialportal/relatica
synced 2024-10-19 16:23:37 +00:00
69 lines
1.6 KiB
Dart
69 lines
1.6 KiB
Dart
enum VisibilityType {
|
|
public,
|
|
private,
|
|
;
|
|
|
|
String toLabel() {
|
|
switch (this) {
|
|
case VisibilityType.public:
|
|
return 'Public';
|
|
case VisibilityType.private:
|
|
return 'Private';
|
|
}
|
|
}
|
|
}
|
|
|
|
class Visibility {
|
|
final VisibilityType type;
|
|
|
|
final List<String> allowedUserIds;
|
|
|
|
final List<String> excludedUserIds;
|
|
|
|
final List<String> allowedGroupIds;
|
|
|
|
final List<String> excludedGroupIds;
|
|
|
|
bool get hasDetails =>
|
|
allowedUserIds.isNotEmpty ||
|
|
excludedUserIds.isNotEmpty ||
|
|
allowedGroupIds.isNotEmpty ||
|
|
excludedGroupIds.isNotEmpty;
|
|
|
|
const Visibility({
|
|
required this.type,
|
|
this.allowedUserIds = const [],
|
|
this.excludedUserIds = const [],
|
|
this.allowedGroupIds = const [],
|
|
this.excludedGroupIds = const [],
|
|
});
|
|
|
|
factory Visibility.public() =>
|
|
const Visibility(
|
|
type: VisibilityType.public,
|
|
);
|
|
|
|
factory Visibility.private() =>
|
|
const Visibility(
|
|
type: VisibilityType.private,
|
|
);
|
|
|
|
@override
|
|
bool operator ==(Object other) =>
|
|
identical(this, other) ||
|
|
other is Visibility &&
|
|
runtimeType == other.runtimeType &&
|
|
type == other.type &&
|
|
allowedUserIds == other.allowedUserIds &&
|
|
excludedUserIds == other.excludedUserIds &&
|
|
allowedGroupIds == other.allowedGroupIds &&
|
|
excludedGroupIds == other.excludedGroupIds;
|
|
|
|
@override
|
|
int get hashCode =>
|
|
type.hashCode ^
|
|
allowedUserIds.hashCode ^
|
|
excludedUserIds.hashCode ^
|
|
allowedGroupIds.hashCode ^
|
|
excludedGroupIds.hashCode;
|
|
}
|