From 05b95513f9d7fc72c4f8c555b261d1f901745e5b Mon Sep 17 00:00:00 2001 From: Krille Fear Date: Sat, 16 Jan 2021 13:24:52 +0000 Subject: [PATCH] fix: Minor apl bugs --- lib/components/chat_settings_popup_menu.dart | 6 +- lib/config/routes.dart | 12 +- lib/views/archive.dart | 1 + lib/views/chat.dart | 10 +- lib/views/chat_details.dart | 2 + lib/views/chat_encryption_settings.dart | 1 + lib/views/chat_permissions_settings.dart | 5 +- lib/views/discover_view.dart | 1 + lib/views/invitation_selection.dart | 1 + lib/views/login.dart | 2 +- lib/views/new_group.dart | 1 + lib/views/new_private_chat.dart | 1 + lib/views/settings.dart | 243 ++++++++++--------- lib/views/settings_3pid.dart | 1 + lib/views/settings_devices.dart | 5 +- lib/views/settings_emotes.dart | 1 + lib/views/settings_ignore_list.dart | 5 +- lib/views/settings_multiple_emotes.dart | 1 + lib/views/settings_notifications.dart | 1 + lib/views/settings_style.dart | 1 + lib/views/sign_up.dart | 2 +- lib/views/sign_up_password.dart | 2 +- 22 files changed, 170 insertions(+), 135 deletions(-) diff --git a/lib/components/chat_settings_popup_menu.dart b/lib/components/chat_settings_popup_menu.dart index 1d767919..83441337 100644 --- a/lib/components/chat_settings_popup_menu.dart +++ b/lib/components/chat_settings_popup_menu.dart @@ -114,8 +114,10 @@ class _ChatSettingsPopupMenuState extends State { startCallAction(context); break; case 'details': - await AdaptivePageLayout.of(context).pushNamedAndRemoveAllOthers( - '/rooms/${widget.room.id}/details'); + if (AdaptivePageLayout.of(context).viewDataStack.length < 3) { + await AdaptivePageLayout.of(context) + .pushNamed('/rooms/${widget.room.id}/details'); + } break; } diff --git a/lib/config/routes.dart b/lib/config/routes.dart index d3314afb..4c21087a 100644 --- a/lib/config/routes.dart +++ b/lib/config/routes.dart @@ -82,7 +82,7 @@ class FluffyRoutes { case 'rooms': if (parts.length == 3) { return ViewData( - leftView: (_) => ChatList(), + leftView: (_) => ChatList(activeChat: parts[2]), mainView: (_) => Chat(parts[2]), ); } else if (parts.length == 4) { @@ -91,31 +91,31 @@ class FluffyRoutes { switch (action) { case 'details': return ViewData( - leftView: (_) => ChatList(), + leftView: (_) => ChatList(activeChat: parts[2]), mainView: (_) => Chat(parts[2]), rightView: (_) => ChatDetails(roomId), ); case 'encryption': return ViewData( - leftView: (_) => ChatList(), + leftView: (_) => ChatList(activeChat: parts[2]), mainView: (_) => Chat(parts[2]), rightView: (_) => ChatEncryptionSettings(roomId), ); case 'permissions': return ViewData( - leftView: (_) => ChatList(), + leftView: (_) => ChatList(activeChat: parts[2]), mainView: (_) => Chat(parts[2]), rightView: (_) => ChatPermissionsSettings(roomId), ); case 'invite': return ViewData( - leftView: (_) => ChatList(), + leftView: (_) => ChatList(activeChat: parts[2]), mainView: (_) => Chat(parts[2]), rightView: (_) => InvitationSelection(roomId), ); case 'emotes': return ViewData( - leftView: (_) => ChatList(), + leftView: (_) => ChatList(activeChat: parts[2]), mainView: (_) => Chat(parts[2]), rightView: (_) => MultipleEmotesSettings(roomId), ); diff --git a/lib/views/archive.dart b/lib/views/archive.dart index 3037739d..ba7e7ecf 100644 --- a/lib/views/archive.dart +++ b/lib/views/archive.dart @@ -36,6 +36,7 @@ class _ArchiveState extends State { Widget build(BuildContext context) { return Scaffold( appBar: AppBar( + leading: BackButton(), title: Text(L10n.of(context).archive), elevation: _scrolledToTop ? 0 : null, ), diff --git a/lib/views/chat.dart b/lib/views/chat.dart index ea4378f1..d6b6cc91 100644 --- a/lib/views/chat.dart +++ b/lib/views/chat.dart @@ -472,7 +472,8 @@ class _ChatState extends State { onPressed: () => setState(() => selectedEvents.clear()), ) : null, - titleSpacing: 0, + titleSpacing: + AdaptivePageLayout.of(context).columnMode(context) ? null : 0, title: selectedEvents.isEmpty ? StreamBuilder( stream: room.onUpdate.stream, @@ -490,7 +491,12 @@ class _ChatState extends State { ), ) : () => AdaptivePageLayout.of(context) - .pushNamed('/rooms/${room.id}/details'), + .viewDataStack + .length < + 3 + ? AdaptivePageLayout.of(context) + .pushNamed('/rooms/${room.id}/details') + : null, title: Text( room.getLocalizedDisplayname( MatrixLocals(L10n.of(context))), diff --git a/lib/views/chat_details.dart b/lib/views/chat_details.dart index 02143b30..ba241eac 100644 --- a/lib/views/chat_details.dart +++ b/lib/views/chat_details.dart @@ -172,6 +172,7 @@ class _ChatDetailsState extends State { if (room == null) { return Scaffold( appBar: AppBar( + leading: BackButton(), title: Text(L10n.of(context).oopsSomethingWentWrong), ), body: Center( @@ -192,6 +193,7 @@ class _ChatDetailsState extends State { headerSliverBuilder: (BuildContext context, bool innerBoxIsScrolled) => [ SliverAppBar( + leading: BackButton(), expandedHeight: 300.0, floating: true, pinned: true, diff --git a/lib/views/chat_encryption_settings.dart b/lib/views/chat_encryption_settings.dart index fb3ef946..4ff8b78a 100644 --- a/lib/views/chat_encryption_settings.dart +++ b/lib/views/chat_encryption_settings.dart @@ -91,6 +91,7 @@ class _ChatEncryptionSettingsState extends State { return Scaffold( appBar: AppBar( + leading: BackButton(), title: Text(L10n.of(context).participatingUserDevices), ), body: StreamBuilder( diff --git a/lib/views/chat_permissions_settings.dart b/lib/views/chat_permissions_settings.dart index 212f44a8..ae5c3bc3 100644 --- a/lib/views/chat_permissions_settings.dart +++ b/lib/views/chat_permissions_settings.dart @@ -45,7 +45,10 @@ class ChatPermissionsSettings extends StatelessWidget { @override Widget build(BuildContext context) { return Scaffold( - appBar: AppBar(title: Text(L10n.of(context).editChatPermissions)), + appBar: AppBar( + leading: BackButton(), + title: Text(L10n.of(context).editChatPermissions), + ), body: StreamBuilder( stream: Matrix.of(context).client.onSync.stream.where( (e) => diff --git a/lib/views/discover_view.dart b/lib/views/discover_view.dart index d31ffcd2..74d11126 100644 --- a/lib/views/discover_view.dart +++ b/lib/views/discover_view.dart @@ -122,6 +122,7 @@ class _DiscoverPageState extends State { ); return Scaffold( appBar: AppBar( + leading: BackButton(), titleSpacing: 0, elevation: _scrolledToTop ? 0 : null, title: DefaultAppBarSearchField( diff --git a/lib/views/invitation_selection.dart b/lib/views/invitation_selection.dart index 0c12c330..b5a82e2f 100644 --- a/lib/views/invitation_selection.dart +++ b/lib/views/invitation_selection.dart @@ -123,6 +123,7 @@ class _InvitationSelectionState extends State { room.name?.isEmpty ?? false ? L10n.of(context).group : room.name; return Scaffold( appBar: AppBar( + leading: BackButton(), titleSpacing: 0, title: DefaultAppBarSearchField( autofocus: true, diff --git a/lib/views/login.dart b/lib/views/login.dart index 8883e862..ba198d02 100644 --- a/lib/views/login.dart +++ b/lib/views/login.dart @@ -156,7 +156,7 @@ class _LoginState extends State { Widget build(BuildContext context) { return Scaffold( appBar: AppBar( - leading: loading ? Container() : null, + leading: loading ? Container() : BackButton(), elevation: 0, title: Text( L10n.of(context).logInTo(Matrix.of(context) diff --git a/lib/views/new_group.dart b/lib/views/new_group.dart index 6e823571..9e107693 100644 --- a/lib/views/new_group.dart +++ b/lib/views/new_group.dart @@ -40,6 +40,7 @@ class _NewGroupState extends State { Widget build(BuildContext context) { return Scaffold( appBar: AppBar( + leading: BackButton(), title: Text(L10n.of(context).createNewGroup), elevation: 0, ), diff --git a/lib/views/new_private_chat.dart b/lib/views/new_private_chat.dart index 52edd788..13e11e4b 100644 --- a/lib/views/new_private_chat.dart +++ b/lib/views/new_private_chat.dart @@ -85,6 +85,7 @@ class _NewPrivateChatState extends State { Widget build(BuildContext context) { return Scaffold( appBar: AppBar( + leading: BackButton(), title: Text(L10n.of(context).newPrivateChat), elevation: 0, ), diff --git a/lib/views/settings.dart b/lib/views/settings.dart index d10cdcdf..76963bf2 100644 --- a/lib/views/settings.dart +++ b/lib/views/settings.dart @@ -260,21 +260,24 @@ class _SettingsState extends State { if (mounted) setState(() => profile = p); return p; }); - crossSigningCachedFuture ??= - client.encryption.crossSigning.isCached().then((c) { - if (mounted) setState(() => crossSigningCached = c); - return c; - }); - megolmBackupCachedFuture ??= - client.encryption.keyManager.isCached().then((c) { - if (mounted) setState(() => megolmBackupCached = c); - return c; - }); + if (client.encryption != null) { + crossSigningCachedFuture ??= + client.encryption.crossSigning.isCached().then((c) { + if (mounted) setState(() => crossSigningCached = c); + return c; + }); + megolmBackupCachedFuture ??= + client.encryption.keyManager.isCached().then((c) { + if (mounted) setState(() => megolmBackupCached = c); + return c; + }); + } return Scaffold( body: NestedScrollView( headerSliverBuilder: (BuildContext context, bool innerBoxIsScrolled) => [ SliverAppBar( + leading: BackButton(), expandedHeight: 300.0, floating: true, pinned: true, @@ -434,126 +437,128 @@ class _SettingsState extends State { ), onTap: () => _deleteAccountAction(context), ), - Divider(thickness: 1), - ListTile( - title: Text( - L10n.of(context).encryption, - style: TextStyle( - color: Theme.of(context).primaryColor, - fontWeight: FontWeight.bold, + if (client.encryption != null) ...{ + Divider(thickness: 1), + ListTile( + title: Text( + L10n.of(context).encryption, + style: TextStyle( + color: Theme.of(context).primaryColor, + fontWeight: FontWeight.bold, + ), ), ), - ), - ListTile( - trailing: Icon(Icons.compare_arrows_outlined), - title: Text(client.encryption.crossSigning.enabled - ? L10n.of(context).crossSigningEnabled - : L10n.of(context).crossSigningDisabled), - subtitle: client.encryption.crossSigning.enabled - ? Text(client.isUnknownSession - ? L10n.of(context).unknownSessionVerify - : L10n.of(context).sessionVerified + - ', ' + - (crossSigningCached == null - ? '⌛' - : (crossSigningCached - ? L10n.of(context).keysCached - : L10n.of(context).keysMissing))) - : null, - onTap: () async { - if (!client.encryption.crossSigning.enabled) { - return BootstrapDialog().show(context); - } - if (client.isUnknownSession) { - final input = await showTextInputDialog( - context: context, - title: L10n.of(context).askSSSSVerify, - textFields: [ - DialogTextField( - hintText: L10n.of(context).passphraseOrKey, - obscureText: true, - minLines: 1, - maxLines: 1, - ) - ], - ); - if (input != null) { - final valid = await showFutureLoadingDialog( - context: context, - future: () async { - // make sure the loading spinner shows before we test the keys - await Future.delayed(Duration(milliseconds: 100)); - var valid = false; - try { - await client.encryption.crossSigning - .selfSign(recoveryKey: input.single); - valid = true; - } catch (_) { + ListTile( + trailing: Icon(Icons.compare_arrows_outlined), + title: Text(client.encryption.crossSigning.enabled + ? L10n.of(context).crossSigningEnabled + : L10n.of(context).crossSigningDisabled), + subtitle: client.encryption.crossSigning.enabled + ? Text(client.isUnknownSession + ? L10n.of(context).unknownSessionVerify + : L10n.of(context).sessionVerified + + ', ' + + (crossSigningCached == null + ? '⌛' + : (crossSigningCached + ? L10n.of(context).keysCached + : L10n.of(context).keysMissing))) + : null, + onTap: () async { + if (!client.encryption.crossSigning.enabled) { + return BootstrapDialog().show(context); + } + if (client.isUnknownSession) { + final input = await showTextInputDialog( + context: context, + title: L10n.of(context).askSSSSVerify, + textFields: [ + DialogTextField( + hintText: L10n.of(context).passphraseOrKey, + obscureText: true, + minLines: 1, + maxLines: 1, + ) + ], + ); + if (input != null) { + final valid = await showFutureLoadingDialog( + context: context, + future: () async { + // make sure the loading spinner shows before we test the keys + await Future.delayed(Duration(milliseconds: 100)); + var valid = false; try { await client.encryption.crossSigning - .selfSign(passphrase: input.single); + .selfSign(recoveryKey: input.single); valid = true; } catch (_) { - valid = false; + try { + await client.encryption.crossSigning + .selfSign(passphrase: input.single); + valid = true; + } catch (_) { + valid = false; + } } - } - return valid; - }); + return valid; + }); - if (valid.result == true) { - await showOkAlertDialog( - context: context, - message: L10n.of(context).verifiedSession, - ); - setState(() { - crossSigningCachedFuture = null; - crossSigningCached = null; - megolmBackupCachedFuture = null; - megolmBackupCached = null; - }); - } else { - await showOkAlertDialog( - context: context, - message: L10n.of(context).incorrectPassphraseOrKey, - ); + if (valid.result == true) { + await showOkAlertDialog( + context: context, + message: L10n.of(context).verifiedSession, + ); + setState(() { + crossSigningCachedFuture = null; + crossSigningCached = null; + megolmBackupCachedFuture = null; + megolmBackupCached = null; + }); + } else { + await showOkAlertDialog( + context: context, + message: L10n.of(context).incorrectPassphraseOrKey, + ); + } } } - } - if (!(await client.encryption.crossSigning.isCached())) { - await requestSSSSCache(context); - } - }, - ), - ListTile( - trailing: Icon(Icons.wb_cloudy_outlined), - title: Text(client.encryption.keyManager.enabled - ? L10n.of(context).onlineKeyBackupEnabled - : L10n.of(context).onlineKeyBackupDisabled), - subtitle: client.encryption.keyManager.enabled - ? Text(megolmBackupCached == null - ? '⌛' - : (megolmBackupCached - ? L10n.of(context).keysCached - : L10n.of(context).keysMissing)) - : null, - onTap: () async { - if (!client.encryption.keyManager.enabled) { - return BootstrapDialog().show(context); - } - if (!(await client.encryption.keyManager.isCached())) { - await requestSSSSCache(context); - } - }, - ), - ListTile( - title: Text(L10n.of(context).yourPublicKey), - onTap: () => showOkAlertDialog( - context: context, - title: L10n.of(context).yourPublicKey, - message: client.fingerprintKey.beautified, + if (!(await client.encryption.crossSigning.isCached())) { + await requestSSSSCache(context); + } + }, ), - trailing: Icon(Icons.vpn_key_outlined), - ), + ListTile( + trailing: Icon(Icons.wb_cloudy_outlined), + title: Text(client.encryption.keyManager.enabled + ? L10n.of(context).onlineKeyBackupEnabled + : L10n.of(context).onlineKeyBackupDisabled), + subtitle: client.encryption.keyManager.enabled + ? Text(megolmBackupCached == null + ? '⌛' + : (megolmBackupCached + ? L10n.of(context).keysCached + : L10n.of(context).keysMissing)) + : null, + onTap: () async { + if (!client.encryption.keyManager.enabled) { + return BootstrapDialog().show(context); + } + if (!(await client.encryption.keyManager.isCached())) { + await requestSSSSCache(context); + } + }, + ), + ListTile( + title: Text(L10n.of(context).yourPublicKey), + onTap: () => showOkAlertDialog( + context: context, + title: L10n.of(context).yourPublicKey, + message: client.fingerprintKey.beautified, + ), + trailing: Icon(Icons.vpn_key_outlined), + ), + }, Divider(thickness: 1), ListTile( title: Text( diff --git a/lib/views/settings_3pid.dart b/lib/views/settings_3pid.dart index fe2a65b9..ea0f89cd 100644 --- a/lib/views/settings_3pid.dart +++ b/lib/views/settings_3pid.dart @@ -95,6 +95,7 @@ class _Settings3PidState extends State { _request ??= Matrix.of(context).client.requestThirdPartyIdentifiers(); return Scaffold( appBar: AppBar( + leading: BackButton(), title: Text(L10n.of(context).passwordRecovery), actions: [ IconButton( diff --git a/lib/views/settings_devices.dart b/lib/views/settings_devices.dart index 5bf6c63a..6d70068e 100644 --- a/lib/views/settings_devices.dart +++ b/lib/views/settings_devices.dart @@ -88,7 +88,10 @@ class DevicesSettingsState extends State { @override Widget build(BuildContext context) { return Scaffold( - appBar: AppBar(title: Text(L10n.of(context).devices)), + appBar: AppBar( + leading: BackButton(), + title: Text(L10n.of(context).devices), + ), body: FutureBuilder( future: _loadUserDevices(context), builder: (BuildContext context, snapshot) { diff --git a/lib/views/settings_emotes.dart b/lib/views/settings_emotes.dart index 15ac32ea..47c97cab 100644 --- a/lib/views/settings_emotes.dart +++ b/lib/views/settings_emotes.dart @@ -169,6 +169,7 @@ class _EmotesSettingsState extends State { } return Scaffold( appBar: AppBar( + leading: BackButton(), title: Text(L10n.of(context).emoteSettings), ), floatingActionButton: showSave diff --git a/lib/views/settings_ignore_list.dart b/lib/views/settings_ignore_list.dart index 887d8592..730ee245 100644 --- a/lib/views/settings_ignore_list.dart +++ b/lib/views/settings_ignore_list.dart @@ -22,7 +22,10 @@ class SettingsIgnoreList extends StatelessWidget { Widget build(BuildContext context) { final client = Matrix.of(context).client; return Scaffold( - appBar: AppBar(title: Text(L10n.of(context).ignoredUsers)), + appBar: AppBar( + leading: BackButton(), + title: Text(L10n.of(context).ignoredUsers), + ), body: Column( children: [ Padding( diff --git a/lib/views/settings_multiple_emotes.dart b/lib/views/settings_multiple_emotes.dart index 80d6fbd9..3a19218b 100644 --- a/lib/views/settings_multiple_emotes.dart +++ b/lib/views/settings_multiple_emotes.dart @@ -14,6 +14,7 @@ class MultipleEmotesSettings extends StatelessWidget { final room = Matrix.of(context).client.getRoomById(roomId); return Scaffold( appBar: AppBar( + leading: BackButton(), title: Text(L10n.of(context).emotePacks), ), body: StreamBuilder( diff --git a/lib/views/settings_notifications.dart b/lib/views/settings_notifications.dart index f3238484..4b540451 100644 --- a/lib/views/settings_notifications.dart +++ b/lib/views/settings_notifications.dart @@ -109,6 +109,7 @@ class SettingsNotifications extends StatelessWidget { Widget build(BuildContext context) { return Scaffold( appBar: AppBar( + leading: BackButton(), title: Text(L10n.of(context).notifications), ), body: StreamBuilder( diff --git a/lib/views/settings_style.dart b/lib/views/settings_style.dart index a18ae6aa..57da3c88 100644 --- a/lib/views/settings_style.dart +++ b/lib/views/settings_style.dart @@ -51,6 +51,7 @@ class _SettingsStyleState extends State { Widget build(BuildContext context) { return Scaffold( appBar: AppBar( + leading: BackButton(), title: Text(L10n.of(context).changeTheme), ), body: ListView( diff --git a/lib/views/sign_up.dart b/lib/views/sign_up.dart index 18366b1c..18a81dc4 100644 --- a/lib/views/sign_up.dart +++ b/lib/views/sign_up.dart @@ -70,7 +70,7 @@ class _SignUpState extends State { return Scaffold( appBar: AppBar( elevation: 0, - leading: loading ? Container() : null, + leading: loading ? Container() : BackButton(), title: Text( Matrix.of(context) .client diff --git a/lib/views/sign_up_password.dart b/lib/views/sign_up_password.dart index 4cb61494..297bc47d 100644 --- a/lib/views/sign_up_password.dart +++ b/lib/views/sign_up_password.dart @@ -110,7 +110,7 @@ class _SignUpPasswordState extends State { return Scaffold( appBar: AppBar( elevation: 0, - leading: loading ? Container() : null, + leading: loading ? Container() : BackButton(), title: Text( L10n.of(context).chooseAStrongPassword, ),