Skip to content

Commit c4c33c6

Browse files
committed
msglist: Move message sender widget to local variable
1 parent 25f04ca commit c4c33c6

File tree

1 file changed

+33
-24
lines changed

1 file changed

+33
-24
lines changed

lib/widgets/message_list.dart

Lines changed: 33 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -784,6 +784,38 @@ class MessageWithPossibleSender extends StatelessWidget {
784784
final time = _kMessageTimestampFormat
785785
.format(DateTime.fromMillisecondsSinceEpoch(1000 * message.timestamp));
786786

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

0 commit comments

Comments
 (0)