Merge branch 'develop' into feat/pinned
This commit is contained in:
@@ -104,6 +104,7 @@ class MessageWidget extends StatefulWidget {
|
||||
this.onQuotedMessageTap,
|
||||
this.customActions = const [],
|
||||
this.onAttachmentTap,
|
||||
this.usernameBuilder,
|
||||
}) : attachmentBuilders = {
|
||||
'image': (context, message, attachments) {
|
||||
final border = RoundedRectangleBorder(
|
||||
@@ -267,6 +268,9 @@ class MessageWidget extends StatefulWidget {
|
||||
/// Widget builder for building text
|
||||
final Widget Function(BuildContext, Message)? textBuilder;
|
||||
|
||||
/// Widget builder for building username
|
||||
final Widget Function(BuildContext, Message)? usernameBuilder;
|
||||
|
||||
/// Function called on long press
|
||||
final void Function(BuildContext, Message)? onMessageActions;
|
||||
|
||||
@@ -751,14 +755,7 @@ class _MessageWidgetState extends State<MessageWidget>
|
||||
child: Text(msg, style: widget.messageTheme.replies),
|
||||
),
|
||||
],
|
||||
if (showUsername)
|
||||
Text(
|
||||
widget.message.user!.name,
|
||||
maxLines: 1,
|
||||
key: usernameKey,
|
||||
style: widget.messageTheme.messageAuthor,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
if (showUsername) _buildUsername(usernameKey),
|
||||
if (showTimeStamp)
|
||||
Text(
|
||||
Jiffy(widget.message.createdAt.toLocal()).jm,
|
||||
@@ -821,6 +818,19 @@ class _MessageWidgetState extends State<MessageWidget>
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildUsername(Key usernameKey) {
|
||||
if (widget.usernameBuilder != null) {
|
||||
return widget.usernameBuilder!(context, widget.message);
|
||||
}
|
||||
return Text(
|
||||
widget.message.user!.name,
|
||||
maxLines: 1,
|
||||
key: usernameKey,
|
||||
style: widget.messageTheme.messageAuthor,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildUrlAttachment() {
|
||||
final urlAttachment = widget.message.attachments
|
||||
.firstWhere((element) => element.ogScrapeUrl != null);
|
||||
@@ -912,6 +922,7 @@ class _MessageWidgetState extends State<MessageWidget>
|
||||
builder: (context) => StreamChannel(
|
||||
channel: channel,
|
||||
child: MessageActionsModal(
|
||||
textBuilder: widget.textBuilder,
|
||||
onCopyTap: (message) =>
|
||||
Clipboard.setData(ClipboardData(text: message.text)),
|
||||
attachmentBorderRadiusGeometry:
|
||||
@@ -962,6 +973,7 @@ class _MessageWidgetState extends State<MessageWidget>
|
||||
builder: (context) => StreamChannel(
|
||||
channel: channel,
|
||||
child: MessageReactionsModal(
|
||||
textBuilder: widget.textBuilder,
|
||||
attachmentBorderRadiusGeometry:
|
||||
widget.attachmentBorderRadiusGeometry as BorderRadius?,
|
||||
showUserAvatar:
|
||||
|
||||
Reference in New Issue
Block a user