mirror of
https://github.com/Iconica-Development/flutter_chat.git
synced 2025-05-19 10:53:51 +02:00
feat: add onPopInvoked callback for a popscope inside the userstory
This commit is contained in:
parent
8b4ada7edc
commit
d13a8013ac
4 changed files with 56 additions and 39 deletions
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
- fix bug where you could make multiple groups quickly by routing back to the previous screen
|
- 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
|
- fix bug where you would route back to the user selection screen insterad of routing back to the chat overview screen
|
||||||
|
- Add onPopInvoked callback to the userstory to add custom behaviour for the back button on the chatscreen
|
||||||
|
|
||||||
## 3.0.0
|
## 3.0.0
|
||||||
|
|
||||||
|
|
|
@ -30,7 +30,11 @@ Widget _chatScreenRoute(
|
||||||
ChatUserStoryConfiguration configuration,
|
ChatUserStoryConfiguration configuration,
|
||||||
BuildContext context,
|
BuildContext context,
|
||||||
) =>
|
) =>
|
||||||
ChatScreen(
|
PopScope(
|
||||||
|
canPop: configuration.onPopInvoked == null,
|
||||||
|
onPopInvoked: (didPop) =>
|
||||||
|
configuration.onPopInvoked?.call(didPop, context),
|
||||||
|
child: ChatScreen(
|
||||||
unreadMessageTextStyle: configuration.unreadMessageTextStyle,
|
unreadMessageTextStyle: configuration.unreadMessageTextStyle,
|
||||||
service: configuration.chatService,
|
service: configuration.chatService,
|
||||||
options: configuration.chatOptionsBuilder(context),
|
options: configuration.chatOptionsBuilder(context),
|
||||||
|
@ -72,6 +76,7 @@ Widget _chatScreenRoute(
|
||||||
configuration.chatService.chatOverviewService.deleteChat(chat),
|
configuration.chatService.chatOverviewService.deleteChat(chat),
|
||||||
deleteChatDialog: configuration.deleteChatDialog,
|
deleteChatDialog: configuration.deleteChatDialog,
|
||||||
translations: configuration.translations,
|
translations: configuration.translations,
|
||||||
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
/// Constructs the chat detail screen route widget.
|
/// Constructs the chat detail screen route widget.
|
||||||
|
|
|
@ -43,6 +43,10 @@ List<GoRoute> getChatStoryRoutes(
|
||||||
return buildScreenWithoutTransition(
|
return buildScreenWithoutTransition(
|
||||||
context: context,
|
context: context,
|
||||||
state: state,
|
state: state,
|
||||||
|
child: PopScope(
|
||||||
|
canPop: configuration.onPopInvoked == null,
|
||||||
|
onPopInvoked: (didPop) =>
|
||||||
|
configuration.onPopInvoked?.call(didPop, context),
|
||||||
child: configuration.chatPageBuilder?.call(
|
child: configuration.chatPageBuilder?.call(
|
||||||
context,
|
context,
|
||||||
chatScreen,
|
chatScreen,
|
||||||
|
@ -51,6 +55,7 @@ List<GoRoute> getChatStoryRoutes(
|
||||||
backgroundColor: theme.colorScheme.surface,
|
backgroundColor: theme.colorScheme.surface,
|
||||||
body: chatScreen,
|
body: chatScreen,
|
||||||
),
|
),
|
||||||
|
),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
|
|
|
@ -21,6 +21,7 @@ class ChatUserStoryConfiguration {
|
||||||
this.onMessageSubmit,
|
this.onMessageSubmit,
|
||||||
this.onReadChat,
|
this.onReadChat,
|
||||||
this.onUploadImage,
|
this.onUploadImage,
|
||||||
|
this.onPopInvoked,
|
||||||
this.onPressCreateChat,
|
this.onPressCreateChat,
|
||||||
this.onPressCreateGroupChat,
|
this.onPressCreateGroupChat,
|
||||||
this.onPressCompleteGroupChatCreation,
|
this.onPressCompleteGroupChatCreation,
|
||||||
|
@ -118,6 +119,11 @@ class ChatUserStoryConfiguration {
|
||||||
/// Callback function triggered when user profile is pressed.
|
/// Callback function triggered when user profile is pressed.
|
||||||
final Function(BuildContext context, ChatUserModel user)? onPressUserProfile;
|
final Function(BuildContext context, ChatUserModel user)? onPressUserProfile;
|
||||||
|
|
||||||
|
/// Callback function triggered when the popscope on the chat
|
||||||
|
/// homepage is triggered.
|
||||||
|
// ignore: avoid_positional_boolean_parameters
|
||||||
|
final Function(bool didPop, BuildContext context)? onPopInvoked;
|
||||||
|
|
||||||
final double? textfieldBottomPadding;
|
final double? textfieldBottomPadding;
|
||||||
|
|
||||||
final Color? iconDisabledColor;
|
final Color? iconDisabledColor;
|
||||||
|
|
Loading…
Reference in a new issue