diff --git a/lib/pages/chat_list/chat_list_item.dart b/lib/pages/chat_list/chat_list_item.dart index 76c75e83b..49978e764 100644 --- a/lib/pages/chat_list/chat_list_item.dart +++ b/lib/pages/chat_list/chat_list_item.dart @@ -239,8 +239,11 @@ class ChatListItem extends StatelessWidget { maxLines: 1, softWrap: false, ) - // #Pangea - : FutureBuilder( + : FutureBuilder( + key: ValueKey( + '${lastEvent?.eventId}_${lastEvent?.type}', + ), + // #Pangea future: room.lastEvent != null ? GetChatListItemSubtitle().getSubtitle( L10n.of(context)!, @@ -248,42 +251,49 @@ class ChatListItem extends StatelessWidget { MatrixState.pangeaController, ) : Future.value(L10n.of(context)!.emptyChat), - builder: (context, snapshot) { - // Pangea# - return Text( - room.membership == Membership.invite - ? isDirectChat - ? L10n.of(context)!.invitePrivateChat - : L10n.of(context)!.inviteGroupChat - // #Pangea - : snapshot.data ?? - // Pangea# - room.lastEvent - ?.calcLocalizedBodyFallback( - MatrixLocals(L10n.of(context)!), - hideReply: true, - hideEdit: true, - plaintextBody: true, - removeMarkdown: true, - withSenderNamePrefix: !isDirectChat || - directChatMatrixId != - room.lastEvent?.senderId, - ) ?? - L10n.of(context)!.emptyChat, - softWrap: false, - maxLines: 1, - overflow: TextOverflow.ellipsis, - style: TextStyle( - fontWeight: unread || room.hasNewMessages - ? FontWeight.bold - : null, - color: theme.colorScheme.onSurfaceVariant, - decoration: room.lastEvent?.redacted == true - ? TextDecoration.lineThrough - : null, - ), - ); - }, + // future: needLastEventSender + // ? lastEvent.calcLocalizedBody( + // MatrixLocals(L10n.of(context)!), + // hideReply: true, + // hideEdit: true, + // plaintextBody: true, + // removeMarkdown: true, + // withSenderNamePrefix: !isDirectChat || + // directChatMatrixId != + // room.lastEvent?.senderId, + // ) + // : null, + // Pangea# + initialData: lastEvent?.calcLocalizedBodyFallback( + MatrixLocals(L10n.of(context)!), + hideReply: true, + hideEdit: true, + plaintextBody: true, + removeMarkdown: true, + withSenderNamePrefix: !isDirectChat || + directChatMatrixId != + room.lastEvent?.senderId, + ), + builder: (context, snapshot) => Text( + room.membership == Membership.invite + ? isDirectChat + ? L10n.of(context)!.invitePrivateChat + : L10n.of(context)!.inviteGroupChat + : snapshot.data ?? + L10n.of(context)!.emptyChat, + softWrap: false, + maxLines: 1, + overflow: TextOverflow.ellipsis, + style: TextStyle( + fontWeight: unread || room.hasNewMessages + ? FontWeight.bold + : null, + color: theme.colorScheme.onSurfaceVariant, + decoration: room.lastEvent?.redacted == true + ? TextDecoration.lineThrough + : null, + ), + ), ), ), const SizedBox(width: 8), diff --git a/lib/utils/date_time_extension.dart b/lib/utils/date_time_extension.dart index 121eaf72e..f546f9a5a 100644 --- a/lib/utils/date_time_extension.dart +++ b/lib/utils/date_time_extension.dart @@ -34,14 +34,8 @@ extension DateTimeExtension on DateTime { } /// Returns a simple time String. - /// TODO: Add localization - String localizedTimeOfDay(BuildContext context) { - if (MediaQuery.of(context).alwaysUse24HourFormat) { - return '${_z(hour)}:${_z(minute)}'; - } else { - return '${_z(hour % 12 == 0 ? 12 : hour % 12)}:${_z(minute)} ${hour > 11 ? "pm" : "am"}'; - } - } + String localizedTimeOfDay(BuildContext context) => + DateFormat.Hm(L10n.of(context)!.localeName).format(this); /// Returns [localizedTimeOfDay()] if the ChatTime is today, the name of the week /// day if the ChatTime is this week and a date string else. @@ -91,6 +85,4 @@ extension DateTimeExtension on DateTime { localizedTimeOfDay(context), ); } - - static String _z(int i) => i < 10 ? '0${i.toString()}' : i.toString(); } diff --git a/pubspec.yaml b/pubspec.yaml index 95ea003b3..6cd4cfe34 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -70,10 +70,13 @@ dependencies: keyboard_shortcuts: ^0.1.4 latlong2: ^0.9.1 linkify: ^5.0.0 + # #Pangea matrix: git: url: https://github.com/pangeachat/matrix-dart-sdk.git # repo ref: main # branch + # matrix: ^0.29.13 + # Pangea# native_imaging: ^0.1.1 package_info_plus: ^6.0.0 pasteboard: ^0.2.0