From 52fe392a9e5f240de93d7d88f44813c95bda30a3 Mon Sep 17 00:00:00 2001 From: Michael Manganiello Date: Wed, 8 Nov 2023 22:16:56 -0500 Subject: [PATCH] fix(mobile): display simple album date when range is single day (#4919) This change makes albums with same start and end date, to just display a single date. Currently, date range is displayed as `Nov 9 - Nov 9 2023`. With this change, just `Nov 9 2023` is displayed. No changes are made for albums where start and end dates do not match. --- .../album/views/album_viewer_page.dart | 20 +++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/mobile/lib/modules/album/views/album_viewer_page.dart b/mobile/lib/modules/album/views/album_viewer_page.dart index 830698b3ec..e474fe877e 100644 --- a/mobile/lib/modules/album/views/album_viewer_page.dart +++ b/mobile/lib/modules/album/views/album_viewer_page.dart @@ -171,11 +171,19 @@ class AlbumViewerPage extends HookConsumerWidget { return const SizedBox(); } - final String startDateText = (startDate.year == endDate.year - ? DateFormat.MMMd() - : DateFormat.yMMMd()) - .format(startDate); - final String endDateText = DateFormat.yMMMd().format(endDate); + final String dateRangeText; + if (startDate.day == endDate.day && + startDate.month == endDate.month && + startDate.year == endDate.year) { + dateRangeText = DateFormat.yMMMd().format(startDate); + } else { + final String startDateText = (startDate.year == endDate.year + ? DateFormat.MMMd() + : DateFormat.yMMMd()) + .format(startDate); + final String endDateText = DateFormat.yMMMd().format(endDate); + dateRangeText = "$startDateText - $endDateText"; + } return Padding( padding: EdgeInsets.only( @@ -183,7 +191,7 @@ class AlbumViewerPage extends HookConsumerWidget { bottom: album.shared ? 0.0 : 8.0, ), child: Text( - "$startDateText - $endDateText", + dateRangeText, style: const TextStyle( fontSize: 14, fontWeight: FontWeight.bold,