Skip to content

Commit

Permalink
feat(ui): add showFailedIndicator parameter into StreamMessageWidget
Browse files Browse the repository at this point in the history
  • Loading branch information
Bravo committed Jul 3, 2024
1 parent f0b162f commit 97ad4c5
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
4 changes: 4 additions & 0 deletions packages/stream_chat_flutter/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
## Upcoming

✅ Added

- Added `showFailedIndicator` parameter for `StreamMessageWidget` to toggle displaying the failed message icon.

🐞 Fixed

- Fixed null errors in web from markdown.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ class StreamMessageWidget extends StatefulWidget {
this.imageAttachmentThumbnailResizeType = 'clip',
this.imageAttachmentThumbnailCropType = 'center',
this.attachmentActionsModalBuilder,
this.showFailedIndicator = true,
});

/// {@template onMentionTap}
Expand Down Expand Up @@ -374,6 +375,11 @@ class StreamMessageWidget extends StatefulWidget {
final String /*center|top|bottom|left|right*/
imageAttachmentThumbnailCropType;

/// {@template showFailedIndicator}
/// Show the failed message indicator
/// {@endtemplate}
final bool showFailedIndicator;

/// {@template copyWith}
/// Creates a copy of [StreamMessageWidget] with specified attributes
/// overridden.
Expand Down Expand Up @@ -628,6 +634,8 @@ class _StreamMessageWidgetState extends State<StreamMessageWidget>

bool get shouldShowDeleteAction => widget.showDeleteMessage || isDeleteFailed;

bool get showFailedIndicator => widget.showFailedIndicator;

@override
bool get wantKeepAlive => widget.message.attachments.isNotEmpty;

Expand Down Expand Up @@ -747,6 +755,7 @@ class _StreamMessageWidgetState extends State<StreamMessageWidget>
widget.bottomRowBuilderWithDefaultWidget,
onUserAvatarTap: widget.onUserAvatarTap,
userAvatarBuilder: widget.userAvatarBuilder,
showFailedIndicator: showFailedIndicator,
);
}),
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ class MessageWidgetContent extends StatelessWidget {
required this.showTimeStamp,
required this.showUsername,
required this.messageWidget,
required this.showFailedIndicator,
this.onUserAvatarTap,
this.borderRadiusGeometry,
this.borderSide,
Expand Down Expand Up @@ -216,6 +217,9 @@ class MessageWidgetContent extends StatelessWidget {
/// {@macro userAvatarBuilder}
final Widget Function(BuildContext, User)? userAvatarBuilder;

/// {@macro showFailedIndicator}
final bool showFailedIndicator;

@override
Widget build(BuildContext context) {
return Column(
Expand Down Expand Up @@ -410,7 +414,7 @@ class MessageWidgetContent extends StatelessWidget {
],
),
),
if (isFailedState)
if (isFailedState && showFailedIndicator)
Positioned(
right: reverse ? 0 : null,
left: reverse ? null : 0,
Expand Down

0 comments on commit 97ad4c5

Please sign in to comment.