From 52ab1d0d10451881d18c1e2b5aea27629dfbabf0 Mon Sep 17 00:00:00 2001 From: LittleSheep Date: Wed, 26 Feb 2025 00:29:35 +0800 Subject: [PATCH] :bug: Fix chat last message displaying inconsistences --- lib/screens/chat.dart | 35 +++++++++++++++++++++++++++++++---- 1 file changed, 31 insertions(+), 4 deletions(-) diff --git a/lib/screens/chat.dart b/lib/screens/chat.dart index f062da4..b4ade10 100644 --- a/lib/screens/chat.dart +++ b/lib/screens/chat.dart @@ -290,10 +290,34 @@ class _ChatScreenState extends State { ], ), subtitle: lastMessage != null - ? Text( - '${ud.getAccountFromCache(lastMessage.sender.accountId)?.nick}: ${lastMessage.body['text'] ?? 'Unable preview'}', - maxLines: 1, - overflow: TextOverflow.ellipsis, + ? Row( + children: [ + Expanded( + child: Text( + lastMessage.body['text'] ?? + 'Unable preview', + maxLines: 1, + overflow: TextOverflow.ellipsis, + ), + ), + const Gap(4), + Text( + DateFormat( + lastMessage.createdAt.toLocal().day == + DateTime.now().day + ? 'HH:mm' + : lastMessage.createdAt + .toLocal() + .year == + DateTime.now().year + ? 'MM/dd' + : 'yy/MM/dd', + ).format(lastMessage.createdAt.toLocal()), + style: GoogleFonts.robotoMono( + fontSize: 12, + ), + ), + ], ) : Text( channel.description, @@ -336,6 +360,8 @@ class _ChatScreenState extends State { 'unknown'.tr()), backgroundColor: Theme.of(context).colorScheme.primary, + textColor: + Theme.of(context).colorScheme.onPrimary, ), const Gap(6), Expanded( @@ -346,6 +372,7 @@ class _ChatScreenState extends State { overflow: TextOverflow.ellipsis, ), ), + const Gap(4), Text( DateFormat( lastMessage.createdAt.toLocal().day ==