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
parent e5c47c2f61
commit 7b3ddc5118
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 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

View file

@ -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,

View file

@ -108,19 +108,29 @@ 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,
);
}
return options.builders.baseScreenBuilder!.call(
context,
mapScreenType,
appBar,
chatTitle.value,
body,
if (options.builders.baseScreenBuilder != null) {
return options.builders.baseScreenBuilder!.call(
context,
mapScreenType,
appBar,
chatTitle.value,
body,
);
}
return Scaffold(
appBar: appBar,
body: body,
);
}