|
| 1 | +// ignore_for_file: use_build_context_synchronously |
| 2 | + |
| 3 | +import 'package:matrix/matrix.dart'; |
| 4 | + |
| 5 | +import '../l10n/app_localizations.dart'; |
| 6 | + |
| 7 | +extension PushRuleExtension on PushRule { |
| 8 | + String getPushRuleName(AppLocalizations l10n) => switch (ruleId) { |
| 9 | + '.m.rule.contains_user_name' => l10n.notificationRuleContainsUserName, |
| 10 | + '.m.rule.master' => l10n.notificationRuleMaster, |
| 11 | + '.m.rule.suppress_notices' => l10n.notificationRuleSuppressNotices, |
| 12 | + '.m.rule.invite_for_me' => l10n.notificationRuleInviteForMe, |
| 13 | + '.m.rule.member_event' => l10n.notificationRuleMemberEvent, |
| 14 | + '.m.rule.is_user_mention' => l10n.notificationRuleIsUserMention, |
| 15 | + '.m.rule.contains_display_name' => l10n.notificationRuleContainsDisplayName, |
| 16 | + '.m.rule.is_room_mention' => l10n.notificationRuleIsRoomMention, |
| 17 | + '.m.rule.roomnotif' => l10n.notificationRuleRoomnotif, |
| 18 | + '.m.rule.tombstone' => l10n.notificationRuleTombstone, |
| 19 | + '.m.rule.reaction' => l10n.notificationRuleReaction, |
| 20 | + '.m.rule.room_server_acl' => l10n.notificationRuleRoomServerAcl, |
| 21 | + '.m.rule.suppress_edits' => l10n.notificationRuleSuppressEdits, |
| 22 | + '.m.rule.call' => l10n.notificationRuleCall, |
| 23 | + '.m.rule.encrypted_room_one_to_one' => |
| 24 | + l10n.notificationRuleEncryptedRoomOneToOne, |
| 25 | + '.m.rule.room_one_to_one' => l10n.notificationRuleRoomOneToOne, |
| 26 | + '.m.rule.message' => l10n.notificationRuleMessage, |
| 27 | + '.m.rule.encrypted' => l10n.notificationRuleEncrypted, |
| 28 | + '.m.rule.room.server_acl' => l10n.notificationRuleServerAcl, |
| 29 | + '.im.vector.jitsi' => l10n.notificationRuleJitsi, |
| 30 | + _ => ruleId.split('.').last.replaceAll('_', ' ').capitalize(), |
| 31 | + }; |
| 32 | + |
| 33 | + String getPushRuleDescription(AppLocalizations l10n) => switch (ruleId) { |
| 34 | + '.m.rule.contains_user_name' => |
| 35 | + l10n.notificationRuleContainsUserNameDescription, |
| 36 | + '.m.rule.master' => l10n.notificationRuleMasterDescription, |
| 37 | + '.m.rule.suppress_notices' => |
| 38 | + l10n.notificationRuleSuppressNoticesDescription, |
| 39 | + '.m.rule.invite_for_me' => l10n.notificationRuleInviteForMeDescription, |
| 40 | + '.m.rule.member_event' => l10n.notificationRuleMemberEventDescription, |
| 41 | + '.m.rule.is_user_mention' => l10n.notificationRuleIsUserMentionDescription, |
| 42 | + '.m.rule.contains_display_name' => |
| 43 | + l10n.notificationRuleContainsDisplayNameDescription, |
| 44 | + '.m.rule.is_room_mention' => l10n.notificationRuleIsRoomMentionDescription, |
| 45 | + '.m.rule.roomnotif' => l10n.notificationRuleRoomnotifDescription, |
| 46 | + '.m.rule.tombstone' => l10n.notificationRuleTombstoneDescription, |
| 47 | + '.m.rule.reaction' => l10n.notificationRuleReactionDescription, |
| 48 | + '.m.rule.room_server_acl' => l10n.notificationRuleRoomServerAclDescription, |
| 49 | + '.m.rule.suppress_edits' => l10n.notificationRuleSuppressEditsDescription, |
| 50 | + '.m.rule.call' => l10n.notificationRuleCallDescription, |
| 51 | + '.m.rule.encrypted_room_one_to_one' => |
| 52 | + l10n.notificationRuleEncryptedRoomOneToOneDescription, |
| 53 | + '.m.rule.room_one_to_one' => l10n.notificationRuleRoomOneToOneDescription, |
| 54 | + '.m.rule.message' => l10n.notificationRuleMessageDescription, |
| 55 | + '.m.rule.encrypted' => l10n.notificationRuleEncryptedDescription, |
| 56 | + '.m.rule.room.server_acl' => l10n.notificationRuleServerAclDescription, |
| 57 | + '.im.vector.jitsi' => l10n.notificationRuleJitsiDescription, |
| 58 | + _ => l10n.unknownPushRule(ruleId), |
| 59 | + }; |
| 60 | +} |
| 61 | + |
| 62 | +extension PushRuleKindLocal on PushRuleKind { |
| 63 | + String localized(AppLocalizations l10n) => switch (this) { |
| 64 | + PushRuleKind.content => l10n.contentNotificationSettings, |
| 65 | + PushRuleKind.override => l10n.generalNotificationSettings, |
| 66 | + PushRuleKind.room => l10n.roomNotificationSettings, |
| 67 | + PushRuleKind.sender => l10n.userSpecificNotificationSettings, |
| 68 | + PushRuleKind.underride => l10n.otherNotificationSettings, |
| 69 | + }; |
| 70 | +} |
| 71 | + |
| 72 | +extension on String { |
| 73 | + String capitalize() => |
| 74 | + '${this[0].toUpperCase()}${substring(1).toLowerCase()}'; |
| 75 | +} |
0 commit comments