fix: routing issues

This commit is contained in:
mike doornenbal 2024-06-06 14:47:07 +02:00
parent 5e4a9c7ab4
commit 61d901c741
8 changed files with 45 additions and 34 deletions

View file

@ -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

View file

@ -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!,
),
),
),
);

View file

@ -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<GoRoute> getChatStoryRoutes(
ChatUserStoryConfiguration configuration,
@ -57,7 +57,7 @@ List<GoRoute> 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<GoRoute> getChatStoryRoutes(
}
if (context.mounted) {
await context.push(
ChatUserStoryRoutes.chatDetailViewPath(chat.id ?? ''),
ChatUserStoryRoutes.chatDetailViewPath(chat.id ?? ""),
);
}
},
@ -231,13 +231,13 @@ List<GoRoute> 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<GoRoute> 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);

View file

@ -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:

View file

@ -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:

View file

@ -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:

View file

@ -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:

View file

@ -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: