This commit is contained in:
Christian Pauly 2020-05-05 14:55:19 +02:00
parent c396e10ea7
commit e02a8d294e
12 changed files with 123 additions and 119 deletions

View file

@ -153,7 +153,7 @@ class ChatListItem extends StatelessWidget {
mainAxisSize: MainAxisSize.min, mainAxisSize: MainAxisSize.min,
children: <Widget>[ children: <Widget>[
Text( Text(
room.getLocalizedDisplayname(context), room.getLocalizedDisplayname(I18n.of(context)),
maxLines: 1, maxLines: 1,
overflow: TextOverflow.ellipsis, overflow: TextOverflow.ellipsis,
), ),
@ -189,7 +189,7 @@ class ChatListItem extends StatelessWidget {
), ),
) )
: Text( : Text(
room.lastEvent.getLocalizedBody(context, room.lastEvent.getLocalizedBody(I18n.of(context),
withSenderNamePrefix: true, hideReply: true), withSenderNamePrefix: true, hideReply: true),
maxLines: 1, maxLines: 1,
overflow: TextOverflow.ellipsis, overflow: TextOverflow.ellipsis,

View file

@ -1,5 +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:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:fluffychat/utils/event_extension.dart'; import 'package:fluffychat/utils/event_extension.dart';
@ -21,7 +22,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(context), event.getLocalizedBody(I18n.of(context)),
textAlign: TextAlign.center, textAlign: TextAlign.center,
style: TextStyle( style: TextStyle(
color: Theme.of(context).textTheme.body1.color, color: Theme.of(context).textTheme.body1.color,

View file

@ -58,7 +58,7 @@ class MessageContent extends StatelessWidget {
); );
} }
return LinkText( return LinkText(
text: event.getLocalizedBody(context, hideReply: true), text: event.getLocalizedBody(I18n.of(context), hideReply: true),
textStyle: TextStyle( textStyle: TextStyle(
color: textColor, color: textColor,
decoration: event.redacted ? TextDecoration.lineThrough : null, decoration: event.redacted ? TextDecoration.lineThrough : null,

View file

@ -1,4 +1,5 @@
import 'package:famedlysdk/famedlysdk.dart'; import 'package:famedlysdk/famedlysdk.dart';
import 'package:fluffychat/i18n/i18n.dart';
import 'package:fluffychat/utils/event_extension.dart'; import 'package:fluffychat/utils/event_extension.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
@ -35,8 +36,11 @@ class ReplyContent extends StatelessWidget {
), ),
), ),
Text( Text(
replyEvent?.getLocalizedBody(context, replyEvent?.getLocalizedBody(
withSenderNamePrefix: false, hideReply: true) ?? I18n.of(context),
withSenderNamePrefix: false,
hideReply: true,
) ??
"", "",
overflow: TextOverflow.ellipsis, overflow: TextOverflow.ellipsis,
maxLines: 1, maxLines: 1,

View file

@ -12,30 +12,28 @@ extension LocalizedBody on Event {
MessageTypes.None, MessageTypes.None,
}; };
String getLocalizedBody(BuildContext context, String getLocalizedBody(I18n i18n,
{bool withSenderNamePrefix = false, bool hideReply = false}) { {bool withSenderNamePrefix = false, bool hideReply = false}) {
if (this.redacted) { if (this.redacted) {
return I18n.of(context) return i18n.removedBy(redactedBecause.sender.calcDisplayname());
.removedBy(redactedBecause.sender.calcDisplayname());
} }
String localizedBody = body; String localizedBody = body;
final String senderName = this.sender.calcDisplayname(); final String senderName = this.sender.calcDisplayname();
switch (this.type) { switch (this.type) {
case EventTypes.Sticker: case EventTypes.Sticker:
localizedBody = I18n.of(context).sentASticker(senderName); localizedBody = i18n.sentASticker(senderName);
break; break;
case EventTypes.Redaction: case EventTypes.Redaction:
localizedBody = I18n.of(context).redactedAnEvent(senderName); localizedBody = i18n.redactedAnEvent(senderName);
break; break;
case EventTypes.RoomAliases: case EventTypes.RoomAliases:
localizedBody = I18n.of(context).changedTheRoomAliases(senderName); localizedBody = i18n.changedTheRoomAliases(senderName);
break; break;
case EventTypes.RoomCanonicalAlias: case EventTypes.RoomCanonicalAlias:
localizedBody = localizedBody = i18n.changedTheRoomInvitationLink(senderName);
I18n.of(context).changedTheRoomInvitationLink(senderName);
break; break;
case EventTypes.RoomCreate: case EventTypes.RoomCreate:
localizedBody = I18n.of(context).createdTheChat(senderName); localizedBody = i18n.createdTheChat(senderName);
break; break;
case EventTypes.RoomJoinRules: case EventTypes.RoomJoinRules:
JoinRules joinRules = JoinRules.values.firstWhere( JoinRules joinRules = JoinRules.values.firstWhere(
@ -44,10 +42,10 @@ extension LocalizedBody on Event {
content["join_rule"], content["join_rule"],
orElse: () => null); orElse: () => null);
if (joinRules == null) { if (joinRules == null) {
localizedBody = I18n.of(context).changedTheJoinRules(senderName); localizedBody = i18n.changedTheJoinRules(senderName);
} else { } else {
localizedBody = I18n.of(context).changedTheJoinRulesTo( localizedBody = i18n.changedTheJoinRulesTo(
senderName, joinRules.getLocalizedString(context)); senderName, joinRules.getLocalizedString(i18n));
} }
break; break;
case EventTypes.RoomMember: case EventTypes.RoomMember:
@ -61,36 +59,35 @@ extension LocalizedBody on Event {
: ""; : "";
if (newMembership != oldMembership) { if (newMembership != oldMembership) {
if (oldMembership == "invite" && newMembership == "join") { if (oldMembership == "invite" && newMembership == "join") {
text = I18n.of(context).acceptedTheInvitation(targetName); text = i18n.acceptedTheInvitation(targetName);
} else if (oldMembership == "invite" && newMembership == "leave") { } else if (oldMembership == "invite" && newMembership == "leave") {
if (this.stateKey == this.senderId) { if (this.stateKey == this.senderId) {
text = I18n.of(context).rejectedTheInvitation(targetName); text = i18n.rejectedTheInvitation(targetName);
} else { } else {
text = I18n.of(context) text = i18n.hasWithdrawnTheInvitationFor(senderName, targetName);
.hasWithdrawnTheInvitationFor(senderName, targetName);
} }
} else if (oldMembership == "leave" && newMembership == "join") { } else if (oldMembership == "leave" && newMembership == "join") {
text = I18n.of(context).joinedTheChat(targetName); text = i18n.joinedTheChat(targetName);
} else if (oldMembership == "join" && newMembership == "ban") { } else if (oldMembership == "join" && newMembership == "ban") {
text = I18n.of(context).kickedAndBanned(senderName, targetName); text = i18n.kickedAndBanned(senderName, targetName);
} else if (oldMembership == "join" && } else if (oldMembership == "join" &&
newMembership == "leave" && newMembership == "leave" &&
this.stateKey != this.senderId) { this.stateKey != this.senderId) {
text = I18n.of(context).kicked(senderName, targetName); text = i18n.kicked(senderName, targetName);
} else if (oldMembership == "join" && } else if (oldMembership == "join" &&
newMembership == "leave" && newMembership == "leave" &&
this.stateKey == this.senderId) { this.stateKey == this.senderId) {
text = I18n.of(context).userLeftTheChat(targetName); text = i18n.userLeftTheChat(targetName);
} else if (oldMembership == "invite" && newMembership == "ban") { } else if (oldMembership == "invite" && newMembership == "ban") {
text = I18n.of(context).bannedUser(senderName, targetName); text = i18n.bannedUser(senderName, targetName);
} else if (oldMembership == "leave" && newMembership == "ban") { } else if (oldMembership == "leave" && newMembership == "ban") {
text = I18n.of(context).bannedUser(senderName, targetName); text = i18n.bannedUser(senderName, targetName);
} else if (oldMembership == "ban" && newMembership == "leave") { } else if (oldMembership == "ban" && newMembership == "leave") {
text = I18n.of(context).unbannedUser(senderName, targetName); text = i18n.unbannedUser(senderName, targetName);
} else if (newMembership == "invite") { } else if (newMembership == "invite") {
text = I18n.of(context).invitedUser(senderName, targetName); text = i18n.invitedUser(senderName, targetName);
} else if (newMembership == "join") { } else if (newMembership == "join") {
text = I18n.of(context).joinedTheChat(targetName); text = i18n.joinedTheChat(targetName);
} }
} else if (newMembership == "join") { } else if (newMembership == "join") {
final String newAvatar = this.content["avatar_url"] ?? ""; final String newAvatar = this.content["avatar_url"] ?? "";
@ -107,29 +104,27 @@ extension LocalizedBody on Event {
// Has the user avatar changed? // Has the user avatar changed?
if (newAvatar != oldAvatar) { if (newAvatar != oldAvatar) {
text = I18n.of(context).changedTheProfileAvatar(targetName); text = i18n.changedTheProfileAvatar(targetName);
} }
// Has the user avatar changed? // Has the user avatar changed?
else if (newDisplayname != oldDisplayname) { else if (newDisplayname != oldDisplayname) {
text = I18n.of(context) text = i18n.changedTheDisplaynameTo(targetName, newDisplayname);
.changedTheDisplaynameTo(targetName, newDisplayname);
} }
} }
localizedBody = text; localizedBody = text;
break; break;
case EventTypes.RoomPowerLevels: case EventTypes.RoomPowerLevels:
localizedBody = I18n.of(context).changedTheChatPermissions(senderName); localizedBody = i18n.changedTheChatPermissions(senderName);
break; break;
case EventTypes.RoomName: case EventTypes.RoomName:
localizedBody = localizedBody = i18n.changedTheChatNameTo(senderName, content["name"]);
I18n.of(context).changedTheChatNameTo(senderName, content["name"]);
break; break;
case EventTypes.RoomTopic: case EventTypes.RoomTopic:
localizedBody = I18n.of(context) localizedBody =
.changedTheChatDescriptionTo(senderName, content["topic"]); i18n.changedTheChatDescriptionTo(senderName, content["topic"]);
break; break;
case EventTypes.RoomAvatar: case EventTypes.RoomAvatar:
localizedBody = I18n.of(context).changedTheChatAvatar(senderName); localizedBody = i18n.changedTheChatAvatar(senderName);
break; break;
case EventTypes.GuestAccess: case EventTypes.GuestAccess:
GuestAccess guestAccess = GuestAccess.values.firstWhere( GuestAccess guestAccess = GuestAccess.values.firstWhere(
@ -138,11 +133,10 @@ extension LocalizedBody on Event {
content["guest_access"], content["guest_access"],
orElse: () => null); orElse: () => null);
if (guestAccess == null) { if (guestAccess == null) {
localizedBody = localizedBody = i18n.changedTheGuestAccessRules(senderName);
I18n.of(context).changedTheGuestAccessRules(senderName);
} else { } else {
localizedBody = I18n.of(context).changedTheGuestAccessRulesTo( localizedBody = i18n.changedTheGuestAccessRulesTo(
senderName, guestAccess.getLocalizedString(context)); senderName, guestAccess.getLocalizedString(i18n));
} }
break; break;
case EventTypes.HistoryVisibility: case EventTypes.HistoryVisibility:
@ -153,40 +147,38 @@ extension LocalizedBody on Event {
content["history_visibility"], content["history_visibility"],
orElse: () => null); orElse: () => null);
if (historyVisibility == null) { if (historyVisibility == null) {
localizedBody = localizedBody = i18n.changedTheHistoryVisibility(senderName);
I18n.of(context).changedTheHistoryVisibility(senderName);
} else { } else {
localizedBody = I18n.of(context).changedTheHistoryVisibilityTo( localizedBody = i18n.changedTheHistoryVisibilityTo(
senderName, historyVisibility.getLocalizedString(context)); senderName, historyVisibility.getLocalizedString(i18n));
} }
break; break;
case EventTypes.Encryption: case EventTypes.Encryption:
localizedBody = localizedBody = i18n.activatedEndToEndEncryption(senderName);
I18n.of(context).activatedEndToEndEncryption(senderName);
if (!room.client.encryptionEnabled) { if (!room.client.encryptionEnabled) {
localizedBody += ". " + I18n.of(context).needPantalaimonWarning; localizedBody += ". " + i18n.needPantalaimonWarning;
} }
break; break;
case EventTypes.Encrypted: case EventTypes.Encrypted:
case EventTypes.Message: case EventTypes.Message:
switch (this.messageType) { switch (this.messageType) {
case MessageTypes.Image: case MessageTypes.Image:
localizedBody = I18n.of(context).sentAPicture(senderName); localizedBody = i18n.sentAPicture(senderName);
break; break;
case MessageTypes.File: case MessageTypes.File:
localizedBody = I18n.of(context).sentAFile(senderName); localizedBody = i18n.sentAFile(senderName);
break; break;
case MessageTypes.Audio: case MessageTypes.Audio:
localizedBody = I18n.of(context).sentAnAudio(senderName); localizedBody = i18n.sentAnAudio(senderName);
break; break;
case MessageTypes.Video: case MessageTypes.Video:
localizedBody = I18n.of(context).sentAVideo(senderName); localizedBody = i18n.sentAVideo(senderName);
break; break;
case MessageTypes.Location: case MessageTypes.Location:
localizedBody = I18n.of(context).sharedTheLocation(senderName); localizedBody = i18n.sharedTheLocation(senderName);
break; break;
case MessageTypes.Sticker: case MessageTypes.Sticker:
localizedBody = I18n.of(context).sentASticker(senderName); localizedBody = i18n.sentASticker(senderName);
break; break;
case MessageTypes.Emote: case MessageTypes.Emote:
localizedBody = "* $body"; localizedBody = "* $body";
@ -195,25 +187,23 @@ extension LocalizedBody on Event {
String errorText; String errorText;
switch (body) { switch (body) {
case DecryptError.CHANNEL_CORRUPTED: case DecryptError.CHANNEL_CORRUPTED:
errorText = I18n.of(context).channelCorruptedDecryptError + "."; errorText = i18n.channelCorruptedDecryptError + ".";
break; break;
case DecryptError.NOT_ENABLED: case DecryptError.NOT_ENABLED:
errorText = I18n.of(context).encryptionNotEnabled + "."; errorText = i18n.encryptionNotEnabled + ".";
break; break;
case DecryptError.UNKNOWN_ALGORITHM: case DecryptError.UNKNOWN_ALGORITHM:
errorText = I18n.of(context).unknownEncryptionAlgorithm + "."; errorText = i18n.unknownEncryptionAlgorithm + ".";
break; break;
case DecryptError.UNKNOWN_SESSION: case DecryptError.UNKNOWN_SESSION:
errorText = I18n.of(context).noPermission + "."; errorText = i18n.noPermission + ".";
break; break;
default: default:
errorText = body; errorText = body;
break; break;
} }
localizedBody = "🔒 " + localizedBody =
I18n.of(context).couldNotDecryptMessage + "🔒 " + i18n.couldNotDecryptMessage + ": " + errorText;
": " +
errorText;
break; break;
case MessageTypes.Text: case MessageTypes.Text:
case MessageTypes.Notice: case MessageTypes.Notice:
@ -224,7 +214,7 @@ extension LocalizedBody on Event {
} }
break; break;
default: default:
localizedBody = I18n.of(context).unknownEvent(this.typeKey); localizedBody = i18n.unknownEvent(this.typeKey);
} }
// Hide reply fallback // Hide reply fallback
@ -237,9 +227,8 @@ extension LocalizedBody on Event {
if (withSenderNamePrefix && if (withSenderNamePrefix &&
this.type == EventTypes.Message && this.type == EventTypes.Message &&
textOnlyMessageTypes.contains(this.messageType)) { textOnlyMessageTypes.contains(this.messageType)) {
final String senderNameOrYou = this.senderId == room.client.userID final String senderNameOrYou =
? I18n.of(context).you this.senderId == room.client.userID ? i18n.you : senderName;
: senderName;
localizedBody = "$senderNameOrYou: $localizedBody"; localizedBody = "$senderNameOrYou: $localizedBody";
} }

View file

@ -160,21 +160,25 @@ abstract class FirebaseController {
: i18n.unreadMessages(unreadEvents.toString()); : i18n.unreadMessages(unreadEvents.toString());
// Calculate the body // Calculate the body
final String body = event.getLocalizedBody(context, final String body = event.getLocalizedBody(
withSenderNamePrefix: true, hideReply: true); i18n,
withSenderNamePrefix: true,
hideReply: true,
);
// The person object for the android message style notification // The person object for the android message style notification
final person = Person( final person = Person(
name: room.getLocalizedDisplayname(context), name: room.getLocalizedDisplayname(i18n),
icon: room.avatar == null icon: room.avatar == null
? null ? null
: await downloadAndSaveAvatar( : BitmapFilePathAndroidIcon(
room.avatar, await downloadAndSaveAvatar(
client, room.avatar,
width: 126, client,
height: 126, width: 126,
height: 126,
),
), ),
iconSource: IconSource.FilePath,
); );
// Show notification // Show notification
@ -182,7 +186,6 @@ abstract class FirebaseController {
'fluffychat_push', 'fluffychat_push',
'FluffyChat push channel', 'FluffyChat push channel',
'Push notifications for FluffyChat', 'Push notifications for FluffyChat',
style: AndroidNotificationStyle.Messaging,
styleInformation: MessagingStyleInformation( styleInformation: MessagingStyleInformation(
person, person,
conversationTitle: title, conversationTitle: title,
@ -200,8 +203,8 @@ abstract class FirebaseController {
var iOSPlatformChannelSpecifics = IOSNotificationDetails(); var iOSPlatformChannelSpecifics = IOSNotificationDetails();
var platformChannelSpecifics = NotificationDetails( var platformChannelSpecifics = NotificationDetails(
androidPlatformChannelSpecifics, iOSPlatformChannelSpecifics); androidPlatformChannelSpecifics, iOSPlatformChannelSpecifics);
await _flutterLocalNotificationsPlugin.show(0, await _flutterLocalNotificationsPlugin.show(
room.getLocalizedDisplayname(context), body, platformChannelSpecifics, 0, room.getLocalizedDisplayname(i18n), body, platformChannelSpecifics,
payload: roomId); payload: roomId);
} catch (exception) { } catch (exception) {
debugPrint("[Push] Error while processing notification: " + debugPrint("[Push] Error while processing notification: " +

View file

@ -1,20 +1,19 @@
import 'package:famedlysdk/famedlysdk.dart'; import 'package:famedlysdk/famedlysdk.dart';
import 'package:fluffychat/i18n/i18n.dart'; import 'package:fluffychat/i18n/i18n.dart';
import 'package:flutter/material.dart';
extension LocalizedRoomDisplayname on Room { extension LocalizedRoomDisplayname on Room {
String getLocalizedDisplayname(BuildContext context) { String getLocalizedDisplayname(I18n i18n) {
if ((this.name?.isEmpty ?? true) && if ((this.name?.isEmpty ?? true) &&
(this.canonicalAlias?.isEmpty ?? true) && (this.canonicalAlias?.isEmpty ?? true) &&
!this.isDirectChat && !this.isDirectChat &&
(this.mHeroes != null && this.mHeroes.isNotEmpty)) { (this.mHeroes != null && this.mHeroes.isNotEmpty)) {
return I18n.of(context).groupWith(this.displayname); return i18n.groupWith(this.displayname);
} }
if ((this.name?.isEmpty ?? true) && if ((this.name?.isEmpty ?? true) &&
(this.canonicalAlias?.isEmpty ?? true) && (this.canonicalAlias?.isEmpty ?? true) &&
!this.isDirectChat && !this.isDirectChat &&
(this.mHeroes?.isEmpty ?? true)) { (this.mHeroes?.isEmpty ?? true)) {
return I18n.of(context).emptyChat; return i18n.emptyChat;
} }
return this.displayname; return this.displayname;
} }

View file

@ -1,18 +1,17 @@
import 'package:famedlysdk/famedlysdk.dart'; import 'package:famedlysdk/famedlysdk.dart';
import 'package:fluffychat/i18n/i18n.dart'; import 'package:fluffychat/i18n/i18n.dart';
import 'package:flutter/material.dart';
extension HistoryVisibilityDisplayString on HistoryVisibility { extension HistoryVisibilityDisplayString on HistoryVisibility {
String getLocalizedString(BuildContext context) { String getLocalizedString(I18n i18n) {
switch (this) { switch (this) {
case HistoryVisibility.invited: case HistoryVisibility.invited:
return I18n.of(context).fromTheInvitation; return i18n.fromTheInvitation;
case HistoryVisibility.joined: case HistoryVisibility.joined:
return I18n.of(context).fromJoining; return i18n.fromJoining;
case HistoryVisibility.shared: case HistoryVisibility.shared:
return I18n.of(context).visibleForAllParticipants; return i18n.visibleForAllParticipants;
case HistoryVisibility.world_readable: case HistoryVisibility.world_readable:
return I18n.of(context).visibleForEveryone; return i18n.visibleForEveryone;
default: default:
return this.toString().replaceAll("HistoryVisibility.", ""); return this.toString().replaceAll("HistoryVisibility.", "");
} }
@ -20,12 +19,12 @@ extension HistoryVisibilityDisplayString on HistoryVisibility {
} }
extension GuestAccessDisplayString on GuestAccess { extension GuestAccessDisplayString on GuestAccess {
String getLocalizedString(BuildContext context) { String getLocalizedString(I18n i18n) {
switch (this) { switch (this) {
case GuestAccess.can_join: case GuestAccess.can_join:
return I18n.of(context).guestsCanJoin; return i18n.guestsCanJoin;
case GuestAccess.forbidden: case GuestAccess.forbidden:
return I18n.of(context).guestsAreForbidden; return i18n.guestsAreForbidden;
default: default:
return this.toString().replaceAll("GuestAccess.", ""); return this.toString().replaceAll("GuestAccess.", "");
} }
@ -33,12 +32,12 @@ extension GuestAccessDisplayString on GuestAccess {
} }
extension JoinRulesDisplayString on JoinRules { extension JoinRulesDisplayString on JoinRules {
String getLocalizedString(BuildContext context) { String getLocalizedString(I18n i18n) {
switch (this) { switch (this) {
case JoinRules.public: case JoinRules.public:
return I18n.of(context).anyoneCanJoin; return i18n.anyoneCanJoin;
case JoinRules.invite: case JoinRules.invite:
return I18n.of(context).invitedUsersOnly; return i18n.invitedUsersOnly;
default: default:
return this.toString().replaceAll("JoinRules.", ""); return this.toString().replaceAll("JoinRules.", "");
} }

View file

@ -244,11 +244,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(context); return selectedEvents.first.getLocalizedBody(I18n.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 += event.getLocalizedBody(context, withSenderNamePrefix: true); copyString +=
event.getLocalizedBody(I18n.of(context), withSenderNamePrefix: true);
} }
return copyString; return copyString;
} }
@ -360,7 +361,7 @@ class _ChatState extends State<_Chat> {
? CrossAxisAlignment.center ? CrossAxisAlignment.center
: CrossAxisAlignment.start, : CrossAxisAlignment.start,
children: <Widget>[ children: <Widget>[
Text(room.getLocalizedDisplayname(context)), Text(room.getLocalizedDisplayname(I18n.of(context))),
AnimatedContainer( AnimatedContainer(
duration: Duration(milliseconds: 500), duration: Duration(milliseconds: 500),
height: typingText.isEmpty ? 0 : 20, height: typingText.isEmpty ? 0 : 20,

View file

@ -35,7 +35,7 @@ class _ChatDetailsState extends State<ChatDetails> {
final String displayname = await SimpleDialogs(context).enterText( final String displayname = await SimpleDialogs(context).enterText(
titleText: I18n.of(context).changeTheNameOfTheGroup, titleText: I18n.of(context).changeTheNameOfTheGroup,
labelText: I18n.of(context).changeTheNameOfTheGroup, labelText: I18n.of(context).changeTheNameOfTheGroup,
hintText: widget.room.getLocalizedDisplayname(context), hintText: widget.room.getLocalizedDisplayname(I18n.of(context)),
); );
if (displayname == null) return; if (displayname == null) return;
final success = await SimpleDialogs(context).tryRequestWithLoadingDialog( final success = await SimpleDialogs(context).tryRequestWithLoadingDialog(
@ -186,7 +186,7 @@ class _ChatDetailsState extends State<ChatDetails> {
), ),
ChatSettingsPopupMenu(widget.room, false) ChatSettingsPopupMenu(widget.room, false)
], ],
title: Text(widget.room.getLocalizedDisplayname(context), title: Text(widget.room.getLocalizedDisplayname(I18n.of(context)),
style: TextStyle( style: TextStyle(
color: color:
Theme.of(context).appBarTheme.textTheme.title.color)), Theme.of(context).appBarTheme.textTheme.title.color)),
@ -251,8 +251,8 @@ class _ChatDetailsState extends State<ChatDetails> {
child: Icon(Icons.people), child: Icon(Icons.people),
), ),
title: Text(I18n.of(context).changeTheNameOfTheGroup), title: Text(I18n.of(context).changeTheNameOfTheGroup),
subtitle: Text( subtitle: Text(widget.room
widget.room.getLocalizedDisplayname(context)), .getLocalizedDisplayname(I18n.of(context))),
onTap: () => setDisplaynameAction(context), onTap: () => setDisplaynameAction(context),
), ),
if (widget.room.canSendEvent("m.room.canonical_alias") && if (widget.room.canSendEvent("m.room.canonical_alias") &&
@ -281,7 +281,8 @@ class _ChatDetailsState extends State<ChatDetails> {
title: Text( title: Text(
I18n.of(context).whoIsAllowedToJoinThisGroup), I18n.of(context).whoIsAllowedToJoinThisGroup),
subtitle: Text( subtitle: Text(
widget.room.joinRules.getLocalizedString(context), widget.room.joinRules
.getLocalizedString(I18n.of(context)),
), ),
), ),
onSelected: (JoinRules joinRule) => onSelected: (JoinRules joinRule) =>
@ -293,14 +294,14 @@ class _ChatDetailsState extends State<ChatDetails> {
if (widget.room.canChangeJoinRules) if (widget.room.canChangeJoinRules)
PopupMenuItem<JoinRules>( PopupMenuItem<JoinRules>(
value: JoinRules.public, value: JoinRules.public,
child: Text( child: Text(JoinRules.public
JoinRules.public.getLocalizedString(context)), .getLocalizedString(I18n.of(context))),
), ),
if (widget.room.canChangeJoinRules) if (widget.room.canChangeJoinRules)
PopupMenuItem<JoinRules>( PopupMenuItem<JoinRules>(
value: JoinRules.invite, value: JoinRules.invite,
child: Text( child: Text(JoinRules.invite
JoinRules.invite.getLocalizedString(context)), .getLocalizedString(I18n.of(context))),
), ),
], ],
), ),
@ -316,7 +317,7 @@ class _ChatDetailsState extends State<ChatDetails> {
Text(I18n.of(context).visibilityOfTheChatHistory), Text(I18n.of(context).visibilityOfTheChatHistory),
subtitle: Text( subtitle: Text(
widget.room.historyVisibility widget.room.historyVisibility
.getLocalizedString(context), .getLocalizedString(I18n.of(context)),
), ),
), ),
onSelected: (HistoryVisibility historyVisibility) => onSelected: (HistoryVisibility historyVisibility) =>
@ -329,25 +330,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(context)), .getLocalizedString(I18n.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(context)), .getLocalizedString(I18n.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(context)), .getLocalizedString(I18n.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(context)), .getLocalizedString(I18n.of(context))),
), ),
], ],
), ),
@ -364,7 +365,7 @@ class _ChatDetailsState extends State<ChatDetails> {
Text(I18n.of(context).areGuestsAllowedToJoin), Text(I18n.of(context).areGuestsAllowedToJoin),
subtitle: Text( subtitle: Text(
widget.room.guestAccess widget.room.guestAccess
.getLocalizedString(context), .getLocalizedString(I18n.of(context)),
), ),
), ),
onSelected: (GuestAccess guestAccess) => onSelected: (GuestAccess guestAccess) =>
@ -379,7 +380,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(context), .getLocalizedString(I18n.of(context)),
), ),
), ),
if (widget.room.canChangeGuestAccess) if (widget.room.canChangeGuestAccess)
@ -387,7 +388,7 @@ class _ChatDetailsState extends State<ChatDetails> {
value: GuestAccess.forbidden, value: GuestAccess.forbidden,
child: Text( child: Text(
GuestAccess.forbidden GuestAccess.forbidden
.getLocalizedString(context), .getLocalizedString(I18n.of(context)),
), ),
), ),
], ],

View file

@ -168,7 +168,14 @@ packages:
name: flutter_local_notifications name: flutter_local_notifications
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "0.8.4+3" version: "1.4.3"
flutter_local_notifications_platform_interface:
dependency: transitive
description:
name: flutter_local_notifications_platform_interface
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.1"
flutter_localizations: flutter_localizations:
dependency: "direct main" dependency: "direct main"
description: flutter description: flutter

View file

@ -39,7 +39,7 @@ dependencies:
sqflite: ^1.2.0 sqflite: ^1.2.0
flutter_advanced_networkimage: any flutter_advanced_networkimage: any
firebase_messaging: ^6.0.13 firebase_messaging: ^6.0.13
flutter_local_notifications: ^0.8.4 flutter_local_notifications: ^1.4.3
link_text: ^0.1.1 link_text: ^0.1.1
path_provider: ^1.5.1 path_provider: ^1.5.1
webview_flutter: ^0.3.19+9 webview_flutter: ^0.3.19+9