refactor: Use non nullable localizations builder and lazy load on web
This commit is contained in:
parent
8cedd2a45a
commit
0d4b7d67cc
111 changed files with 879 additions and 883 deletions
|
|
@ -61,12 +61,12 @@ class BootstrapDialogState extends State<BootstrapDialog> {
|
|||
|
||||
String _getSecureStorageLocalizedName() {
|
||||
if (PlatformInfos.isAndroid) {
|
||||
return L10n.of(context)!.storeInAndroidKeystore;
|
||||
return L10n.of(context).storeInAndroidKeystore;
|
||||
}
|
||||
if (PlatformInfos.isIOS || PlatformInfos.isMacOS) {
|
||||
return L10n.of(context)!.storeInAppleKeyChain;
|
||||
return L10n.of(context).storeInAppleKeyChain;
|
||||
}
|
||||
return L10n.of(context)!.storeSecurlyOnThisDevice;
|
||||
return L10n.of(context).storeSecurlyOnThisDevice;
|
||||
}
|
||||
|
||||
@override
|
||||
|
|
@ -92,12 +92,12 @@ class BootstrapDialogState extends State<BootstrapDialog> {
|
|||
_wipe ??= widget.wipe;
|
||||
final buttons = <Widget>[];
|
||||
Widget body = const CircularProgressIndicator.adaptive();
|
||||
titleText = L10n.of(context)!.loadingPleaseWait;
|
||||
titleText = L10n.of(context).loadingPleaseWait;
|
||||
|
||||
if (bootstrap.newSsssKey?.recoveryKey != null &&
|
||||
_recoveryKeyStored == false) {
|
||||
final key = bootstrap.newSsssKey!.recoveryKey;
|
||||
titleText = L10n.of(context)!.recoveryKey;
|
||||
titleText = L10n.of(context).recoveryKey;
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
centerTitle: true,
|
||||
|
|
@ -105,7 +105,7 @@ class BootstrapDialogState extends State<BootstrapDialog> {
|
|||
icon: const Icon(Icons.close),
|
||||
onPressed: Navigator.of(context).pop,
|
||||
),
|
||||
title: Text(L10n.of(context)!.recoveryKey),
|
||||
title: Text(L10n.of(context).recoveryKey),
|
||||
),
|
||||
body: Center(
|
||||
child: ConstrainedBox(
|
||||
|
|
@ -123,7 +123,7 @@ class BootstrapDialogState extends State<BootstrapDialog> {
|
|||
color: theme.colorScheme.primary,
|
||||
),
|
||||
),
|
||||
subtitle: Text(L10n.of(context)!.chatBackupDescription),
|
||||
subtitle: Text(L10n.of(context).chatBackupDescription),
|
||||
),
|
||||
const Divider(
|
||||
height: 32,
|
||||
|
|
@ -153,7 +153,7 @@ class BootstrapDialogState extends State<BootstrapDialog> {
|
|||
},
|
||||
title: Text(_getSecureStorageLocalizedName()),
|
||||
subtitle:
|
||||
Text(L10n.of(context)!.storeInSecureStorageDescription),
|
||||
Text(L10n.of(context).storeInSecureStorageDescription),
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
CheckboxListTile.adaptive(
|
||||
|
|
@ -164,13 +164,13 @@ class BootstrapDialogState extends State<BootstrapDialog> {
|
|||
FluffyShare.share(key!, context);
|
||||
setState(() => _recoveryKeyCopied = true);
|
||||
},
|
||||
title: Text(L10n.of(context)!.copyToClipboard),
|
||||
subtitle: Text(L10n.of(context)!.saveKeyManuallyDescription),
|
||||
title: Text(L10n.of(context).copyToClipboard),
|
||||
subtitle: Text(L10n.of(context).saveKeyManuallyDescription),
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
ElevatedButton.icon(
|
||||
icon: const Icon(Icons.check_outlined),
|
||||
label: Text(L10n.of(context)!.next),
|
||||
label: Text(L10n.of(context).next),
|
||||
onPressed:
|
||||
(_recoveryKeyCopied || _storeInSecureStorage == true)
|
||||
? () {
|
||||
|
|
@ -227,7 +227,7 @@ class BootstrapDialogState extends State<BootstrapDialog> {
|
|||
icon: const Icon(Icons.close),
|
||||
onPressed: Navigator.of(context).pop,
|
||||
),
|
||||
title: Text(L10n.of(context)!.chatBackup),
|
||||
title: Text(L10n.of(context).chatBackup),
|
||||
),
|
||||
body: Center(
|
||||
child: ConstrainedBox(
|
||||
|
|
@ -245,7 +245,7 @@ class BootstrapDialogState extends State<BootstrapDialog> {
|
|||
color: theme.colorScheme.primary,
|
||||
),
|
||||
subtitle: Text(
|
||||
L10n.of(context)!.pleaseEnterRecoveryKeyDescription,
|
||||
L10n.of(context).pleaseEnterRecoveryKeyDescription,
|
||||
),
|
||||
),
|
||||
const Divider(height: 32),
|
||||
|
|
@ -265,7 +265,7 @@ class BootstrapDialogState extends State<BootstrapDialog> {
|
|||
fontFamily: theme.textTheme.bodyLarge?.fontFamily,
|
||||
),
|
||||
prefixIcon: const Icon(Icons.key_outlined),
|
||||
labelText: L10n.of(context)!.recoveryKey,
|
||||
labelText: L10n.of(context).recoveryKey,
|
||||
hintText: 'Es** **** **** ****',
|
||||
errorText: _recoveryKeyInputError,
|
||||
errorMaxLines: 2,
|
||||
|
|
@ -280,7 +280,7 @@ class BootstrapDialogState extends State<BootstrapDialog> {
|
|||
icon: _recoveryKeyInputLoading
|
||||
? const CircularProgressIndicator.adaptive()
|
||||
: const Icon(Icons.lock_open_outlined),
|
||||
label: Text(L10n.of(context)!.unlockOldMessages),
|
||||
label: Text(L10n.of(context).unlockOldMessages),
|
||||
onPressed: _recoveryKeyInputLoading
|
||||
? null
|
||||
: () async {
|
||||
|
|
@ -323,7 +323,7 @@ class BootstrapDialogState extends State<BootstrapDialog> {
|
|||
} on FormatException catch (_) {
|
||||
setState(
|
||||
() => _recoveryKeyInputError =
|
||||
L10n.of(context)!.wrongRecoveryKey,
|
||||
L10n.of(context).wrongRecoveryKey,
|
||||
);
|
||||
} catch (e, s) {
|
||||
ErrorReporter(
|
||||
|
|
@ -347,7 +347,7 @@ class BootstrapDialogState extends State<BootstrapDialog> {
|
|||
const Expanded(child: Divider()),
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(12.0),
|
||||
child: Text(L10n.of(context)!.or),
|
||||
child: Text(L10n.of(context).or),
|
||||
),
|
||||
const Expanded(child: Divider()),
|
||||
],
|
||||
|
|
@ -355,17 +355,17 @@ class BootstrapDialogState extends State<BootstrapDialog> {
|
|||
const SizedBox(height: 16),
|
||||
ElevatedButton.icon(
|
||||
icon: const Icon(Icons.cast_connected_outlined),
|
||||
label: Text(L10n.of(context)!.transferFromAnotherDevice),
|
||||
label: Text(L10n.of(context).transferFromAnotherDevice),
|
||||
onPressed: _recoveryKeyInputLoading
|
||||
? null
|
||||
: () async {
|
||||
final consent = await showOkCancelAlertDialog(
|
||||
context: context,
|
||||
title: L10n.of(context)!.verifyOtherDevice,
|
||||
message: L10n.of(context)!
|
||||
title: L10n.of(context).verifyOtherDevice,
|
||||
message: L10n.of(context)
|
||||
.verifyOtherDeviceDescription,
|
||||
okLabel: L10n.of(context)!.ok,
|
||||
cancelLabel: L10n.of(context)!.cancel,
|
||||
okLabel: L10n.of(context).ok,
|
||||
cancelLabel: L10n.of(context).cancel,
|
||||
fullyCapitalizedForMaterial: false,
|
||||
);
|
||||
if (consent != OkCancelResult.ok) return;
|
||||
|
|
@ -391,7 +391,7 @@ class BootstrapDialogState extends State<BootstrapDialog> {
|
|||
foregroundColor: theme.colorScheme.onErrorContainer,
|
||||
),
|
||||
icon: const Icon(Icons.delete_outlined),
|
||||
label: Text(L10n.of(context)!.recoveryKeyLost),
|
||||
label: Text(L10n.of(context).recoveryKeyLost),
|
||||
onPressed: _recoveryKeyInputLoading
|
||||
? null
|
||||
: () async {
|
||||
|
|
@ -399,10 +399,10 @@ class BootstrapDialogState extends State<BootstrapDialog> {
|
|||
await showOkCancelAlertDialog(
|
||||
useRootNavigator: false,
|
||||
context: context,
|
||||
title: L10n.of(context)!.recoveryKeyLost,
|
||||
message: L10n.of(context)!.wipeChatBackup,
|
||||
okLabel: L10n.of(context)!.ok,
|
||||
cancelLabel: L10n.of(context)!.cancel,
|
||||
title: L10n.of(context).recoveryKeyLost,
|
||||
message: L10n.of(context).wipeChatBackup,
|
||||
okLabel: L10n.of(context).ok,
|
||||
cancelLabel: L10n.of(context).cancel,
|
||||
isDestructiveAction: true,
|
||||
)) {
|
||||
setState(() => _createBootstrap(true));
|
||||
|
|
@ -440,18 +440,18 @@ class BootstrapDialogState extends State<BootstrapDialog> {
|
|||
);
|
||||
break;
|
||||
case BootstrapState.error:
|
||||
titleText = L10n.of(context)!.oopsSomethingWentWrong;
|
||||
titleText = L10n.of(context).oopsSomethingWentWrong;
|
||||
body = const Icon(Icons.error_outline, color: Colors.red, size: 80);
|
||||
buttons.add(
|
||||
OutlinedButton(
|
||||
onPressed: () =>
|
||||
Navigator.of(context, rootNavigator: false).pop<bool>(false),
|
||||
child: Text(L10n.of(context)!.close),
|
||||
child: Text(L10n.of(context).close),
|
||||
),
|
||||
);
|
||||
break;
|
||||
case BootstrapState.done:
|
||||
titleText = L10n.of(context)!.everythingReady;
|
||||
titleText = L10n.of(context).everythingReady;
|
||||
body = Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
|
|
@ -462,7 +462,7 @@ class BootstrapDialogState extends State<BootstrapDialog> {
|
|||
),
|
||||
const SizedBox(height: 16),
|
||||
Text(
|
||||
L10n.of(context)!.yourChatBackupHasBeenSetUp,
|
||||
L10n.of(context).yourChatBackupHasBeenSetUp,
|
||||
style: const TextStyle(fontSize: 20),
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
|
|
@ -472,7 +472,7 @@ class BootstrapDialogState extends State<BootstrapDialog> {
|
|||
OutlinedButton(
|
||||
onPressed: () =>
|
||||
Navigator.of(context, rootNavigator: false).pop<bool>(false),
|
||||
child: Text(L10n.of(context)!.close),
|
||||
child: Text(L10n.of(context).close),
|
||||
),
|
||||
);
|
||||
break;
|
||||
|
|
@ -487,7 +487,7 @@ class BootstrapDialogState extends State<BootstrapDialog> {
|
|||
Navigator.of(context, rootNavigator: false).pop<bool>(true),
|
||||
),
|
||||
),
|
||||
title: Text(titleText ?? L10n.of(context)!.loadingPleaseWait),
|
||||
title: Text(titleText ?? L10n.of(context).loadingPleaseWait),
|
||||
),
|
||||
body: Center(
|
||||
child: Column(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue