diff --git a/lib/src/channel_preview.dart b/lib/src/channel_preview.dart index 5f58e254..f7f67bae 100644 --- a/lib/src/channel_preview.dart +++ b/lib/src/channel_preview.dart @@ -155,12 +155,18 @@ class ChannelPreview extends StatelessWidget { String stringDate; final now = DateTime.now(); - if (now.year != lastMessageAt.year || - now.month != lastMessageAt.month || - now.day != lastMessageAt.day) { - stringDate = Jiffy(lastMessageAt.toLocal()).format('dd/MM/yyyy'); - } else { + var startOfDay = DateTime(now.year, now.month, now.day); + + if (lastMessageAt.millisecondsSinceEpoch >= + startOfDay.millisecondsSinceEpoch) { stringDate = Jiffy(lastMessageAt.toLocal()).format('HH:mm'); + } else if (lastMessageAt.millisecondsSinceEpoch >= + startOfDay.subtract(Duration(days: 1)).millisecondsSinceEpoch) { + stringDate = 'Yesterday'; + } else if (startOfDay.difference(lastMessageAt).inDays < 7) { + stringDate = Jiffy(lastMessageAt.toLocal()).EEEE; + } else { + stringDate = Jiffy(lastMessageAt.toLocal()).format('dd/MM/yyyy'); } return Text( diff --git a/lib/src/channel_unread_indicator.dart b/lib/src/channel_unread_indicator.dart index 8080b1e9..c15db13a 100644 --- a/lib/src/channel_unread_indicator.dart +++ b/lib/src/channel_unread_indicator.dart @@ -19,6 +19,7 @@ class ChannelUnreadIndicator extends StatelessWidget { if (!snapshot.hasData || snapshot.data == 0) { return SizedBox(); } + return Material( borderRadius: BorderRadius.circular(8), color: StreamChatTheme.of(context) @@ -33,7 +34,7 @@ class ChannelUnreadIndicator extends StatelessWidget { ), child: Center( child: Text( - '${snapshot.data}', + '${snapshot.data > 99 ? '99+' : snapshot.data}', style: TextStyle( fontSize: 11, color: Colors.white,