mirror of
https://github.com/Iconica-Development/flutter_chat.git
synced 2025-05-18 18:33:49 +02:00
fix: add back button to chatOverviewScreen when onExit is not null
This commit is contained in:
parent
33d790bb6e
commit
99c15dbd7f
3 changed files with 14 additions and 4 deletions
|
@ -1,6 +1,7 @@
|
|||
## 6.0.1
|
||||
- Added proper implementation for getAllUsersForChat in Firebase repository
|
||||
- Removed cast which throws an error in ChatProfileScreen
|
||||
- Added BackButton to ChatOverviewScreen when onExit is not null
|
||||
|
||||
## 6.0.0
|
||||
- Added pending message repository to temporarily store messages that are not yet received by the backend
|
||||
|
|
|
@ -78,6 +78,8 @@ abstract class _BaseChatNavigatorUserstory extends HookWidget {
|
|||
final ChatOptions options;
|
||||
|
||||
/// 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;
|
||||
|
||||
/// Implemented by subclasses to provide the initial route of the userstory.
|
||||
|
@ -108,7 +110,7 @@ abstract class _BaseChatNavigatorUserstory extends HookWidget {
|
|||
service: service,
|
||||
popHandler: popHandler,
|
||||
child: NavigatorPopHandler(
|
||||
onPop: () => popHandler.handlePop(),
|
||||
onPop: popHandler.handlePop,
|
||||
child: Navigator(
|
||||
key: nestedNavigatorKey,
|
||||
onGenerateInitialRoutes: (_, __) => [
|
||||
|
|
|
@ -46,7 +46,7 @@ class ChatScreen extends HookWidget {
|
|||
|
||||
if (options.builders.baseScreenBuilder == null) {
|
||||
return Scaffold(
|
||||
appBar: const _AppBar(),
|
||||
appBar: _AppBar(onExit),
|
||||
body: _Body(
|
||||
onPressChat: onPressChat,
|
||||
onPressStartChat: onPressStartChat,
|
||||
|
@ -58,7 +58,7 @@ class ChatScreen extends HookWidget {
|
|||
return options.builders.baseScreenBuilder!.call(
|
||||
context,
|
||||
mapScreenType,
|
||||
const _AppBar(),
|
||||
_AppBar(onExit),
|
||||
translations.chatsTitle,
|
||||
_Body(
|
||||
onPressChat: onPressChat,
|
||||
|
@ -70,7 +70,9 @@ class ChatScreen extends HookWidget {
|
|||
}
|
||||
|
||||
class _AppBar extends StatelessWidget implements PreferredSizeWidget {
|
||||
const _AppBar();
|
||||
const _AppBar(this.onExit);
|
||||
|
||||
final VoidCallback? onExit;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
|
@ -81,6 +83,11 @@ class _AppBar extends StatelessWidget implements PreferredSizeWidget {
|
|||
var theme = Theme.of(context);
|
||||
|
||||
return AppBar(
|
||||
leading: onExit != null
|
||||
? BackButton(
|
||||
onPressed: () => onExit?.call(),
|
||||
)
|
||||
: null,
|
||||
title: Text(
|
||||
translations.chatsTitle,
|
||||
),
|
||||
|
|
Loading…
Reference in a new issue