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(ui): add showFailedIndicator parameter into StreamMessageWidget #1976

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions packages/stream_chat_flutter/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@

## 8.0.0

✅ 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 @@ -28,6 +28,7 @@ class MessageCard extends StatefulWidget {
required this.attachmentActionsModalBuilder,
required this.textPadding,
required this.reverse,
required this.showFailedIndicator,
this.shape,
this.borderSide,
this.borderRadiusGeometry,
Expand Down Expand Up @@ -116,6 +117,9 @@ class MessageCard extends StatefulWidget {
/// {@macro reverse}
final bool reverse;

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

@override
State<MessageCard> createState() => _MessageCardState();
}
Expand Down Expand Up @@ -161,8 +165,9 @@ class _MessageCardState extends State<MessageCard> {
return Container(
constraints: const BoxConstraints().copyWith(maxWidth: widthLimit),
margin: EdgeInsets.symmetric(
horizontal: (widget.isFailedState ? 15.0 : 0.0) +
(widget.showUserAvatar == DisplayWidget.gone ? 0 : 4.0),
horizontal:
(widget.isFailedState && widget.showFailedIndicator ? 15.0 : 0.0) +
(widget.showUserAvatar == DisplayWidget.gone ? 0 : 4.0),
),
clipBehavior: Clip.hardEdge,
decoration: ShapeDecoration(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ class StreamMessageWidget extends StatefulWidget {
this.imageAttachmentThumbnailResizeType = 'clip',
this.imageAttachmentThumbnailCropType = 'center',
this.attachmentActionsModalBuilder,
this.showFailedIndicator = true,
});

/// {@template onMentionTap}
Expand Down Expand Up @@ -380,6 +381,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 @@ -445,6 +451,7 @@ class StreamMessageWidget extends StatefulWidget {
String? imageAttachmentThumbnailResizeType,
String? imageAttachmentThumbnailCropType,
AttachmentActionsBuilder? attachmentActionsModalBuilder,
bool? showFailedIndicator
}) {
return StreamMessageWidget(
key: key ?? this.key,
Expand Down Expand Up @@ -514,6 +521,7 @@ class StreamMessageWidget extends StatefulWidget {
this.imageAttachmentThumbnailCropType,
attachmentActionsModalBuilder:
attachmentActionsModalBuilder ?? this.attachmentActionsModalBuilder,
showFailedIndicator: showFailedIndicator ?? this.showFailedIndicator,
);
}

Expand Down Expand Up @@ -641,6 +649,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 @@ -762,6 +772,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 @@ -64,6 +64,7 @@ class MessageWidgetContent extends StatelessWidget {
required this.showEditedLabel,
required this.messageWidget,
required this.onThreadTap,
required this.showFailedIndicator,
this.onUserAvatarTap,
this.borderRadiusGeometry,
this.borderSide,
Expand Down Expand Up @@ -224,6 +225,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 @@ -328,6 +332,8 @@ class MessageWidgetContent extends StatelessWidget {
: MessageCard(
message: message,
isFailedState: isFailedState,
showFailedIndicator:
showFailedIndicator,
showUserAvatar: showUserAvatar,
messageTheme: messageTheme,
hasQuotedMessage: hasQuotedMessage,
Expand Down Expand Up @@ -418,7 +424,7 @@ class MessageWidgetContent extends StatelessWidget {
],
),
),
if (isFailedState)
if (isFailedState && showFailedIndicator)
Positioned(
right: reverse ? 0 : null,
left: reverse ? null : 0,
Expand Down
Loading