From ff68d8f9b1cbe6369f3eb02899ca1472957d31bd Mon Sep 17 00:00:00 2001 From: Salvatore Giordano Date: Wed, 8 Apr 2020 09:48:29 +0200 Subject: [PATCH] make username next to timestamp opt-in --- lib/src/message_list_view.dart | 5 +++++ lib/src/message_widget.dart | 6 +++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/lib/src/message_list_view.dart b/lib/src/message_list_view.dart index 9d51458b..a0bf35f4 100644 --- a/lib/src/message_list_view.dart +++ b/lib/src/message_list_view.dart @@ -61,6 +61,7 @@ class MessageListView extends StatefulWidget { this.parentMessage, this.threadBuilder, this.onThreadTap, + this.showOtherMessageUsername = false, }) : super(key: key); /// Function used to build a custom message widget @@ -79,6 +80,9 @@ class MessageListView extends StatefulWidget { /// Parent message in case of a thread final Message parentMessage; + /// If true show the other users username next to the timestamp of the message + final bool showOtherMessageUsername; + @override _MessageListViewState createState() => _MessageListViewState(); } @@ -193,6 +197,7 @@ class _MessageListViewState extends State { message: message, nextMessage: nextMessage, onThreadTap: _onThreadTap, + showOtherMessageUsername: widget.showOtherMessageUsername, ); }, childCount: _messages.length + 2, diff --git a/lib/src/message_widget.dart b/lib/src/message_widget.dart index 9fe748de..10b787da 100644 --- a/lib/src/message_widget.dart +++ b/lib/src/message_widget.dart @@ -38,6 +38,7 @@ class MessageWidget extends StatefulWidget { this.onMessageActions, this.isParent = false, this.onMentionTap, + this.showOtherMessageUsername = false, }) : super(key: key); /// Function called on mention tap @@ -46,6 +47,9 @@ class MessageWidget extends StatefulWidget { /// Function called on long press final Function(BuildContext, Message) onMessageActions; + /// If true show the other users username next to the timestamp of the message + final bool showOtherMessageUsername; + /// This message final Message message; @@ -984,7 +988,7 @@ class _MessageWidgetState extends State text: TextSpan( style: _messageTheme.createdAt, children: [ - if (!_isMyMessage) + if (!_isMyMessage && widget.showOtherMessageUsername) TextSpan( text: widget.message.user.name, style: TextStyle(fontWeight: FontWeight.bold),