Skip to content

Commit

Permalink
Merge pull request #150 from GetStream/feature/messageTap
Browse files Browse the repository at this point in the history
add message tap callbacks
  • Loading branch information
deven98 authored Nov 25, 2020
2 parents 3781408 + 026edeb commit 8bfb939
Show file tree
Hide file tree
Showing 5 changed files with 242 additions and 193 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 0.2.14

- Add onMessageTap callbacks

## 0.2.13+2

- Add debounce to on change messageinput listener
Expand Down
15 changes: 15 additions & 0 deletions lib/src/message_list_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,9 @@ class MessageListView extends StatefulWidget {
this.threadBuilder,
this.onThreadTap,
this.dateDividerBuilder,
this.onMessageTap,
this.onSystemMessageTap,
this.onParentMessageTap,
this.scrollPhysics = const AlwaysScrollableScrollPhysics(),
this.keyboardDismissBehavior = ScrollViewKeyboardDismissBehavior.manual,
}) : super(key: key);
Expand All @@ -120,6 +123,15 @@ class MessageListView extends StatefulWidget {
/// By default it calls [Navigator.push] using the widget built using [threadBuilder]
final ThreadTapCallback onThreadTap;

/// The function called when tapping on the message when the message is not failed
final Function(Message) onMessageTap;

/// The function called when tapping on a system message
final Function(Message) onSystemMessageTap;

/// The function called when tapping on the parent message when the message is not failed
final Function(Message) onParentMessageTap;

/// Parent message in case of a thread
final Message parentMessage;

Expand Down Expand Up @@ -412,6 +424,7 @@ class _MessageListViewState extends State<MessageListView> {
topRight: Radius.circular(16),
bottomRight: Radius.circular(16),
),
onMessageTap: widget.onParentMessageTap,
borderSide: isMyMessage ? BorderSide.none : null,
showUserAvatar: DisplayWidget.show,
messageTheme: isMyMessage
Expand All @@ -427,6 +440,7 @@ class _MessageListViewState extends State<MessageListView> {
) {
if (message.type == 'system' && message.text?.isNotEmpty == true) {
return SystemMessage(
onMessageTap: widget.onSystemMessageTap,
message: message,
);
}
Expand Down Expand Up @@ -464,6 +478,7 @@ class _MessageListViewState extends State<MessageListView> {
(index == 0 || message.status != MessageSendingStatus.SENT)
? DisplayWidget.show
: DisplayWidget.hide,
onMessageTap: widget.onMessageTap,
showTimestamp: !isNextUser || readList?.isNotEmpty == true,
showEditMessage: isMyMessage,
showDeleteMessage: isMyMessage,
Expand Down
Loading

0 comments on commit 8bfb939

Please sign in to comment.