diff --git a/lib/config/routes.dart b/lib/config/routes.dart index e83f75e2..5a554605 100644 --- a/lib/config/routes.dart +++ b/lib/config/routes.dart @@ -139,7 +139,7 @@ class AppRoutes { nestedRoutes: [ VWidget( path: '', - widget: EmptyPage(), + widget: Chat(), buildTransition: _fadeTransition, ), VWidget( diff --git a/lib/pages/chat.dart b/lib/pages/chat.dart index 2a66392e..eb9b8923 100644 --- a/lib/pages/chat.dart +++ b/lib/pages/chat.dart @@ -620,7 +620,7 @@ class ChatController extends State { future: room.leave, ); if (result.error == null) { - VRouter.of(context).to('/rooms/${result.result}'); + VRouter.of(context).toSegments(['rooms', result.result]); } } diff --git a/lib/pages/chat_list.dart b/lib/pages/chat_list.dart index 575d2e97..84a42330 100644 --- a/lib/pages/chat_list.dart +++ b/lib/pages/chat_list.dart @@ -60,7 +60,7 @@ class ChatListController extends State { void editSpace(BuildContext context, String spaceId) async { Scaffold.of(context).openEndDrawer(); await Matrix.of(context).client.getRoomById(spaceId).postLoad(); - VRouter.of(context).to('/spaces/$spaceId'); + VRouter.of(context).toSegments(['spaces', spaceId]); } List get spaces => diff --git a/lib/pages/new_group.dart b/lib/pages/new_group.dart index f7445a42..3fa0cc4a 100644 --- a/lib/pages/new_group.dart +++ b/lib/pages/new_group.dart @@ -32,7 +32,7 @@ class NewGroupController extends State { ), ); if (roomID.error == null) { - VRouter.of(context).to('/rooms/${roomID.result}/invite'); + VRouter.of(context).toSegments(['rooms', roomID.result, 'invite']); } } diff --git a/lib/pages/new_private_chat.dart b/lib/pages/new_private_chat.dart index e29f4278..29291577 100644 --- a/lib/pages/new_private_chat.dart +++ b/lib/pages/new_private_chat.dart @@ -47,7 +47,7 @@ class NewPrivateChatController extends State { ); if (roomID.error == null) { - VRouter.of(context).to('/rooms/${roomID.result}'); + VRouter.of(context).toSegments(['rooms', roomID.result]); } } diff --git a/lib/pages/new_space.dart b/lib/pages/new_space.dart index 751ec85c..21fe86e5 100644 --- a/lib/pages/new_space.dart +++ b/lib/pages/new_space.dart @@ -34,7 +34,7 @@ class NewSpaceController extends State { ), ); if (roomID.error == null) { - VRouter.of(context).to('/rooms/${roomID.result}/details'); + VRouter.of(context).toSegments(['rooms', roomID.result, 'details']); } } diff --git a/lib/pages/search.dart b/lib/pages/search.dart index fe674f53..c3c2e5ea 100644 --- a/lib/pages/search.dart +++ b/lib/pages/search.dart @@ -77,7 +77,7 @@ class SearchController extends State { ), ); if (success.error == null) { - VRouter.of(context).to('/rooms/${success.result}'); + VRouter.of(context).toSegments(['rooms', success.result]); } } diff --git a/lib/pages/user_bottom_sheet.dart b/lib/pages/user_bottom_sheet.dart index cc458dc8..8e048fb9 100644 --- a/lib/pages/user_bottom_sheet.dart +++ b/lib/pages/user_bottom_sheet.dart @@ -88,7 +88,8 @@ class UserBottomSheetController extends State { future: () => widget.user.startDirectChat(), ); if (roomIdResult.error != null) return; - VRouter.of(widget.outerContext).to('/rooms/${roomIdResult.result}'); + VRouter.of(widget.outerContext) + .toSegments(['rooms', roomIdResult.result]); Navigator.of(context, rootNavigator: false).pop(); break; } diff --git a/lib/pages/views/chat_details_view.dart b/lib/pages/views/chat_details_view.dart index 867613ca..16d6df50 100644 --- a/lib/pages/views/chat_details_view.dart +++ b/lib/pages/views/chat_details_view.dart @@ -52,11 +52,11 @@ class ChatDetailsView extends StatelessWidget { SliverAppBar( leading: IconButton( icon: Icon(Icons.close_outlined), - onPressed: () => VRouter.of(context) - .path - .startsWith('/spaces/') - ? VRouter.of(context).pop() - : VRouter.of(context).to('/rooms/${controller.roomId}'), + onPressed: () => + VRouter.of(context).path.startsWith('/spaces/') + ? VRouter.of(context).pop() + : VRouter.of(context) + .toSegments(['rooms', controller.roomId]), ), elevation: Theme.of(context).appBarTheme.elevation, expandedHeight: 300.0, @@ -264,7 +264,8 @@ class ChatDetailsView extends StatelessWidget { .visibilityOfTheChatHistory), subtitle: Text( room.historyVisibility.getLocalizedString( - MatrixLocals(L10n.of(context))), + MatrixLocals(L10n.of(context))) ?? + '', ), ), ), diff --git a/lib/pages/views/chat_encryption_settings_view.dart b/lib/pages/views/chat_encryption_settings_view.dart index 3546d567..b8d15de9 100644 --- a/lib/pages/views/chat_encryption_settings_view.dart +++ b/lib/pages/views/chat_encryption_settings_view.dart @@ -23,7 +23,7 @@ class ChatEncryptionSettingsView extends StatelessWidget { leading: IconButton( icon: Icon(Icons.close_outlined), onPressed: () => - VRouter.of(context).to('/rooms/${controller.roomId}'), + VRouter.of(context).toSegments(['rooms', controller.roomId]), ), title: Text(L10n.of(context).tapOnDeviceToVerify), bottom: PreferredSize( diff --git a/lib/pages/views/chat_permissions_settings_view.dart b/lib/pages/views/chat_permissions_settings_view.dart index ee27f4d2..9014e8ba 100644 --- a/lib/pages/views/chat_permissions_settings_view.dart +++ b/lib/pages/views/chat_permissions_settings_view.dart @@ -22,8 +22,8 @@ class ChatPermissionsSettingsView extends StatelessWidget { ? null : IconButton( icon: Icon(Icons.close_outlined), - onPressed: () => - VRouter.of(context).to('/rooms/${controller.roomId}'), + onPressed: () => VRouter.of(context) + .toSegments(['rooms', controller.roomId]), ), title: Text(L10n.of(context).editChatPermissions), ), diff --git a/lib/pages/views/chat_view.dart b/lib/pages/views/chat_view.dart index 8b9f5af7..12f18552 100644 --- a/lib/pages/views/chat_view.dart +++ b/lib/pages/views/chat_view.dart @@ -98,8 +98,8 @@ class ChatView extends StatelessWidget { '${controller.room.getUserByMXIDSync(controller.room.directChatMatrixID).mention} ', ), ) - : () => VRouter.of(context) - .to('/rooms/${controller.room.id}/details'), + : () => VRouter.of(context).toSegments( + ['rooms', controller.room.id, 'details']), title: Text( controller.room.getLocalizedDisplayname( MatrixLocals(L10n.of(context))), diff --git a/lib/pages/views/invitation_selection_view.dart b/lib/pages/views/invitation_selection_view.dart index 5510c217..3ba086de 100644 --- a/lib/pages/views/invitation_selection_view.dart +++ b/lib/pages/views/invitation_selection_view.dart @@ -25,8 +25,8 @@ class InvitationSelectionView extends StatelessWidget { ? null : IconButton( icon: Icon(Icons.close_outlined), - onPressed: () => - VRouter.of(context).to('/rooms/${controller.roomId}'), + onPressed: () => VRouter.of(context) + .toSegments(['rooms', controller.roomId]), ), titleSpacing: 0, title: DefaultAppBarSearchField( diff --git a/lib/pages/views/search_view.dart b/lib/pages/views/search_view.dart index 1902d331..3f6ec98f 100644 --- a/lib/pages/views/search_view.dart +++ b/lib/pages/views/search_view.dart @@ -238,7 +238,8 @@ class SearchView extends StatelessWidget { .startDirectChat(foundProfile.userId), ); if (roomID.error == null) { - VRouter.of(context).to('/rooms/${roomID.result}'); + VRouter.of(context) + .toSegments(['rooms', roomID.result]); } }, leading: Avatar( diff --git a/lib/pages/views/settings_multiple_emotes_view.dart b/lib/pages/views/settings_multiple_emotes_view.dart index e1cce3d2..15830099 100644 --- a/lib/pages/views/settings_multiple_emotes_view.dart +++ b/lib/pages/views/settings_multiple_emotes_view.dart @@ -44,8 +44,8 @@ class MultipleEmotesSettingsView extends StatelessWidget { return ListTile( title: Text(packName), onTap: () async { - VRouter.of(context) - .to('/rooms/${room.id}/details/emotes/${keys[i]}'); + VRouter.of(context).toSegments( + ['rooms', room.id, 'details', 'emotes', keys[i]]); }, ); }); diff --git a/lib/utils/background_push.dart b/lib/utils/background_push.dart index c7403683..0279fcee 100644 --- a/lib/utils/background_push.dart +++ b/lib/utils/background_push.dart @@ -283,7 +283,7 @@ class BackgroundPush { if (router == null) { return; } - router.currentState.to('/rooms/$roomId'); + router.currentState.toSegments(['rooms', roomId]); } catch (e, s) { Logs().e('[Push] Failed to open room', e, s); } diff --git a/lib/utils/url_launcher.dart b/lib/utils/url_launcher.dart index da911996..98639545 100644 --- a/lib/utils/url_launcher.dart +++ b/lib/utils/url_launcher.dart @@ -110,10 +110,10 @@ class UrlLauncher { if (room != null) { // we have the room, so....just open it if (event != null) { - VRouter.of(context) - .to('/rooms/${room.id}', queryParameters: {'event': event}); + VRouter.of(context).toSegments(['rooms', room.id], + queryParameters: {'event': event}); } else { - VRouter.of(context).to('/rooms/${room.id}'); + VRouter.of(context).toSegments(['rooms', room.id]); } return; } @@ -138,9 +138,10 @@ class UrlLauncher { context: context, future: () => Future.delayed(const Duration(seconds: 2))); if (event != null) { - VRouter.of(context).to('/rooms/${response.result}/$event'); + VRouter.of(context).toSegments(['rooms', response.result], + queryParameters: {'event': event}); } else { - VRouter.of(context).to('/rooms/${response.result}'); + VRouter.of(context).toSegments(['rooms', response.result]); } } } else { @@ -155,7 +156,7 @@ class UrlLauncher { ); var roomId = matrix.client.getDirectChatFromUserId(user.id); if (roomId != null) { - VRouter.of(context).to('/rooms/$roomId'); + VRouter.of(context).toSegments(['rooms', roomId]); return; } @@ -173,7 +174,7 @@ class UrlLauncher { .result; if (roomId != null) { - VRouter.of(context).to('/rooms/$roomId'); + VRouter.of(context).toSegments(['rooms', roomId]); } } } diff --git a/lib/widgets/chat_settings_popup_menu.dart b/lib/widgets/chat_settings_popup_menu.dart index b8c597b6..b340099e 100644 --- a/lib/widgets/chat_settings_popup_menu.dart +++ b/lib/widgets/chat_settings_popup_menu.dart @@ -95,7 +95,8 @@ class _ChatSettingsPopupMenuState extends State { widget.room.setPushRuleState(PushRuleState.notify)); break; case 'details': - VRouter.of(context).to('/rooms/${widget.room.id}/details'); + VRouter.of(context) + .toSegments(['rooms', widget.room.id, 'details']); break; } }, diff --git a/lib/widgets/contacts_list.dart b/lib/widgets/contacts_list.dart index dae014cf..f782f886 100644 --- a/lib/widgets/contacts_list.dart +++ b/lib/widgets/contacts_list.dart @@ -102,8 +102,12 @@ class _ContactListTile extends StatelessWidget { fontWeight: FontWeight.bold, ) : null), - onTap: () => VRouter.of(context).to( - '/rooms/${Matrix.of(context).client.getDirectChatFromUserId(contact.senderId)}'), + onTap: () => VRouter.of(context).toSegments([ + 'rooms', + Matrix.of(context) + .client + .getDirectChatFromUserId(contact.senderId) + ]), ); }); } diff --git a/lib/widgets/encryption_button.dart b/lib/widgets/encryption_button.dart index 0c8f9535..3d044ced 100644 --- a/lib/widgets/encryption_button.dart +++ b/lib/widgets/encryption_button.dart @@ -21,7 +21,7 @@ class _EncryptionButtonState extends State { void _enableEncryptionAction() async { if (widget.room.encrypted) { - VRouter.of(context).to('/rooms/${widget.room.id}/encryption'); + VRouter.of(context).toSegments(['rooms', widget.room.id, 'encryption']); return; } if (widget.room.joinRules == JoinRules.public) { diff --git a/lib/widgets/list_items/chat_list_item.dart b/lib/widgets/list_items/chat_list_item.dart index ee7af093..d34bf9ee 100644 --- a/lib/widgets/list_items/chat_list_item.dart +++ b/lib/widgets/list_items/chat_list_item.dart @@ -112,7 +112,7 @@ class ChatListItem extends StatelessWidget { } Matrix.of(context).shareContent = null; } - VRouter.of(context).to('/rooms/${room.id}'); + VRouter.of(context).toSegments(['rooms', room.id]); } } } diff --git a/lib/widgets/list_items/public_room_list_item.dart b/lib/widgets/list_items/public_room_list_item.dart index 50c072e1..196bccfc 100644 --- a/lib/widgets/list_items/public_room_list_item.dart +++ b/lib/widgets/list_items/public_room_list_item.dart @@ -18,7 +18,7 @@ class PublicRoomListItem extends StatelessWidget { future: () => _joinRoomAndWait(context), ); if (success.error == null) { - VRouter.of(context).toNamed('/rooms/${success.result}'); + VRouter.of(context).toSegments(['rooms', success.result]); } }