From 3b162b294dce458fe2ec96200827b5957e470062 Mon Sep 17 00:00:00 2001 From: Kurt Lourens Date: Thu, 16 Feb 2023 12:17:57 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20Fix=20the=20display=20of=20timer?= =?UTF-8?q?s=20on=20the=20Timers=20page?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../tilePresenters/timer_tile_presenter.dart | 23 +++++++++++++++++-- lib/contracts/timer/timer_item.dart | 4 ++-- lib/pages/timer/add_edit_timer_page.dart | 5 ++-- lib/pages/timer/timer_page_view.dart | 6 ++++- release_notes.txt | 1 + 5 files changed, 32 insertions(+), 7 deletions(-) diff --git a/lib/components/tilePresenters/timer_tile_presenter.dart b/lib/components/tilePresenters/timer_tile_presenter.dart index 43d751f7..03a75715 100644 --- a/lib/components/tilePresenters/timer_tile_presenter.dart +++ b/lib/components/tilePresenters/timer_tile_presenter.dart @@ -10,6 +10,25 @@ Widget timerTilePresenter( void Function(TimerItem) onEdit, void Function(String) onDelete, ) { + DateTime tweakedStart = (DateTime( + timer.startDate.year, + timer.startDate.month, + timer.startDate.day, + timer.startDate.hour, + timer.startDate.minute, + timer.startDate.second, + timer.startDate.millisecond, + )); + DateTime tweakedEnd = (DateTime( + timer.completionDate.year, + timer.completionDate.month, + timer.completionDate.day, + timer.completionDate.hour, + timer.completionDate.minute, + timer.completionDate.second, + timer.completionDate.millisecond, + )); + return genericListTileWithSubtitle( context, leadingImage: timer.icon, @@ -18,8 +37,8 @@ Widget timerTilePresenter( padding: const EdgeInsets.only(top: 4.0, bottom: 4.0), child: getProgressbarFromDates( context, - timer.startDate, - timer.completionDate, + tweakedStart, + tweakedEnd, animation: false, ), ), diff --git a/lib/contracts/timer/timer_item.dart b/lib/contracts/timer/timer_item.dart index 28e3ee7e..1cc921a4 100644 --- a/lib/contracts/timer/timer_item.dart +++ b/lib/contracts/timer/timer_item.dart @@ -59,7 +59,7 @@ class TimerItem { 'uuid': uuid, 'name': name, 'icon': icon, - 'startDate': startDate.toString(), - 'completionDate': completionDate.toString(), + 'startDate': startDate.toIso8601String(), + 'completionDate': completionDate.toIso8601String(), }; } diff --git a/lib/pages/timer/add_edit_timer_page.dart b/lib/pages/timer/add_edit_timer_page.dart index 551d51cd..0f61a525 100644 --- a/lib/pages/timer/add_edit_timer_page.dart +++ b/lib/pages/timer/add_edit_timer_page.dart @@ -30,11 +30,11 @@ class _AddEditTimerState extends State { DateTime now = DateTime.now(); _AddEditTimerState(this.timer, this.isEdit) { - int selectedIndex = UserSelectionIcons.timer.indexOf(timer.icon!); + int selectedIndex = UserSelectionIcons.timer.indexOf(timer.icon ?? ''); selectedImageIndex = selectedIndex >= 0 ? selectedIndex : 0; timer.icon = UserSelectionIcons.timer[selectedImageIndex]; - var diff = + int diff = now.millisecondsSinceEpoch - timer.startDate.millisecondsSinceEpoch; if (diff.abs() < millisecondsDrift) { // If startDate is set to now-ish @@ -131,6 +131,7 @@ class _AddEditTimerState extends State { )); widgets.add(Wrap( + spacing: 4, alignment: WrapAlignment.center, children: getQuickAccessButtons(context), )); diff --git a/lib/pages/timer/timer_page_view.dart b/lib/pages/timer/timer_page_view.dart index 2b571739..918e45a6 100644 --- a/lib/pages/timer/timer_page_view.dart +++ b/lib/pages/timer/timer_page_view.dart @@ -94,7 +94,11 @@ class _TimersPageViewState extends State { void Function()? onTap, }) => timerTilePresenter( - presenterContext, timer, onEdit, (String id) => deleteTimer(id)); + presenterContext, + timer, + onEdit, + (String id) => deleteTimer(id), + ); return SearchableList( getSearchListFutureFromList( diff --git a/release_notes.txt b/release_notes.txt index 8c43ccab..5663fb65 100644 --- a/release_notes.txt +++ b/release_notes.txt @@ -3,6 +3,7 @@ - 💫 Improve the transition after selecting/deselecting platforms | Closes #175 - ⚡️ Improve itemDetails page loading performance - 🐛 Remove focus on navigating away from searchList (commit is in AA common library) | Closes #183 +- 🐛 Fix the display of timers on the Timers page ⠀