feat: add chatScreenBuilder to use instead of baseScreenBuilder on the ChatDetailScreen

This commit is contained in:
Freek van de Ven 2025-02-19 15:40:24 +01:00 committed by FlutterJoey
parent 6a63429efd
commit 62f04e2d9b
3 changed files with 36 additions and 10 deletions

View file

@ -18,6 +18,7 @@
- Added sender and chatId to uploadImage in the ChatRepositoryInterface - 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?> - 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 - 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 ## 4.0.0
- Move to the new user story architecture - Move to the new user story architecture

View file

@ -13,6 +13,7 @@ class ChatBuilders {
/// The chat builders constructor /// The chat builders constructor
const ChatBuilders({ const ChatBuilders({
this.baseScreenBuilder, this.baseScreenBuilder,
this.chatScreenBuilder,
this.messageInputBuilder, this.messageInputBuilder,
this.chatRowContainerBuilder, this.chatRowContainerBuilder,
this.groupAvatarBuilder, this.groupAvatarBuilder,
@ -45,6 +46,11 @@ class ChatBuilders {
/// ``` /// ```
final BaseScreenBuilder? baseScreenBuilder; 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 /// The message input builder
final TextInputBuilder? messageInputBuilder; final TextInputBuilder? messageInputBuilder;
@ -133,6 +139,15 @@ typedef BaseScreenBuilder = Widget Function(
Widget body, Widget body,
); );
/// The chat screen builder
typedef ChatScreenBuilder = Widget Function(
BuildContext context,
ChatModel? chat,
PreferredSizeWidget appBar,
String? title,
Widget body,
);
/// The container builder /// The container builder
typedef ContainerBuilder = Widget Function( typedef ContainerBuilder = Widget Function(
BuildContext context, BuildContext context,

View file

@ -108,19 +108,29 @@ class ChatDetailScreen extends HookWidget {
onReadChat: onReadChat, onReadChat: onReadChat,
); );
if (options.builders.baseScreenBuilder == null) { if (options.builders.chatScreenBuilder != null) {
return Scaffold( return options.builders.chatScreenBuilder!.call(
appBar: appBar, context,
body: body, chat,
appBar,
chatTitle.value,
body,
); );
} }
return options.builders.baseScreenBuilder!.call( if (options.builders.baseScreenBuilder != null) {
context, return options.builders.baseScreenBuilder!.call(
mapScreenType, context,
appBar, mapScreenType,
chatTitle.value, appBar,
body, chatTitle.value,
body,
);
}
return Scaffold(
appBar: appBar,
body: body,
); );
} }