From c931e5142d57ab1b7331e4e7a6d1a5804af0d152 Mon Sep 17 00:00:00 2001 From: Sahil Kumar Date: Fri, 8 Jan 2021 17:38:03 +0530 Subject: [PATCH] [DateDivider] Fix text case and add 1px vertical padding Signed-off-by: Sahil Kumar --- lib/src/date_divider.dart | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/lib/src/date_divider.dart b/lib/src/date_divider.dart index 12070e51..c7cfe296 100644 --- a/lib/src/date_divider.dart +++ b/lib/src/date_divider.dart @@ -5,10 +5,12 @@ import 'package:stream_chat_flutter/src/stream_chat_theme.dart'; /// It shows a date divider depending on the date difference class DateDivider extends StatelessWidget { final DateTime dateTime; + final bool uppercase; const DateDivider({ Key key, @required this.dateTime, + this.uppercase = false, }) : super(key: key); @override @@ -18,38 +20,37 @@ class DateDivider extends StatelessWidget { String dayInfo; if (Jiffy(createdAt).isSame(now, Units.DAY)) { - dayInfo = 'TODAY'; + dayInfo = 'Today'; } else if (Jiffy(createdAt) .isSame(now.subtract(Duration(days: 1)), Units.DAY)) { - dayInfo = 'YESTERDAY'; + dayInfo = 'Yesterday'; } else if (Jiffy(createdAt).isAfter( now.subtract(Duration(days: 7)), Units.DAY, )) { - dayInfo = createdAt.format('EEEE').toUpperCase(); + dayInfo = createdAt.format('EEEE'); } else if (Jiffy(createdAt).isAfter( Jiffy(now).subtract(years: 1), Units.DAY, )) { - dayInfo = createdAt.format('MMMM d').toUpperCase(); + dayInfo = createdAt.format('MMMM d'); } else { - dayInfo = createdAt.format('MMMM d').toUpperCase(); + dayInfo = createdAt.format('MMMM d'); } + if (uppercase) dayInfo = dayInfo.toUpperCase(); + return Center( child: Container( - padding: const EdgeInsets.symmetric(horizontal: 8), + padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 1), decoration: BoxDecoration( - color: StreamChatTheme.of(context).colorTheme.black.withOpacity(0.5), - borderRadius: BorderRadius.circular( - 8, - ), + color: StreamChatTheme.of(context).colorTheme.overlayDark, + borderRadius: BorderRadius.circular(8), ), child: Text( dayInfo, - style: StreamChatTheme.of(context).textTheme.footnoteBold.copyWith( + style: StreamChatTheme.of(context).textTheme.footnote.copyWith( color: StreamChatTheme.of(context).colorTheme.white, - fontWeight: FontWeight.bold, ), ), ),