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

@ -25,9 +25,9 @@ class SettingsSecurityController extends State<SettingsSecurity> {
final newLock = await showTextInputDialog(
useRootNavigator: false,
context: context,
title: L10n.of(context)!.pleaseChooseAPasscode,
message: L10n.of(context)!.pleaseEnter4Digits,
cancelLabel: L10n.of(context)!.cancel,
title: L10n.of(context).pleaseChooseAPasscode,
message: L10n.of(context).pleaseEnter4Digits,
cancelLabel: L10n.of(context).cancel,
textFields: [
DialogTextField(
validator: (text) {
@ -35,7 +35,7 @@ class SettingsSecurityController extends State<SettingsSecurity> {
(text.length == 4 && int.tryParse(text)! >= 0)) {
return null;
}
return L10n.of(context)!.pleaseEnter4Digits;
return L10n.of(context).pleaseEnter4Digits;
},
keyboardType: TextInputType.number,
obscureText: true,
@ -54,10 +54,10 @@ class SettingsSecurityController extends State<SettingsSecurity> {
if (await showOkCancelAlertDialog(
useRootNavigator: false,
context: context,
title: L10n.of(context)!.warning,
message: L10n.of(context)!.deactivateAccountWarning,
okLabel: L10n.of(context)!.ok,
cancelLabel: L10n.of(context)!.cancel,
title: L10n.of(context).warning,
message: L10n.of(context).deactivateAccountWarning,
okLabel: L10n.of(context).ok,
cancelLabel: L10n.of(context).cancel,
isDestructiveAction: true,
) ==
OkCancelResult.cancel) {
@ -67,17 +67,17 @@ class SettingsSecurityController extends State<SettingsSecurity> {
final mxids = await showTextInputDialog(
useRootNavigator: false,
context: context,
title: L10n.of(context)!.confirmMatrixId,
title: L10n.of(context).confirmMatrixId,
textFields: [
DialogTextField(
validator: (text) => text == supposedMxid
? null
: L10n.of(context)!.supposedMxid(supposedMxid),
: L10n.of(context).supposedMxid(supposedMxid),
),
],
isDestructiveAction: true,
okLabel: L10n.of(context)!.delete,
cancelLabel: L10n.of(context)!.cancel,
okLabel: L10n.of(context).delete,
cancelLabel: L10n.of(context).cancel,
);
if (mxids == null || mxids.length != 1 || mxids.single != supposedMxid) {
return;
@ -85,9 +85,9 @@ class SettingsSecurityController extends State<SettingsSecurity> {
final input = await showTextInputDialog(
useRootNavigator: false,
context: context,
title: L10n.of(context)!.pleaseEnterYourPassword,
okLabel: L10n.of(context)!.ok,
cancelLabel: L10n.of(context)!.cancel,
title: L10n.of(context).pleaseEnterYourPassword,
okLabel: L10n.of(context).ok,
cancelLabel: L10n.of(context).cancel,
isDestructiveAction: true,
textFields: [
const DialogTextField(

View file

@ -21,7 +21,7 @@ class SettingsSecurityView extends StatelessWidget {
final theme = Theme.of(context);
return Scaffold(
appBar: AppBar(title: Text(L10n.of(context)!.security)),
appBar: AppBar(title: Text(L10n.of(context).security)),
body: ListTileTheme(
iconColor: theme.colorScheme.onSurface,
child: MaxWidthBody(
@ -45,7 +45,7 @@ class SettingsSecurityView extends StatelessWidget {
children: [
ListTile(
title: Text(
L10n.of(context)!.privacy,
L10n.of(context).privacy,
style: TextStyle(
color: theme.colorScheme.secondary,
fontWeight: FontWeight.bold,
@ -53,25 +53,25 @@ class SettingsSecurityView extends StatelessWidget {
),
),
SettingsSwitchListTile.adaptive(
title: L10n.of(context)!.sendTypingNotifications,
title: L10n.of(context).sendTypingNotifications,
subtitle:
L10n.of(context)!.sendTypingNotificationsDescription,
L10n.of(context).sendTypingNotificationsDescription,
onChanged: (b) => AppConfig.sendTypingNotifications = b,
storeKey: SettingKeys.sendTypingNotifications,
defaultValue: AppConfig.sendTypingNotifications,
),
SettingsSwitchListTile.adaptive(
title: L10n.of(context)!.sendReadReceipts,
subtitle: L10n.of(context)!.sendReadReceiptsDescription,
title: L10n.of(context).sendReadReceipts,
subtitle: L10n.of(context).sendReadReceiptsDescription,
onChanged: (b) => AppConfig.sendPublicReadReceipts = b,
storeKey: SettingKeys.sendPublicReadReceipts,
defaultValue: AppConfig.sendPublicReadReceipts,
),
ListTile(
trailing: const Icon(Icons.chevron_right_outlined),
title: Text(L10n.of(context)!.blockedUsers),
title: Text(L10n.of(context).blockedUsers),
subtitle: Text(
L10n.of(context)!.thereAreCountUsersBlocked(
L10n.of(context).thereAreCountUsersBlocked(
Matrix.of(context).client.ignoredUsers.length,
),
),
@ -82,15 +82,15 @@ class SettingsSecurityView extends StatelessWidget {
if (PlatformInfos.isMobile)
ListTile(
trailing: const Icon(Icons.chevron_right_outlined),
title: Text(L10n.of(context)!.appLock),
subtitle: Text(L10n.of(context)!.appLockDescription),
title: Text(L10n.of(context).appLock),
subtitle: Text(L10n.of(context).appLockDescription),
onTap: controller.setAppLockAction,
),
},
Divider(color: theme.dividerColor),
ListTile(
title: Text(
L10n.of(context)!.account,
L10n.of(context).account,
style: TextStyle(
color: theme.colorScheme.secondary,
fontWeight: FontWeight.bold,
@ -98,7 +98,7 @@ class SettingsSecurityView extends StatelessWidget {
),
),
ListTile(
title: Text(L10n.of(context)!.yourPublicKey),
title: Text(L10n.of(context).yourPublicKey),
leading: const Icon(Icons.vpn_key_outlined),
subtitle: SelectableText(
Matrix.of(context).client.fingerprintKey.beautified,
@ -110,7 +110,7 @@ class SettingsSecurityView extends StatelessWidget {
ListTile(
leading: const Icon(Icons.password_outlined),
trailing: const Icon(Icons.chevron_right_outlined),
title: Text(L10n.of(context)!.changePassword),
title: Text(L10n.of(context).changePassword),
onTap: () =>
context.go('/rooms/settings/security/password'),
),
@ -118,7 +118,7 @@ class SettingsSecurityView extends StatelessWidget {
iconColor: Colors.orange,
leading: const Icon(Icons.delete_sweep_outlined),
title: Text(
L10n.of(context)!.dehydrate,
L10n.of(context).dehydrate,
style: const TextStyle(color: Colors.orange),
),
onTap: controller.dehydrateAction,
@ -128,7 +128,7 @@ class SettingsSecurityView extends StatelessWidget {
iconColor: Colors.red,
leading: const Icon(Icons.delete_outlined),
title: Text(
L10n.of(context)!.deleteAccount,
L10n.of(context).deleteAccount,
style: const TextStyle(color: Colors.red),
),
onTap: controller.deleteAccountAction,