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

@ -98,22 +98,22 @@ class UserBottomSheetController extends State<UserBottomSheet> {
final score = await showConfirmationDialog<int>(
context: context,
title: L10n.of(context)!.reportUser,
message: L10n.of(context)!.howOffensiveIsThisContent,
cancelLabel: L10n.of(context)!.cancel,
okLabel: L10n.of(context)!.ok,
title: L10n.of(context).reportUser,
message: L10n.of(context).howOffensiveIsThisContent,
cancelLabel: L10n.of(context).cancel,
okLabel: L10n.of(context).ok,
actions: [
AlertDialogAction(
key: -100,
label: L10n.of(context)!.extremeOffensive,
label: L10n.of(context).extremeOffensive,
),
AlertDialogAction(
key: -50,
label: L10n.of(context)!.offensive,
label: L10n.of(context).offensive,
),
AlertDialogAction(
key: 0,
label: L10n.of(context)!.inoffensive,
label: L10n.of(context).inoffensive,
),
],
);
@ -121,10 +121,10 @@ class UserBottomSheetController extends State<UserBottomSheet> {
final reason = await showTextInputDialog(
useRootNavigator: false,
context: context,
title: L10n.of(context)!.whyDoYouWantToReportThis,
okLabel: L10n.of(context)!.ok,
cancelLabel: L10n.of(context)!.cancel,
textFields: [DialogTextField(hintText: L10n.of(context)!.reason)],
title: L10n.of(context).whyDoYouWantToReportThis,
okLabel: L10n.of(context).ok,
cancelLabel: L10n.of(context).cancel,
textFields: [DialogTextField(hintText: L10n.of(context).reason)],
);
if (reason == null || reason.single.isEmpty) return;
@ -139,7 +139,7 @@ class UserBottomSheetController extends State<UserBottomSheet> {
);
if (result.error != null) return;
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(content: Text(L10n.of(context)!.contentHasBeenReported)),
SnackBar(content: Text(L10n.of(context).contentHasBeenReported)),
);
break;
case UserBottomSheetAction.mention:
@ -152,10 +152,10 @@ class UserBottomSheetController extends State<UserBottomSheet> {
if (await showOkCancelAlertDialog(
useRootNavigator: false,
context: context,
title: L10n.of(context)!.areYouSure,
okLabel: L10n.of(context)!.yes,
cancelLabel: L10n.of(context)!.no,
message: L10n.of(context)!.banUserDescription,
title: L10n.of(context).areYouSure,
okLabel: L10n.of(context).yes,
cancelLabel: L10n.of(context).no,
message: L10n.of(context).banUserDescription,
) ==
OkCancelResult.ok) {
await showFutureLoadingDialog(
@ -170,10 +170,10 @@ class UserBottomSheetController extends State<UserBottomSheet> {
if (await showOkCancelAlertDialog(
useRootNavigator: false,
context: context,
title: L10n.of(context)!.areYouSure,
okLabel: L10n.of(context)!.yes,
cancelLabel: L10n.of(context)!.no,
message: L10n.of(context)!.unbanUserDescription,
title: L10n.of(context).areYouSure,
okLabel: L10n.of(context).yes,
cancelLabel: L10n.of(context).no,
message: L10n.of(context).unbanUserDescription,
) ==
OkCancelResult.ok) {
await showFutureLoadingDialog(
@ -188,10 +188,10 @@ class UserBottomSheetController extends State<UserBottomSheet> {
if (await showOkCancelAlertDialog(
useRootNavigator: false,
context: context,
title: L10n.of(context)!.areYouSure,
okLabel: L10n.of(context)!.yes,
cancelLabel: L10n.of(context)!.no,
message: L10n.of(context)!.kickUserDescription,
title: L10n.of(context).areYouSure,
okLabel: L10n.of(context).yes,
cancelLabel: L10n.of(context).no,
message: L10n.of(context).kickUserDescription,
) ==
OkCancelResult.ok) {
await showFutureLoadingDialog(
@ -300,10 +300,10 @@ class UserBottomSheetController extends State<UserBottomSheet> {
final consent = await showOkCancelAlertDialog(
useRootNavigator: false,
context: context,
title: L10n.of(context)!.areYouSure,
okLabel: L10n.of(context)!.yes,
cancelLabel: L10n.of(context)!.no,
message: L10n.of(context)!.makeAdminDescription,
title: L10n.of(context).areYouSure,
okLabel: L10n.of(context).yes,
cancelLabel: L10n.of(context).no,
message: L10n.of(context).makeAdminDescription,
);
if (consent != OkCancelResult.ok) return;
}

View file

@ -79,7 +79,7 @@ class UserBottomSheetView extends StatelessWidget {
title: Padding(
padding: const EdgeInsets.only(bottom: 12.0),
child: Text(
L10n.of(context)!
L10n.of(context)
.userWouldLikeToChangeTheChat(displayname),
),
),
@ -92,7 +92,7 @@ class UserBottomSheetView extends StatelessWidget {
),
onPressed: controller.knockAccept,
icon: const Icon(Icons.check_outlined),
label: Text(L10n.of(context)!.accept),
label: Text(L10n.of(context).accept),
),
const SizedBox(width: 12),
TextButton.icon(
@ -104,7 +104,7 @@ class UserBottomSheetView extends StatelessWidget {
),
onPressed: controller.knockDecline,
icon: const Icon(Icons.cancel_outlined),
label: Text(L10n.of(context)!.decline),
label: Text(L10n.of(context).decline),
),
],
),
@ -181,13 +181,13 @@ class UserBottomSheetView extends StatelessWidget {
const SizedBox(width: 12),
if (presence.currentlyActive == true)
Text(
L10n.of(context)!.currentlyActive,
L10n.of(context).currentlyActive,
overflow: TextOverflow.ellipsis,
style: theme.textTheme.bodySmall,
)
else if (lastActiveTimestamp != null)
Text(
L10n.of(context)!.lastActiveAgo(
L10n.of(context).lastActiveAgo(
lastActiveTimestamp
.localizedTimeShort(context),
),
@ -238,7 +238,7 @@ class UserBottomSheetView extends StatelessWidget {
UserBottomSheetAction.message,
),
icon: const Icon(Icons.chat_outlined),
label: Text(L10n.of(context)!.startConversation),
label: Text(L10n.of(context).startConversation),
)
: TextField(
controller: controller.sendController,
@ -250,7 +250,7 @@ class UserBottomSheetView extends StatelessWidget {
decoration: InputDecoration(
errorText: controller.sendError
?.toLocalizedString(context),
hintText: L10n.of(context)!.sendMessages,
hintText: L10n.of(context).sendMessages,
suffix: controller.isSending
? const SizedBox(
width: 16,
@ -272,7 +272,7 @@ class UserBottomSheetView extends StatelessWidget {
if (controller.widget.onMention != null)
ListTile(
leading: const Icon(Icons.alternate_email_outlined),
title: Text(L10n.of(context)!.mention),
title: Text(L10n.of(context).mention),
onTap: () => controller
.participantAction(UserBottomSheetAction.mention),
),
@ -280,7 +280,7 @@ class UserBottomSheetView extends StatelessWidget {
Divider(color: theme.dividerColor),
ListTile(
title: Text(
'${L10n.of(context)!.userRole} (${user.powerLevel})',
'${L10n.of(context).userRole} (${user.powerLevel})',
),
leading: const Icon(Icons.person_outlined),
trailing: Material(
@ -304,19 +304,19 @@ class UserBottomSheetView extends StatelessWidget {
items: [
DropdownMenuItem(
value: 0,
child: Text(L10n.of(context)!.user),
child: Text(L10n.of(context).user),
),
DropdownMenuItem(
value: 50,
child: Text(L10n.of(context)!.moderator),
child: Text(L10n.of(context).moderator),
),
DropdownMenuItem(
value: 100,
child: Text(L10n.of(context)!.admin),
child: Text(L10n.of(context).admin),
),
DropdownMenuItem(
value: null,
child: Text(L10n.of(context)!.custom),
child: Text(L10n.of(context).custom),
),
],
),
@ -328,7 +328,7 @@ class UserBottomSheetView extends StatelessWidget {
ListTile(
textColor: theme.colorScheme.error,
iconColor: theme.colorScheme.error,
title: Text(L10n.of(context)!.kickFromChat),
title: Text(L10n.of(context).kickFromChat),
leading: const Icon(Icons.exit_to_app_outlined),
onTap: () => controller
.participantAction(UserBottomSheetAction.kick),
@ -339,7 +339,7 @@ class UserBottomSheetView extends StatelessWidget {
ListTile(
textColor: theme.colorScheme.onErrorContainer,
iconColor: theme.colorScheme.onErrorContainer,
title: Text(L10n.of(context)!.banFromChat),
title: Text(L10n.of(context).banFromChat),
leading: const Icon(Icons.warning_sharp),
onTap: () =>
controller.participantAction(UserBottomSheetAction.ban),
@ -348,7 +348,7 @@ class UserBottomSheetView extends StatelessWidget {
user.canBan &&
user.membership == Membership.ban)
ListTile(
title: Text(L10n.of(context)!.unbanFromChat),
title: Text(L10n.of(context).unbanFromChat),
leading: const Icon(Icons.warning_outlined),
onTap: () => controller
.participantAction(UserBottomSheetAction.unban),
@ -357,7 +357,7 @@ class UserBottomSheetView extends StatelessWidget {
ListTile(
textColor: theme.colorScheme.onErrorContainer,
iconColor: theme.colorScheme.onErrorContainer,
title: Text(L10n.of(context)!.reportUser),
title: Text(L10n.of(context).reportUser),
leading: const Icon(Icons.gavel_outlined),
onTap: () => controller
.participantAction(UserBottomSheetAction.report),
@ -369,7 +369,7 @@ class UserBottomSheetView extends StatelessWidget {
color: Colors.orange,
),
subtitle: Text(
L10n.of(context)!.profileNotFound,
L10n.of(context).profileNotFound,
style: const TextStyle(color: Colors.orange),
),
),
@ -379,7 +379,7 @@ class UserBottomSheetView extends StatelessWidget {
textColor: theme.colorScheme.onErrorContainer,
iconColor: theme.colorScheme.onErrorContainer,
leading: const Icon(Icons.block_outlined),
title: Text(L10n.of(context)!.block),
title: Text(L10n.of(context).block),
onTap: () => controller
.participantAction(UserBottomSheetAction.ignore),
),