From 61d901c741e5b31e59a356cf9beb3ee30611ea27 Mon Sep 17 00:00:00 2001 From: mike doornenbal Date: Thu, 6 Jun 2024 14:47:07 +0200 Subject: [PATCH] fix: routing issues --- CHANGELOG.md | 5 ++++ .../src/flutter_chat_navigator_userstory.dart | 30 +++++++++++-------- .../lib/src/flutter_chat_userstory.dart | 22 +++++++------- packages/flutter_chat/pubspec.yaml | 8 ++--- packages/flutter_chat_firebase/pubspec.yaml | 4 +-- packages/flutter_chat_interface/pubspec.yaml | 2 +- packages/flutter_chat_local/pubspec.yaml | 4 +-- packages/flutter_chat_view/pubspec.yaml | 4 +-- 8 files changed, 45 insertions(+), 34 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 561b5ac..e0f230e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,8 @@ +## 3.0.1 + +- fix bug where you could make multiple groups quickly by routing back to the previous screen +- fix bug where you would route back to the user selection screen insterad of routing back to the chat overview screen + ## 3.0.0 - Add theming diff --git a/packages/flutter_chat/lib/src/flutter_chat_navigator_userstory.dart b/packages/flutter_chat/lib/src/flutter_chat_navigator_userstory.dart index af7e574..9a9fa89 100644 --- a/packages/flutter_chat/lib/src/flutter_chat_navigator_userstory.dart +++ b/packages/flutter_chat/lib/src/flutter_chat_navigator_userstory.dart @@ -2,8 +2,8 @@ // // SPDX-License-Identifier: BSD-3-Clause -import 'package:flutter/material.dart'; -import 'package:flutter_chat/flutter_chat.dart'; +import "package:flutter/material.dart"; +import "package:flutter_chat/flutter_chat.dart"; /// Navigates to the chat user story screen. /// @@ -218,7 +218,7 @@ Widget _newChatScreenRoute( if (configuration.onPressCreateChat != null) return; var chat = await configuration.chatService.chatOverviewService .getChatByUser(user); - debugPrint('Chat is ${chat.id}'); + debugPrint("Chat is ${chat.id}"); if (chat.id == null) { chat = await configuration.chatService.chatOverviewService .storeChatIfNot( @@ -230,10 +230,13 @@ Widget _newChatScreenRoute( if (context.mounted) { await Navigator.of(context).push( MaterialPageRoute( - builder: (context) => _chatDetailScreenRoute( - configuration, - context, - chat.id!, + builder: (context) => PopScope( + canPop: false, + child: _chatDetailScreenRoute( + configuration, + context, + chat.id!, + ), ), ), ); @@ -279,17 +282,20 @@ Widget _newGroupChatOverviewScreenRoute( GroupChatModel( canBeDeleted: true, title: groupChatName, - imageUrl: 'https://picsum.photos/200/300', + imageUrl: "https://picsum.photos/200/300", users: users, ), ); if (context.mounted) { await Navigator.of(context).pushReplacement( MaterialPageRoute( - builder: (context) => _chatDetailScreenRoute( - configuration, - context, - chat.id!, + builder: (context) => PopScope( + canPop: false, + child: _chatDetailScreenRoute( + configuration, + context, + chat.id!, + ), ), ), ); diff --git a/packages/flutter_chat/lib/src/flutter_chat_userstory.dart b/packages/flutter_chat/lib/src/flutter_chat_userstory.dart index 3416f72..dc5c22c 100644 --- a/packages/flutter_chat/lib/src/flutter_chat_userstory.dart +++ b/packages/flutter_chat/lib/src/flutter_chat_userstory.dart @@ -2,10 +2,10 @@ // // SPDX-License-Identifier: BSD-3-Clause -import 'package:flutter/material.dart'; -import 'package:flutter_chat/flutter_chat.dart'; -import 'package:flutter_chat/src/go_router.dart'; -import 'package:go_router/go_router.dart'; +import "package:flutter/material.dart"; +import "package:flutter_chat/flutter_chat.dart"; +import "package:flutter_chat/src/go_router.dart"; +import "package:go_router/go_router.dart"; List getChatStoryRoutes( ChatUserStoryConfiguration configuration, @@ -57,7 +57,7 @@ List getChatStoryRoutes( GoRoute( path: ChatUserStoryRoutes.chatDetailScreen, pageBuilder: (context, state) { - var chatId = state.pathParameters['id']; + var chatId = state.pathParameters["id"]; var service = configuration.chatServiceBuilder?.call(context) ?? configuration.chatService; var theme = Theme.of(context); @@ -156,7 +156,7 @@ List getChatStoryRoutes( } if (context.mounted) { await context.push( - ChatUserStoryRoutes.chatDetailViewPath(chat.id ?? ''), + ChatUserStoryRoutes.chatDetailViewPath(chat.id ?? ""), ); } }, @@ -231,13 +231,13 @@ List getChatStoryRoutes( GroupChatModel( canBeDeleted: true, title: groupChatName, - imageUrl: 'https://picsum.photos/200/300', + imageUrl: "https://picsum.photos/200/300", users: users, ), ); if (context.mounted) { context.go( - ChatUserStoryRoutes.chatDetailViewPath(chat.id ?? ''), + ChatUserStoryRoutes.chatDetailViewPath(chat.id ?? ""), ); } }, @@ -259,9 +259,9 @@ List getChatStoryRoutes( GoRoute( path: ChatUserStoryRoutes.chatProfileScreen, pageBuilder: (context, state) { - var chatId = state.pathParameters['id']; - var userId = state.pathParameters['userId']; - var id = userId == 'null' ? null : userId; + var chatId = state.pathParameters["id"]; + var userId = state.pathParameters["userId"]; + var id = userId == "null" ? null : userId; var service = configuration.chatServiceBuilder?.call(context) ?? configuration.chatService; var theme = Theme.of(context); diff --git a/packages/flutter_chat/pubspec.yaml b/packages/flutter_chat/pubspec.yaml index 9f26749..0b1fa88 100644 --- a/packages/flutter_chat/pubspec.yaml +++ b/packages/flutter_chat/pubspec.yaml @@ -4,7 +4,7 @@ name: flutter_chat description: A new Flutter package project. -version: 3.0.0 +version: 3.0.1 publish_to: none @@ -20,17 +20,17 @@ dependencies: git: url: https://github.com/Iconica-Development/flutter_chat path: packages/flutter_chat_view - ref: 3.0.0 + ref: 3.0.1 flutter_chat_interface: git: url: https://github.com/Iconica-Development/flutter_chat path: packages/flutter_chat_interface - ref: 3.0.0 + ref: 3.0.1 flutter_chat_local: git: url: https://github.com/Iconica-Development/flutter_chat path: packages/flutter_chat_local - ref: 3.0.0 + ref: 3.0.1 uuid: ^4.3.3 dev_dependencies: diff --git a/packages/flutter_chat_firebase/pubspec.yaml b/packages/flutter_chat_firebase/pubspec.yaml index c9a8225..8acc134 100644 --- a/packages/flutter_chat_firebase/pubspec.yaml +++ b/packages/flutter_chat_firebase/pubspec.yaml @@ -4,7 +4,7 @@ name: flutter_chat_firebase description: A new Flutter package project. -version: 3.0.0 +version: 3.0.1 publish_to: none environment: @@ -23,7 +23,7 @@ dependencies: git: url: https://github.com/Iconica-Development/flutter_chat path: packages/flutter_chat_interface - ref: 3.0.0 + ref: 3.0.1 dev_dependencies: flutter_iconica_analysis: diff --git a/packages/flutter_chat_interface/pubspec.yaml b/packages/flutter_chat_interface/pubspec.yaml index 80fd053..f03cb0b 100644 --- a/packages/flutter_chat_interface/pubspec.yaml +++ b/packages/flutter_chat_interface/pubspec.yaml @@ -4,7 +4,7 @@ name: flutter_chat_interface description: A new Flutter package project. -version: 3.0.0 +version: 3.0.1 publish_to: none environment: diff --git a/packages/flutter_chat_local/pubspec.yaml b/packages/flutter_chat_local/pubspec.yaml index e77b94c..a659074 100644 --- a/packages/flutter_chat_local/pubspec.yaml +++ b/packages/flutter_chat_local/pubspec.yaml @@ -1,6 +1,6 @@ name: flutter_chat_local description: "A new Flutter package project." -version: 3.0.0 +version: 3.0.1 publish_to: none environment: @@ -14,7 +14,7 @@ dependencies: git: url: https://github.com/Iconica-Development/flutter_chat path: packages/flutter_chat_interface - ref: 3.0.0 + ref: 3.0.1 dev_dependencies: flutter_test: diff --git a/packages/flutter_chat_view/pubspec.yaml b/packages/flutter_chat_view/pubspec.yaml index 0c1b85d..9057aa0 100644 --- a/packages/flutter_chat_view/pubspec.yaml +++ b/packages/flutter_chat_view/pubspec.yaml @@ -4,7 +4,7 @@ name: flutter_chat_view description: A standard flutter package. -version: 3.0.0 +version: 3.0.1 publish_to: none @@ -20,7 +20,7 @@ dependencies: git: url: https://github.com/Iconica-Development/flutter_chat path: packages/flutter_chat_interface - ref: 3.0.0 + ref: 3.0.1 cached_network_image: ^3.2.2 flutter_image_picker: git: