From e9680e5e1b0daf6910559800664e4d5e788bc2dc Mon Sep 17 00:00:00 2001 From: Shu Chen Date: Fri, 1 Dec 2023 15:46:38 +0000 Subject: [PATCH] widget fixes --- lib/widgets/message_list.dart | 81 +++++++++++++++++++---------------- 1 file changed, 44 insertions(+), 37 deletions(-) diff --git a/lib/widgets/message_list.dart b/lib/widgets/message_list.dart index 060c441786..dd8d658bda 100644 --- a/lib/widgets/message_list.dart +++ b/lib/widgets/message_list.dart @@ -773,47 +773,54 @@ class MessageWithPossibleSender extends StatelessWidget { final time = _kMessageTimestampFormat .format(DateTime.fromMillisecondsSinceEpoch(1000 * message.timestamp)); + final Widget senderWidget; + if (item.showSender) { + senderWidget = Row(mainAxisAlignment: MainAxisAlignment.spaceBetween, + crossAxisAlignment: CrossAxisAlignment.baseline, + textBaseline: TextBaseline.alphabetic, + children: [ + Flexible( + fit: FlexFit.loose, + child: Padding( + padding: const EdgeInsets.fromLTRB(16, 6, 0, 0), + child: GestureDetector( + onTap: () => Navigator.push(context, + ProfilePage.buildRoute(context: context, + userId: message.senderId)), + child: Row( + children: [ + Avatar(size: 32, borderRadius: 3, userId: message.senderId), + const SizedBox(width: 8), + Text(message.senderFullName, // TODO get from user data + style: const TextStyle( + fontFamily: 'Source Sans 3', + fontSize: 18, + height: (22 / 18), + ).merge(weightVariableTextStyle(context, wght: 600, wghtIfPlatformRequestsBold: 900)), + overflow: TextOverflow.ellipsis), + ])))), + Padding( + padding: const EdgeInsets.only(right: 16), + child: Text(time, + style: TextStyle( + color: _kMessageTimestampColor, + fontFamily: 'Source Sans 3', + fontSize: 17, + height: (22 / 17), + fontFeatures: const [FontFeature.enable('c2sc'), FontFeature.enable('smcp')], + ).merge(weightVariableTextStyle(context)))), + ]); + } else { + senderWidget = const SizedBox.shrink(); + } + return GestureDetector( behavior: HitTestBehavior.translucent, onLongPress: () => showMessageActionSheet(context: context, message: message), - // TODO clean up this layout, by less precisely imitating web child: Column( children: [ const SizedBox(height: 2), - if (item.showSender) - Row(mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Flexible( - fit: FlexFit.loose, - child: Padding( - padding: const EdgeInsets.fromLTRB(16, 6, 0, 0), - child: GestureDetector( - onTap: () => Navigator.push(context, - ProfilePage.buildRoute(context: context, - userId: message.senderId)), - child: Row( - children: [ - Avatar(size: 32, borderRadius: 3, userId: message.senderId), - const SizedBox(width: 8), - Text(message.senderFullName, // TODO get from user data - style: const TextStyle( - fontFamily: 'Source Sans 3', - fontSize: 18, - height: (22 / 18), - ).merge(weightVariableTextStyle(context, wght: 600, wghtIfPlatformRequestsBold: 900)), - overflow: TextOverflow.ellipsis), - ])))), - Padding( - padding: const EdgeInsets.only(right: 16), - child: Text(time, - style: TextStyle( - color: _kMessageTimestampColor, - fontFamily: 'Source Sans 3', - fontSize: 17, - height: (22 / 17), - fontFeatures: const [FontFeature.enable('c2sc'), FontFeature.enable('smcp')], - ).merge(weightVariableTextStyle(context)))), - ]), + senderWidget, Row( mainAxisSize: MainAxisSize.max, crossAxisAlignment: CrossAxisAlignment.end, @@ -821,8 +828,8 @@ class MessageWithPossibleSender extends StatelessWidget { const SizedBox(width: 16), Expanded( child: Padding( - padding: const EdgeInsets.symmetric(vertical: 4), - child: MessageContent(message: message, content: item.content))), + padding: const EdgeInsets.symmetric(vertical: 4), + child: MessageContent(message: message, content: item.content))), SizedBox(width: 16, child: Column( children: [