Skip to content

Commit

Permalink
Merge pull request #506 from GetStream/feat/userAvatarBuilder
Browse files Browse the repository at this point in the history
feat: userAvatarBuilder in MessageWiget
  • Loading branch information
imtoori authored Jun 29, 2021
2 parents 2d11044 + 5912edc commit 3885f0e
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions packages/stream_chat_flutter/lib/src/message_widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ class MessageWidget extends StatefulWidget {
this.onLinkTap,
this.onMessageActions,
this.onShowMessage,
this.userAvatarBuilder,
this.editMessageInputBuilder,
this.textBuilder,
this.onReturnAction,
Expand Down Expand Up @@ -274,6 +275,9 @@ class MessageWidget extends StatefulWidget {
/// Function called on long press
final void Function(BuildContext, Message)? onMessageActions;

/// Widget builder for building user avatar
final Widget Function(BuildContext, User)? userAvatarBuilder;

/// The message
final Message message;

Expand Down Expand Up @@ -448,6 +452,7 @@ class MessageWidget extends StatefulWidget {
void Function(Message)? onMessageTap,
List<MessageAction>? customActions,
void Function(Message message, Attachment attachment)? onAttachmentTap,
Widget Function(BuildContext, User)? userAvatarBuilder,
}) =>
MessageWidget(
key: key ?? this.key,
Expand Down Expand Up @@ -506,6 +511,7 @@ class MessageWidget extends StatefulWidget {
onMessageTap: onMessageTap ?? this.onMessageTap,
customActions: customActions ?? this.customActions,
onAttachmentTap: onAttachmentTap ?? this.onAttachmentTap,
userAvatarBuilder: userAvatarBuilder ?? this.userAvatarBuilder,
);

@override
Expand Down Expand Up @@ -1231,13 +1237,14 @@ class _MessageWidgetState extends State<MessageWidget>
2
: 0,
),
child: UserAvatar(
user: widget.message.user!,
onTap: widget.onUserAvatarTap,
constraints: widget.messageTheme.avatarTheme!.constraints,
borderRadius: widget.messageTheme.avatarTheme!.borderRadius,
showOnlineStatus: false,
),
child: widget.userAvatarBuilder?.call(context, widget.message.user!) ??
UserAvatar(
user: widget.message.user!,
onTap: widget.onUserAvatarTap,
constraints: widget.messageTheme.avatarTheme!.constraints,
borderRadius: widget.messageTheme.avatarTheme!.borderRadius,
showOnlineStatus: false,
),
);

Widget _buildTextBubble() {
Expand Down

0 comments on commit 3885f0e

Please sign in to comment.