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

@ -43,14 +43,14 @@ class AddWidgetTileState extends State<AddWidgetTile> {
if (name.length < 3) {
setState(() {
nameError = L10n.of(context)!.widgetNameError;
nameError = L10n.of(context).widgetNameError;
});
return;
}
if (uri == null || uri.scheme != 'https') {
setState(() {
urlError = L10n.of(context)!.widgetUrlError;
urlError = L10n.of(context).widgetUrlError;
});
return;
}
@ -75,7 +75,7 @@ class AddWidgetTileState extends State<AddWidgetTile> {
Navigator.of(context).pop();
} catch (e) {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(content: Text(L10n.of(context)!.errorAddingWidget)),
SnackBar(content: Text(L10n.of(context).errorAddingWidget)),
);
}
}

View file

@ -13,7 +13,7 @@ class AddWidgetTileView extends StatelessWidget {
@override
Widget build(BuildContext context) {
return ExpansionTile(
title: Text(L10n.of(context)!.addWidget),
title: Text(L10n.of(context).addWidget),
leading: const Icon(Icons.add),
initiallyExpanded: controller.initiallyExpanded,
children: [
@ -21,10 +21,10 @@ class AddWidgetTileView extends StatelessWidget {
groupValue: controller.widgetType,
padding: const EdgeInsets.all(8),
children: {
'm.etherpad': Text(L10n.of(context)!.widgetEtherpad),
'm.jitsi': Text(L10n.of(context)!.widgetJitsi),
'm.video': Text(L10n.of(context)!.widgetVideo),
'm.custom': Text(L10n.of(context)!.widgetCustom),
'm.etherpad': Text(L10n.of(context).widgetEtherpad),
'm.jitsi': Text(L10n.of(context).widgetJitsi),
'm.video': Text(L10n.of(context).widgetVideo),
'm.custom': Text(L10n.of(context).widgetCustom),
}.map(
(key, value) => MapEntry(
key,
@ -43,7 +43,7 @@ class AddWidgetTileView extends StatelessWidget {
autofocus: true,
decoration: InputDecoration(
prefixIcon: const Icon(Icons.label),
label: Text(L10n.of(context)!.widgetName),
label: Text(L10n.of(context).widgetName),
errorText: controller.nameError,
),
),
@ -54,7 +54,7 @@ class AddWidgetTileView extends StatelessWidget {
controller: controller.urlController,
decoration: InputDecoration(
prefixIcon: const Icon(Icons.add_link),
label: Text(L10n.of(context)!.link),
label: Text(L10n.of(context).link),
errorText: controller.urlError,
),
),
@ -63,7 +63,7 @@ class AddWidgetTileView extends StatelessWidget {
children: [
TextButton(
onPressed: controller.addWidget,
child: Text(L10n.of(context)!.addWidget),
child: Text(L10n.of(context).addWidget),
),
],
),

View file

@ -56,12 +56,11 @@ class ChatPage extends StatelessWidget {
final room = Matrix.of(context).client.getRoomById(roomId);
if (room == null) {
return Scaffold(
appBar: AppBar(title: Text(L10n.of(context)!.oopsSomethingWentWrong)),
appBar: AppBar(title: Text(L10n.of(context).oopsSomethingWentWrong)),
body: Center(
child: Padding(
padding: const EdgeInsets.all(16),
child:
Text(L10n.of(context)!.youAreNoLongerParticipatingInThisChat),
child: Text(L10n.of(context).youAreNoLongerParticipatingInThisChat),
),
),
);
@ -446,7 +445,7 @@ class ChatController extends State<ChatPageWithRoom>
final commandMatch = RegExp(r'^\/(\w+)').firstMatch(sendController.text);
if (commandMatch != null &&
!sendingClient.commands.keys.contains(commandMatch[1]!.toLowerCase())) {
final l10n = L10n.of(context)!;
final l10n = L10n.of(context);
final dialogResult = await showOkCancelAlertDialog(
context: context,
title: l10n.commandInvalid,
@ -564,9 +563,9 @@ class ChatController extends State<ChatPageWithRoom>
if (info.version.sdkInt < 19) {
showOkAlertDialog(
context: context,
title: L10n.of(context)!.unsupportedAndroidVersion,
message: L10n.of(context)!.unsupportedAndroidVersionLong,
okLabel: L10n.of(context)!.close,
title: L10n.of(context).unsupportedAndroidVersion,
message: L10n.of(context).unsupportedAndroidVersionLong,
okLabel: L10n.of(context).close,
);
return;
}
@ -646,12 +645,12 @@ class ChatController extends State<ChatPageWithRoom>
if (selectedEvents.length == 1) {
return selectedEvents.first
.getDisplayEvent(timeline!)
.calcLocalizedBodyFallback(MatrixLocals(L10n.of(context)!));
.calcLocalizedBodyFallback(MatrixLocals(L10n.of(context)));
}
for (final event in selectedEvents) {
if (copyString.isNotEmpty) copyString += '\n\n';
copyString += event.getDisplayEvent(timeline!).calcLocalizedBodyFallback(
MatrixLocals(L10n.of(context)!),
MatrixLocals(L10n.of(context)),
withSenderNamePrefix: true,
);
}
@ -670,32 +669,32 @@ class ChatController extends State<ChatPageWithRoom>
final event = selectedEvents.single;
final score = await showConfirmationDialog<int>(
context: context,
title: L10n.of(context)!.reportMessage,
message: L10n.of(context)!.howOffensiveIsThisContent,
cancelLabel: L10n.of(context)!.cancel,
okLabel: L10n.of(context)!.ok,
title: L10n.of(context).reportMessage,
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,
),
],
);
if (score == null) return;
final reason = await showTextInputDialog(
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;
final result = await showFutureLoadingDialog(
@ -713,7 +712,7 @@ class ChatController extends State<ChatPageWithRoom>
selectedEvents.clear();
});
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(content: Text(L10n.of(context)!.contentHasBeenReported)),
SnackBar(content: Text(L10n.of(context).contentHasBeenReported)),
);
}
@ -740,16 +739,16 @@ class ChatController extends State<ChatPageWithRoom>
final reasonInput = selectedEvents.any((event) => event.status.isSent)
? await showTextInputDialog(
context: context,
title: L10n.of(context)!.redactMessage,
message: L10n.of(context)!.redactMessageDescription,
title: L10n.of(context).redactMessage,
message: L10n.of(context).redactMessageDescription,
isDestructiveAction: true,
textFields: [
DialogTextField(
hintText: L10n.of(context)!.optionalRedactReason,
hintText: L10n.of(context).optionalRedactReason,
),
],
okLabel: L10n.of(context)!.remove,
cancelLabel: L10n.of(context)!.cancel,
okLabel: L10n.of(context).remove,
cancelLabel: L10n.of(context).cancel,
)
: <String>[];
if (reasonInput == null) return;
@ -1015,7 +1014,7 @@ class ChatController extends State<ChatPageWithRoom>
editEvent = selectedEvents.first;
sendController.text =
editEvent!.getDisplayEvent(timeline!).calcLocalizedBodyFallback(
MatrixLocals(L10n.of(context)!),
MatrixLocals(L10n.of(context)),
withSenderNamePrefix: false,
hideReply: true,
);
@ -1028,13 +1027,13 @@ class ChatController extends State<ChatPageWithRoom>
if (OkCancelResult.ok !=
await showOkCancelAlertDialog(
context: context,
title: L10n.of(context)!.goToTheNewRoom,
title: L10n.of(context).goToTheNewRoom,
message: room
.getState(EventTypes.RoomTombstone)!
.parsedTombstoneContent
.body,
okLabel: L10n.of(context)!.ok,
cancelLabel: L10n.of(context)!.cancel,
okLabel: L10n.of(context).ok,
cancelLabel: L10n.of(context).cancel,
)) {
return;
}
@ -1117,10 +1116,10 @@ class ChatController extends State<ChatPageWithRoom>
unpinEvent(String eventId) async {
final response = await showOkCancelAlertDialog(
context: context,
title: L10n.of(context)!.unpin,
message: L10n.of(context)!.confirmEventUnpin,
okLabel: L10n.of(context)!.unpin,
cancelLabel: L10n.of(context)!.cancel,
title: L10n.of(context).unpin,
message: L10n.of(context).confirmEventUnpin,
okLabel: L10n.of(context).unpin,
cancelLabel: L10n.of(context).cancel,
);
if (response == OkCancelResult.ok) {
final events = room.pinnedEventIds
@ -1214,26 +1213,26 @@ class ChatController extends State<ChatPageWithRoom>
Navigator.pop(context);
showOkAlertDialog(
context: context,
title: L10n.of(context)!.unsupportedAndroidVersion,
message: L10n.of(context)!.unsupportedAndroidVersionLong,
okLabel: L10n.of(context)!.close,
title: L10n.of(context).unsupportedAndroidVersion,
message: L10n.of(context).unsupportedAndroidVersionLong,
okLabel: L10n.of(context).close,
);
}
});
}
final callType = await showModalActionSheet<CallType>(
context: context,
title: L10n.of(context)!.warning,
message: L10n.of(context)!.videoCallsBetaWarning,
cancelLabel: L10n.of(context)!.cancel,
title: L10n.of(context).warning,
message: L10n.of(context).videoCallsBetaWarning,
cancelLabel: L10n.of(context).cancel,
actions: [
SheetAction(
label: L10n.of(context)!.voiceCall,
label: L10n.of(context).voiceCall,
icon: Icons.phone_outlined,
key: CallType.kVoice,
),
SheetAction(
label: L10n.of(context)!.videoCall,
label: L10n.of(context).videoCall,
icon: Icons.video_call_outlined,
key: CallType.kVideo,
),

View file

@ -36,7 +36,7 @@ class ChatAppBarTitle extends StatelessWidget {
child: Avatar(
mxContent: room.avatar,
name: room.getLocalizedDisplayname(
MatrixLocals(L10n.of(context)!),
MatrixLocals(L10n.of(context)),
),
size: 32,
),
@ -47,7 +47,7 @@ class ChatAppBarTitle extends StatelessWidget {
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
room.getLocalizedDisplayname(MatrixLocals(L10n.of(context)!)),
room.getLocalizedDisplayname(MatrixLocals(L10n.of(context))),
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: const TextStyle(
@ -63,13 +63,13 @@ class ChatAppBarTitle extends StatelessWidget {
final style = Theme.of(context).textTheme.bodySmall;
if (presence?.currentlyActive == true) {
return Text(
L10n.of(context)!.currentlyActive,
L10n.of(context).currentlyActive,
style: style,
);
}
if (lastActiveTimestamp != null) {
return Text(
L10n.of(context)!.lastActiveAgo(
L10n.of(context).lastActiveAgo(
lastActiveTimestamp.localizedTimeShort(context),
),
style: style,

View file

@ -30,8 +30,8 @@ class ChatEmojiPicker extends StatelessWidget {
children: [
TabBar(
tabs: [
Tab(text: L10n.of(context)!.emojis),
Tab(text: L10n.of(context)!.stickers),
Tab(text: L10n.of(context).emojis),
Tab(text: L10n.of(context).stickers),
],
),
Expanded(
@ -97,7 +97,7 @@ class NoRecent extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Text(
L10n.of(context)!.emoteKeyboardNoRecents,
L10n.of(context).emoteKeyboardNoRecents,
style: Theme.of(context).textTheme.bodyLarge,
);
}

View file

@ -44,7 +44,7 @@ class ChatInputRow extends StatelessWidget {
child: Row(
children: <Widget>[
const Icon(Icons.delete),
Text(L10n.of(context)!.delete),
Text(L10n.of(context).delete),
],
),
),
@ -57,7 +57,7 @@ class ChatInputRow extends StatelessWidget {
child: Row(
children: <Widget>[
const Icon(Icons.keyboard_arrow_left_outlined),
Text(L10n.of(context)!.forward),
Text(L10n.of(context).forward),
],
),
),
@ -73,7 +73,7 @@ class ChatInputRow extends StatelessWidget {
onPressed: controller.replyAction,
child: Row(
children: <Widget>[
Text(L10n.of(context)!.reply),
Text(L10n.of(context).reply),
const Icon(Icons.keyboard_arrow_right),
],
),
@ -85,7 +85,7 @@ class ChatInputRow extends StatelessWidget {
onPressed: controller.sendAgainAction,
child: Row(
children: <Widget>[
Text(L10n.of(context)!.tryToSendAgain),
Text(L10n.of(context).tryToSendAgain),
const SizedBox(width: 4),
const Icon(Icons.send_outlined, size: 16),
],
@ -103,7 +103,7 @@ class ChatInputRow extends StatelessWidget {
},
onKeysPressed: () =>
controller.onAddPopupMenuButtonSelected('file'),
helpLabel: L10n.of(context)!.sendFile,
helpLabel: L10n.of(context).sendFile,
child: AnimatedContainer(
duration: FluffyThemes.animationDuration,
curve: FluffyThemes.animationCurve,
@ -125,7 +125,7 @@ class ChatInputRow extends StatelessWidget {
foregroundColor: Colors.white,
child: Icon(Icons.attachment_outlined),
),
title: Text(L10n.of(context)!.sendFile),
title: Text(L10n.of(context).sendFile),
contentPadding: const EdgeInsets.all(0),
),
),
@ -137,7 +137,7 @@ class ChatInputRow extends StatelessWidget {
foregroundColor: Colors.white,
child: Icon(Icons.image_outlined),
),
title: Text(L10n.of(context)!.sendImage),
title: Text(L10n.of(context).sendImage),
contentPadding: const EdgeInsets.all(0),
),
),
@ -150,7 +150,7 @@ class ChatInputRow extends StatelessWidget {
foregroundColor: Colors.white,
child: Icon(Icons.camera_alt_outlined),
),
title: Text(L10n.of(context)!.openCamera),
title: Text(L10n.of(context).openCamera),
contentPadding: const EdgeInsets.all(0),
),
),
@ -163,7 +163,7 @@ class ChatInputRow extends StatelessWidget {
foregroundColor: Colors.white,
child: Icon(Icons.videocam_outlined),
),
title: Text(L10n.of(context)!.openVideoCamera),
title: Text(L10n.of(context).openVideoCamera),
contentPadding: const EdgeInsets.all(0),
),
),
@ -176,7 +176,7 @@ class ChatInputRow extends StatelessWidget {
foregroundColor: Colors.white,
child: Icon(Icons.gps_fixed_outlined),
),
title: Text(L10n.of(context)!.shareLocation),
title: Text(L10n.of(context).shareLocation),
contentPadding: const EdgeInsets.all(0),
),
),
@ -194,9 +194,9 @@ class ChatInputRow extends StatelessWidget {
LogicalKeyboardKey.keyE,
},
onKeysPressed: controller.emojiPickerAction,
helpLabel: L10n.of(context)!.emojis,
helpLabel: L10n.of(context).emojis,
child: IconButton(
tooltip: L10n.of(context)!.emojis,
tooltip: L10n.of(context).emojis,
icon: PageTransitionSwitcher(
transitionBuilder: (
Widget child,
@ -255,7 +255,7 @@ class ChatInputRow extends StatelessWidget {
bottom: 6.0,
top: 3.0,
),
hintText: L10n.of(context)!.writeAMessage,
hintText: L10n.of(context).writeAMessage,
hintMaxLines: 1,
border: InputBorder.none,
enabledBorder: InputBorder.none,
@ -272,7 +272,7 @@ class ChatInputRow extends StatelessWidget {
child: PlatformInfos.platformCanRecord &&
controller.sendController.text.isEmpty
? FloatingActionButton.small(
tooltip: L10n.of(context)!.voiceMessage,
tooltip: L10n.of(context).voiceMessage,
onPressed: controller.voiceMessageAction,
elevation: 0,
heroTag: null,
@ -284,7 +284,7 @@ class ChatInputRow extends StatelessWidget {
child: const Icon(Icons.mic_none_outlined),
)
: FloatingActionButton.small(
tooltip: L10n.of(context)!.send,
tooltip: L10n.of(context).send,
onPressed: controller.send,
elevation: 0,
heroTag: null,

View file

@ -38,12 +38,12 @@ class ChatView extends StatelessWidget {
if (controller.canEditSelectedEvents)
IconButton(
icon: const Icon(Icons.edit_outlined),
tooltip: L10n.of(context)!.edit,
tooltip: L10n.of(context).edit,
onPressed: controller.editSelectedEventAction,
),
IconButton(
icon: const Icon(Icons.copy_outlined),
tooltip: L10n.of(context)!.copy,
tooltip: L10n.of(context).copy,
onPressed: controller.copyEventsAction,
),
if (controller.canSaveSelectedEvent)
@ -51,7 +51,7 @@ class ChatView extends StatelessWidget {
Builder(
builder: (context) => IconButton(
icon: Icon(Icons.adaptive.share),
tooltip: L10n.of(context)!.share,
tooltip: L10n.of(context).share,
onPressed: () => controller.saveSelectedEvent(context),
),
),
@ -59,12 +59,12 @@ class ChatView extends StatelessWidget {
IconButton(
icon: const Icon(Icons.push_pin_outlined),
onPressed: controller.pinEvent,
tooltip: L10n.of(context)!.pinMessage,
tooltip: L10n.of(context).pinMessage,
),
if (controller.canRedactSelectedEvents)
IconButton(
icon: const Icon(Icons.delete_outlined),
tooltip: L10n.of(context)!.redactMessage,
tooltip: L10n.of(context).redactMessage,
onPressed: controller.redactEventsAction,
),
if (controller.selectedEvents.length == 1)
@ -88,7 +88,7 @@ class ChatView extends StatelessWidget {
children: [
const Icon(Icons.info_outlined),
const SizedBox(width: 12),
Text(L10n.of(context)!.messageInfo),
Text(L10n.of(context).messageInfo),
],
),
),
@ -103,7 +103,7 @@ class ChatView extends StatelessWidget {
color: Colors.red,
),
const SizedBox(width: 12),
Text(L10n.of(context)!.reportMessage),
Text(L10n.of(context).reportMessage),
],
),
),
@ -117,7 +117,7 @@ class ChatView extends StatelessWidget {
IconButton(
onPressed: controller.onPhoneButtonTap,
icon: const Icon(Icons.call_outlined),
tooltip: L10n.of(context)!.placeCall,
tooltip: L10n.of(context).placeCall,
),
EncryptionButton(controller.room),
ChatSettingsPopupMenu(controller.room, true),
@ -180,7 +180,7 @@ class ChatView extends StatelessWidget {
? IconButton(
icon: const Icon(Icons.close),
onPressed: controller.clearSelectedEvents,
tooltip: L10n.of(context)!.close,
tooltip: L10n.of(context).close,
color: theme.colorScheme.primary,
)
: StreamBuilder<Object>(
@ -213,7 +213,7 @@ class ChatView extends StatelessWidget {
),
trailing: TextButton(
onPressed: controller.goToNewRoomAction,
child: Text(L10n.of(context)!.goToTheNewRoom),
child: Text(L10n.of(context).goToTheNewRoom),
),
),
if (scrollUpBannerEventId != null)
@ -221,13 +221,13 @@ class ChatView extends StatelessWidget {
leading: IconButton(
color: theme.colorScheme.onSurfaceVariant,
icon: const Icon(Icons.close),
tooltip: L10n.of(context)!.close,
tooltip: L10n.of(context).close,
onPressed: () {
controller.discardScrollUpBannerEventId();
controller.setReadMarker();
},
),
title: L10n.of(context)!.jumpToLastReadMessage,
title: L10n.of(context).jumpToLastReadMessage,
trailing: TextButton(
onPressed: () {
controller.scrollToEventId(
@ -235,7 +235,7 @@ class ChatView extends StatelessWidget {
);
controller.discardScrollUpBannerEventId();
},
child: Text(L10n.of(context)!.jump),
child: Text(L10n.of(context).jump),
),
),
],
@ -333,7 +333,7 @@ class ChatView extends StatelessWidget {
),
onPressed: controller.leaveChat,
label: Text(
L10n.of(context)!.leave,
L10n.of(context).leave,
),
),
TextButton.icon(
@ -347,7 +347,7 @@ class ChatView extends StatelessWidget {
),
onPressed: controller.recreateChat,
label: Text(
L10n.of(context)!.reopenChat,
L10n.of(context).reopenChat,
),
),
],

View file

@ -25,8 +25,8 @@ class EncryptionButton extends StatelessWidget {
: Future.value(EncryptionHealthState.allVerified),
builder: (BuildContext context, snapshot) => IconButton(
tooltip: room.encrypted
? L10n.of(context)!.encrypted
: L10n.of(context)!.encryptionNotEnabled,
? L10n.of(context).encrypted
: L10n.of(context).encryptionNotEnabled,
icon: Icon(
room.encrypted ? Icons.lock_outlined : Icons.lock_open_outlined,
size: 20,

View file

@ -14,7 +14,7 @@ extension EventInfoDialogExtension on Event {
void showInfoDialog(BuildContext context) => showAdaptiveBottomSheet(
context: context,
builder: (context) =>
EventInfoDialog(l10n: L10n.of(context)!, event: this),
EventInfoDialog(l10n: L10n.of(context), event: this),
);
}
@ -40,11 +40,11 @@ class EventInfoDialog extends StatelessWidget {
final originalSource = event.originalSource;
return Scaffold(
appBar: AppBar(
title: Text(L10n.of(context)!.messageInfo),
title: Text(L10n.of(context).messageInfo),
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,
),
),
body: ListView(
@ -56,20 +56,20 @@ class EventInfoDialog extends StatelessWidget {
client: event.room.client,
presenceUserId: event.senderId,
),
title: Text(L10n.of(context)!.sender),
title: Text(L10n.of(context).sender),
subtitle: Text(
'${event.senderFromMemoryOrFallback.calcDisplayname()} [${event.senderId}]',
),
),
ListTile(
title: Text('${L10n.of(context)!.time}:'),
title: Text('${L10n.of(context).time}:'),
subtitle: Text(event.originServerTs.localizedTime(context)),
),
ListTile(
title: Text('${L10n.of(context)!.status}:'),
title: Text('${L10n.of(context).status}:'),
subtitle: Text(event.status.name),
),
ListTile(title: Text('${L10n.of(context)!.sourceCode}:')),
ListTile(title: Text('${L10n.of(context).sourceCode}:')),
Padding(
padding: const EdgeInsets.all(12.0),
child: Material(
@ -88,7 +88,7 @@ class EventInfoDialog extends StatelessWidget {
),
),
if (originalSource != null) ...[
ListTile(title: Text('${L10n.of(context)!.encrypted}:')),
ListTile(title: Text('${L10n.of(context).encrypted}:')),
Padding(
padding: const EdgeInsets.all(12.0),
child: Material(

View file

@ -72,19 +72,19 @@ class _CuteContentState extends State<CuteContent> {
generateLabel(User? user) {
switch (widget.event.content['cute_type']) {
case 'googly_eyes':
return L10n.of(context)?.googlyEyesContent(
return L10n.of(context).googlyEyesContent(
user?.displayName ??
widget.event.senderFromMemoryOrFallback.displayName ??
'',
);
case 'cuddle':
return L10n.of(context)?.cuddleContent(
return L10n.of(context).cuddleContent(
user?.displayName ??
widget.event.senderFromMemoryOrFallback.displayName ??
'',
);
case 'hug':
return L10n.of(context)?.hugContent(
return L10n.of(context).hugContent(
user?.displayName ??
widget.event.senderFromMemoryOrFallback.displayName ??
'',

View file

@ -484,7 +484,7 @@ class Message extends StatelessWidget {
horizontal: 8,
),
child: Text(
L10n.of(context)!.readUpToHere,
L10n.of(context).readUpToHere,
style: TextStyle(color: theme.colorScheme.primary),
),
),

View file

@ -38,7 +38,7 @@ class MessageContent extends StatelessWidget {
});
void _verifyOrRequestKey(BuildContext context) async {
final l10n = L10n.of(context)!;
final l10n = L10n.of(context);
if (event.content['can_request_session'] != true) {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
@ -184,7 +184,7 @@ class MessageContent extends StatelessWidget {
textColor: buttonTextColor,
onPressed: () => _verifyOrRequestKey(context),
icon: '🔒',
label: L10n.of(context)!.encrypted,
label: L10n.of(context).encrypted,
fontSize: fontSize,
);
case MessageTypes.Location:
@ -213,7 +213,7 @@ class MessageContent extends StatelessWidget {
onPressed:
UrlLauncher(context, geoUri.toString()).launchUrl,
label: Text(
L10n.of(context)!.openInMaps,
L10n.of(context).openInMaps,
style: TextStyle(color: textColor),
),
),
@ -233,11 +233,11 @@ class MessageContent extends StatelessWidget {
event.redactedBecause?.content.tryGet<String>('reason');
final redactedBy = snapshot.data?.calcDisplayname() ??
event.redactedBecause?.senderId.localpart ??
L10n.of(context)!.user;
L10n.of(context).user;
return _ButtonContent(
label: reason == null
? L10n.of(context)!.redactedBy(redactedBy)
: L10n.of(context)!.redactedByBecause(
? L10n.of(context).redactedBy(redactedBy)
: L10n.of(context).redactedByBecause(
redactedBy,
reason,
),
@ -254,7 +254,7 @@ class MessageContent extends StatelessWidget {
event.numberEmotes <= 10;
return Linkify(
text: event.calcLocalizedBodyFallback(
MatrixLocals(L10n.of(context)!),
MatrixLocals(L10n.of(context)),
hideReply: true,
),
style: TextStyle(
@ -277,7 +277,7 @@ class MessageContent extends StatelessWidget {
future: event.fetchSenderUser(),
builder: (context, snapshot) {
return _ButtonContent(
label: L10n.of(context)!.startedACall(
label: L10n.of(context).startedACall(
snapshot.data?.calcDisplayname() ??
event.senderFromMemoryOrFallback.calcDisplayname(),
),
@ -293,7 +293,7 @@ class MessageContent extends StatelessWidget {
future: event.fetchSenderUser(),
builder: (context, snapshot) {
return _ButtonContent(
label: L10n.of(context)!.userSentUnknownEvent(
label: L10n.of(context).userSentUnknownEvent(
snapshot.data?.calcDisplayname() ??
event.senderFromMemoryOrFallback.calcDisplayname(),
event.type,

View file

@ -72,7 +72,7 @@ class ReplyContent extends StatelessWidget {
),
Text(
displayEvent.calcLocalizedBodyFallback(
MatrixLocals(L10n.of(context)!),
MatrixLocals(L10n.of(context)),
withSenderNamePrefix: false,
hideReply: true,
),

View file

@ -21,7 +21,7 @@ class StateMessage extends StatelessWidget {
padding: const EdgeInsets.all(8),
child: Text(
event.calcLocalizedBodyFallback(
MatrixLocals(L10n.of(context)!),
MatrixLocals(L10n.of(context)),
),
textAlign: TextAlign.center,
style: TextStyle(

View file

@ -58,10 +58,10 @@ class VerificationRequestContent extends StatelessWidget {
canceled
? 'Error ${cancel.first.content.tryGet<String>('code')}: ${cancel.first.content.tryGet<String>('reason')}'
: (fullyDone
? L10n.of(context)!.verifySuccess
? L10n.of(context).verifySuccess
: (started
? L10n.of(context)!.loadingPleaseWait
: L10n.of(context)!.newVerificationRequest)),
? L10n.of(context).loadingPleaseWait
: L10n.of(context).newVerificationRequest)),
),
],
),

View file

@ -137,8 +137,8 @@ class EventVideoPlayerState extends State<EventVideoPlayer> {
)
: const Icon(Icons.play_circle_outlined),
tooltip: _isDownloading
? L10n.of(context)!.loadingPleaseWait
: L10n.of(context)!.videoWithSize(
? L10n.of(context).loadingPleaseWait
: L10n.of(context).videoWithSize(
widget.event.sizeString ?? '?MB',
),
onPressed: _isDownloading ? null : _downloadAction,

View file

@ -226,7 +226,7 @@ class InputBar extends StatelessWidget {
const padding = EdgeInsets.all(4.0);
if (suggestion['type'] == 'command') {
final command = suggestion['name']!;
final hint = commandHint(L10n.of(context)!, command);
final hint = commandHint(L10n.of(context), command);
return Tooltip(
message: hint,
waitDuration: const Duration(days: 1), // don't show on hover

View file

@ -32,13 +32,13 @@ class PinnedEvents extends StatelessWidget {
? events.single?.eventId
: await showConfirmationDialog<String>(
context: context,
title: L10n.of(context)!.pinMessage,
title: L10n.of(context).pinMessage,
actions: events
.map(
(event) => AlertDialogAction(
key: event?.eventId ?? '',
label: event?.calcLocalizedBodyFallback(
MatrixLocals(L10n.of(context)!),
MatrixLocals(L10n.of(context)),
withSenderNamePrefix: true,
hideReply: true,
) ??
@ -67,17 +67,17 @@ class PinnedEvents extends StatelessWidget {
final event = snapshot.data;
return ChatAppBarListTile(
title: event?.calcLocalizedBodyFallback(
MatrixLocals(L10n.of(context)!),
MatrixLocals(L10n.of(context)),
withSenderNamePrefix: true,
hideReply: true,
) ??
L10n.of(context)!.loadingPleaseWait,
L10n.of(context).loadingPleaseWait,
leading: IconButton(
splashRadius: 18,
iconSize: 18,
color: theme.colorScheme.onSurfaceVariant,
icon: const Icon(Icons.push_pin),
tooltip: L10n.of(context)!.unpin,
tooltip: L10n.of(context).unpin,
onPressed: controller.room.canSendEvent(EventTypes.RoomPinnedEvents)
? () => controller.unpinEvent(event!.eventId)
: null,

View file

@ -137,7 +137,7 @@ class RecordingDialogState extends State<RecordingDialog> {
final time =
'${_duration.inMinutes.toString().padLeft(2, '0')}:${(_duration.inSeconds % 60).toString().padLeft(2, '0')}';
final content = error
? Text(L10n.of(context)!.oopsSomethingWentWrong)
? Text(L10n.of(context).oopsSomethingWentWrong)
: Row(
children: [
Container(
@ -185,7 +185,7 @@ class RecordingDialogState extends State<RecordingDialog> {
CupertinoDialogAction(
onPressed: () => Navigator.of(context, rootNavigator: false).pop(),
child: Text(
L10n.of(context)!.cancel.toUpperCase(),
L10n.of(context).cancel.toUpperCase(),
style: TextStyle(
color: theme.textTheme.bodyMedium?.color?.withAlpha(150),
),
@ -194,7 +194,7 @@ class RecordingDialogState extends State<RecordingDialog> {
if (error != true)
CupertinoDialogAction(
onPressed: _stopAndSend,
child: Text(L10n.of(context)!.send.toUpperCase()),
child: Text(L10n.of(context).send.toUpperCase()),
),
],
);
@ -205,7 +205,7 @@ class RecordingDialogState extends State<RecordingDialog> {
TextButton(
onPressed: () => Navigator.of(context, rootNavigator: false).pop(),
child: Text(
L10n.of(context)!.cancel.toUpperCase(),
L10n.of(context).cancel.toUpperCase(),
style: TextStyle(
color: theme.textTheme.bodyMedium?.color?.withAlpha(150),
),
@ -217,7 +217,7 @@ class RecordingDialogState extends State<RecordingDialog> {
child: Row(
mainAxisSize: MainAxisSize.min,
children: <Widget>[
Text(L10n.of(context)!.send.toUpperCase()),
Text(L10n.of(context).send.toUpperCase()),
const SizedBox(width: 4),
const Icon(Icons.send_outlined, size: 15),
],

View file

@ -29,7 +29,7 @@ class ReplyDisplay extends StatelessWidget {
child: Row(
children: <Widget>[
IconButton(
tooltip: L10n.of(context)!.close,
tooltip: L10n.of(context).close,
icon: const Icon(Icons.close),
onPressed: controller.cancelReplyEventAction,
),
@ -71,7 +71,7 @@ class _EditContent extends StatelessWidget {
Container(width: 15.0),
Text(
event.calcLocalizedBodyFallback(
MatrixLocals(L10n.of(context)!),
MatrixLocals(L10n.of(context)),
withSenderNamePrefix: false,
hideReply: true,
),

View file

@ -40,7 +40,7 @@ class SendFileDialogState extends State<SendFileDialog> {
Future<void> _send() async {
final scaffoldMessenger = ScaffoldMessenger.of(widget.outerContext);
final l10n = L10n.of(context)!;
final l10n = L10n.of(context);
try {
scaffoldMessenger.showLoadingSnackBar(l10n.prepareSendingAttachment);
@ -146,7 +146,7 @@ class SendFileDialogState extends State<SendFileDialog> {
Widget build(BuildContext context) {
final theme = Theme.of(context);
var sendStr = L10n.of(context)!.sendFile;
var sendStr = L10n.of(context).sendFile;
final uniqueMimeType = widget.files
.map((file) => file.mimeType ?? lookupMimeType(file.path))
.toSet()
@ -154,21 +154,21 @@ class SendFileDialogState extends State<SendFileDialog> {
final fileName = widget.files.length == 1
? widget.files.single.name
: L10n.of(context)!.countFiles(widget.files.length.toString());
: L10n.of(context).countFiles(widget.files.length.toString());
if (uniqueMimeType?.startsWith('image') ?? false) {
sendStr = L10n.of(context)!.sendImage;
sendStr = L10n.of(context).sendImage;
} else if (uniqueMimeType?.startsWith('audio') ?? false) {
sendStr = L10n.of(context)!.sendAudio;
sendStr = L10n.of(context).sendAudio;
} else if (uniqueMimeType?.startsWith('video') ?? false) {
sendStr = L10n.of(context)!.sendVideo;
sendStr = L10n.of(context).sendVideo;
}
return FutureBuilder<String>(
future: _calcCombinedFileSize(),
builder: (context, snapshot) {
final sizeString =
snapshot.data ?? L10n.of(context)!.calculatingFileSize;
snapshot.data ?? L10n.of(context).calculatingFileSize;
Widget contentWidget;
if (uniqueMimeType?.startsWith('image') ?? false) {
@ -210,7 +210,7 @@ class SendFileDialogState extends State<SendFileDialog> {
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
L10n.of(context)!.sendOriginal,
L10n.of(context).sendOriginal,
style: const TextStyle(fontWeight: FontWeight.bold),
),
Text(sizeString),
@ -270,7 +270,7 @@ class SendFileDialogState extends State<SendFileDialog> {
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
L10n.of(context)!.sendOriginal,
L10n.of(context).sendOriginal,
style:
const TextStyle(fontWeight: FontWeight.bold),
),
@ -293,11 +293,11 @@ class SendFileDialogState extends State<SendFileDialog> {
// just close the dialog
Navigator.of(context, rootNavigator: false).pop();
},
child: Text(L10n.of(context)!.cancel),
child: Text(L10n.of(context).cancel),
),
TextButton(
onPressed: _send,
child: Text(L10n.of(context)!.send),
child: Text(L10n.of(context).send),
),
],
);

View file

@ -93,12 +93,12 @@ class SendLocationDialogState extends State<SendLocationDialog> {
longitude: position!.longitude,
);
} else if (disabled) {
contentWidget = Text(L10n.of(context)!.locationDisabledNotice);
contentWidget = Text(L10n.of(context).locationDisabledNotice);
} else if (denied) {
contentWidget = Text(L10n.of(context)!.locationPermissionDeniedNotice);
contentWidget = Text(L10n.of(context).locationPermissionDeniedNotice);
} else if (error != null) {
contentWidget =
Text(L10n.of(context)!.errorObtainingLocation(error.toString()));
Text(L10n.of(context).errorObtainingLocation(error.toString()));
} else {
contentWidget = Row(
mainAxisSize: MainAxisSize.min,
@ -106,22 +106,22 @@ class SendLocationDialogState extends State<SendLocationDialog> {
children: [
const CupertinoActivityIndicator(),
const SizedBox(width: 12),
Text(L10n.of(context)!.obtainingLocation),
Text(L10n.of(context).obtainingLocation),
],
);
}
return AlertDialog.adaptive(
title: Text(L10n.of(context)!.shareLocation),
title: Text(L10n.of(context).shareLocation),
content: contentWidget,
actions: [
TextButton(
onPressed: Navigator.of(context, rootNavigator: false).pop,
child: Text(L10n.of(context)!.cancel),
child: Text(L10n.of(context).cancel),
),
if (position != null)
TextButton(
onPressed: isSending ? null : sendAction,
child: Text(L10n.of(context)!.send),
child: Text(L10n.of(context).send),
),
],
);

View file

@ -117,7 +117,7 @@ class StickerPickerDialogState extends State<StickerPickerDialog> {
child: TextField(
autofocus: false,
decoration: InputDecoration(
hintText: L10n.of(context)!.search,
hintText: L10n.of(context).search,
prefixIcon: const Icon(Icons.search_outlined),
contentPadding: EdgeInsets.zero,
),
@ -131,7 +131,7 @@ class StickerPickerDialogState extends State<StickerPickerDialog> {
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
Text(L10n.of(context)!.noEmotesFound),
Text(L10n.of(context).noEmotesFound),
const SizedBox(height: 12),
OutlinedButton.icon(
onPressed: () => UrlLauncher(
@ -139,7 +139,7 @@ class StickerPickerDialogState extends State<StickerPickerDialog> {
'https://matrix.to/#/#fluffychat-stickers:janian.de',
).launchUrl(),
icon: const Icon(Icons.explore_outlined),
label: Text(L10n.of(context)!.discover),
label: Text(L10n.of(context).discover),
),
],
),