Refactoring l10n

This commit is contained in:
Christian Pauly 2020-05-07 07:52:40 +02:00
parent 05ea1290b6
commit d7e2ff7ae0
42 changed files with 287 additions and 287 deletions

View file

@ -72,23 +72,23 @@ Text("Hello world"),
``` ```
with a method call: with a method call:
``` ```
Text(I18n.of(context).helloWorld), Text(L10n.of(context).helloWorld),
``` ```
And add the method to `/lib/i18n/i18n.dart`: And add the method to `/lib/l10n/l10n.dart`:
``` ```
String get helloWorld => Intl.message('Hello world'); String get helloWorld => Intl.message('Hello world');
``` ```
2. Add the string to the .arb files with this command: 2. Add the string to the .arb files with this command:
``` ```
flutter pub run intl_translation:extract_to_arb --output-dir=lib/i18n lib/i18n/i18n.dart flutter pub run intl_translation:extract_to_arb --output-dir=lib/l10n lib/l10n/l10n.dart
``` ```
3. Copy the new translation objects from `/lib/i18n/intl_message.arb` to `/lib/i18n/intl_<yourlanguage>.arb` and translate it or create a new file for your language by copying `intl_message.arb`. 3. Copy the new translation objects from `/lib/l10n/intl_message.arb` to `/lib/l10n/intl_<yourlanguage>.arb` and translate it or create a new file for your language by copying `intl_message.arb`.
4. Update the translations with this command: 4. Update the translations with this command:
``` ```
flutter pub pub run intl_translation:generate_from_arb --output-dir=lib/i18n --no-use-deferred-loading lib/i18n/i18n.dart lib/i18n/intl_*.arb flutter pub pub run intl_translation:generate_from_arb --output-dir=lib/l10n --no-use-deferred-loading lib/l10n/l10n.dart lib/l10n/intl_*.arb
``` ```
5. Make sure your language is in `supportedLocales` in `/lib/main.dart`. 5. Make sure your language is in `supportedLocales` in `/lib/main.dart`.

View file

@ -1,7 +1,7 @@
import 'dart:async'; import 'dart:async';
import 'package:famedlysdk/famedlysdk.dart'; import 'package:famedlysdk/famedlysdk.dart';
import 'package:fluffychat/i18n/i18n.dart'; import 'package:fluffychat/l10n/l10n.dart';
import 'package:fluffychat/utils/app_route.dart'; import 'package:fluffychat/utils/app_route.dart';
import 'package:fluffychat/views/chat_details.dart'; import 'package:fluffychat/views/chat_details.dart';
import 'package:fluffychat/views/chat_list.dart'; import 'package:fluffychat/views/chat_list.dart';
@ -56,19 +56,19 @@ class _ChatSettingsPopupMenuState extends State<ChatSettingsPopupMenu> {
widget.room.pushRuleState == PushRuleState.notify widget.room.pushRuleState == PushRuleState.notify
? PopupMenuItem<String>( ? PopupMenuItem<String>(
value: "mute", value: "mute",
child: Text(I18n.of(context).muteChat), child: Text(L10n.of(context).muteChat),
) )
: PopupMenuItem<String>( : PopupMenuItem<String>(
value: "unmute", value: "unmute",
child: Text(I18n.of(context).unmuteChat), child: Text(L10n.of(context).unmuteChat),
), ),
PopupMenuItem<String>( PopupMenuItem<String>(
value: "call", value: "call",
child: Text(I18n.of(context).videoCall), child: Text(L10n.of(context).videoCall),
), ),
PopupMenuItem<String>( PopupMenuItem<String>(
value: "leave", value: "leave",
child: Text(I18n.of(context).leave), child: Text(L10n.of(context).leave),
), ),
]; ];
if (widget.displayChatDetails) { if (widget.displayChatDetails) {
@ -76,7 +76,7 @@ class _ChatSettingsPopupMenuState extends State<ChatSettingsPopupMenu> {
0, 0,
PopupMenuItem<String>( PopupMenuItem<String>(
value: "details", value: "details",
child: Text(I18n.of(context).chatDetails), child: Text(L10n.of(context).chatDetails),
), ),
); );
} }

View file

@ -1,6 +1,6 @@
import 'dart:async'; import 'dart:async';
import 'package:fluffychat/i18n/i18n.dart'; import 'package:fluffychat/l10n/l10n.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_sound/flutter_sound.dart'; import 'package:flutter_sound/flutter_sound.dart';
import 'package:intl/intl.dart'; import 'package:intl/intl.dart';
@ -67,7 +67,7 @@ class _RecordingDialogState extends State<RecordingDialog> {
SizedBox(width: 8), SizedBox(width: 8),
Expanded( Expanded(
child: Text( child: Text(
"${I18n.of(context).recording}: $time", "${L10n.of(context).recording}: $time",
style: TextStyle( style: TextStyle(
fontSize: 18, fontSize: 18,
), ),
@ -78,7 +78,7 @@ class _RecordingDialogState extends State<RecordingDialog> {
actions: <Widget>[ actions: <Widget>[
FlatButton( FlatButton(
child: Text( child: Text(
I18n.of(context).cancel.toUpperCase(), L10n.of(context).cancel.toUpperCase(),
style: TextStyle( style: TextStyle(
color: Theme.of(context).textTheme.bodyText2.color.withAlpha(150), color: Theme.of(context).textTheme.bodyText2.color.withAlpha(150),
), ),
@ -88,7 +88,7 @@ class _RecordingDialogState extends State<RecordingDialog> {
FlatButton( FlatButton(
child: Row( child: Row(
children: <Widget>[ children: <Widget>[
Text(I18n.of(context).send.toUpperCase()), Text(L10n.of(context).send.toUpperCase()),
SizedBox(width: 4), SizedBox(width: 4),
Icon(Icons.send, size: 15), Icon(Icons.send, size: 15),
], ],

View file

@ -1,4 +1,4 @@
import 'package:fluffychat/i18n/i18n.dart'; import 'package:fluffychat/l10n/l10n.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:famedlysdk/famedlysdk.dart'; import 'package:famedlysdk/famedlysdk.dart';
import 'package:flutter_styled_toast/flutter_styled_toast.dart'; import 'package:flutter_styled_toast/flutter_styled_toast.dart';
@ -51,14 +51,14 @@ class SimpleDialogs {
FlatButton( FlatButton(
child: Text( child: Text(
cancelText?.toUpperCase() ?? cancelText?.toUpperCase() ??
I18n.of(context).close.toUpperCase(), L10n.of(context).close.toUpperCase(),
style: TextStyle(color: Colors.blueGrey)), style: TextStyle(color: Colors.blueGrey)),
onPressed: () => Navigator.of(context).pop(), onPressed: () => Navigator.of(context).pop(),
), ),
FlatButton( FlatButton(
child: Text( child: Text(
confirmText?.toUpperCase() ?? confirmText?.toUpperCase() ??
I18n.of(context).confirm.toUpperCase(), L10n.of(context).confirm.toUpperCase(),
), ),
onPressed: () { onPressed: () {
input = controller.text; input = controller.text;
@ -81,20 +81,20 @@ class SimpleDialogs {
await showDialog( await showDialog(
context: context, context: context,
builder: (c) => AlertDialog( builder: (c) => AlertDialog(
title: Text(titleText ?? I18n.of(context).areYouSure), title: Text(titleText ?? L10n.of(context).areYouSure),
content: contentText != null ? Text(contentText) : null, content: contentText != null ? Text(contentText) : null,
actions: <Widget>[ actions: <Widget>[
FlatButton( FlatButton(
child: Text( child: Text(
cancelText?.toUpperCase() ?? cancelText?.toUpperCase() ??
I18n.of(context).close.toUpperCase(), L10n.of(context).close.toUpperCase(),
style: TextStyle(color: Colors.blueGrey)), style: TextStyle(color: Colors.blueGrey)),
onPressed: () => Navigator.of(context).pop(), onPressed: () => Navigator.of(context).pop(),
), ),
FlatButton( FlatButton(
child: Text( child: Text(
confirmText?.toUpperCase() ?? confirmText?.toUpperCase() ??
I18n.of(context).confirm.toUpperCase(), L10n.of(context).confirm.toUpperCase(),
), ),
onPressed: () { onPressed: () {
confirmed = true; confirmed = true;
@ -142,7 +142,7 @@ class SimpleDialogs {
children: <Widget>[ children: <Widget>[
CircularProgressIndicator(), CircularProgressIndicator(),
SizedBox(width: 16), SizedBox(width: 16),
Text(I18n.of(context).loadingPleaseWait), Text(L10n.of(context).loadingPleaseWait),
], ],
), ),
), ),

View file

@ -1,7 +1,7 @@
import 'dart:async'; import 'dart:async';
import 'package:famedlysdk/famedlysdk.dart'; import 'package:famedlysdk/famedlysdk.dart';
import 'package:fluffychat/i18n/i18n.dart'; import 'package:fluffychat/l10n/l10n.dart';
import 'package:fluffychat/utils/app_route.dart'; import 'package:fluffychat/utils/app_route.dart';
import 'package:fluffychat/views/chat_encryption_settings.dart'; import 'package:fluffychat/views/chat_encryption_settings.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
@ -22,7 +22,7 @@ class _EncryptionButtonState extends State<EncryptionButton> {
void _enableEncryptionAction() async { void _enableEncryptionAction() async {
if (widget.room.encrypted) { if (widget.room.encrypted) {
showToast(I18n.of(context).warningEncryptionInBeta); showToast(L10n.of(context).warningEncryptionInBeta);
await Navigator.of(context).push( await Navigator.of(context).push(
AppRoute.defaultRoute( AppRoute.defaultRoute(
context, context,
@ -32,15 +32,15 @@ class _EncryptionButtonState extends State<EncryptionButton> {
return; return;
} }
if (!widget.room.client.encryptionEnabled) { if (!widget.room.client.encryptionEnabled) {
showToast(I18n.of(context).needPantalaimonWarning); showToast(L10n.of(context).needPantalaimonWarning);
return; return;
} }
if (await SimpleDialogs(context).askConfirmation( if (await SimpleDialogs(context).askConfirmation(
titleText: I18n.of(context).enableEncryptionWarning, titleText: L10n.of(context).enableEncryptionWarning,
contentText: widget.room.client.encryptionEnabled contentText: widget.room.client.encryptionEnabled
? I18n.of(context).warningEncryptionInBeta ? L10n.of(context).warningEncryptionInBeta
: I18n.of(context).needPantalaimonWarning, : L10n.of(context).needPantalaimonWarning,
confirmText: I18n.of(context).yes, confirmText: L10n.of(context).yes,
) == ) ==
true) { true) {
await SimpleDialogs(context).tryRequestWithLoadingDialog( await SimpleDialogs(context).tryRequestWithLoadingDialog(

View file

@ -5,7 +5,7 @@ import 'package:flutter_slidable/flutter_slidable.dart';
import 'package:flutter_styled_toast/flutter_styled_toast.dart'; import 'package:flutter_styled_toast/flutter_styled_toast.dart';
import 'package:pedantic/pedantic.dart'; import 'package:pedantic/pedantic.dart';
import '../../i18n/i18n.dart'; import '../../l10n/l10n.dart';
import '../../utils/app_route.dart'; import '../../utils/app_route.dart';
import '../../utils/date_time_extension.dart'; import '../../utils/date_time_extension.dart';
import '../../views/chat.dart'; import '../../views/chat.dart';
@ -31,7 +31,7 @@ class ChatListItem extends StatelessWidget {
} }
if (room.membership == Membership.ban) { if (room.membership == Membership.ban) {
showToast(I18n.of(context).youHaveBeenBannedFromThisChat); showToast(L10n.of(context).youHaveBeenBannedFromThisChat);
return; return;
} }
@ -39,16 +39,16 @@ class ChatListItem extends StatelessWidget {
await showDialog( await showDialog(
context: context, context: context,
builder: (BuildContext context) => AlertDialog( builder: (BuildContext context) => AlertDialog(
title: Text(I18n.of(context).archivedRoom), title: Text(L10n.of(context).archivedRoom),
content: Text(I18n.of(context).thisRoomHasBeenArchived), content: Text(L10n.of(context).thisRoomHasBeenArchived),
actions: <Widget>[ actions: <Widget>[
FlatButton( FlatButton(
child: Text(I18n.of(context).close.toUpperCase(), child: Text(L10n.of(context).close.toUpperCase(),
style: TextStyle(color: Colors.blueGrey)), style: TextStyle(color: Colors.blueGrey)),
onPressed: () => Navigator.of(context).pop(), onPressed: () => Navigator.of(context).pop(),
), ),
FlatButton( FlatButton(
child: Text(I18n.of(context).delete.toUpperCase(), child: Text(L10n.of(context).delete.toUpperCase(),
style: TextStyle(color: Colors.red)), style: TextStyle(color: Colors.red)),
onPressed: () async { onPressed: () async {
await archiveAction(context); await archiveAction(context);
@ -56,7 +56,7 @@ class ChatListItem extends StatelessWidget {
}, },
), ),
FlatButton( FlatButton(
child: Text(I18n.of(context).rejoin.toUpperCase(), child: Text(L10n.of(context).rejoin.toUpperCase(),
style: TextStyle(color: Colors.blue)), style: TextStyle(color: Colors.blue)),
onPressed: () async { onPressed: () async {
await SimpleDialogs(context) await SimpleDialogs(context)
@ -122,14 +122,14 @@ class ChatListItem extends StatelessWidget {
secondaryActions: <Widget>[ secondaryActions: <Widget>[
if ([Membership.join, Membership.invite].contains(room.membership)) if ([Membership.join, Membership.invite].contains(room.membership))
IconSlideAction( IconSlideAction(
caption: I18n.of(context).leave, caption: L10n.of(context).leave,
color: Colors.red, color: Colors.red,
icon: Icons.archive, icon: Icons.archive,
onTap: () => archiveAction(context), onTap: () => archiveAction(context),
), ),
if ([Membership.leave, Membership.ban].contains(room.membership)) if ([Membership.leave, Membership.ban].contains(room.membership))
IconSlideAction( IconSlideAction(
caption: I18n.of(context).delete, caption: L10n.of(context).delete,
color: Colors.red, color: Colors.red,
icon: Icons.delete_forever, icon: Icons.delete_forever,
onTap: () => archiveAction(context), onTap: () => archiveAction(context),
@ -151,7 +151,7 @@ class ChatListItem extends StatelessWidget {
mainAxisSize: MainAxisSize.min, mainAxisSize: MainAxisSize.min,
children: <Widget>[ children: <Widget>[
Text( Text(
room.getLocalizedDisplayname(I18n.of(context)), room.getLocalizedDisplayname(L10n.of(context)),
maxLines: 1, maxLines: 1,
overflow: TextOverflow.ellipsis, overflow: TextOverflow.ellipsis,
), ),
@ -181,13 +181,13 @@ class ChatListItem extends StatelessWidget {
Expanded( Expanded(
child: room.membership == Membership.invite child: room.membership == Membership.invite
? Text( ? Text(
I18n.of(context).youAreInvitedToThisChat, L10n.of(context).youAreInvitedToThisChat,
style: TextStyle( style: TextStyle(
color: Theme.of(context).primaryColor, color: Theme.of(context).primaryColor,
), ),
) )
: Text( : Text(
room.lastEvent.getLocalizedBody(I18n.of(context), room.lastEvent.getLocalizedBody(L10n.of(context),
withSenderNamePrefix: true, hideReply: true), withSenderNamePrefix: true, hideReply: true),
maxLines: 1, maxLines: 1,
overflow: TextOverflow.ellipsis, overflow: TextOverflow.ellipsis,

View file

@ -3,7 +3,7 @@ import 'package:famedlysdk/famedlysdk.dart';
import 'package:fluffychat/components/dialogs/simple_dialogs.dart'; import 'package:fluffychat/components/dialogs/simple_dialogs.dart';
import 'package:fluffychat/components/message_content.dart'; import 'package:fluffychat/components/message_content.dart';
import 'package:fluffychat/components/reply_content.dart'; import 'package:fluffychat/components/reply_content.dart';
import 'package:fluffychat/i18n/i18n.dart'; import 'package:fluffychat/l10n/l10n.dart';
import 'package:fluffychat/utils/date_time_extension.dart'; import 'package:fluffychat/utils/date_time_extension.dart';
import 'package:fluffychat/utils/event_extension.dart'; import 'package:fluffychat/utils/event_extension.dart';
import 'package:fluffychat/utils/string_color.dart'; import 'package:fluffychat/utils/string_color.dart';
@ -114,7 +114,7 @@ class Message extends StatelessWidget {
RaisedButton( RaisedButton(
color: color.withAlpha(100), color: color.withAlpha(100),
child: Text( child: Text(
I18n.of(context).requestPermission, L10n.of(context).requestPermission,
style: TextStyle(color: textColor), style: TextStyle(color: textColor),
), ),
onPressed: () => SimpleDialogs(context) onPressed: () => SimpleDialogs(context)

View file

@ -1,6 +1,6 @@
import 'package:famedlysdk/famedlysdk.dart'; import 'package:famedlysdk/famedlysdk.dart';
import 'package:fluffychat/components/dialogs/simple_dialogs.dart'; import 'package:fluffychat/components/dialogs/simple_dialogs.dart';
import 'package:fluffychat/i18n/i18n.dart'; import 'package:fluffychat/l10n/l10n.dart';
import 'package:fluffychat/utils/app_route.dart'; import 'package:fluffychat/utils/app_route.dart';
import 'package:fluffychat/views/chat.dart'; import 'package:fluffychat/views/chat.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
@ -65,19 +65,19 @@ class ParticipantListItem extends StatelessWidget {
Widget build(BuildContext context) { Widget build(BuildContext context) {
Map<Membership, String> membershipBatch = { Map<Membership, String> membershipBatch = {
Membership.join: "", Membership.join: "",
Membership.ban: I18n.of(context).banned, Membership.ban: L10n.of(context).banned,
Membership.invite: I18n.of(context).invited, Membership.invite: L10n.of(context).invited,
Membership.leave: I18n.of(context).leftTheChat, Membership.leave: L10n.of(context).leftTheChat,
}; };
final String permissionBatch = user.powerLevel == 100 final String permissionBatch = user.powerLevel == 100
? I18n.of(context).admin ? L10n.of(context).admin
: user.powerLevel >= 50 ? I18n.of(context).moderator : ""; : user.powerLevel >= 50 ? L10n.of(context).moderator : "";
List<PopupMenuEntry<String>> items = <PopupMenuEntry<String>>[]; List<PopupMenuEntry<String>> items = <PopupMenuEntry<String>>[];
if (user.id != Matrix.of(context).client.userID) { if (user.id != Matrix.of(context).client.userID) {
items.add( items.add(
PopupMenuItem( PopupMenuItem(
child: Text(I18n.of(context).sendAMessage), value: "message"), child: Text(L10n.of(context).sendAMessage), value: "message"),
); );
} }
if (user.canChangePowerLevel && if (user.canChangePowerLevel &&
@ -85,7 +85,7 @@ class ParticipantListItem extends StatelessWidget {
user.powerLevel != 100) { user.powerLevel != 100) {
items.add( items.add(
PopupMenuItem( PopupMenuItem(
child: Text(I18n.of(context).makeAnAdmin), value: "admin"), child: Text(L10n.of(context).makeAnAdmin), value: "admin"),
); );
} }
if (user.canChangePowerLevel && if (user.canChangePowerLevel &&
@ -93,29 +93,29 @@ class ParticipantListItem extends StatelessWidget {
user.powerLevel != 50) { user.powerLevel != 50) {
items.add( items.add(
PopupMenuItem( PopupMenuItem(
child: Text(I18n.of(context).makeAModerator), value: "moderator"), child: Text(L10n.of(context).makeAModerator), value: "moderator"),
); );
} }
if (user.canChangePowerLevel && user.powerLevel != 0) { if (user.canChangePowerLevel && user.powerLevel != 0) {
items.add( items.add(
PopupMenuItem( PopupMenuItem(
child: Text(I18n.of(context).revokeAllPermissions), value: "user"), child: Text(L10n.of(context).revokeAllPermissions), value: "user"),
); );
} }
if (user.canKick) { if (user.canKick) {
items.add( items.add(
PopupMenuItem( PopupMenuItem(
child: Text(I18n.of(context).kickFromChat), value: "kick"), child: Text(L10n.of(context).kickFromChat), value: "kick"),
); );
} }
if (user.canBan && user.membership != Membership.ban) { if (user.canBan && user.membership != Membership.ban) {
items.add( items.add(
PopupMenuItem(child: Text(I18n.of(context).banFromChat), value: "ban"), PopupMenuItem(child: Text(L10n.of(context).banFromChat), value: "ban"),
); );
} else if (user.canBan && user.membership == Membership.ban) { } else if (user.canBan && user.membership == Membership.ban) {
items.add( items.add(
PopupMenuItem( PopupMenuItem(
child: Text(I18n.of(context).removeExile), value: "unban"), child: Text(L10n.of(context).removeExile), value: "unban"),
); );
} }
return PopupMenuButton( return PopupMenuButton(

View file

@ -1,5 +1,5 @@
import 'package:famedlysdk/famedlysdk.dart'; import 'package:famedlysdk/famedlysdk.dart';
import 'package:fluffychat/i18n/i18n.dart'; import 'package:fluffychat/l10n/l10n.dart';
import 'package:fluffychat/utils/app_route.dart'; import 'package:fluffychat/utils/app_route.dart';
import 'package:fluffychat/views/chat.dart'; import 'package:fluffychat/views/chat.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
@ -62,7 +62,7 @@ class PresenceListItem extends StatelessWidget {
actions: <Widget>[ actions: <Widget>[
if (presence.sender != Matrix.of(context).client.userID) if (presence.sender != Matrix.of(context).client.userID)
FlatButton( FlatButton(
child: Text(I18n.of(context).sendAMessage), child: Text(L10n.of(context).sendAMessage),
onPressed: () async { onPressed: () async {
final String roomId = await User( final String roomId = await User(
presence.sender, presence.sender,
@ -77,7 +77,7 @@ class PresenceListItem extends StatelessWidget {
}, },
), ),
FlatButton( FlatButton(
child: Text(I18n.of(context).close), child: Text(L10n.of(context).close),
onPressed: () => Navigator.of(context).pop(), onPressed: () => Navigator.of(context).pop(),
), ),
], ],

View file

@ -2,7 +2,7 @@ import 'package:famedlysdk/famedlysdk.dart';
import 'package:fluffychat/components/dialogs/simple_dialogs.dart'; import 'package:fluffychat/components/dialogs/simple_dialogs.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import '../../i18n/i18n.dart'; import '../../l10n/l10n.dart';
import '../../utils/app_route.dart'; import '../../utils/app_route.dart';
import '../../views/chat.dart'; import '../../views/chat.dart';
import '../avatar.dart'; import '../avatar.dart';
@ -41,7 +41,7 @@ class PublicRoomListItem extends StatelessWidget {
subtitle: Text( subtitle: Text(
hasTopic hasTopic
? publicRoomEntry.topic ? publicRoomEntry.topic
: I18n.of(context).countParticipants( : L10n.of(context).countParticipants(
publicRoomEntry.numJoinedMembers?.toString() ?? "0"), publicRoomEntry.numJoinedMembers?.toString() ?? "0"),
maxLines: 1, maxLines: 1,
), ),

View file

@ -1,6 +1,6 @@
import 'package:bubble/bubble.dart'; import 'package:bubble/bubble.dart';
import 'package:famedlysdk/famedlysdk.dart'; import 'package:famedlysdk/famedlysdk.dart';
import 'package:fluffychat/i18n/i18n.dart'; import 'package:fluffychat/l10n/l10n.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
class StateMessage extends StatelessWidget { class StateMessage extends StatelessWidget {
@ -21,7 +21,7 @@ class StateMessage extends StatelessWidget {
color: Theme.of(context).backgroundColor.withOpacity(0.66), color: Theme.of(context).backgroundColor.withOpacity(0.66),
alignment: Alignment.center, alignment: Alignment.center,
child: Text( child: Text(
event.getLocalizedBody(I18n.of(context)), event.getLocalizedBody(L10n.of(context)),
textAlign: TextAlign.center, textAlign: TextAlign.center,
style: TextStyle( style: TextStyle(
color: Theme.of(context).textTheme.bodyText2.color, color: Theme.of(context).textTheme.bodyText2.color,

View file

@ -9,7 +9,7 @@ import 'package:flutter/material.dart';
import 'package:localstorage/localstorage.dart'; import 'package:localstorage/localstorage.dart';
import 'package:url_launcher/url_launcher.dart'; import 'package:url_launcher/url_launcher.dart';
import '../i18n/i18n.dart'; import '../l10n/l10n.dart';
import '../utils/beautify_string_extension.dart'; import '../utils/beautify_string_extension.dart';
import '../utils/famedlysdk_store.dart'; import '../utils/famedlysdk_store.dart';
import 'avatar.dart'; import 'avatar.dart';
@ -106,7 +106,7 @@ class MatrixState extends State<Matrix> {
showDialog( showDialog(
context: context, context: context,
builder: (context) => AlertDialog( builder: (context) => AlertDialog(
title: Text(I18n.of(context).videoCall), title: Text(L10n.of(context).videoCall),
content: Column( content: Column(
mainAxisSize: MainAxisSize.min, mainAxisSize: MainAxisSize.min,
children: <Widget>[ children: <Widget>[
@ -165,11 +165,11 @@ class MatrixState extends State<Matrix> {
final Room room = request.room; final Room room = request.room;
final User sender = room.getUserByMXIDSync(request.sender); final User sender = room.getUserByMXIDSync(request.sender);
if (await SimpleDialogs(context).askConfirmation( if (await SimpleDialogs(context).askConfirmation(
titleText: I18n.of(context).requestToReadOlderMessages, titleText: L10n.of(context).requestToReadOlderMessages,
contentText: contentText:
"${sender.id}\n\n${I18n.of(context).device}:\n${request.requestingDevice.deviceId}\n\n${I18n.of(context).identity}:\n${request.requestingDevice.curve25519Key.beautified}", "${sender.id}\n\n${L10n.of(context).device}:\n${request.requestingDevice.deviceId}\n\n${L10n.of(context).identity}:\n${request.requestingDevice.curve25519Key.beautified}",
confirmText: I18n.of(context).verify, confirmText: L10n.of(context).verify,
cancelText: I18n.of(context).deny, cancelText: L10n.of(context).deny,
)) { )) {
await request.forwardKey(); await request.forwardKey();
} }

View file

@ -1,7 +1,7 @@
import 'package:famedlysdk/famedlysdk.dart'; import 'package:famedlysdk/famedlysdk.dart';
import 'package:fluffychat/components/audio_player.dart'; import 'package:fluffychat/components/audio_player.dart';
import 'package:fluffychat/components/image_bubble.dart'; import 'package:fluffychat/components/image_bubble.dart';
import 'package:fluffychat/i18n/i18n.dart'; import 'package:fluffychat/l10n/l10n.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:link_text/link_text.dart'; import 'package:link_text/link_text.dart';
import 'package:url_launcher/url_launcher.dart'; import 'package:url_launcher/url_launcher.dart';
@ -50,14 +50,14 @@ class MessageContent extends StatelessWidget {
mainAxisSize: MainAxisSize.min, mainAxisSize: MainAxisSize.min,
children: <Widget>[ children: <Widget>[
Icon(Icons.phone), Icon(Icons.phone),
Text(I18n.of(context).videoCall), Text(L10n.of(context).videoCall),
], ],
), ),
onPressed: () => launch(event.body), onPressed: () => launch(event.body),
); );
} }
return LinkText( return LinkText(
text: event.getLocalizedBody(I18n.of(context), hideReply: true), text: event.getLocalizedBody(L10n.of(context), hideReply: true),
textStyle: TextStyle( textStyle: TextStyle(
color: textColor, color: textColor,
decoration: event.redacted ? TextDecoration.lineThrough : null, decoration: event.redacted ? TextDecoration.lineThrough : null,
@ -67,7 +67,7 @@ class MessageContent extends StatelessWidget {
break; break;
default: default:
return Text( return Text(
I18n.of(context).userSentUnknownEvent( L10n.of(context).userSentUnknownEvent(
event.sender.calcDisplayname(), event.typeKey), event.sender.calcDisplayname(), event.typeKey),
style: TextStyle( style: TextStyle(
color: textColor, color: textColor,

View file

@ -1,5 +1,5 @@
import 'package:famedlysdk/famedlysdk.dart'; import 'package:famedlysdk/famedlysdk.dart';
import 'package:fluffychat/i18n/i18n.dart'; import 'package:fluffychat/l10n/l10n.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:fluffychat/utils/matrix_file_extension.dart'; import 'package:fluffychat/utils/matrix_file_extension.dart';
import 'package:fluffychat/utils/event_extension.dart'; import 'package:fluffychat/utils/event_extension.dart';
@ -22,7 +22,7 @@ class MessageDownloadContent extends StatelessWidget {
RaisedButton( RaisedButton(
color: Colors.blueGrey, color: Colors.blueGrey,
child: Text( child: Text(
I18n.of(context).downloadFile, L10n.of(context).downloadFile,
overflow: TextOverflow.fade, overflow: TextOverflow.fade,
softWrap: false, softWrap: false,
maxLines: 1, maxLines: 1,

View file

@ -1,5 +1,5 @@
import 'package:famedlysdk/famedlysdk.dart'; import 'package:famedlysdk/famedlysdk.dart';
import 'package:fluffychat/i18n/i18n.dart'; import 'package:fluffychat/l10n/l10n.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
class ReplyContent extends StatelessWidget { class ReplyContent extends StatelessWidget {
@ -36,7 +36,7 @@ class ReplyContent extends StatelessWidget {
), ),
Text( Text(
replyEvent?.getLocalizedBody( replyEvent?.getLocalizedBody(
I18n.of(context), L10n.of(context),
withSenderNamePrefix: false, withSenderNamePrefix: false,
hideReply: true, hideReply: true,
) ?? ) ??

View file

@ -2,7 +2,7 @@ import 'package:flutter/material.dart';
import '../components/theme_switcher.dart'; import '../components/theme_switcher.dart';
import '../components/matrix.dart'; import '../components/matrix.dart';
import '../i18n/i18n.dart'; import '../l10n/l10n.dart';
class ThemesSettings extends StatefulWidget { class ThemesSettings extends StatefulWidget {
@override @override
@ -25,7 +25,7 @@ class ThemesSettingsState extends State<ThemesSettings> {
children: <Widget>[ children: <Widget>[
RadioListTile<Themes>( RadioListTile<Themes>(
title: Text( title: Text(
I18n.of(context).systemTheme, L10n.of(context).systemTheme,
), ),
value: Themes.system, value: Themes.system,
groupValue: _selectedTheme, groupValue: _selectedTheme,
@ -39,7 +39,7 @@ class ThemesSettingsState extends State<ThemesSettings> {
), ),
RadioListTile<Themes>( RadioListTile<Themes>(
title: Text( title: Text(
I18n.of(context).lightTheme, L10n.of(context).lightTheme,
), ),
value: Themes.light, value: Themes.light,
groupValue: _selectedTheme, groupValue: _selectedTheme,
@ -53,7 +53,7 @@ class ThemesSettingsState extends State<ThemesSettings> {
), ),
RadioListTile<Themes>( RadioListTile<Themes>(
title: Text( title: Text(
I18n.of(context).darkTheme, L10n.of(context).darkTheme,
), ),
value: Themes.dark, value: Themes.dark,
groupValue: _selectedTheme, groupValue: _selectedTheme,
@ -67,7 +67,7 @@ class ThemesSettingsState extends State<ThemesSettings> {
), ),
ListTile( ListTile(
title: Text( title: Text(
I18n.of(context).useAmoledTheme, L10n.of(context).useAmoledTheme,
), ),
trailing: Switch( trailing: Switch(
value: _amoledEnabled, value: _amoledEnabled,

View file

@ -1,5 +1,5 @@
{ {
"@@last_modified": "2020-05-06T19:24:19.377156", "@@last_modified": "2020-05-07T07:52:19.301540",
"About": "About", "About": "About",
"@About": { "@About": {
"type": "text", "type": "text",

View file

@ -3,7 +3,7 @@ import 'package:flutter/material.dart';
import 'package:intl/intl.dart'; import 'package:intl/intl.dart';
import 'messages_all.dart'; import 'messages_all.dart';
class AppLocalizationsDelegate extends LocalizationsDelegate<I18n> { class AppLocalizationsDelegate extends LocalizationsDelegate<L10n> {
const AppLocalizationsDelegate(); const AppLocalizationsDelegate();
@override @override
@ -12,32 +12,32 @@ class AppLocalizationsDelegate extends LocalizationsDelegate<I18n> {
} }
@override @override
Future<I18n> load(Locale locale) { Future<L10n> load(Locale locale) {
return I18n.load(locale); return L10n.load(locale);
} }
@override @override
bool shouldReload(LocalizationsDelegate<I18n> old) { bool shouldReload(LocalizationsDelegate<L10n> old) {
return false; return false;
} }
} }
class I18n extends MatrixLocalizations { class L10n extends MatrixLocalizations {
I18n(this.localeName); L10n(this.localeName);
static Future<I18n> load(Locale locale) { static Future<L10n> load(Locale locale) {
final String name = final String name =
locale.countryCode == null ? locale.languageCode : locale.toString(); locale.countryCode == null ? locale.languageCode : locale.toString();
final String localeName = Intl.canonicalizedLocale(name); final String localeName = Intl.canonicalizedLocale(name);
return initializeMessages(localeName).then((bool _) { return initializeMessages(localeName).then((bool _) {
Intl.defaultLocale = localeName; Intl.defaultLocale = localeName;
return I18n(localeName); return L10n(localeName);
}); });
} }
static I18n of(BuildContext context) { static L10n of(BuildContext context) {
return Localizations.of<I18n>(context, I18n); return Localizations.of<L10n>(context, L10n);
} }
final String localeName; final String localeName;

View file

@ -8,7 +8,7 @@ import 'package:flutter/services.dart';
import 'package:flutter_localizations/flutter_localizations.dart'; import 'package:flutter_localizations/flutter_localizations.dart';
import 'package:flutter_styled_toast/flutter_styled_toast.dart'; import 'package:flutter_styled_toast/flutter_styled_toast.dart';
import 'i18n/i18n.dart'; import 'l10n/l10n.dart';
import 'components/theme_switcher.dart'; import 'components/theme_switcher.dart';
import 'components/matrix.dart'; import 'components/matrix.dart';
import 'views/chat_list.dart'; import 'views/chat_list.dart';

View file

@ -1,4 +1,4 @@
import 'package:fluffychat/i18n/i18n.dart'; import 'package:fluffychat/l10n/l10n.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
/// Provides extra functionality for formatting the time. /// Provides extra functionality for formatting the time.
@ -34,7 +34,7 @@ extension DateTimeExtension on DateTime {
/// Returns a simple time String. /// Returns a simple time String.
/// TODO: Add localization /// TODO: Add localization
String localizedTimeOfDay(BuildContext context) { String localizedTimeOfDay(BuildContext context) {
return I18n.of(context).timeOfDay(_z(this.hour % 12), _z(this.hour), return L10n.of(context).timeOfDay(_z(this.hour % 12), _z(this.hour),
_z(this.minute), this.hour > 11 ? 'pm' : 'am'); _z(this.minute), this.hour > 11 ? 'pm' : 'am');
} }
@ -57,26 +57,26 @@ extension DateTimeExtension on DateTime {
} else if (sameWeek) { } else if (sameWeek) {
switch (this.weekday) { switch (this.weekday) {
case 1: case 1:
return I18n.of(context).monday; return L10n.of(context).monday;
case 2: case 2:
return I18n.of(context).tuesday; return L10n.of(context).tuesday;
case 3: case 3:
return I18n.of(context).wednesday; return L10n.of(context).wednesday;
case 4: case 4:
return I18n.of(context).thursday; return L10n.of(context).thursday;
case 5: case 5:
return I18n.of(context).friday; return L10n.of(context).friday;
case 6: case 6:
return I18n.of(context).saturday; return L10n.of(context).saturday;
case 7: case 7:
return I18n.of(context).sunday; return L10n.of(context).sunday;
} }
} else if (sameYear) { } else if (sameYear) {
return I18n.of(context).dateWithoutYear( return L10n.of(context).dateWithoutYear(
this.month.toString().padLeft(2, '0'), this.month.toString().padLeft(2, '0'),
this.day.toString().padLeft(2, '0')); this.day.toString().padLeft(2, '0'));
} }
return I18n.of(context).dateWithYear( return L10n.of(context).dateWithYear(
this.year.toString(), this.year.toString(),
this.month.toString().padLeft(2, '0'), this.month.toString().padLeft(2, '0'),
this.day.toString().padLeft(2, '0')); this.day.toString().padLeft(2, '0'));
@ -93,7 +93,7 @@ extension DateTimeExtension on DateTime {
bool sameDay = sameYear && now.month == this.month && now.day == this.day; bool sameDay = sameYear && now.month == this.month && now.day == this.day;
if (sameDay) return localizedTimeOfDay(context); if (sameDay) return localizedTimeOfDay(context);
return I18n.of(context).dateAndTimeOfDay( return L10n.of(context).dateAndTimeOfDay(
localizedTimeShort(context), localizedTimeOfDay(context)); localizedTimeShort(context), localizedTimeOfDay(context));
} }

View file

@ -3,7 +3,7 @@ import 'dart:io';
import 'package:firebase_messaging/firebase_messaging.dart'; import 'package:firebase_messaging/firebase_messaging.dart';
import 'package:fluffychat/components/matrix.dart'; import 'package:fluffychat/components/matrix.dart';
import 'package:fluffychat/i18n/i18n.dart'; import 'package:fluffychat/l10n/l10n.dart';
import 'package:fluffychat/utils/app_route.dart'; import 'package:fluffychat/utils/app_route.dart';
import 'package:fluffychat/views/chat.dart'; import 'package:fluffychat/views/chat.dart';
import 'package:flutter/foundation.dart'; import 'package:flutter/foundation.dart';
@ -31,7 +31,7 @@ abstract class FirebaseController {
} }
if (token?.isEmpty ?? true) { if (token?.isEmpty ?? true) {
showToast( showToast(
I18n.of(context).noGoogleServicesWarning, L10n.of(context).noGoogleServicesWarning,
duration: Duration(seconds: 15), duration: Duration(seconds: 15),
); );
return; return;
@ -106,7 +106,7 @@ abstract class FirebaseController {
if (context != null && Matrix.of(context).activeRoomId == roomId) { if (context != null && Matrix.of(context).activeRoomId == roomId) {
return null; return null;
} }
final i18n = context == null ? I18n('en') : I18n.of(context); final i18n = context == null ? L10n('en') : L10n.of(context);
// Get the client // Get the client
Client client; Client client;

View file

@ -1,5 +1,5 @@
import 'package:famedlysdk/famedlysdk.dart'; import 'package:famedlysdk/famedlysdk.dart';
import 'package:fluffychat/i18n/i18n.dart'; import 'package:fluffychat/l10n/l10n.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'date_time_extension.dart'; import 'date_time_extension.dart';
@ -8,6 +8,6 @@ extension PresenceExtension on Presence {
if (statusMsg?.isNotEmpty ?? false) { if (statusMsg?.isNotEmpty ?? false) {
return statusMsg; return statusMsg;
} }
return I18n.of(context).lastActiveAgo(time.localizedTimeShort(context)); return L10n.of(context).lastActiveAgo(time.localizedTimeShort(context));
} }
} }

View file

@ -1,7 +1,7 @@
import 'package:famedlysdk/famedlysdk.dart'; import 'package:famedlysdk/famedlysdk.dart';
import 'package:fluffychat/components/adaptive_page_layout.dart'; import 'package:fluffychat/components/adaptive_page_layout.dart';
import 'package:fluffychat/components/matrix.dart'; import 'package:fluffychat/components/matrix.dart';
import 'package:fluffychat/i18n/i18n.dart'; import 'package:fluffychat/l10n/l10n.dart';
import 'package:fluffychat/views/chat_list.dart'; import 'package:fluffychat/views/chat_list.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:olm/olm.dart' as olm; import 'package:olm/olm.dart' as olm;
@ -24,12 +24,12 @@ class AppInfo extends StatelessWidget {
Client client = Matrix.of(context).client; Client client = Matrix.of(context).client;
return Scaffold( return Scaffold(
appBar: AppBar( appBar: AppBar(
title: Text(I18n.of(context).accountInformations), title: Text(L10n.of(context).accountInformations),
), ),
body: ListView( body: ListView(
children: <Widget>[ children: <Widget>[
ListTile( ListTile(
title: Text(I18n.of(context).yourOwnUsername + ":"), title: Text(L10n.of(context).yourOwnUsername + ":"),
subtitle: Text(client.userID), subtitle: Text(client.userID),
), ),
ListTile( ListTile(

View file

@ -2,7 +2,7 @@ import 'package:famedlysdk/famedlysdk.dart';
import 'package:fluffychat/components/adaptive_page_layout.dart'; import 'package:fluffychat/components/adaptive_page_layout.dart';
import 'package:fluffychat/components/list_items/chat_list_item.dart'; import 'package:fluffychat/components/list_items/chat_list_item.dart';
import 'package:fluffychat/components/matrix.dart'; import 'package:fluffychat/components/matrix.dart';
import 'package:fluffychat/i18n/i18n.dart'; import 'package:fluffychat/l10n/l10n.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
class Archive extends StatefulWidget { class Archive extends StatefulWidget {
@ -23,7 +23,7 @@ class _ArchiveState extends State<Archive> {
return AdaptivePageLayout( return AdaptivePageLayout(
firstScaffold: Scaffold( firstScaffold: Scaffold(
appBar: AppBar( appBar: AppBar(
title: Text(I18n.of(context).archive), title: Text(L10n.of(context).archive),
), ),
body: FutureBuilder<List<Room>>( body: FutureBuilder<List<Room>>(
future: getArchive(context), future: getArchive(context),

View file

@ -1,5 +1,5 @@
import 'package:fluffychat/components/matrix.dart'; import 'package:fluffychat/components/matrix.dart';
import 'package:fluffychat/i18n/i18n.dart'; import 'package:fluffychat/l10n/l10n.dart';
import 'package:flutter/foundation.dart'; import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:url_launcher/url_launcher.dart'; import 'package:url_launcher/url_launcher.dart';
@ -19,7 +19,7 @@ class AuthWebView extends StatelessWidget {
if (kIsWeb) launch(url); if (kIsWeb) launch(url);
return Scaffold( return Scaffold(
appBar: AppBar( appBar: AppBar(
title: Text(I18n.of(context).authentication), title: Text(L10n.of(context).authentication),
leading: IconButton( leading: IconButton(
icon: Icon(Icons.close), icon: Icon(Icons.close),
onPressed: () { onPressed: () {

View file

@ -11,7 +11,7 @@ import 'package:fluffychat/components/encryption_button.dart';
import 'package:fluffychat/components/list_items/message.dart'; import 'package:fluffychat/components/list_items/message.dart';
import 'package:fluffychat/components/matrix.dart'; import 'package:fluffychat/components/matrix.dart';
import 'package:fluffychat/components/reply_content.dart'; import 'package:fluffychat/components/reply_content.dart';
import 'package:fluffychat/i18n/i18n.dart'; import 'package:fluffychat/l10n/l10n.dart';
import 'package:flutter/foundation.dart'; import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/services.dart'; import 'package:flutter/services.dart';
@ -119,14 +119,14 @@ class _ChatState extends State<_Chat> {
r.user.id == room.client.userID || r.user.id == room.client.userID ||
r.user.id == timeline.events.first.senderId); r.user.id == timeline.events.first.senderId);
if (lastReceipts.length == 1) { if (lastReceipts.length == 1) {
seenByText = I18n.of(context) seenByText = L10n.of(context)
.seenByUser(lastReceipts.first.user.calcDisplayname()); .seenByUser(lastReceipts.first.user.calcDisplayname());
} else if (lastReceipts.length == 2) { } else if (lastReceipts.length == 2) {
seenByText = seenByText = I18n.of(context).seenByUserAndUser( seenByText = seenByText = L10n.of(context).seenByUserAndUser(
lastReceipts.first.user.calcDisplayname(), lastReceipts.first.user.calcDisplayname(),
lastReceipts[1].user.calcDisplayname()); lastReceipts[1].user.calcDisplayname());
} else if (lastReceipts.length > 2) { } else if (lastReceipts.length > 2) {
seenByText = I18n.of(context).seenByUserAndCountOthers( seenByText = L10n.of(context).seenByUserAndCountOthers(
lastReceipts.first.user.calcDisplayname(), lastReceipts.first.user.calcDisplayname(),
(lastReceipts.length - 1).toString()); (lastReceipts.length - 1).toString());
} }
@ -175,7 +175,7 @@ class _ChatState extends State<_Chat> {
void sendFileAction(BuildContext context) async { void sendFileAction(BuildContext context) async {
if (kIsWeb) { if (kIsWeb) {
showToast(I18n.of(context).notSupportedInWeb); showToast(L10n.of(context).notSupportedInWeb);
return; return;
} }
File file = await FilePicker.getFile(); File file = await FilePicker.getFile();
@ -189,7 +189,7 @@ class _ChatState extends State<_Chat> {
void sendImageAction(BuildContext context) async { void sendImageAction(BuildContext context) async {
if (kIsWeb) { if (kIsWeb) {
showToast(I18n.of(context).notSupportedInWeb); showToast(L10n.of(context).notSupportedInWeb);
return; return;
} }
File file = await ImagePicker.pickImage( File file = await ImagePicker.pickImage(
@ -207,7 +207,7 @@ class _ChatState extends State<_Chat> {
void openCameraAction(BuildContext context) async { void openCameraAction(BuildContext context) async {
if (kIsWeb) { if (kIsWeb) {
showToast(I18n.of(context).notSupportedInWeb); showToast(L10n.of(context).notSupportedInWeb);
return; return;
} }
File file = await ImagePicker.pickImage( File file = await ImagePicker.pickImage(
@ -242,12 +242,12 @@ class _ChatState extends State<_Chat> {
String _getSelectedEventString(BuildContext context) { String _getSelectedEventString(BuildContext context) {
String copyString = ""; String copyString = "";
if (selectedEvents.length == 1) { if (selectedEvents.length == 1) {
return selectedEvents.first.getLocalizedBody(I18n.of(context)); return selectedEvents.first.getLocalizedBody(L10n.of(context));
} }
for (Event event in selectedEvents) { for (Event event in selectedEvents) {
if (copyString.isNotEmpty) copyString += "\n\n"; if (copyString.isNotEmpty) copyString += "\n\n";
copyString += copyString +=
event.getLocalizedBody(I18n.of(context), withSenderNamePrefix: true); event.getLocalizedBody(L10n.of(context), withSenderNamePrefix: true);
} }
return copyString; return copyString;
} }
@ -259,8 +259,8 @@ class _ChatState extends State<_Chat> {
void redactEventsAction(BuildContext context) async { void redactEventsAction(BuildContext context) async {
bool confirmed = await SimpleDialogs(context).askConfirmation( bool confirmed = await SimpleDialogs(context).askConfirmation(
titleText: I18n.of(context).messageWillBeRemovedWarning, titleText: L10n.of(context).messageWillBeRemovedWarning,
confirmText: I18n.of(context).remove, confirmText: L10n.of(context).remove,
); );
if (!confirmed) return; if (!confirmed) return;
for (Event event in selectedEvents) { for (Event event in selectedEvents) {
@ -311,10 +311,10 @@ class _ChatState extends State<_Chat> {
if (room == null) { if (room == null) {
return Scaffold( return Scaffold(
appBar: AppBar( appBar: AppBar(
title: Text(I18n.of(context).oopsSomethingWentWrong), title: Text(L10n.of(context).oopsSomethingWentWrong),
), ),
body: Center( body: Center(
child: Text(I18n.of(context).youAreNoLongerParticipatingInThisChat), child: Text(L10n.of(context).youAreNoLongerParticipatingInThisChat),
), ),
); );
} }
@ -329,17 +329,17 @@ class _ChatState extends State<_Chat> {
typingUsers.removeWhere((User u) => u.id == client.userID); typingUsers.removeWhere((User u) => u.id == client.userID);
if (typingUsers.length == 1) { if (typingUsers.length == 1) {
typingText = I18n.of(context).isTyping; typingText = L10n.of(context).isTyping;
if (typingUsers.first.id != room.directChatMatrixID) { if (typingUsers.first.id != room.directChatMatrixID) {
typingText = typingText =
I18n.of(context).userIsTyping(typingUsers.first.calcDisplayname()); L10n.of(context).userIsTyping(typingUsers.first.calcDisplayname());
} }
} else if (typingUsers.length == 2) { } else if (typingUsers.length == 2) {
typingText = I18n.of(context).userAndUserAreTyping( typingText = L10n.of(context).userAndUserAreTyping(
typingUsers.first.calcDisplayname(), typingUsers.first.calcDisplayname(),
typingUsers[1].calcDisplayname()); typingUsers[1].calcDisplayname());
} else if (typingUsers.length > 2) { } else if (typingUsers.length > 2) {
typingText = I18n.of(context).userAndOthersAreTyping( typingText = L10n.of(context).userAndOthersAreTyping(
typingUsers.first.calcDisplayname(), typingUsers.first.calcDisplayname(),
(typingUsers.length - 1).toString()); (typingUsers.length - 1).toString());
} }
@ -359,7 +359,7 @@ class _ChatState extends State<_Chat> {
? CrossAxisAlignment.center ? CrossAxisAlignment.center
: CrossAxisAlignment.start, : CrossAxisAlignment.start,
children: <Widget>[ children: <Widget>[
Text(room.getLocalizedDisplayname(I18n.of(context))), Text(room.getLocalizedDisplayname(L10n.of(context))),
AnimatedContainer( AnimatedContainer(
duration: Duration(milliseconds: 500), duration: Duration(milliseconds: 500),
height: typingText.isEmpty ? 0 : 20, height: typingText.isEmpty ? 0 : 20,
@ -384,7 +384,7 @@ class _ChatState extends State<_Chat> {
), ),
], ],
) )
: Text(I18n.of(context) : Text(L10n.of(context)
.numberSelected(selectedEvents.length.toString())), .numberSelected(selectedEvents.length.toString())),
actions: selectMode actions: selectMode
? <Widget>[ ? <Widget>[
@ -550,7 +550,7 @@ class _ChatState extends State<_Chat> {
child: Row( child: Row(
children: <Widget>[ children: <Widget>[
Icon(Icons.keyboard_arrow_left), Icon(Icons.keyboard_arrow_left),
Text(I18n.of(context).forward), Text(L10n.of(context).forward),
], ],
), ),
), ),
@ -564,7 +564,7 @@ class _ChatState extends State<_Chat> {
child: Row( child: Row(
children: <Widget>[ children: <Widget>[
Text( Text(
I18n.of(context).reply), L10n.of(context).reply),
Icon(Icons Icon(Icons
.keyboard_arrow_right), .keyboard_arrow_right),
], ],
@ -578,7 +578,7 @@ class _ChatState extends State<_Chat> {
sendAgainAction(), sendAgainAction(),
child: Row( child: Row(
children: <Widget>[ children: <Widget>[
Text(I18n.of(context) Text(L10n.of(context)
.tryToSendAgain), .tryToSendAgain),
SizedBox(width: 4), SizedBox(width: 4),
Icon(Icons.send, size: 16), Icon(Icons.send, size: 16),
@ -616,7 +616,7 @@ class _ChatState extends State<_Chat> {
child: Icon(Icons.attachment), child: Icon(Icons.attachment),
), ),
title: title:
Text(I18n.of(context).sendFile), Text(L10n.of(context).sendFile),
contentPadding: EdgeInsets.all(0), contentPadding: EdgeInsets.all(0),
), ),
), ),
@ -629,7 +629,7 @@ class _ChatState extends State<_Chat> {
child: Icon(Icons.image), child: Icon(Icons.image),
), ),
title: Text( title: Text(
I18n.of(context).sendImage), L10n.of(context).sendImage),
contentPadding: EdgeInsets.all(0), contentPadding: EdgeInsets.all(0),
), ),
), ),
@ -642,7 +642,7 @@ class _ChatState extends State<_Chat> {
child: Icon(Icons.camera_alt), child: Icon(Icons.camera_alt),
), ),
title: Text( title: Text(
I18n.of(context).openCamera), L10n.of(context).openCamera),
contentPadding: EdgeInsets.all(0), contentPadding: EdgeInsets.all(0),
), ),
), ),
@ -655,7 +655,7 @@ class _ChatState extends State<_Chat> {
child: Icon(Icons.mic), child: Icon(Icons.mic),
), ),
title: Text( title: Text(
I18n.of(context).voiceMessage), L10n.of(context).voiceMessage),
contentPadding: EdgeInsets.all(0), contentPadding: EdgeInsets.all(0),
), ),
), ),
@ -681,7 +681,7 @@ class _ChatState extends State<_Chat> {
controller: sendController, controller: sendController,
decoration: InputDecoration( decoration: InputDecoration(
hintText: hintText:
I18n.of(context).writeAMessage, L10n.of(context).writeAMessage,
border: InputBorder.none, border: InputBorder.none,
), ),
onChanged: (String text) { onChanged: (String text) {

View file

@ -7,7 +7,7 @@ import 'package:fluffychat/components/chat_settings_popup_menu.dart';
import 'package:fluffychat/components/content_banner.dart'; import 'package:fluffychat/components/content_banner.dart';
import 'package:fluffychat/components/dialogs/simple_dialogs.dart'; import 'package:fluffychat/components/dialogs/simple_dialogs.dart';
import 'package:fluffychat/components/list_items/participant_list_item.dart'; import 'package:fluffychat/components/list_items/participant_list_item.dart';
import 'package:fluffychat/i18n/i18n.dart'; import 'package:fluffychat/l10n/l10n.dart';
import 'package:fluffychat/utils/app_route.dart'; import 'package:fluffychat/utils/app_route.dart';
import 'package:fluffychat/views/chat_list.dart'; import 'package:fluffychat/views/chat_list.dart';
import 'package:fluffychat/views/invitation_selection.dart'; import 'package:fluffychat/views/invitation_selection.dart';
@ -31,24 +31,24 @@ class _ChatDetailsState extends State<ChatDetails> {
List<User> members; List<User> members;
void setDisplaynameAction(BuildContext context) async { void setDisplaynameAction(BuildContext context) async {
final String displayname = await SimpleDialogs(context).enterText( final String displayname = await SimpleDialogs(context).enterText(
titleText: I18n.of(context).changeTheNameOfTheGroup, titleText: L10n.of(context).changeTheNameOfTheGroup,
labelText: I18n.of(context).changeTheNameOfTheGroup, labelText: L10n.of(context).changeTheNameOfTheGroup,
hintText: widget.room.getLocalizedDisplayname(I18n.of(context)), hintText: widget.room.getLocalizedDisplayname(L10n.of(context)),
); );
if (displayname == null) return; if (displayname == null) return;
final success = await SimpleDialogs(context).tryRequestWithLoadingDialog( final success = await SimpleDialogs(context).tryRequestWithLoadingDialog(
widget.room.setName(displayname), widget.room.setName(displayname),
); );
if (success != false) { if (success != false) {
showToast(I18n.of(context).displaynameHasBeenChanged); showToast(L10n.of(context).displaynameHasBeenChanged);
} }
} }
void setCanonicalAliasAction(context) async { void setCanonicalAliasAction(context) async {
final String s = await SimpleDialogs(context).enterText( final String s = await SimpleDialogs(context).enterText(
titleText: I18n.of(context).setInvitationLink, titleText: L10n.of(context).setInvitationLink,
labelText: I18n.of(context).setInvitationLink, labelText: L10n.of(context).setInvitationLink,
hintText: I18n.of(context).alias.toLowerCase(), hintText: L10n.of(context).alias.toLowerCase(),
prefixText: "#", prefixText: "#",
suffixText: ":" + widget.room.client.userID.domain, suffixText: ":" + widget.room.client.userID.domain,
); );
@ -89,11 +89,11 @@ class _ChatDetailsState extends State<ChatDetails> {
void setTopicAction(BuildContext context) async { void setTopicAction(BuildContext context) async {
final String displayname = await SimpleDialogs(context).enterText( final String displayname = await SimpleDialogs(context).enterText(
titleText: I18n.of(context).setGroupDescription, titleText: L10n.of(context).setGroupDescription,
labelText: I18n.of(context).setGroupDescription, labelText: L10n.of(context).setGroupDescription,
hintText: (widget.room.topic?.isNotEmpty ?? false) hintText: (widget.room.topic?.isNotEmpty ?? false)
? widget.room.topic ? widget.room.topic
: I18n.of(context).addGroupDescription, : L10n.of(context).addGroupDescription,
multiLine: true, multiLine: true,
); );
if (displayname == null) return; if (displayname == null) return;
@ -101,7 +101,7 @@ class _ChatDetailsState extends State<ChatDetails> {
widget.room.setDescription(displayname), widget.room.setDescription(displayname),
); );
if (success != false) { if (success != false) {
showToast(I18n.of(context).groupDescriptionHasBeenChanged); showToast(L10n.of(context).groupDescriptionHasBeenChanged);
} }
} }
@ -121,7 +121,7 @@ class _ChatDetailsState extends State<ChatDetails> {
), ),
); );
if (success != false) { if (success != false) {
showToast(I18n.of(context).avatarHasBeenChanged); showToast(L10n.of(context).avatarHasBeenChanged);
} }
} }
@ -144,10 +144,10 @@ class _ChatDetailsState extends State<ChatDetails> {
if (widget.room == null) { if (widget.room == null) {
return Scaffold( return Scaffold(
appBar: AppBar( appBar: AppBar(
title: Text(I18n.of(context).oopsSomethingWentWrong), title: Text(L10n.of(context).oopsSomethingWentWrong),
), ),
body: Center( body: Center(
child: Text(I18n.of(context).youAreNoLongerParticipatingInThisChat), child: Text(L10n.of(context).youAreNoLongerParticipatingInThisChat),
), ),
); );
} }
@ -179,12 +179,12 @@ class _ChatDetailsState extends State<ChatDetails> {
Clipboard.setData( Clipboard.setData(
ClipboardData(text: widget.room.canonicalAlias), ClipboardData(text: widget.room.canonicalAlias),
); );
showToast(I18n.of(context).copiedToClipboard); showToast(L10n.of(context).copiedToClipboard);
}, },
), ),
ChatSettingsPopupMenu(widget.room, false) ChatSettingsPopupMenu(widget.room, false)
], ],
title: Text(widget.room.getLocalizedDisplayname(I18n.of(context)), title: Text(widget.room.getLocalizedDisplayname(L10n.of(context)),
style: TextStyle( style: TextStyle(
color: Theme.of(context) color: Theme.of(context)
.appBarTheme .appBarTheme
@ -215,13 +215,13 @@ class _ChatDetailsState extends State<ChatDetails> {
child: Icon(Icons.edit), child: Icon(Icons.edit),
) )
: null, : null,
title: Text("${I18n.of(context).groupDescription}:", title: Text("${L10n.of(context).groupDescription}:",
style: TextStyle( style: TextStyle(
color: Theme.of(context).primaryColor, color: Theme.of(context).primaryColor,
fontWeight: FontWeight.bold)), fontWeight: FontWeight.bold)),
subtitle: LinkText( subtitle: LinkText(
text: widget.room.topic?.isEmpty ?? true text: widget.room.topic?.isEmpty ?? true
? I18n.of(context).addGroupDescription ? L10n.of(context).addGroupDescription
: widget.room.topic, : widget.room.topic,
linkStyle: TextStyle(color: Colors.blueAccent), linkStyle: TextStyle(color: Colors.blueAccent),
textStyle: TextStyle( textStyle: TextStyle(
@ -236,7 +236,7 @@ class _ChatDetailsState extends State<ChatDetails> {
Divider(thickness: 1), Divider(thickness: 1),
ListTile( ListTile(
title: Text( title: Text(
I18n.of(context).settings, L10n.of(context).settings,
style: TextStyle( style: TextStyle(
color: Theme.of(context).primaryColor, color: Theme.of(context).primaryColor,
fontWeight: FontWeight.bold, fontWeight: FontWeight.bold,
@ -251,9 +251,9 @@ class _ChatDetailsState extends State<ChatDetails> {
foregroundColor: Colors.grey, foregroundColor: Colors.grey,
child: Icon(Icons.people), child: Icon(Icons.people),
), ),
title: Text(I18n.of(context).changeTheNameOfTheGroup), title: Text(L10n.of(context).changeTheNameOfTheGroup),
subtitle: Text(widget.room subtitle: Text(widget.room
.getLocalizedDisplayname(I18n.of(context))), .getLocalizedDisplayname(L10n.of(context))),
onTap: () => setDisplaynameAction(context), onTap: () => setDisplaynameAction(context),
), ),
if (widget.room.canSendEvent("m.room.canonical_alias") && if (widget.room.canSendEvent("m.room.canonical_alias") &&
@ -266,11 +266,11 @@ class _ChatDetailsState extends State<ChatDetails> {
child: Icon(Icons.link), child: Icon(Icons.link),
), ),
onTap: () => setCanonicalAliasAction(context), onTap: () => setCanonicalAliasAction(context),
title: Text(I18n.of(context).setInvitationLink), title: Text(L10n.of(context).setInvitationLink),
subtitle: Text( subtitle: Text(
(widget.room.canonicalAlias?.isNotEmpty ?? false) (widget.room.canonicalAlias?.isNotEmpty ?? false)
? widget.room.canonicalAlias ? widget.room.canonicalAlias
: I18n.of(context).none), : L10n.of(context).none),
), ),
PopupMenuButton( PopupMenuButton(
child: ListTile( child: ListTile(
@ -280,10 +280,10 @@ class _ChatDetailsState extends State<ChatDetails> {
foregroundColor: Colors.grey, foregroundColor: Colors.grey,
child: Icon(Icons.public)), child: Icon(Icons.public)),
title: Text( title: Text(
I18n.of(context).whoIsAllowedToJoinThisGroup), L10n.of(context).whoIsAllowedToJoinThisGroup),
subtitle: Text( subtitle: Text(
widget.room.joinRules widget.room.joinRules
.getLocalizedString(I18n.of(context)), .getLocalizedString(L10n.of(context)),
), ),
), ),
onSelected: (JoinRules joinRule) => onSelected: (JoinRules joinRule) =>
@ -296,13 +296,13 @@ class _ChatDetailsState extends State<ChatDetails> {
PopupMenuItem<JoinRules>( PopupMenuItem<JoinRules>(
value: JoinRules.public, value: JoinRules.public,
child: Text(JoinRules.public child: Text(JoinRules.public
.getLocalizedString(I18n.of(context))), .getLocalizedString(L10n.of(context))),
), ),
if (widget.room.canChangeJoinRules) if (widget.room.canChangeJoinRules)
PopupMenuItem<JoinRules>( PopupMenuItem<JoinRules>(
value: JoinRules.invite, value: JoinRules.invite,
child: Text(JoinRules.invite child: Text(JoinRules.invite
.getLocalizedString(I18n.of(context))), .getLocalizedString(L10n.of(context))),
), ),
], ],
), ),
@ -315,10 +315,10 @@ class _ChatDetailsState extends State<ChatDetails> {
child: Icon(Icons.visibility), child: Icon(Icons.visibility),
), ),
title: title:
Text(I18n.of(context).visibilityOfTheChatHistory), Text(L10n.of(context).visibilityOfTheChatHistory),
subtitle: Text( subtitle: Text(
widget.room.historyVisibility widget.room.historyVisibility
.getLocalizedString(I18n.of(context)), .getLocalizedString(L10n.of(context)),
), ),
), ),
onSelected: (HistoryVisibility historyVisibility) => onSelected: (HistoryVisibility historyVisibility) =>
@ -331,25 +331,25 @@ class _ChatDetailsState extends State<ChatDetails> {
PopupMenuItem<HistoryVisibility>( PopupMenuItem<HistoryVisibility>(
value: HistoryVisibility.invited, value: HistoryVisibility.invited,
child: Text(HistoryVisibility.invited child: Text(HistoryVisibility.invited
.getLocalizedString(I18n.of(context))), .getLocalizedString(L10n.of(context))),
), ),
if (widget.room.canChangeHistoryVisibility) if (widget.room.canChangeHistoryVisibility)
PopupMenuItem<HistoryVisibility>( PopupMenuItem<HistoryVisibility>(
value: HistoryVisibility.joined, value: HistoryVisibility.joined,
child: Text(HistoryVisibility.joined child: Text(HistoryVisibility.joined
.getLocalizedString(I18n.of(context))), .getLocalizedString(L10n.of(context))),
), ),
if (widget.room.canChangeHistoryVisibility) if (widget.room.canChangeHistoryVisibility)
PopupMenuItem<HistoryVisibility>( PopupMenuItem<HistoryVisibility>(
value: HistoryVisibility.shared, value: HistoryVisibility.shared,
child: Text(HistoryVisibility.shared child: Text(HistoryVisibility.shared
.getLocalizedString(I18n.of(context))), .getLocalizedString(L10n.of(context))),
), ),
if (widget.room.canChangeHistoryVisibility) if (widget.room.canChangeHistoryVisibility)
PopupMenuItem<HistoryVisibility>( PopupMenuItem<HistoryVisibility>(
value: HistoryVisibility.world_readable, value: HistoryVisibility.world_readable,
child: Text(HistoryVisibility.world_readable child: Text(HistoryVisibility.world_readable
.getLocalizedString(I18n.of(context))), .getLocalizedString(L10n.of(context))),
), ),
], ],
), ),
@ -363,10 +363,10 @@ class _ChatDetailsState extends State<ChatDetails> {
child: Icon(Icons.info_outline), child: Icon(Icons.info_outline),
), ),
title: title:
Text(I18n.of(context).areGuestsAllowedToJoin), Text(L10n.of(context).areGuestsAllowedToJoin),
subtitle: Text( subtitle: Text(
widget.room.guestAccess widget.room.guestAccess
.getLocalizedString(I18n.of(context)), .getLocalizedString(L10n.of(context)),
), ),
), ),
onSelected: (GuestAccess guestAccess) => onSelected: (GuestAccess guestAccess) =>
@ -381,7 +381,7 @@ class _ChatDetailsState extends State<ChatDetails> {
value: GuestAccess.can_join, value: GuestAccess.can_join,
child: Text( child: Text(
GuestAccess.can_join GuestAccess.can_join
.getLocalizedString(I18n.of(context)), .getLocalizedString(L10n.of(context)),
), ),
), ),
if (widget.room.canChangeGuestAccess) if (widget.room.canChangeGuestAccess)
@ -389,7 +389,7 @@ class _ChatDetailsState extends State<ChatDetails> {
value: GuestAccess.forbidden, value: GuestAccess.forbidden,
child: Text( child: Text(
GuestAccess.forbidden GuestAccess.forbidden
.getLocalizedString(I18n.of(context)), .getLocalizedString(L10n.of(context)),
), ),
), ),
], ],
@ -398,9 +398,9 @@ class _ChatDetailsState extends State<ChatDetails> {
ListTile( ListTile(
title: Text( title: Text(
actualMembersCount > 1 actualMembersCount > 1
? I18n.of(context).countParticipants( ? L10n.of(context).countParticipants(
actualMembersCount.toString()) actualMembersCount.toString())
: I18n.of(context).emptyChat, : L10n.of(context).emptyChat,
style: TextStyle( style: TextStyle(
color: Theme.of(context).primaryColor, color: Theme.of(context).primaryColor,
fontWeight: FontWeight.bold, fontWeight: FontWeight.bold,
@ -409,7 +409,7 @@ class _ChatDetailsState extends State<ChatDetails> {
), ),
widget.room.canInvite widget.room.canInvite
? ListTile( ? ListTile(
title: Text(I18n.of(context).inviteContact), title: Text(L10n.of(context).inviteContact),
leading: CircleAvatar( leading: CircleAvatar(
child: Icon(Icons.add), child: Icon(Icons.add),
backgroundColor: Theme.of(context).primaryColor, backgroundColor: Theme.of(context).primaryColor,
@ -428,7 +428,7 @@ class _ChatDetailsState extends State<ChatDetails> {
: i < members.length + 1 : i < members.length + 1
? ParticipantListItem(members[i - 1]) ? ParticipantListItem(members[i - 1])
: ListTile( : ListTile(
title: Text(I18n.of(context).loadCountMoreParticipants( title: Text(L10n.of(context).loadCountMoreParticipants(
(actualMembersCount - members.length).toString())), (actualMembersCount - members.length).toString())),
leading: CircleAvatar( leading: CircleAvatar(
backgroundColor: backgroundColor:

View file

@ -5,7 +5,7 @@ import 'package:fluffychat/components/adaptive_page_layout.dart';
import 'package:fluffychat/components/avatar.dart'; import 'package:fluffychat/components/avatar.dart';
import 'package:fluffychat/components/matrix.dart'; import 'package:fluffychat/components/matrix.dart';
import 'package:fluffychat/utils/beautify_string_extension.dart'; import 'package:fluffychat/utils/beautify_string_extension.dart';
import 'package:fluffychat/i18n/i18n.dart'; import 'package:fluffychat/l10n/l10n.dart';
import 'package:fluffychat/views/chat_list.dart'; import 'package:fluffychat/views/chat_list.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
@ -52,7 +52,7 @@ class _ChatEncryptionSettingsState extends State<ChatEncryptionSettings> {
return Scaffold( return Scaffold(
appBar: AppBar( appBar: AppBar(
title: Text(I18n.of(context).participatingUserDevices), title: Text(L10n.of(context).participatingUserDevices),
), ),
body: Column( body: Column(
children: <Widget>[ children: <Widget>[
@ -61,7 +61,7 @@ class _ChatEncryptionSettingsState extends State<ChatEncryptionSettings> {
builder: (BuildContext context, snapshot) { builder: (BuildContext context, snapshot) {
if (snapshot.hasError) { if (snapshot.hasError) {
return Center( return Center(
child: Text(I18n.of(context).oopsSomethingWentWrong + child: Text(L10n.of(context).oopsSomethingWentWrong +
": " + ": " +
snapshot.error.toString()), snapshot.error.toString()),
); );
@ -99,7 +99,7 @@ class _ChatEncryptionSettingsState extends State<ChatEncryptionSettings> {
), ),
CheckboxListTile( CheckboxListTile(
title: Text( title: Text(
"${deviceKeys[i].unsigned["device_display_name"] ?? I18n.of(context).unknownDevice} - ${deviceKeys[i].deviceId}", "${deviceKeys[i].unsigned["device_display_name"] ?? L10n.of(context).unknownDevice} - ${deviceKeys[i].deviceId}",
style: TextStyle( style: TextStyle(
color: deviceKeys[i].blocked color: deviceKeys[i].blocked
? Colors.red ? Colors.red

View file

@ -15,7 +15,7 @@ import '../components/theme_switcher.dart';
import '../components/adaptive_page_layout.dart'; import '../components/adaptive_page_layout.dart';
import '../components/list_items/chat_list_item.dart'; import '../components/list_items/chat_list_item.dart';
import '../components/matrix.dart'; import '../components/matrix.dart';
import '../i18n/i18n.dart'; import '../l10n/l10n.dart';
import '../utils/app_route.dart'; import '../utils/app_route.dart';
import '../utils/url_launcher.dart'; import '../utils/url_launcher.dart';
import '../utils/client_presence_extension.dart'; import '../utils/client_presence_extension.dart';
@ -185,9 +185,9 @@ class _ChatListState extends State<ChatList> {
Navigator.of(context).pop(); Navigator.of(context).pop();
final status = await SimpleDialogs(context).enterText( final status = await SimpleDialogs(context).enterText(
multiLine: true, multiLine: true,
titleText: I18n.of(context).setStatus, titleText: L10n.of(context).setStatus,
labelText: I18n.of(context).setStatus, labelText: L10n.of(context).setStatus,
hintText: I18n.of(context).statusExampleMessage, hintText: L10n.of(context).statusExampleMessage,
); );
if (status?.isEmpty ?? true) return; if (status?.isEmpty ?? true) return;
await SimpleDialogs(context).tryRequestWithLoadingDialog( await SimpleDialogs(context).tryRequestWithLoadingDialog(
@ -238,31 +238,31 @@ class _ChatListState extends State<ChatList> {
children: <Widget>[ children: <Widget>[
ListTile( ListTile(
leading: Icon(Icons.edit), leading: Icon(Icons.edit),
title: Text(I18n.of(context).setStatus), title: Text(L10n.of(context).setStatus),
onTap: () => _setStatus(context), onTap: () => _setStatus(context),
), ),
Divider(height: 1), Divider(height: 1),
ListTile( ListTile(
leading: Icon(Icons.people_outline), leading: Icon(Icons.people_outline),
title: Text(I18n.of(context).createNewGroup), title: Text(L10n.of(context).createNewGroup),
onTap: () => _drawerTapAction(NewGroupView()), onTap: () => _drawerTapAction(NewGroupView()),
), ),
ListTile( ListTile(
leading: Icon(Icons.person_add), leading: Icon(Icons.person_add),
title: Text(I18n.of(context).newPrivateChat), title: Text(L10n.of(context).newPrivateChat),
onTap: () => _drawerTapAction(NewPrivateChatView()), onTap: () => _drawerTapAction(NewPrivateChatView()),
), ),
Divider(height: 1), Divider(height: 1),
ListTile( ListTile(
leading: Icon(Icons.archive), leading: Icon(Icons.archive),
title: Text(I18n.of(context).archive), title: Text(L10n.of(context).archive),
onTap: () => _drawerTapAction( onTap: () => _drawerTapAction(
Archive(), Archive(),
), ),
), ),
ListTile( ListTile(
leading: Icon(Icons.settings), leading: Icon(Icons.settings),
title: Text(I18n.of(context).settings), title: Text(L10n.of(context).settings),
onTap: () => _drawerTapAction( onTap: () => _drawerTapAction(
SettingsView(), SettingsView(),
), ),
@ -270,10 +270,10 @@ class _ChatListState extends State<ChatList> {
Divider(height: 1), Divider(height: 1),
ListTile( ListTile(
leading: Icon(Icons.share), leading: Icon(Icons.share),
title: Text(I18n.of(context).inviteContact), title: Text(L10n.of(context).inviteContact),
onTap: () { onTap: () {
Navigator.of(context).pop(); Navigator.of(context).pop();
Share.share(I18n.of(context).inviteText( Share.share(L10n.of(context).inviteText(
Matrix.of(context).client.userID, Matrix.of(context).client.userID,
"https://matrix.to/#/${Matrix.of(context).client.userID}")); "https://matrix.to/#/${Matrix.of(context).client.userID}"));
}, },
@ -291,7 +291,7 @@ class _ChatListState extends State<ChatList> {
), ),
titleSpacing: 0, titleSpacing: 0,
title: selectMode == SelectMode.share title: selectMode == SelectMode.share
? Text(I18n.of(context).share) ? Text(L10n.of(context).share)
: Container( : Container(
padding: EdgeInsets.all(8), padding: EdgeInsets.all(8),
height: 42, height: 42,
@ -316,7 +316,7 @@ class _ChatListState extends State<ChatList> {
: Icon(Icons.search), : Icon(Icons.search),
contentPadding: EdgeInsets.all(9), contentPadding: EdgeInsets.all(9),
border: InputBorder.none, border: InputBorder.none,
hintText: I18n.of(context).searchForAChat, hintText: L10n.of(context).searchForAChat,
), ),
), ),
), ),
@ -334,7 +334,7 @@ class _ChatListState extends State<ChatList> {
child: Icon(Icons.people_outline), child: Icon(Icons.people_outline),
foregroundColor: Colors.white, foregroundColor: Colors.white,
backgroundColor: Colors.blue, backgroundColor: Colors.blue,
label: I18n.of(context).createNewGroup, label: L10n.of(context).createNewGroup,
labelStyle: TextStyle(fontSize: 18.0, color: Colors.black), labelStyle: TextStyle(fontSize: 18.0, color: Colors.black),
onTap: () => Navigator.of(context).pushAndRemoveUntil( onTap: () => Navigator.of(context).pushAndRemoveUntil(
AppRoute.defaultRoute(context, NewGroupView()), AppRoute.defaultRoute(context, NewGroupView()),
@ -344,7 +344,7 @@ class _ChatListState extends State<ChatList> {
child: Icon(Icons.person_add), child: Icon(Icons.person_add),
foregroundColor: Colors.white, foregroundColor: Colors.white,
backgroundColor: Colors.green, backgroundColor: Colors.green,
label: I18n.of(context).newPrivateChat, label: L10n.of(context).newPrivateChat,
labelStyle: TextStyle(fontSize: 18.0, color: Colors.black), labelStyle: TextStyle(fontSize: 18.0, color: Colors.black),
onTap: () => Navigator.of(context).pushAndRemoveUntil( onTap: () => Navigator.of(context).pushAndRemoveUntil(
AppRoute.defaultRoute(context, NewPrivateChatView()), AppRoute.defaultRoute(context, NewPrivateChatView()),
@ -373,8 +373,8 @@ class _ChatListState extends State<ChatList> {
color: Colors.grey, color: Colors.grey,
), ),
Text(searchMode Text(searchMode
? I18n.of(context).noRoomsFound ? L10n.of(context).noRoomsFound
: I18n.of(context).startYourFirstChat), : L10n.of(context).startYourFirstChat),
], ],
), ),
); );
@ -388,7 +388,7 @@ class _ChatListState extends State<ChatList> {
? Material( ? Material(
elevation: 2, elevation: 2,
child: ListTile( child: ListTile(
title: Text(I18n.of(context).publicRooms), title: Text(L10n.of(context).publicRooms),
), ),
) )
: Container(), : Container(),

View file

@ -2,7 +2,7 @@ import 'dart:math';
import 'package:fluffychat/components/dialogs/simple_dialogs.dart'; import 'package:fluffychat/components/dialogs/simple_dialogs.dart';
import 'package:fluffychat/components/matrix.dart'; import 'package:fluffychat/components/matrix.dart';
import 'package:fluffychat/i18n/i18n.dart'; import 'package:fluffychat/l10n/l10n.dart';
import 'package:fluffychat/utils/app_route.dart'; import 'package:fluffychat/utils/app_route.dart';
import 'package:fluffychat/views/sign_up.dart'; import 'package:fluffychat/views/sign_up.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
@ -10,7 +10,7 @@ import 'package:flutter/material.dart';
class HomeserverPicker extends StatelessWidget { class HomeserverPicker extends StatelessWidget {
_setHomeserverAction(BuildContext context) async { _setHomeserverAction(BuildContext context) async {
final homeserver = await SimpleDialogs(context).enterText( final homeserver = await SimpleDialogs(context).enterText(
titleText: I18n.of(context).enterYourHomeserver, titleText: L10n.of(context).enterYourHomeserver,
hintText: Matrix.defaultHomeserver, hintText: Matrix.defaultHomeserver,
prefixText: 'https://'); prefixText: 'https://');
if (homeserver?.isEmpty ?? true) return; if (homeserver?.isEmpty ?? true) return;
@ -45,7 +45,7 @@ class HomeserverPicker extends StatelessWidget {
Padding( Padding(
padding: const EdgeInsets.all(16.0), padding: const EdgeInsets.all(16.0),
child: Text( child: Text(
I18n.of(context).welcomeText, L10n.of(context).welcomeText,
textAlign: TextAlign.center, textAlign: TextAlign.center,
style: TextStyle( style: TextStyle(
fontSize: 22, fontSize: 22,
@ -66,7 +66,7 @@ class HomeserverPicker extends StatelessWidget {
borderRadius: BorderRadius.circular(6), borderRadius: BorderRadius.circular(6),
), ),
child: Text( child: Text(
I18n.of(context).connect.toUpperCase(), L10n.of(context).connect.toUpperCase(),
style: TextStyle(color: Colors.white, fontSize: 16), style: TextStyle(color: Colors.white, fontSize: 16),
), ),
onPressed: () => _checkHomeserverAction( onPressed: () => _checkHomeserverAction(
@ -80,7 +80,7 @@ class HomeserverPicker extends StatelessWidget {
child: Opacity( child: Opacity(
opacity: 0.75, opacity: 0.75,
child: Text( child: Text(
I18n.of(context).byDefaultYouWillBeConnectedTo( L10n.of(context).byDefaultYouWillBeConnectedTo(
Matrix.defaultHomeserver), Matrix.defaultHomeserver),
textAlign: TextAlign.center, textAlign: TextAlign.center,
style: TextStyle( style: TextStyle(
@ -91,7 +91,7 @@ class HomeserverPicker extends StatelessWidget {
), ),
FlatButton( FlatButton(
child: Text( child: Text(
I18n.of(context).changeTheHomeserver, L10n.of(context).changeTheHomeserver,
style: TextStyle( style: TextStyle(
decoration: TextDecoration.underline, decoration: TextDecoration.underline,
color: Colors.blue, color: Colors.blue,

View file

@ -5,7 +5,7 @@ import 'package:fluffychat/components/adaptive_page_layout.dart';
import 'package:fluffychat/components/avatar.dart'; import 'package:fluffychat/components/avatar.dart';
import 'package:fluffychat/components/dialogs/simple_dialogs.dart'; import 'package:fluffychat/components/dialogs/simple_dialogs.dart';
import 'package:fluffychat/components/matrix.dart'; import 'package:fluffychat/components/matrix.dart';
import 'package:fluffychat/i18n/i18n.dart'; import 'package:fluffychat/l10n/l10n.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_styled_toast/flutter_styled_toast.dart'; import 'package:flutter_styled_toast/flutter_styled_toast.dart';
@ -58,7 +58,7 @@ class _InvitationSelectionState extends State<InvitationSelection> {
widget.room.invite(id), widget.room.invite(id),
); );
if (success != false) { if (success != false) {
showToast(I18n.of(context).contactHasBeenInvitedToTheGroup); showToast(L10n.of(context).contactHasBeenInvitedToTheGroup);
} }
} }
@ -116,14 +116,14 @@ class _InvitationSelectionState extends State<InvitationSelection> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final String groupName = widget.room.name?.isEmpty ?? false final String groupName = widget.room.name?.isEmpty ?? false
? I18n.of(context).group ? L10n.of(context).group
: widget.room.name; : widget.room.name;
return AdaptivePageLayout( return AdaptivePageLayout(
primaryPage: FocusPage.SECOND, primaryPage: FocusPage.SECOND,
firstScaffold: ChatList(activeChat: widget.room.id), firstScaffold: ChatList(activeChat: widget.room.id),
secondScaffold: Scaffold( secondScaffold: Scaffold(
appBar: AppBar( appBar: AppBar(
title: Text(I18n.of(context).inviteContact), title: Text(L10n.of(context).inviteContact),
bottom: PreferredSize( bottom: PreferredSize(
preferredSize: Size.fromHeight(92), preferredSize: Size.fromHeight(92),
child: Padding( child: Padding(
@ -139,8 +139,8 @@ class _InvitationSelectionState extends State<InvitationSelection> {
decoration: InputDecoration( decoration: InputDecoration(
border: OutlineInputBorder(), border: OutlineInputBorder(),
prefixText: "@", prefixText: "@",
hintText: I18n.of(context).username, hintText: L10n.of(context).username,
labelText: I18n.of(context).inviteContactToGroup(groupName), labelText: L10n.of(context).inviteContactToGroup(groupName),
suffixIcon: loading suffixIcon: loading
? Container( ? Container(
padding: const EdgeInsets.all(8.0), padding: const EdgeInsets.all(8.0),

View file

@ -2,7 +2,7 @@ import 'dart:math';
import 'package:famedlysdk/famedlysdk.dart'; import 'package:famedlysdk/famedlysdk.dart';
import 'package:fluffychat/components/matrix.dart'; import 'package:fluffychat/components/matrix.dart';
import 'package:fluffychat/i18n/i18n.dart'; import 'package:fluffychat/l10n/l10n.dart';
import 'package:fluffychat/utils/app_route.dart'; import 'package:fluffychat/utils/app_route.dart';
import 'package:fluffychat/utils/firebase_controller.dart'; import 'package:fluffychat/utils/firebase_controller.dart';
import 'package:flutter/foundation.dart'; import 'package:flutter/foundation.dart';
@ -26,12 +26,12 @@ class _LoginState extends State<Login> {
void login(BuildContext context) async { void login(BuildContext context) async {
MatrixState matrix = Matrix.of(context); MatrixState matrix = Matrix.of(context);
if (usernameController.text.isEmpty) { if (usernameController.text.isEmpty) {
setState(() => usernameError = I18n.of(context).pleaseEnterYourUsername); setState(() => usernameError = L10n.of(context).pleaseEnterYourUsername);
} else { } else {
setState(() => usernameError = null); setState(() => usernameError = null);
} }
if (passwordController.text.isEmpty) { if (passwordController.text.isEmpty) {
setState(() => passwordError = I18n.of(context).pleaseEnterYourPassword); setState(() => passwordError = L10n.of(context).pleaseEnterYourPassword);
} else { } else {
setState(() => passwordError = null); setState(() => passwordError = null);
} }
@ -77,7 +77,7 @@ class _LoginState extends State<Login> {
leading: loading ? Container() : null, leading: loading ? Container() : null,
elevation: 0, elevation: 0,
title: Text( title: Text(
I18n.of(context).logInTo(Matrix.of(context) L10n.of(context).logInTo(Matrix.of(context)
.client .client
.homeserver .homeserver
.replaceFirst('https://', '')), .replaceFirst('https://', '')),
@ -101,9 +101,9 @@ class _LoginState extends State<Login> {
controller: usernameController, controller: usernameController,
decoration: InputDecoration( decoration: InputDecoration(
hintText: hintText:
"@${I18n.of(context).username.toLowerCase()}:domain", "@${L10n.of(context).username.toLowerCase()}:domain",
errorText: usernameError, errorText: usernameError,
labelText: I18n.of(context).username), labelText: L10n.of(context).username),
), ),
), ),
ListTile( ListTile(
@ -129,7 +129,7 @@ class _LoginState extends State<Login> {
onPressed: () => onPressed: () =>
setState(() => showPassword = !showPassword), setState(() => showPassword = !showPassword),
), ),
labelText: I18n.of(context).password), labelText: L10n.of(context).password),
), ),
), ),
SizedBox(height: 20), SizedBox(height: 20),
@ -147,7 +147,7 @@ class _LoginState extends State<Login> {
child: loading child: loading
? CircularProgressIndicator() ? CircularProgressIndicator()
: Text( : Text(
I18n.of(context).login.toUpperCase(), L10n.of(context).login.toUpperCase(),
style: TextStyle(color: Colors.white, fontSize: 16), style: TextStyle(color: Colors.white, fontSize: 16),
), ),
onPressed: () => loading ? null : login(context), onPressed: () => loading ? null : login(context),

View file

@ -1,7 +1,7 @@
import 'package:fluffychat/components/adaptive_page_layout.dart'; import 'package:fluffychat/components/adaptive_page_layout.dart';
import 'package:fluffychat/components/dialogs/simple_dialogs.dart'; import 'package:fluffychat/components/dialogs/simple_dialogs.dart';
import 'package:fluffychat/components/matrix.dart'; import 'package:fluffychat/components/matrix.dart';
import 'package:fluffychat/i18n/i18n.dart'; import 'package:fluffychat/l10n/l10n.dart';
import 'package:fluffychat/utils/app_route.dart'; import 'package:fluffychat/utils/app_route.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:pedantic/pedantic.dart'; import 'package:pedantic/pedantic.dart';
@ -72,7 +72,7 @@ class _NewGroupState extends State<_NewGroup> {
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Scaffold( return Scaffold(
appBar: AppBar( appBar: AppBar(
title: Text(I18n.of(context).createNewGroup), title: Text(L10n.of(context).createNewGroup),
elevation: 0, elevation: 0,
), ),
body: Column( body: Column(
@ -88,13 +88,13 @@ class _NewGroupState extends State<_NewGroup> {
onSubmitted: (s) => submitAction(context), onSubmitted: (s) => submitAction(context),
decoration: InputDecoration( decoration: InputDecoration(
border: OutlineInputBorder(), border: OutlineInputBorder(),
labelText: I18n.of(context).optionalGroupName, labelText: L10n.of(context).optionalGroupName,
prefixIcon: Icon(Icons.people), prefixIcon: Icon(Icons.people),
hintText: I18n.of(context).enterAGroupName), hintText: L10n.of(context).enterAGroupName),
), ),
), ),
SwitchListTile( SwitchListTile(
title: Text(I18n.of(context).groupIsPublic), title: Text(L10n.of(context).groupIsPublic),
value: publicGroup, value: publicGroup,
onChanged: (bool b) => setState(() => publicGroup = b), onChanged: (bool b) => setState(() => publicGroup = b),
), ),

View file

@ -5,7 +5,7 @@ import 'package:fluffychat/components/adaptive_page_layout.dart';
import 'package:fluffychat/components/avatar.dart'; import 'package:fluffychat/components/avatar.dart';
import 'package:fluffychat/components/dialogs/simple_dialogs.dart'; import 'package:fluffychat/components/dialogs/simple_dialogs.dart';
import 'package:fluffychat/components/matrix.dart'; import 'package:fluffychat/components/matrix.dart';
import 'package:fluffychat/i18n/i18n.dart'; import 'package:fluffychat/l10n/l10n.dart';
import 'package:fluffychat/utils/app_route.dart'; import 'package:fluffychat/utils/app_route.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:share/share.dart'; import 'package:share/share.dart';
@ -110,7 +110,7 @@ class _NewPrivateChatState extends State<_NewPrivateChat> {
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Scaffold( return Scaffold(
appBar: AppBar( appBar: AppBar(
title: Text(I18n.of(context).newPrivateChat), title: Text(L10n.of(context).newPrivateChat),
elevation: 0, elevation: 0,
), ),
body: Column( body: Column(
@ -129,24 +129,24 @@ class _NewPrivateChatState extends State<_NewPrivateChat> {
onFieldSubmitted: (s) => submitAction(context), onFieldSubmitted: (s) => submitAction(context),
validator: (value) { validator: (value) {
if (value.isEmpty) { if (value.isEmpty) {
return I18n.of(context).pleaseEnterAMatrixIdentifier; return L10n.of(context).pleaseEnterAMatrixIdentifier;
} }
final MatrixState matrix = Matrix.of(context); final MatrixState matrix = Matrix.of(context);
String mxid = "@" + controller.text.trim(); String mxid = "@" + controller.text.trim();
if (mxid == matrix.client.userID) { if (mxid == matrix.client.userID) {
return I18n.of(context).youCannotInviteYourself; return L10n.of(context).youCannotInviteYourself;
} }
if (!mxid.contains("@")) { if (!mxid.contains("@")) {
return I18n.of(context).makeSureTheIdentifierIsValid; return L10n.of(context).makeSureTheIdentifierIsValid;
} }
if (!mxid.contains(":")) { if (!mxid.contains(":")) {
return I18n.of(context).makeSureTheIdentifierIsValid; return L10n.of(context).makeSureTheIdentifierIsValid;
} }
return null; return null;
}, },
decoration: InputDecoration( decoration: InputDecoration(
border: OutlineInputBorder(), border: OutlineInputBorder(),
labelText: I18n.of(context).enterAUsername, labelText: L10n.of(context).enterAUsername,
prefixIcon: loading prefixIcon: loading
? Container( ? Container(
padding: const EdgeInsets.all(8.0), padding: const EdgeInsets.all(8.0),
@ -168,7 +168,7 @@ class _NewPrivateChatState extends State<_NewPrivateChat> {
) )
: Icon(Icons.account_circle), : Icon(Icons.account_circle),
prefixText: "@", prefixText: "@",
hintText: "${I18n.of(context).username.toLowerCase()}", hintText: "${L10n.of(context).username.toLowerCase()}",
), ),
), ),
), ),
@ -217,11 +217,11 @@ class _NewPrivateChatState extends State<_NewPrivateChat> {
Icons.share, Icons.share,
size: 16, size: 16,
), ),
onTap: () => Share.share(I18n.of(context).inviteText( onTap: () => Share.share(L10n.of(context).inviteText(
Matrix.of(context).client.userID, Matrix.of(context).client.userID,
"https://matrix.to/#/${Matrix.of(context).client.userID}")), "https://matrix.to/#/${Matrix.of(context).client.userID}")),
title: Text( title: Text(
"${I18n.of(context).yourOwnUsername}:", "${L10n.of(context).yourOwnUsername}:",
style: TextStyle( style: TextStyle(
fontStyle: FontStyle.italic, fontStyle: FontStyle.italic,
), ),

View file

@ -15,7 +15,7 @@ import '../components/adaptive_page_layout.dart';
import '../components/dialogs/simple_dialogs.dart'; import '../components/dialogs/simple_dialogs.dart';
import '../components/content_banner.dart'; import '../components/content_banner.dart';
import '../components/matrix.dart'; import '../components/matrix.dart';
import '../i18n/i18n.dart'; import '../l10n/l10n.dart';
import '../utils/app_route.dart'; import '../utils/app_route.dart';
class SettingsView extends StatelessWidget { class SettingsView extends StatelessWidget {
@ -52,9 +52,9 @@ class _SettingsState extends State<Settings> {
void setJitsiInstanceAction(BuildContext context) async { void setJitsiInstanceAction(BuildContext context) async {
var jitsi = await SimpleDialogs(context).enterText( var jitsi = await SimpleDialogs(context).enterText(
titleText: I18n.of(context).editJitsiInstance, titleText: L10n.of(context).editJitsiInstance,
hintText: Matrix.of(context).jitsiInstance, hintText: Matrix.of(context).jitsiInstance,
labelText: I18n.of(context).editJitsiInstance, labelText: L10n.of(context).editJitsiInstance,
); );
if (jitsi == null) return; if (jitsi == null) return;
if (!jitsi.endsWith('/')) { if (!jitsi.endsWith('/')) {
@ -67,10 +67,10 @@ class _SettingsState extends State<Settings> {
void setDisplaynameAction(BuildContext context) async { void setDisplaynameAction(BuildContext context) async {
final String displayname = await SimpleDialogs(context).enterText( final String displayname = await SimpleDialogs(context).enterText(
titleText: I18n.of(context).editDisplayname, titleText: L10n.of(context).editDisplayname,
hintText: hintText:
profile?.displayname ?? Matrix.of(context).client.userID.localpart, profile?.displayname ?? Matrix.of(context).client.userID.localpart,
labelText: I18n.of(context).enterAUsername, labelText: L10n.of(context).enterAUsername,
); );
if (displayname == null) return; if (displayname == null) return;
final MatrixState matrix = Matrix.of(context); final MatrixState matrix = Matrix.of(context);
@ -147,7 +147,7 @@ class _SettingsState extends State<Settings> {
backgroundColor: Theme.of(context).appBarTheme.color, backgroundColor: Theme.of(context).appBarTheme.color,
flexibleSpace: FlexibleSpaceBar( flexibleSpace: FlexibleSpaceBar(
title: Text( title: Text(
I18n.of(context).settings, L10n.of(context).settings,
style: TextStyle( style: TextStyle(
color: Theme.of(context) color: Theme.of(context)
.appBarTheme .appBarTheme
@ -169,7 +169,7 @@ class _SettingsState extends State<Settings> {
children: <Widget>[ children: <Widget>[
ListTile( ListTile(
title: Text( title: Text(
I18n.of(context).changeTheme, L10n.of(context).changeTheme,
style: TextStyle( style: TextStyle(
color: Theme.of(context).primaryColor, color: Theme.of(context).primaryColor,
fontWeight: FontWeight.bold, fontWeight: FontWeight.bold,
@ -181,7 +181,7 @@ class _SettingsState extends State<Settings> {
if (!kIsWeb && client.storeAPI != null) if (!kIsWeb && client.storeAPI != null)
ListTile( ListTile(
title: Text( title: Text(
I18n.of(context).wallpaper, L10n.of(context).wallpaper,
style: TextStyle( style: TextStyle(
color: Theme.of(context).primaryColor, color: Theme.of(context).primaryColor,
fontWeight: FontWeight.bold, fontWeight: FontWeight.bold,
@ -204,7 +204,7 @@ class _SettingsState extends State<Settings> {
if (!kIsWeb && client.storeAPI != null) if (!kIsWeb && client.storeAPI != null)
Builder(builder: (context) { Builder(builder: (context) {
return ListTile( return ListTile(
title: Text(I18n.of(context).changeWallpaper), title: Text(L10n.of(context).changeWallpaper),
trailing: Icon(Icons.wallpaper), trailing: Icon(Icons.wallpaper),
onTap: () => setWallpaperAction(context), onTap: () => setWallpaperAction(context),
); );
@ -212,7 +212,7 @@ class _SettingsState extends State<Settings> {
Divider(thickness: 1), Divider(thickness: 1),
ListTile( ListTile(
title: Text( title: Text(
I18n.of(context).account, L10n.of(context).account,
style: TextStyle( style: TextStyle(
color: Theme.of(context).primaryColor, color: Theme.of(context).primaryColor,
fontWeight: FontWeight.bold, fontWeight: FontWeight.bold,
@ -221,19 +221,19 @@ class _SettingsState extends State<Settings> {
), ),
ListTile( ListTile(
trailing: Icon(Icons.edit), trailing: Icon(Icons.edit),
title: Text(I18n.of(context).editDisplayname), title: Text(L10n.of(context).editDisplayname),
subtitle: Text(profile?.displayname ?? client.userID.localpart), subtitle: Text(profile?.displayname ?? client.userID.localpart),
onTap: () => setDisplaynameAction(context), onTap: () => setDisplaynameAction(context),
), ),
ListTile( ListTile(
trailing: Icon(Icons.phone), trailing: Icon(Icons.phone),
title: Text(I18n.of(context).editJitsiInstance), title: Text(L10n.of(context).editJitsiInstance),
subtitle: Text(Matrix.of(context).jitsiInstance), subtitle: Text(Matrix.of(context).jitsiInstance),
onTap: () => setJitsiInstanceAction(context), onTap: () => setJitsiInstanceAction(context),
), ),
ListTile( ListTile(
trailing: Icon(Icons.devices_other), trailing: Icon(Icons.devices_other),
title: Text(I18n.of(context).devices), title: Text(L10n.of(context).devices),
onTap: () async => await Navigator.of(context).push( onTap: () async => await Navigator.of(context).push(
AppRoute.defaultRoute( AppRoute.defaultRoute(
context, context,
@ -243,7 +243,7 @@ class _SettingsState extends State<Settings> {
), ),
ListTile( ListTile(
trailing: Icon(Icons.account_circle), trailing: Icon(Icons.account_circle),
title: Text(I18n.of(context).accountInformations), title: Text(L10n.of(context).accountInformations),
onTap: () => Navigator.of(context).push( onTap: () => Navigator.of(context).push(
AppRoute.defaultRoute( AppRoute.defaultRoute(
context, context,
@ -253,13 +253,13 @@ class _SettingsState extends State<Settings> {
), ),
ListTile( ListTile(
trailing: Icon(Icons.exit_to_app), trailing: Icon(Icons.exit_to_app),
title: Text(I18n.of(context).logout), title: Text(L10n.of(context).logout),
onTap: () => logoutAction(context), onTap: () => logoutAction(context),
), ),
Divider(thickness: 1), Divider(thickness: 1),
ListTile( ListTile(
title: Text( title: Text(
I18n.of(context).about, L10n.of(context).about,
style: TextStyle( style: TextStyle(
color: Theme.of(context).primaryColor, color: Theme.of(context).primaryColor,
fontWeight: FontWeight.bold, fontWeight: FontWeight.bold,
@ -268,19 +268,19 @@ class _SettingsState extends State<Settings> {
), ),
ListTile( ListTile(
trailing: Icon(Icons.help), trailing: Icon(Icons.help),
title: Text(I18n.of(context).help), title: Text(L10n.of(context).help),
onTap: () => launch( onTap: () => launch(
"https://gitlab.com/ChristianPauly/fluffychat-flutter/issues"), "https://gitlab.com/ChristianPauly/fluffychat-flutter/issues"),
), ),
ListTile( ListTile(
trailing: Icon(Icons.link), trailing: Icon(Icons.link),
title: Text(I18n.of(context).license), title: Text(L10n.of(context).license),
onTap: () => launch( onTap: () => launch(
"https://gitlab.com/ChristianPauly/fluffychat-flutter/raw/master/LICENSE"), "https://gitlab.com/ChristianPauly/fluffychat-flutter/raw/master/LICENSE"),
), ),
ListTile( ListTile(
trailing: Icon(Icons.code), trailing: Icon(Icons.code),
title: Text(I18n.of(context).sourceCode), title: Text(L10n.of(context).sourceCode),
onTap: () => launch( onTap: () => launch(
"https://gitlab.com/ChristianPauly/fluffychat-flutter"), "https://gitlab.com/ChristianPauly/fluffychat-flutter"),
), ),

View file

@ -5,7 +5,7 @@ import 'package:flutter/material.dart';
import '../utils/date_time_extension.dart'; import '../utils/date_time_extension.dart';
import '../components/adaptive_page_layout.dart'; import '../components/adaptive_page_layout.dart';
import '../components/matrix.dart'; import '../components/matrix.dart';
import '../i18n/i18n.dart'; import '../l10n/l10n.dart';
import 'chat_list.dart'; import 'chat_list.dart';
class DevicesSettingsView extends StatelessWidget { class DevicesSettingsView extends StatelessWidget {
@ -46,8 +46,8 @@ class DevicesSettingsState extends State<DevicesSettings> {
.tryRequestWithLoadingDialog(matrix.client.deleteDevices(deviceIds), .tryRequestWithLoadingDialog(matrix.client.deleteDevices(deviceIds),
onAdditionalAuth: (MatrixException exception) async { onAdditionalAuth: (MatrixException exception) async {
final String password = await SimpleDialogs(context).enterText( final String password = await SimpleDialogs(context).enterText(
titleText: I18n.of(context).pleaseEnterYourPassword, titleText: L10n.of(context).pleaseEnterYourPassword,
labelText: I18n.of(context).pleaseEnterYourPassword, labelText: L10n.of(context).pleaseEnterYourPassword,
hintText: "******", hintText: "******",
password: true); password: true);
if (password == null) return; if (password == null) return;
@ -63,7 +63,7 @@ class DevicesSettingsState extends State<DevicesSettings> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Scaffold( return Scaffold(
appBar: AppBar(title: Text(I18n.of(context).devices)), appBar: AppBar(title: Text(L10n.of(context).devices)),
body: FutureBuilder<bool>( body: FutureBuilder<bool>(
future: _loadUserDevices(context), future: _loadUserDevices(context),
builder: (BuildContext context, snapshot) { builder: (BuildContext context, snapshot) {
@ -99,7 +99,7 @@ class DevicesSettingsState extends State<DevicesSettings> {
if (devices.isNotEmpty) if (devices.isNotEmpty)
ListTile( ListTile(
title: Text( title: Text(
I18n.of(context).removeAllOtherDevices, L10n.of(context).removeAllOtherDevices,
style: TextStyle(color: Colors.red), style: TextStyle(color: Colors.red),
), ),
trailing: Icon(Icons.delete_outline), trailing: Icon(Icons.delete_outline),
@ -152,7 +152,7 @@ class UserDeviceListItem extends StatelessWidget {
itemBuilder: (BuildContext context) => [ itemBuilder: (BuildContext context) => [
PopupMenuItem<String>( PopupMenuItem<String>(
value: "remove", value: "remove",
child: Text(I18n.of(context).removeDevice, child: Text(L10n.of(context).removeDevice,
style: TextStyle(color: Colors.red)), style: TextStyle(color: Colors.red)),
), ),
], ],
@ -164,7 +164,7 @@ class UserDeviceListItem extends StatelessWidget {
child: Text( child: Text(
(userDevice.displayName?.isNotEmpty ?? false) (userDevice.displayName?.isNotEmpty ?? false)
? userDevice.displayName ? userDevice.displayName
: I18n.of(context).unknownDevice, : L10n.of(context).unknownDevice,
maxLines: 1, maxLines: 1,
overflow: TextOverflow.ellipsis, overflow: TextOverflow.ellipsis,
), ),
@ -175,8 +175,8 @@ class UserDeviceListItem extends StatelessWidget {
subtitle: Column( subtitle: Column(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[ children: <Widget>[
Text("${I18n.of(context).id}: ${userDevice.deviceId}"), Text("${L10n.of(context).id}: ${userDevice.deviceId}"),
Text("${I18n.of(context).lastSeenIp}: ${userDevice.lastSeenIp}"), Text("${L10n.of(context).lastSeenIp}: ${userDevice.lastSeenIp}"),
], ],
), ),
), ),

View file

@ -3,7 +3,7 @@ import 'dart:math';
import 'package:famedlysdk/famedlysdk.dart'; import 'package:famedlysdk/famedlysdk.dart';
import 'package:fluffychat/components/matrix.dart'; import 'package:fluffychat/components/matrix.dart';
import 'package:fluffychat/i18n/i18n.dart'; import 'package:fluffychat/l10n/l10n.dart';
import 'package:fluffychat/utils/app_route.dart'; import 'package:fluffychat/utils/app_route.dart';
import 'package:fluffychat/views/login.dart'; import 'package:fluffychat/views/login.dart';
import 'package:fluffychat/views/sign_up_password.dart'; import 'package:fluffychat/views/sign_up_password.dart';
@ -35,7 +35,7 @@ class _SignUpState extends State<SignUp> {
void signUpAction(BuildContext context) async { void signUpAction(BuildContext context) async {
MatrixState matrix = Matrix.of(context); MatrixState matrix = Matrix.of(context);
if (usernameController.text.isEmpty) { if (usernameController.text.isEmpty) {
setState(() => usernameError = I18n.of(context).pleaseChooseAUsername); setState(() => usernameError = L10n.of(context).pleaseChooseAUsername);
} else { } else {
setState(() => usernameError = null); setState(() => usernameError = null);
} }
@ -105,8 +105,8 @@ class _SignUpState extends State<SignUp> {
color: Colors.red, color: Colors.red,
), ),
title: Text(avatar == null title: Text(avatar == null
? I18n.of(context).setAProfilePicture ? L10n.of(context).setAProfilePicture
: I18n.of(context).discardPicture), : L10n.of(context).discardPicture),
onTap: avatar == null onTap: avatar == null
? setAvatarAction ? setAvatarAction
: () => setState(() => avatar = null), : () => setState(() => avatar = null),
@ -126,9 +126,9 @@ class _SignUpState extends State<SignUp> {
controller: usernameController, controller: usernameController,
onSubmitted: (s) => signUpAction(context), onSubmitted: (s) => signUpAction(context),
decoration: InputDecoration( decoration: InputDecoration(
hintText: I18n.of(context).username, hintText: L10n.of(context).username,
errorText: usernameError, errorText: usernameError,
labelText: I18n.of(context).chooseAUsername), labelText: L10n.of(context).chooseAUsername),
), ),
), ),
SizedBox(height: 20), SizedBox(height: 20),
@ -146,7 +146,7 @@ class _SignUpState extends State<SignUp> {
child: loading child: loading
? CircularProgressIndicator() ? CircularProgressIndicator()
: Text( : Text(
I18n.of(context).signUp.toUpperCase(), L10n.of(context).signUp.toUpperCase(),
style: TextStyle(color: Colors.white, fontSize: 16), style: TextStyle(color: Colors.white, fontSize: 16),
), ),
onPressed: () => loading ? null : signUpAction(context), onPressed: () => loading ? null : signUpAction(context),
@ -156,7 +156,7 @@ class _SignUpState extends State<SignUp> {
Center( Center(
child: FlatButton( child: FlatButton(
child: Text( child: Text(
I18n.of(context).alreadyHaveAnAccount, L10n.of(context).alreadyHaveAnAccount,
style: TextStyle( style: TextStyle(
decoration: TextDecoration.underline, decoration: TextDecoration.underline,
color: Colors.blue, color: Colors.blue,

View file

@ -3,7 +3,7 @@ import 'dart:math';
import 'package:famedlysdk/famedlysdk.dart'; import 'package:famedlysdk/famedlysdk.dart';
import 'package:fluffychat/components/matrix.dart'; import 'package:fluffychat/components/matrix.dart';
import 'package:fluffychat/i18n/i18n.dart'; import 'package:fluffychat/l10n/l10n.dart';
import 'package:fluffychat/utils/app_route.dart'; import 'package:fluffychat/utils/app_route.dart';
import 'package:fluffychat/views/auth_web_view.dart'; import 'package:fluffychat/views/auth_web_view.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
@ -29,7 +29,7 @@ class _SignUpPasswordState extends State<SignUpPassword> {
void _signUpAction(BuildContext context, {Map<String, dynamic> auth}) async { void _signUpAction(BuildContext context, {Map<String, dynamic> auth}) async {
MatrixState matrix = Matrix.of(context); MatrixState matrix = Matrix.of(context);
if (passwordController.text.isEmpty) { if (passwordController.text.isEmpty) {
setState(() => passwordError = I18n.of(context).pleaseEnterYourPassword); setState(() => passwordError = L10n.of(context).pleaseEnterYourPassword);
} else { } else {
setState(() => passwordError = null); setState(() => passwordError = null);
} }
@ -96,7 +96,7 @@ class _SignUpPasswordState extends State<SignUpPassword> {
try { try {
await matrix.client.setDisplayname(widget.displayname); await matrix.client.setDisplayname(widget.displayname);
} catch (exception) { } catch (exception) {
showToast(I18n.of(context).couldNotSetDisplayname); showToast(L10n.of(context).couldNotSetDisplayname);
} }
if (widget.avatar != null) { if (widget.avatar != null) {
try { try {
@ -107,7 +107,7 @@ class _SignUpPasswordState extends State<SignUpPassword> {
), ),
); );
} catch (exception) { } catch (exception) {
showToast(I18n.of(context).couldNotSetAvatar); showToast(L10n.of(context).couldNotSetAvatar);
} }
} }
await Navigator.of(context).pushAndRemoveUntil( await Navigator.of(context).pushAndRemoveUntil(
@ -122,7 +122,7 @@ class _SignUpPasswordState extends State<SignUpPassword> {
elevation: 0, elevation: 0,
leading: loading ? Container() : null, leading: loading ? Container() : null,
title: Text( title: Text(
I18n.of(context).chooseAStrongPassword, L10n.of(context).chooseAStrongPassword,
), ),
), ),
body: ListView( body: ListView(
@ -149,7 +149,7 @@ class _SignUpPasswordState extends State<SignUpPassword> {
onPressed: () => onPressed: () =>
setState(() => showPassword = !showPassword), setState(() => showPassword = !showPassword),
), ),
labelText: I18n.of(context).password), labelText: L10n.of(context).password),
), ),
), ),
SizedBox(height: 20), SizedBox(height: 20),
@ -167,7 +167,7 @@ class _SignUpPasswordState extends State<SignUpPassword> {
child: loading child: loading
? CircularProgressIndicator() ? CircularProgressIndicator()
: Text( : Text(
I18n.of(context).createAccountNow.toUpperCase(), L10n.of(context).createAccountNow.toUpperCase(),
style: TextStyle(color: Colors.white, fontSize: 16), style: TextStyle(color: Colors.white, fontSize: 16),
), ),
onPressed: () => loading ? null : _signUpAction(context), onPressed: () => loading ? null : _signUpAction(context),