FurryChat/lib/utils/room_state_enums_extensions.dart

46 lines
1.3 KiB
Dart
Raw Normal View History

2020-01-19 14:07:42 +00:00
import 'package:famedlysdk/famedlysdk.dart';
2020-01-20 12:46:39 +00:00
import 'package:fluffychat/i18n/i18n.dart';
2020-01-19 14:07:42 +00:00
extension HistoryVisibilityDisplayString on HistoryVisibility {
2020-05-05 12:55:19 +00:00
String getLocalizedString(I18n i18n) {
2020-01-19 14:07:42 +00:00
switch (this) {
case HistoryVisibility.invited:
2020-05-05 12:55:19 +00:00
return i18n.fromTheInvitation;
2020-01-19 14:07:42 +00:00
case HistoryVisibility.joined:
2020-05-05 12:55:19 +00:00
return i18n.fromJoining;
2020-01-19 14:07:42 +00:00
case HistoryVisibility.shared:
2020-05-05 12:55:19 +00:00
return i18n.visibleForAllParticipants;
2020-01-19 14:07:42 +00:00
case HistoryVisibility.world_readable:
2020-05-05 12:55:19 +00:00
return i18n.visibleForEveryone;
2020-01-19 14:07:42 +00:00
default:
return this.toString().replaceAll("HistoryVisibility.", "");
}
}
}
extension GuestAccessDisplayString on GuestAccess {
2020-05-05 12:55:19 +00:00
String getLocalizedString(I18n i18n) {
2020-01-19 14:07:42 +00:00
switch (this) {
case GuestAccess.can_join:
2020-05-05 12:55:19 +00:00
return i18n.guestsCanJoin;
2020-01-19 14:07:42 +00:00
case GuestAccess.forbidden:
2020-05-05 12:55:19 +00:00
return i18n.guestsAreForbidden;
2020-01-19 14:07:42 +00:00
default:
return this.toString().replaceAll("GuestAccess.", "");
}
}
}
extension JoinRulesDisplayString on JoinRules {
2020-05-05 12:55:19 +00:00
String getLocalizedString(I18n i18n) {
2020-01-19 14:07:42 +00:00
switch (this) {
case JoinRules.public:
2020-05-05 12:55:19 +00:00
return i18n.anyoneCanJoin;
2020-01-19 14:07:42 +00:00
case JoinRules.invite:
2020-05-05 12:55:19 +00:00
return i18n.invitedUsersOnly;
2020-01-19 14:07:42 +00:00
default:
return this.toString().replaceAll("JoinRules.", "");
}
}
}