From 4957619707cee2b326d4f4a7d7fa8b8a68f83bd8 Mon Sep 17 00:00:00 2001 From: Salvatore Giordano Date: Tue, 21 Apr 2020 10:24:15 +0200 Subject: [PATCH] fix message divider for week and years --- lib/src/message_list_view.dart | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/lib/src/message_list_view.dart b/lib/src/message_list_view.dart index 2476c69e..468bf054 100644 --- a/lib/src/message_list_view.dart +++ b/lib/src/message_list_view.dart @@ -241,8 +241,18 @@ class _MessageListViewState extends State { } else if (Jiffy(createdAt) .isSame(now.subtract(Duration(days: 1)), Units.DAY)) { dayInfo = 'YESTERDAY'; - } else { + } else if (Jiffy(createdAt).isAfter( + now.subtract(Duration(days: 7)), + Units.DAY, + )) { dayInfo = createdAt.format('EEEE').toUpperCase(); + } else if (Jiffy(createdAt).isAfter( + Jiffy(now).subtract(years: 1), + Units.DAY, + )) { + dayInfo = createdAt.format('dd/MM').toUpperCase(); + } else { + dayInfo = createdAt.format('dd/MM/yyyy').toUpperCase(); } return Column(