diff --git a/lib/l10n/intl_en.arb b/lib/l10n/intl_en.arb index fd77d55c..7b59bdbf 100644 --- a/lib/l10n/intl_en.arb +++ b/lib/l10n/intl_en.arb @@ -81,6 +81,16 @@ "type": "text", "placeholders": {} }, + "roomVersion": "Room version", + "@roomVersion": { + "type": "text", + "placeholders": {} + }, + "goToTheNewRoom": "Go to the new room", + "@goToTheNewRoom": { + "type": "text", + "placeholders": {} + }, "alreadyHaveAnAccount": "Already have an account?", "@alreadyHaveAnAccount": { "type": "text", diff --git a/lib/views/chat.dart b/lib/views/chat.dart index dc26cefb..3ff0ab31 100644 --- a/lib/views/chat.dart +++ b/lib/views/chat.dart @@ -701,32 +701,56 @@ class _ChatState extends State { ConnectionStatusHeader(), if (room.getState(EventTypes.RoomTombstone) != null) Container( - height: 56, - color: Theme.of(context).secondaryHeaderColor, - child: ListTile( - leading: Icon(Icons.upgrade_outlined), - title: Text(room - .getState(EventTypes.RoomTombstone) - .parsedTombstoneContent - .body), - onTap: () async { - final result = await showFutureLoadingDialog( - context: context, - future: () => room.client.joinRoom(room + height: 72, + child: Material( + color: Theme.of(context).secondaryHeaderColor, + child: ListTile( + leading: CircleAvatar( + foregroundColor: Theme.of(context).accentColor, + backgroundColor: Theme.of(context).backgroundColor, + child: Icon(Icons.upgrade_outlined), + ), + title: Text( + room .getState(EventTypes.RoomTombstone) .parsedTombstoneContent - .replacementRoom), - ); - await showFutureLoadingDialog( - context: context, - future: () => room.leave(), - ); - if (result.error == null) { - await AdaptivePageLayout.of(context) - .pushNamedAndRemoveUntilIsFirst( - '/rooms/${result.result}'); - } - }, + .body, + maxLines: 1, + overflow: TextOverflow.ellipsis, + ), + subtitle: Text(L10n.of(context).goToTheNewRoom), + onTap: () async { + if (OkCancelResult.ok != + await showOkCancelAlertDialog( + context: context, + title: L10n.of(context).goToTheNewRoom, + message: room + .getState(EventTypes.RoomTombstone) + .parsedTombstoneContent + .body, + okLabel: L10n.of(context).ok, + cancelLabel: L10n.of(context).cancel, + )) { + return; + } + final result = await showFutureLoadingDialog( + context: context, + future: () => room.client.joinRoom(room + .getState(EventTypes.RoomTombstone) + .parsedTombstoneContent + .replacementRoom), + ); + await showFutureLoadingDialog( + context: context, + future: () => room.leave(), + ); + if (result.error == null) { + await AdaptivePageLayout.of(context) + .pushNamedAndRemoveUntilIsFirst( + '/rooms/${result.result}'); + } + }, + ), ), ), Expanded( diff --git a/lib/views/chat_permissions_settings.dart b/lib/views/chat_permissions_settings.dart index b1961542..b2f58b6f 100644 --- a/lib/views/chat_permissions_settings.dart +++ b/lib/views/chat_permissions_settings.dart @@ -141,32 +141,35 @@ class ChatPermissionsSettings extends StatelessWidget { .getState(EventTypes.RoomCreate) .content['room_version'] ?? '1'; - final shouldHaveVersion = - snapshot.data.mRoomVersions.defaultVersion; return ListTile( - title: Text('Current room version: $roomVersion'), - subtitle: roomVersion == shouldHaveVersion - ? null - : Text( - 'Upgrade to $shouldHaveVersion available!', - style: TextStyle( - fontWeight: FontWeight.bold, - color: Theme.of(context).accentColor), - ), + title: Text( + '${L10n.of(context).roomVersion}: $roomVersion'), onTap: () async { final newVersion = await showConfirmationDialog( context: context, - title: 'Choose Room Version', + title: L10n.of(context) + .replaceRoomWithNewerVersion, actions: snapshot .data.mRoomVersions.available.entries .where((r) => r.key != roomVersion) .map((version) => AlertDialogAction( key: version.key, label: - '${version.key} (${version.value.toString().split('.').last})')), + '${version.key} (${version.value.toString().split('.').last})')) + .toList(), ); + if (newVersion == null || + OkCancelResult.cancel == + await showOkCancelAlertDialog( + context: context, + okLabel: L10n.of(context).yes, + cancelLabel: L10n.of(context).cancel, + title: L10n.of(context).areYouSure, + )) { + return; + } await showFutureLoadingDialog( context: context, future: () =>