mirror of
https://github.com/Iconica-Development/flutter_chat.git
synced 2025-05-18 18:33:49 +02:00
feat: add chatScreenBuilder to use instead of baseScreenBuilder on the ChatDetailScreen
This commit is contained in:
parent
6a63429efd
commit
62f04e2d9b
3 changed files with 36 additions and 10 deletions
|
@ -18,6 +18,7 @@
|
|||
- Added sender and chatId to uploadImage in the ChatRepositoryInterface
|
||||
- Added imagePickerBuilder to the builders in the ChatOptions to override the image picker with a custom implementation that needs to return a Future<Uint8List?>
|
||||
- Changed the ChatBottomInputSection to be multiline and go from 45px to 120px in height depending on how many lines are in the textfield
|
||||
- Added chatScreenBuilder to the userstory configuration to customize the specific chat screen with a ChatModel as argument
|
||||
|
||||
## 4.0.0
|
||||
- Move to the new user story architecture
|
||||
|
|
|
@ -13,6 +13,7 @@ class ChatBuilders {
|
|||
/// The chat builders constructor
|
||||
const ChatBuilders({
|
||||
this.baseScreenBuilder,
|
||||
this.chatScreenBuilder,
|
||||
this.messageInputBuilder,
|
||||
this.chatRowContainerBuilder,
|
||||
this.groupAvatarBuilder,
|
||||
|
@ -45,6 +46,11 @@ class ChatBuilders {
|
|||
/// ```
|
||||
final BaseScreenBuilder? baseScreenBuilder;
|
||||
|
||||
/// The chat screen builder
|
||||
/// This builder is used instead of the [baseScreenBuilder] when building the
|
||||
/// chat screen. While the chat is still loading the [chat] will be null
|
||||
final ChatScreenBuilder? chatScreenBuilder;
|
||||
|
||||
/// The message input builder
|
||||
final TextInputBuilder? messageInputBuilder;
|
||||
|
||||
|
@ -133,6 +139,15 @@ typedef BaseScreenBuilder = Widget Function(
|
|||
Widget body,
|
||||
);
|
||||
|
||||
/// The chat screen builder
|
||||
typedef ChatScreenBuilder = Widget Function(
|
||||
BuildContext context,
|
||||
ChatModel? chat,
|
||||
PreferredSizeWidget appBar,
|
||||
String? title,
|
||||
Widget body,
|
||||
);
|
||||
|
||||
/// The container builder
|
||||
typedef ContainerBuilder = Widget Function(
|
||||
BuildContext context,
|
||||
|
|
|
@ -108,13 +108,17 @@ class ChatDetailScreen extends HookWidget {
|
|||
onReadChat: onReadChat,
|
||||
);
|
||||
|
||||
if (options.builders.baseScreenBuilder == null) {
|
||||
return Scaffold(
|
||||
appBar: appBar,
|
||||
body: body,
|
||||
if (options.builders.chatScreenBuilder != null) {
|
||||
return options.builders.chatScreenBuilder!.call(
|
||||
context,
|
||||
chat,
|
||||
appBar,
|
||||
chatTitle.value,
|
||||
body,
|
||||
);
|
||||
}
|
||||
|
||||
if (options.builders.baseScreenBuilder != null) {
|
||||
return options.builders.baseScreenBuilder!.call(
|
||||
context,
|
||||
mapScreenType,
|
||||
|
@ -124,6 +128,12 @@ class ChatDetailScreen extends HookWidget {
|
|||
);
|
||||
}
|
||||
|
||||
return Scaffold(
|
||||
appBar: appBar,
|
||||
body: body,
|
||||
);
|
||||
}
|
||||
|
||||
String? _getChatTitle({
|
||||
required ChatScope chatScope,
|
||||
required ChatModel chat,
|
||||
|
|
Loading…
Reference in a new issue