Skip to content

Commit

Permalink
fix(ui): added calculation for reaction picker tail (#1953)
Browse files Browse the repository at this point in the history
* added calculation for reaction picker tail

* added changelog entry

* added docs

* added docs

* lint and formatting
  • Loading branch information
deven98 authored Jun 17, 2024
1 parent a7f6652 commit 0089810
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 3 deletions.
8 changes: 6 additions & 2 deletions packages/stream_chat_flutter/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,17 @@

✅ Added

- Copying a message now replaces the User IDs with user names.
- Exported thumbnail widgets from the package.
- Added `customAttachmentBuilders` parameter for `StreamAttachmentWidgetBuilder.defaultBuilders`.
- `attachmentBuilders` parameter for `StreamMessageWidget` now only expects custom builders.
- Added `StreamMediaAttachmentBuilder` widget to show media attachments in a message.

🐞 Fixed

- Added export for `message_widget_content_components.dart` to allow for easier customization of message content components.
- Fixed error when channel image is not set.
- Fixes reaction picker tail showing up unexpectedly.
- Copying a message now replaces the User IDs with user names.
- Exported thumbnail widgets from the package.
- Extends predicates for sending and clearing messages to mobile.

## 7.2.1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ class StreamMessageWidget extends StatefulWidget {
this.onReactionsTap,
this.onReactionsHover,
this.showReactionPicker = true,
this.showReactionTail,
this.showUserAvatar = DisplayWidget.show,
this.showSendingIndicator = true,
this.showThreadReplyIndicator = false,
Expand Down Expand Up @@ -246,6 +247,12 @@ class StreamMessageWidget extends StatefulWidget {
/// {@endtemplate}
final bool showReactionPicker;

/// {@template showReactionPickerTail}
/// Whether or not to show the reaction picker tail.
/// This is calculated internally in most cases and does not need to be set.
/// {@endtemplate}
final bool? showReactionTail;

/// {@template onShowMessage}
/// Callback when show message is tapped
/// {@endtemplate}
Expand Down Expand Up @@ -403,6 +410,7 @@ class StreamMessageWidget extends StatefulWidget {
void Function(String)? onLinkTap,
bool? showReactionBrowser,
bool? showReactionPicker,
bool? showReactionTail,
List<Read>? readList,
ShowMessageCallback? onShowMessage,
bool? showUsername,
Expand Down Expand Up @@ -465,6 +473,7 @@ class StreamMessageWidget extends StatefulWidget {
onUserAvatarTap: onUserAvatarTap ?? this.onUserAvatarTap,
onLinkTap: onLinkTap ?? this.onLinkTap,
showReactionPicker: showReactionPicker ?? this.showReactionPicker,
showReactionTail: showReactionTail ?? this.showReactionTail,
onShowMessage: onShowMessage ?? this.onShowMessage,
showUsername: showUsername ?? this.showUsername,
showTimestamp: showTimestamp ?? this.showTimestamp,
Expand Down Expand Up @@ -713,7 +722,9 @@ class _StreamMessageWidgetState extends State<StreamMessageWidget>
messageWidget: widget,
showBottomRow: showBottomRow,
showPinHighlight: widget.showPinHighlight,
showReactionPickerTail: widget.showReactionPicker,
showReactionPickerTail: calculateReactionTailEnabled(
ReactionTailType.list,
),
showReactions: showReactions,
onReactionsTap: () {
widget.onReactionsTap != null
Expand Down Expand Up @@ -958,6 +969,9 @@ class _StreamMessageWidgetState extends State<StreamMessageWidget>
: widget.message.text,
),
showReactions: false,
showReactionTail: calculateReactionTailEnabled(
ReactionTailType.reactions,
),
showUsername: false,
showTimestamp: false,
translateUserAvatar: false,
Expand Down Expand Up @@ -1011,6 +1025,9 @@ class _StreamMessageWidgetState extends State<StreamMessageWidget>
: widget.message.text,
),
showReactions: false,
showReactionTail: calculateReactionTailEnabled(
ReactionTailType.messageActions,
),
showUsername: false,
showTimestamp: false,
translateUserAvatar: false,
Expand Down Expand Up @@ -1063,4 +1080,31 @@ class _StreamMessageWidgetState extends State<StreamMessageWidget>
},
);
}

/// Calculates if the reaction picker tail should be enabled.
bool calculateReactionTailEnabled(ReactionTailType type) {
if (widget.showReactionTail != null) return widget.showReactionTail!;

switch (type) {
case ReactionTailType.list:
return false;
case ReactionTailType.messageActions:
return widget.showReactionPicker;
case ReactionTailType.reactions:
return widget.showReactionPicker;
}
}
}

/// Enum for declaring the location of the message for which the reaction picker
/// is to be enabled.
enum ReactionTailType {
/// Message is in the [StreamMessageListView]
list,

/// Message is in the [MessageActionsModal]
messageActions,

/// Message is in the message reactions modal
reactions,
}

0 comments on commit 0089810

Please sign in to comment.