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
|
|
@ -57,7 +57,7 @@ class ChatSettingsPopupMenuState extends State<ChatSettingsPopupMenu> {
|
|||
LogicalKeyboardKey.controlLeft,
|
||||
LogicalKeyboardKey.keyI,
|
||||
},
|
||||
helpLabel: L10n.of(context)!.chatDetails,
|
||||
helpLabel: L10n.of(context).chatDetails,
|
||||
onKeysPressed: _showChatDetails,
|
||||
child: const SizedBox.shrink(),
|
||||
),
|
||||
|
|
@ -68,10 +68,10 @@ class ChatSettingsPopupMenuState extends State<ChatSettingsPopupMenu> {
|
|||
final confirmed = await showOkCancelAlertDialog(
|
||||
useRootNavigator: false,
|
||||
context: context,
|
||||
title: L10n.of(context)!.areYouSure,
|
||||
okLabel: L10n.of(context)!.ok,
|
||||
cancelLabel: L10n.of(context)!.cancel,
|
||||
message: L10n.of(context)!.archiveRoomDescription,
|
||||
title: L10n.of(context).areYouSure,
|
||||
okLabel: L10n.of(context).ok,
|
||||
cancelLabel: L10n.of(context).cancel,
|
||||
message: L10n.of(context).archiveRoomDescription,
|
||||
);
|
||||
if (confirmed == OkCancelResult.ok) {
|
||||
final success = await showFutureLoadingDialog(
|
||||
|
|
@ -113,7 +113,7 @@ class ChatSettingsPopupMenuState extends State<ChatSettingsPopupMenu> {
|
|||
children: [
|
||||
const Icon(Icons.info_outline_rounded),
|
||||
const SizedBox(width: 12),
|
||||
Text(L10n.of(context)!.chatDetails),
|
||||
Text(L10n.of(context).chatDetails),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
|
@ -124,7 +124,7 @@ class ChatSettingsPopupMenuState extends State<ChatSettingsPopupMenu> {
|
|||
children: [
|
||||
const Icon(Icons.notifications_off_outlined),
|
||||
const SizedBox(width: 12),
|
||||
Text(L10n.of(context)!.muteChat),
|
||||
Text(L10n.of(context).muteChat),
|
||||
],
|
||||
),
|
||||
)
|
||||
|
|
@ -135,7 +135,7 @@ class ChatSettingsPopupMenuState extends State<ChatSettingsPopupMenu> {
|
|||
children: [
|
||||
const Icon(Icons.notifications_on_outlined),
|
||||
const SizedBox(width: 12),
|
||||
Text(L10n.of(context)!.unmuteChat),
|
||||
Text(L10n.of(context).unmuteChat),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
|
@ -145,7 +145,7 @@ class ChatSettingsPopupMenuState extends State<ChatSettingsPopupMenu> {
|
|||
children: [
|
||||
const Icon(Icons.search_outlined),
|
||||
const SizedBox(width: 12),
|
||||
Text(L10n.of(context)!.search),
|
||||
Text(L10n.of(context).search),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
|
@ -155,7 +155,7 @@ class ChatSettingsPopupMenuState extends State<ChatSettingsPopupMenu> {
|
|||
children: [
|
||||
const Icon(Icons.delete_outlined),
|
||||
const SizedBox(width: 12),
|
||||
Text(L10n.of(context)!.leave),
|
||||
Text(L10n.of(context).leave),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
|
|
|||
|
|
@ -79,7 +79,7 @@ extension on SyncStatusUpdate {
|
|||
String toLocalizedString(BuildContext context) {
|
||||
switch (status) {
|
||||
case SyncStatus.waitingForResponse:
|
||||
return L10n.of(context)!.loadingPleaseWait;
|
||||
return L10n.of(context).loadingPleaseWait;
|
||||
case SyncStatus.error:
|
||||
return ((error?.exception ?? Object()) as Object)
|
||||
.toLocalizedString(context);
|
||||
|
|
@ -87,7 +87,7 @@ extension on SyncStatusUpdate {
|
|||
case SyncStatus.cleaningUp:
|
||||
case SyncStatus.finished:
|
||||
default:
|
||||
return L10n.of(context)!.synchronizingPleaseWait;
|
||||
return L10n.of(context).synchronizingPleaseWait;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -128,14 +128,14 @@ class _PrivacyButtons extends StatelessWidget {
|
|||
TextButton(
|
||||
onPressed: () => PlatformInfos.showDialog(context),
|
||||
child: Text(
|
||||
L10n.of(context)!.about,
|
||||
L10n.of(context).about,
|
||||
style: shadowTextStyle,
|
||||
),
|
||||
),
|
||||
TextButton(
|
||||
onPressed: () => launchUrlString(AppConfig.privacyUrl),
|
||||
child: Text(
|
||||
L10n.of(context)!.privacy,
|
||||
L10n.of(context).privacy,
|
||||
style: shadowTextStyle,
|
||||
),
|
||||
),
|
||||
|
|
|
|||
|
|
@ -37,9 +37,9 @@ extension LocalNotificationsExtension on MatrixState {
|
|||
if (room.notificationCount == 0) return;
|
||||
|
||||
final event = Event.fromJson(eventUpdate.content, room);
|
||||
final title = room.getLocalizedDisplayname(MatrixLocals(L10n.of(context)!));
|
||||
final title = room.getLocalizedDisplayname(MatrixLocals(L10n.of(context)));
|
||||
final body = await event.calcLocalizedBody(
|
||||
MatrixLocals(L10n.of(context)!),
|
||||
MatrixLocals(L10n.of(context)),
|
||||
withSenderNamePrefix:
|
||||
!room.isDirectChat || room.lastEvent?.senderId == client.userID,
|
||||
plaintextBody: true,
|
||||
|
|
@ -91,11 +91,11 @@ extension LocalNotificationsExtension on MatrixState {
|
|||
actions: [
|
||||
NotificationAction(
|
||||
DesktopNotificationActions.openChat.name,
|
||||
L10n.of(context)!.openChat,
|
||||
L10n.of(context).openChat,
|
||||
),
|
||||
NotificationAction(
|
||||
DesktopNotificationActions.seen.name,
|
||||
L10n.of(context)!.markAsRead,
|
||||
L10n.of(context).markAsRead,
|
||||
),
|
||||
],
|
||||
hints: [
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ class _LockScreenState extends State<LockScreen> {
|
|||
final enteredPin = int.tryParse(text);
|
||||
if (enteredPin == null || text.length != 4) {
|
||||
setState(() {
|
||||
_errorText = L10n.of(context)!.invalidInput;
|
||||
_errorText = L10n.of(context).invalidInput;
|
||||
});
|
||||
_textEditingController.clear();
|
||||
return;
|
||||
|
|
@ -46,7 +46,7 @@ class _LockScreenState extends State<LockScreen> {
|
|||
}
|
||||
|
||||
setState(() {
|
||||
_errorText = L10n.of(context)!.wrongPinEntered(_coolDownSeconds);
|
||||
_errorText = L10n.of(context).wrongPinEntered(_coolDownSeconds);
|
||||
_inputBlocked = true;
|
||||
});
|
||||
Future.delayed(Duration(seconds: _coolDownSeconds)).then((_) {
|
||||
|
|
@ -63,7 +63,7 @@ class _LockScreenState extends State<LockScreen> {
|
|||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: Text(L10n.of(context)!.pleaseEnterYourPin),
|
||||
title: Text(L10n.of(context).pleaseEnterYourPin),
|
||||
centerTitle: true,
|
||||
),
|
||||
extendBodyBehindAppBar: true,
|
||||
|
|
|
|||
|
|
@ -239,8 +239,8 @@ class MatrixState extends State<Matrix> with WidgetsBindingObserver {
|
|||
|
||||
void initLoadingDialog() {
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
LoadingDialog.defaultTitle = L10n.of(context)!.loadingPleaseWait;
|
||||
LoadingDialog.defaultBackLabel = L10n.of(context)!.close;
|
||||
LoadingDialog.defaultTitle = L10n.of(context).loadingPleaseWait;
|
||||
LoadingDialog.defaultBackLabel = L10n.of(context).close;
|
||||
LoadingDialog.defaultOnError =
|
||||
(e) => (e as Object?)!.toLocalizedString(context);
|
||||
});
|
||||
|
|
@ -312,7 +312,7 @@ class MatrixState extends State<Matrix> with WidgetsBindingObserver {
|
|||
context,
|
||||
).showSnackBar(
|
||||
SnackBar(
|
||||
content: Text(L10n.of(context)!.oneClientLoggedOut),
|
||||
content: Text(L10n.of(context).oneClientLoggedOut),
|
||||
),
|
||||
);
|
||||
|
||||
|
|
@ -371,13 +371,12 @@ class MatrixState extends State<Matrix> with WidgetsBindingObserver {
|
|||
context: FluffyChatApp
|
||||
.router.routerDelegate.navigatorKey.currentContext ??
|
||||
context,
|
||||
title: L10n.of(context)!.pushNotificationsNotAvailable,
|
||||
title: L10n.of(context).pushNotificationsNotAvailable,
|
||||
message: errorMsg,
|
||||
fullyCapitalizedForMaterial: false,
|
||||
okLabel: link == null
|
||||
? L10n.of(context)!.ok
|
||||
: L10n.of(context)!.learnMore,
|
||||
cancelLabel: L10n.of(context)!.doNotShowAgain,
|
||||
okLabel:
|
||||
link == null ? L10n.of(context).ok : L10n.of(context).learnMore,
|
||||
cancelLabel: L10n.of(context).doNotShowAgain,
|
||||
);
|
||||
if (result == OkCancelResult.ok && link != null) {
|
||||
launchUrlString(
|
||||
|
|
@ -495,8 +494,8 @@ class MatrixState extends State<Matrix> with WidgetsBindingObserver {
|
|||
final response = await showOkCancelAlertDialog(
|
||||
context: context,
|
||||
isDestructiveAction: true,
|
||||
title: L10n.of(context)!.dehydrate,
|
||||
message: L10n.of(context)!.dehydrateWarning,
|
||||
title: L10n.of(context).dehydrate,
|
||||
message: L10n.of(context).dehydrateWarning,
|
||||
);
|
||||
if (response != OkCancelResult.ok) {
|
||||
return;
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ Future<int?> showPermissionChooser(
|
|||
}) async {
|
||||
final customLevel = await showTextInputDialog(
|
||||
context: context,
|
||||
title: L10n.of(context)!.setPermissionsLevel,
|
||||
title: L10n.of(context).setPermissionsLevel,
|
||||
textFields: [
|
||||
DialogTextField(
|
||||
initialText: currentLevel.toString(),
|
||||
|
|
@ -18,11 +18,11 @@ Future<int?> showPermissionChooser(
|
|||
autocorrect: false,
|
||||
validator: (text) {
|
||||
if (text == null) {
|
||||
return L10n.of(context)!.pleaseEnterANumber;
|
||||
return L10n.of(context).pleaseEnterANumber;
|
||||
}
|
||||
final level = int.tryParse(text);
|
||||
if (level == null) {
|
||||
return L10n.of(context)!.pleaseEnterANumber;
|
||||
return L10n.of(context).pleaseEnterANumber;
|
||||
}
|
||||
return null;
|
||||
},
|
||||
|
|
|
|||
|
|
@ -76,7 +76,7 @@ class PublicRoomBottomSheet extends StatelessWidget {
|
|||
),
|
||||
);
|
||||
if (!query.chunk.any(_testRoom)) {
|
||||
throw (L10n.of(outerContext)!.noRoomsFound);
|
||||
throw (L10n.of(outerContext).noRoomsFound);
|
||||
}
|
||||
return query.chunk.firstWhere(_testRoom);
|
||||
}
|
||||
|
|
@ -95,7 +95,7 @@ class PublicRoomBottomSheet extends StatelessWidget {
|
|||
leading: IconButton(
|
||||
icon: const Icon(Icons.arrow_downward_outlined),
|
||||
onPressed: Navigator.of(context, rootNavigator: false).pop,
|
||||
tooltip: L10n.of(context)!.close,
|
||||
tooltip: L10n.of(context).close,
|
||||
),
|
||||
actions: [
|
||||
Padding(
|
||||
|
|
@ -170,7 +170,7 @@ class PublicRoomBottomSheet extends StatelessWidget {
|
|||
foregroundColor: theme.colorScheme.onSurface,
|
||||
),
|
||||
label: Text(
|
||||
L10n.of(context)!.countParticipants(
|
||||
L10n.of(context).countParticipants(
|
||||
profile?.numJoinedMembers ?? 0,
|
||||
),
|
||||
maxLines: 1,
|
||||
|
|
@ -192,10 +192,10 @@ class PublicRoomBottomSheet extends StatelessWidget {
|
|||
.client
|
||||
.getRoomById(chunk!.roomId) ==
|
||||
null
|
||||
? L10n.of(context)!.knock
|
||||
? L10n.of(context).knock
|
||||
: chunk?.roomType == 'm.space'
|
||||
? L10n.of(context)!.joinSpace
|
||||
: L10n.of(context)!.joinRoom,
|
||||
? L10n.of(context).joinSpace
|
||||
: L10n.of(context).joinRoom,
|
||||
),
|
||||
icon: const Icon(Icons.navigate_next),
|
||||
),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue