FurryChat/lib/utils/room_state_enums_extensions.dart

47 lines
1.4 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
import 'package:flutter/material.dart';
extension HistoryVisibilityDisplayString on HistoryVisibility {
String getLocalizedString(BuildContext context) {
switch (this) {
case HistoryVisibility.invited:
2020-01-20 12:46:39 +00:00
return I18n.of(context).fromTheInvitation;
2020-01-19 14:07:42 +00:00
case HistoryVisibility.joined:
2020-01-20 12:46:39 +00:00
return I18n.of(context).fromJoining;
2020-01-19 14:07:42 +00:00
case HistoryVisibility.shared:
2020-01-20 12:46:39 +00:00
return I18n.of(context).visibleForAllParticipants;
2020-01-19 14:07:42 +00:00
case HistoryVisibility.world_readable:
2020-01-20 12:46:39 +00:00
return I18n.of(context).visibleForEveryone;
2020-01-19 14:07:42 +00:00
default:
return this.toString().replaceAll("HistoryVisibility.", "");
}
}
}
extension GuestAccessDisplayString on GuestAccess {
String getLocalizedString(BuildContext context) {
switch (this) {
case GuestAccess.can_join:
2020-01-20 12:46:39 +00:00
return I18n.of(context).guestsCanJoin;
2020-01-19 14:07:42 +00:00
case GuestAccess.forbidden:
2020-01-20 12:46:39 +00:00
return I18n.of(context).guestsAreForbidden;
2020-01-19 14:07:42 +00:00
default:
return this.toString().replaceAll("GuestAccess.", "");
}
}
}
extension JoinRulesDisplayString on JoinRules {
String getLocalizedString(BuildContext context) {
switch (this) {
case JoinRules.public:
2020-01-20 12:46:39 +00:00
return I18n.of(context).anyoneCanJoin;
2020-01-19 14:07:42 +00:00
case JoinRules.invite:
2020-01-20 12:46:39 +00:00
return I18n.of(context).invitedUsersOnly;
2020-01-19 14:07:42 +00:00
default:
return this.toString().replaceAll("JoinRules.", "");
}
}
}