refactor: Use non nullable localizations builder and lazy load on web

This commit is contained in:
krille-chan 2024-10-06 08:35:37 +02:00
commit 0d4b7d67cc
No known key found for this signature in database
111 changed files with 879 additions and 883 deletions

View file

@ -31,7 +31,7 @@ class ChatPermissionsSettingsController extends State<ChatPermissionsSettings> {
final room = Matrix.of(context).client.getRoomById(roomId!)!;
if (!room.canSendEvent(EventTypes.RoomPowerLevels)) {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(content: Text(L10n.of(context)!.noPermission)),
SnackBar(content: Text(L10n.of(context).noPermission)),
);
return;
}

View file

@ -20,7 +20,7 @@ class ChatPermissionsSettingsView extends StatelessWidget {
return Scaffold(
appBar: AppBar(
leading: const Center(child: BackButton()),
title: Text(L10n.of(context)!.chatPermissions),
title: Text(L10n.of(context).chatPermissions),
),
body: MaxWidthBody(
child: StreamBuilder(
@ -31,7 +31,7 @@ class ChatPermissionsSettingsView extends StatelessWidget {
? null
: Matrix.of(context).client.getRoomById(roomId);
if (room == null) {
return Center(child: Text(L10n.of(context)!.noRoomsFound));
return Center(child: Text(L10n.of(context).noRoomsFound));
}
final powerLevelsContent = Map<String, Object?>.from(
room.getState(EventTypes.RoomPowerLevels)?.content ?? {},
@ -46,13 +46,13 @@ class ChatPermissionsSettingsView extends StatelessWidget {
ListTile(
leading: const Icon(Icons.info_outlined),
subtitle: Text(
L10n.of(context)!.chatPermissionsDescription,
L10n.of(context).chatPermissionsDescription,
),
),
Divider(color: theme.dividerColor),
ListTile(
title: Text(
L10n.of(context)!.chatPermissions,
L10n.of(context).chatPermissions,
style: TextStyle(
color: theme.colorScheme.primary,
fontWeight: FontWeight.bold,
@ -77,7 +77,7 @@ class ChatPermissionsSettingsView extends StatelessWidget {
Divider(color: theme.dividerColor),
ListTile(
title: Text(
L10n.of(context)!.notifications,
L10n.of(context).notifications,
style: TextStyle(
color: theme.colorScheme.primary,
fontWeight: FontWeight.bold,
@ -112,7 +112,7 @@ class ChatPermissionsSettingsView extends StatelessWidget {
Divider(color: theme.dividerColor),
ListTile(
title: Text(
L10n.of(context)!.configureChat,
L10n.of(context).configureChat,
style: TextStyle(
color: theme.colorScheme.primary,
fontWeight: FontWeight.bold,

View file

@ -25,45 +25,45 @@ class PermissionsListTile extends StatelessWidget {
if (category == null) {
switch (permissionKey) {
case 'users_default':
return L10n.of(context)!.defaultPermissionLevel;
return L10n.of(context).defaultPermissionLevel;
case 'events_default':
return L10n.of(context)!.sendMessages;
return L10n.of(context).sendMessages;
case 'state_default':
return L10n.of(context)!.changeGeneralChatSettings;
return L10n.of(context).changeGeneralChatSettings;
case 'ban':
return L10n.of(context)!.banFromChat;
return L10n.of(context).banFromChat;
case 'kick':
return L10n.of(context)!.kickFromChat;
return L10n.of(context).kickFromChat;
case 'redact':
return L10n.of(context)!.deleteMessage;
return L10n.of(context).deleteMessage;
case 'invite':
return L10n.of(context)!.inviteOtherUsers;
return L10n.of(context).inviteOtherUsers;
}
} else if (category == 'notifications') {
switch (permissionKey) {
case 'rooms':
return L10n.of(context)!.sendRoomNotifications;
return L10n.of(context).sendRoomNotifications;
}
} else if (category == 'events') {
switch (permissionKey) {
case EventTypes.RoomName:
return L10n.of(context)!.changeTheNameOfTheGroup;
return L10n.of(context).changeTheNameOfTheGroup;
case EventTypes.RoomTopic:
return L10n.of(context)!.changeTheDescriptionOfTheGroup;
return L10n.of(context).changeTheDescriptionOfTheGroup;
case EventTypes.RoomPowerLevels:
return L10n.of(context)!.changeTheChatPermissions;
return L10n.of(context).changeTheChatPermissions;
case EventTypes.HistoryVisibility:
return L10n.of(context)!.changeTheVisibilityOfChatHistory;
return L10n.of(context).changeTheVisibilityOfChatHistory;
case EventTypes.RoomCanonicalAlias:
return L10n.of(context)!.changeTheCanonicalRoomAlias;
return L10n.of(context).changeTheCanonicalRoomAlias;
case EventTypes.RoomAvatar:
return L10n.of(context)!.editRoomAvatar;
return L10n.of(context).editRoomAvatar;
case EventTypes.RoomTombstone:
return L10n.of(context)!.replaceRoomWithNewerVersion;
return L10n.of(context).replaceRoomWithNewerVersion;
case EventTypes.Encryption:
return L10n.of(context)!.enableEncryption;
return L10n.of(context).enableEncryption;
case 'm.room.server_acl':
return L10n.of(context)!.editBlockedServers;
return L10n.of(context).editBlockedServers;
}
}
return permissionKey;
@ -96,13 +96,13 @@ class PermissionsListTile extends StatelessWidget {
DropdownMenuItem(
value: permission < 50 ? permission : 0,
child: Text(
L10n.of(context)!.userLevel(permission < 50 ? permission : 0),
L10n.of(context).userLevel(permission < 50 ? permission : 0),
),
),
DropdownMenuItem(
value: permission < 100 && permission >= 50 ? permission : 50,
child: Text(
L10n.of(context)!.moderatorLevel(
L10n.of(context).moderatorLevel(
permission < 100 && permission >= 50 ? permission : 50,
),
),
@ -110,13 +110,13 @@ class PermissionsListTile extends StatelessWidget {
DropdownMenuItem(
value: permission >= 100 ? permission : 100,
child: Text(
L10n.of(context)!
L10n.of(context)
.adminLevel(permission >= 100 ? permission : 100),
),
),
DropdownMenuItem(
value: null,
child: Text(L10n.of(context)!.custom),
child: Text(L10n.of(context).custom),
),
],
),