Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add custom data and configs to be used in custom widgets. #199

Open
wants to merge 11 commits into
base: main
Choose a base branch
from
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,12 @@ For web demo visit [Chat View Example](https://simformsolutionspvtltd.github.io/
}
```

- Add MessageConfiguration, isMessageBySender, highlightImage, highlightScale to customMessageBuilder wherever you use it.
ex:
```dart

```

## Installing

1. Add dependency to `pubspec.yaml`
Expand Down
4 changes: 4 additions & 0 deletions lib/src/models/message.dart
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ class Message {
/// Provides max duration for recorded voice message.
Duration? voiceMessageDuration;

/// Custom Data mainly be used in in custom types with customMessageBuilder.
Map<String, dynamic> customData;

Message({
this.id = '',
required this.message,
Expand All @@ -64,6 +67,7 @@ class Message {
this.messageType = MessageType.text,
this.voiceMessageDuration,
MessageStatus status = MessageStatus.pending,
this.customData = const <String, dynamic>{},
}) : reaction = reaction ?? Reaction(reactions: [], reactedUserIds: []),
key = GlobalKey(),
_status = ValueNotifier(status),
Expand Down
2 changes: 1 addition & 1 deletion lib/src/models/message_configuration.dart
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class MessageConfiguration {
final EmojiMessageConfiguration? emojiMessageConfig;

/// Provides builder to create view for custom messages.
final Widget Function(Message)? customMessageBuilder;
final Widget Function(Message, MessageConfiguration?, bool, bool, double)? customMessageBuilder;

/// Configurations for voice message bubble
final VoiceMessageConfiguration? voiceMessageConfig;
Expand Down
2 changes: 1 addition & 1 deletion lib/src/widgets/message_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ class _MessageViewState extends State<MessageView>
);
} else if (widget.message.messageType.isCustom &&
messageConfig?.customMessageBuilder != null) {
return messageConfig?.customMessageBuilder!(widget.message);
return messageConfig?.customMessageBuilder!(widget.message, messageConfig, widget.isMessageBySender, widget.shouldHighlight, widget.highlightScale);
}
}()) ??
const SizedBox(),
Expand Down