Skip to content

Commit 4537a5a

Browse files
committed
msglist: Move message sender widget to local variable
1 parent 6a5c6ad commit 4537a5a

File tree

1 file changed

+32
-23
lines changed

1 file changed

+32
-23
lines changed

lib/widgets/message_list.dart

Lines changed: 32 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -783,6 +783,37 @@ class MessageWithPossibleSender extends StatelessWidget {
783783
final time = _kMessageTimestampFormat
784784
.format(DateTime.fromMillisecondsSinceEpoch(1000 * message.timestamp));
785785

786+
final Widget senderWidget;
787+
if (item.showSender) {
788+
senderWidget = Column(
789+
children: [
790+
const SizedBox(height: 3),
791+
GestureDetector(
792+
onTap: () => Navigator.push(context,
793+
ProfilePage.buildRoute(context: context,
794+
userId: message.senderId)),
795+
child: Row(
796+
children: [
797+
Avatar(size: 32, borderRadius: 3, userId: message.senderId),
798+
const SizedBox(width: 8),
799+
Flexible(
800+
child: Text(message.senderFullName, // TODO get from user data
801+
style: const TextStyle(
802+
fontFamily: 'Source Sans 3',
803+
fontSize: 18,
804+
height: (22 / 18),
805+
).merge(weightVariableTextStyle(context, wght: 600,
806+
wghtIfPlatformRequestsBold: 900)),
807+
overflow: TextOverflow.ellipsis),
808+
),
809+
])),
810+
const SizedBox(height: 4),
811+
],
812+
);
813+
} else {
814+
senderWidget = const SizedBox.shrink();
815+
}
816+
786817
return GestureDetector(
787818
behavior: HitTestBehavior.translucent,
788819
onLongPress: () => showMessageActionSheet(context: context, message: message),
@@ -794,29 +825,7 @@ class MessageWithPossibleSender extends StatelessWidget {
794825
child: Column(
795826
crossAxisAlignment: CrossAxisAlignment.stretch,
796827
children: [
797-
if (item.showSender) ...[
798-
const SizedBox(height: 3),
799-
GestureDetector(
800-
onTap: () => Navigator.push(context,
801-
ProfilePage.buildRoute(context: context,
802-
userId: message.senderId)),
803-
child: Row(
804-
children: [
805-
Avatar(size: 32, borderRadius: 3, userId: message.senderId),
806-
const SizedBox(width: 8),
807-
Flexible(
808-
child: Text(message.senderFullName, // TODO get from user data
809-
style: const TextStyle(
810-
fontFamily: 'Source Sans 3',
811-
fontSize: 18,
812-
height: (22 / 18),
813-
).merge(weightVariableTextStyle(context, wght: 600,
814-
wghtIfPlatformRequestsBold: 900)),
815-
overflow: TextOverflow.ellipsis),
816-
),
817-
])),
818-
const SizedBox(height: 4),
819-
],
828+
senderWidget,
820829
MessageContent(message: message, content: item.content),
821830
if ((message.reactions?.total ?? 0) > 0)
822831
ReactionChipsList(messageId: message.id, reactions: message.reactions!)

0 commit comments

Comments
 (0)