fix: add back button to chatOverviewScreen when onExit is not null

This commit is contained in:
Jacques 2025-04-24 10:50:28 +02:00
parent 33d790bb6e
commit 99c15dbd7f
3 changed files with 14 additions and 4 deletions

View file

@ -1,6 +1,7 @@
## 6.0.1 ## 6.0.1
- Added proper implementation for getAllUsersForChat in Firebase repository - Added proper implementation for getAllUsersForChat in Firebase repository
- Removed cast which throws an error in ChatProfileScreen - Removed cast which throws an error in ChatProfileScreen
- Added BackButton to ChatOverviewScreen when onExit is not null
## 6.0.0 ## 6.0.0
- Added pending message repository to temporarily store messages that are not yet received by the backend - Added pending message repository to temporarily store messages that are not yet received by the backend

View file

@ -78,6 +78,8 @@ abstract class _BaseChatNavigatorUserstory extends HookWidget {
final ChatOptions options; final ChatOptions options;
/// Callback for when the user wants to navigate back. /// Callback for when the user wants to navigate back.
///
/// This will also show the back button in the appbar when not null
final VoidCallback? onExit; final VoidCallback? onExit;
/// Implemented by subclasses to provide the initial route of the userstory. /// Implemented by subclasses to provide the initial route of the userstory.
@ -108,7 +110,7 @@ abstract class _BaseChatNavigatorUserstory extends HookWidget {
service: service, service: service,
popHandler: popHandler, popHandler: popHandler,
child: NavigatorPopHandler( child: NavigatorPopHandler(
onPop: () => popHandler.handlePop(), onPop: popHandler.handlePop,
child: Navigator( child: Navigator(
key: nestedNavigatorKey, key: nestedNavigatorKey,
onGenerateInitialRoutes: (_, __) => [ onGenerateInitialRoutes: (_, __) => [

View file

@ -46,7 +46,7 @@ class ChatScreen extends HookWidget {
if (options.builders.baseScreenBuilder == null) { if (options.builders.baseScreenBuilder == null) {
return Scaffold( return Scaffold(
appBar: const _AppBar(), appBar: _AppBar(onExit),
body: _Body( body: _Body(
onPressChat: onPressChat, onPressChat: onPressChat,
onPressStartChat: onPressStartChat, onPressStartChat: onPressStartChat,
@ -58,7 +58,7 @@ class ChatScreen extends HookWidget {
return options.builders.baseScreenBuilder!.call( return options.builders.baseScreenBuilder!.call(
context, context,
mapScreenType, mapScreenType,
const _AppBar(), _AppBar(onExit),
translations.chatsTitle, translations.chatsTitle,
_Body( _Body(
onPressChat: onPressChat, onPressChat: onPressChat,
@ -70,7 +70,9 @@ class ChatScreen extends HookWidget {
} }
class _AppBar extends StatelessWidget implements PreferredSizeWidget { class _AppBar extends StatelessWidget implements PreferredSizeWidget {
const _AppBar(); const _AppBar(this.onExit);
final VoidCallback? onExit;
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
@ -81,6 +83,11 @@ class _AppBar extends StatelessWidget implements PreferredSizeWidget {
var theme = Theme.of(context); var theme = Theme.of(context);
return AppBar( return AppBar(
leading: onExit != null
? BackButton(
onPressed: () => onExit?.call(),
)
: null,
title: Text( title: Text(
translations.chatsTitle, translations.chatsTitle,
), ),