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

@ -36,9 +36,9 @@ class SettingsController extends State<Settings> {
final input = await showTextInputDialog(
useRootNavigator: false,
context: context,
title: L10n.of(context)!.editDisplayname,
okLabel: L10n.of(context)!.ok,
cancelLabel: L10n.of(context)!.cancel,
title: L10n.of(context).editDisplayname,
okLabel: L10n.of(context).ok,
cancelLabel: L10n.of(context).cancel,
textFields: [
DialogTextField(
initialText: profile?.displayName ??
@ -63,11 +63,11 @@ class SettingsController extends State<Settings> {
if (await showOkCancelAlertDialog(
useRootNavigator: false,
context: context,
title: L10n.of(context)!.areYouSureYouWantToLogout,
message: L10n.of(context)!.noBackupWarning,
title: L10n.of(context).areYouSureYouWantToLogout,
message: L10n.of(context).noBackupWarning,
isDestructiveAction: noBackup,
okLabel: L10n.of(context)!.logout,
cancelLabel: L10n.of(context)!.cancel,
okLabel: L10n.of(context).logout,
cancelLabel: L10n.of(context).cancel,
) ==
OkCancelResult.cancel) {
return;
@ -85,19 +85,19 @@ class SettingsController extends State<Settings> {
if (PlatformInfos.isMobile)
SheetAction(
key: AvatarAction.camera,
label: L10n.of(context)!.openCamera,
label: L10n.of(context).openCamera,
isDefaultAction: true,
icon: Icons.camera_alt_outlined,
),
SheetAction(
key: AvatarAction.file,
label: L10n.of(context)!.openGallery,
label: L10n.of(context).openGallery,
icon: Icons.photo_outlined,
),
if (profile?.avatarUrl != null)
SheetAction(
key: AvatarAction.remove,
label: L10n.of(context)!.removeYourAvatar,
label: L10n.of(context).removeYourAvatar,
isDestructiveAction: true,
icon: Icons.delete_outlined,
),
@ -106,7 +106,7 @@ class SettingsController extends State<Settings> {
? actions.single.key
: await showModalActionSheet<AvatarAction>(
context: context,
title: L10n.of(context)!.changeYourAvatar,
title: L10n.of(context).changeYourAvatar,
actions: actions,
);
if (action == null) return;
@ -189,9 +189,9 @@ class SettingsController extends State<Settings> {
if (showChatBackupBanner != true) {
showOkAlertDialog(
context: context,
title: L10n.of(context)!.chatBackup,
message: L10n.of(context)!.onlineKeyBackupEnabled,
okLabel: L10n.of(context)!.close,
title: L10n.of(context).chatBackup,
message: L10n.of(context).onlineKeyBackupEnabled,
okLabel: L10n.of(context).close,
);
return;
}

View file

@ -28,7 +28,7 @@ class SettingsView extends StatelessWidget {
onPressed: () => context.go('/rooms'),
),
),
title: Text(L10n.of(context)!.settings),
title: Text(L10n.of(context).settings),
),
body: ListTileTheme(
iconColor: theme.colorScheme.onSurface,
@ -40,7 +40,7 @@ class SettingsView extends StatelessWidget {
builder: (context, snapshot) {
final profile = snapshot.data;
final mxid =
Matrix.of(context).client.userID ?? L10n.of(context)!.user;
Matrix.of(context).client.userID ?? L10n.of(context).user;
final displayname =
profile?.displayName ?? mxid.localpart ?? mxid;
return Row(
@ -118,7 +118,7 @@ class SettingsView extends StatelessWidget {
if (showChatBackupBanner == null)
ListTile(
leading: const Icon(Icons.backup_outlined),
title: Text(L10n.of(context)!.chatBackup),
title: Text(L10n.of(context).chatBackup),
trailing: const CircularProgressIndicator.adaptive(),
)
else
@ -126,7 +126,7 @@ class SettingsView extends StatelessWidget {
controlAffinity: ListTileControlAffinity.trailing,
value: controller.showChatBackupBanner == false,
secondary: const Icon(Icons.backup_outlined),
title: Text(L10n.of(context)!.chatBackup),
title: Text(L10n.of(context).chatBackup),
onChanged: controller.firstRunBootstrapAction,
),
Divider(
@ -134,49 +134,49 @@ class SettingsView extends StatelessWidget {
),
ListTile(
leading: const Icon(Icons.format_paint_outlined),
title: Text(L10n.of(context)!.changeTheme),
title: Text(L10n.of(context).changeTheme),
onTap: () => context.go('/rooms/settings/style'),
),
ListTile(
leading: const Icon(Icons.notifications_outlined),
title: Text(L10n.of(context)!.notifications),
title: Text(L10n.of(context).notifications),
onTap: () => context.go('/rooms/settings/notifications'),
),
ListTile(
leading: const Icon(Icons.devices_outlined),
title: Text(L10n.of(context)!.devices),
title: Text(L10n.of(context).devices),
onTap: () => context.go('/rooms/settings/devices'),
),
ListTile(
leading: const Icon(Icons.forum_outlined),
title: Text(L10n.of(context)!.chat),
title: Text(L10n.of(context).chat),
onTap: () => context.go('/rooms/settings/chat'),
),
ListTile(
leading: const Icon(Icons.shield_outlined),
title: Text(L10n.of(context)!.security),
title: Text(L10n.of(context).security),
onTap: () => context.go('/rooms/settings/security'),
),
Divider(color: theme.dividerColor),
ListTile(
leading: const Icon(Icons.help_outline_outlined),
title: Text(L10n.of(context)!.help),
title: Text(L10n.of(context).help),
onTap: () => launchUrlString(AppConfig.supportUrl),
),
ListTile(
leading: const Icon(Icons.shield_sharp),
title: Text(L10n.of(context)!.privacy),
title: Text(L10n.of(context).privacy),
onTap: () => launchUrlString(AppConfig.privacyUrl),
),
ListTile(
leading: const Icon(Icons.info_outline_rounded),
title: Text(L10n.of(context)!.about),
title: Text(L10n.of(context).about),
onTap: () => PlatformInfos.showDialog(context),
),
Divider(color: theme.dividerColor),
ListTile(
leading: const Icon(Icons.logout_outlined),
title: Text(L10n.of(context)!.logout),
title: Text(L10n.of(context).logout),
onTap: controller.logoutAction,
),
],