From e0208e2575e1d7ac969c4d709da8ee5ba96fe076 Mon Sep 17 00:00:00 2001 From: Jens Pfahl Date: Sun, 10 Mar 2024 19:48:12 +0100 Subject: [PATCH 1/4] Fix progress bar dark red color and movefixed schedules forward from checkmark action --- lib/model/ScheduledTask.dart | 11 ++++------- lib/ui/components/ScheduledTaskWidget.dart | 23 +++++++++++++++++----- pubspec.yaml | 2 +- 3 files changed, 23 insertions(+), 13 deletions(-) diff --git a/lib/model/ScheduledTask.dart b/lib/model/ScheduledTask.dart index 8641be6..ea4718a 100644 --- a/lib/model/ScheduledTask.dart +++ b/lib/model/ScheduledTask.dart @@ -101,12 +101,9 @@ class ScheduledTask extends TitleAndDescription implements Comparable { bool isDue() => !isOneTimeCompleted && (isDueNow() || isNextScheduleOverdue(false)); - bool isNextScheduleReached() { - var duration = getMissingDuration(); - if (duration != null) { - return _getRoundedDurationValue(duration) == 0; - } - return false; + bool isNextScheduleAlmostReached() { + return (getNextRepetitionIndicatorValue()??0.0) > 0.9; + } bool isDueNow() => getNextSchedule() != null && truncToMinutes(getNextSchedule()!) == truncToMinutes(DateTime.now()); @@ -125,7 +122,7 @@ class ScheduledTask extends TitleAndDescription implements Comparable { } /* - * Returns the duration in the next bigger unit then the repitition steps are defined. + * Returns the duration in the next bigger unit then the repetition steps are defined. */ int _getRoundedDurationValue(Duration duration) { if (schedule.repetitionStep == RepetitionStep.DAILY diff --git a/lib/ui/components/ScheduledTaskWidget.dart b/lib/ui/components/ScheduledTaskWidget.dart index 2a6c1fb..ab71ec1 100644 --- a/lib/ui/components/ScheduledTaskWidget.dart +++ b/lib/ui/components/ScheduledTaskWidget.dart @@ -98,7 +98,20 @@ class ScheduledTaskWidget extends StatefulWidget { .currentState ?.addTaskEvent(insertedTaskEvent, justSetState: true); - scheduledTask.executeSchedule(insertedTaskEvent); + if (scheduledTask.schedule.repetitionMode == RepetitionMode.FIXED) { + + // move schedule forward if check-marked directly + var newNextDueDate = scheduledTask.simulateExecuteSchedule(null); + if (!scheduledTask.isDue()) { + // get schedule after next due date to move forward + newNextDueDate = scheduledTask.getNextScheduleAfter(newNextDueDate); + } + // because the schedule snaps to the next due date we have to subtract one day + scheduledTask.lastScheduledEventOn = newNextDueDate?.subtract(Duration(days: 1)); + } + else { + scheduledTask.executeSchedule(insertedTaskEvent); + } ScheduledTaskRepository.update(scheduledTask).then((changedScheduledTask) { cancelSnoozedNotification(scheduledTask); pagesHolder @@ -185,9 +198,9 @@ class ScheduledTaskWidgetState extends State { value: scheduledTask.isNextScheduleOverdue(true) ? null : scheduledTask.getNextRepetitionIndicatorValue(), color: scheduledTask.isNextScheduleOverdue(false) ? Colors.red[500] - : (scheduledTask.isNextScheduleReached() - ? scheduledTask.getDueColor(context, lighter: false) - : null), + : (scheduledTask.isNextScheduleAlmostReached() + ? scheduledTask.getDueColor(context, lighter: false) + : null), backgroundColor: scheduledTask.getDueBackgroundColor(context), ), ), @@ -562,7 +575,7 @@ class ScheduledTaskWidgetState extends State { icon: Icon(resetIcon), okPressed: () { if (scheduledTask.schedule.repetitionMode == RepetitionMode.FIXED) { - // because the schedule snaps to the next due date we have to substract one day + // because the schedule snaps to the next due date we have to subtract one day scheduledTask.lastScheduledEventOn = newNextDueDate?.subtract(Duration(days: 1)); } else { diff --git a/pubspec.yaml b/pubspec.yaml index 9044c8c..72c4085 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -15,7 +15,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev # In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion. # Read more about iOS versioning at # https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html -version: 1.6.0+10600 +version: 1.6.1+10601 environment: sdk: ">=3.0.0" From 944e4fa52c3a27c0b7a549ebd0c95f305af7d330 Mon Sep 17 00:00:00 2001 From: Jens Pfahl Date: Tue, 12 Mar 2024 21:02:34 +0100 Subject: [PATCH 2/4] Fix reused fixed schedules order problem --- lib/model/ScheduledTask.dart | 11 ++++++++++- lib/ui/forms/ScheduledTaskForm.dart | 5 +---- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/lib/model/ScheduledTask.dart b/lib/model/ScheduledTask.dart index ea4718a..69104b2 100644 --- a/lib/model/ScheduledTask.dart +++ b/lib/model/ScheduledTask.dart @@ -160,7 +160,16 @@ class ScheduledTask extends TitleAndDescription implements Comparable { var scheduledDuration = getScheduledDuration(); var missingDuration = getMissingDuration(); if (scheduledDuration != null && missingDuration != null) { - return 1 - (missingDuration.inMinutes / (scheduledDuration.inMinutes != 0 ? scheduledDuration.inMinutes : 1)); + final value = 1 - (missingDuration.inMinutes / (scheduledDuration.inMinutes != 0 ? scheduledDuration.inMinutes : 1)); + if (value.isNegative && schedule.repetitionMode == RepetitionMode.ONE_TIME) { + // It can be negative if the schedule was reused after stopped or done and due date was set to a past date (which is an unusual use case). + // With having this, we cannot really compare by progress since the start value is random by the users reactivation date + final missingDays = missingDuration.inHours / 24; + return 1 + (missingDays * 0.5); + } + else { + return value; + } } return null; } diff --git a/lib/ui/forms/ScheduledTaskForm.dart b/lib/ui/forms/ScheduledTaskForm.dart index b94110b..f153ae1 100644 --- a/lib/ui/forms/ScheduledTaskForm.dart +++ b/lib/ui/forms/ScheduledTaskForm.dart @@ -712,15 +712,12 @@ class _ScheduledTaskFormState extends State { var scheduleFrom = schedule.getPreviousRepetitionFrom(nextDueOn); var oneTimeDueOn = _scheduledTask?.schedule.oneTimeDueOn; - DateTime? oneTimeCompletedOn = null; if (_repetitionMode == RepetitionMode.ONE_TIME) { - oneTimeCompletedOn = _scheduledTask?.oneTimeCompletedOn; final now = DateTime.now(); if (_scheduledTask == null || _scheduledTask!.isOneTimeCompleted) { // reuse this schedule once completed scheduleFrom = now; oneTimeDueOn = nextDueOn; - oneTimeCompletedOn = null; } else { // just update this schedule @@ -739,7 +736,7 @@ class _ScheduledTaskFormState extends State { createdAt: _scheduledTask?.createdAt ?? DateTime.now(), schedule: schedule, lastScheduledEventOn: scheduleFrom, - oneTimeCompletedOn: oneTimeCompletedOn, + oneTimeCompletedOn: null, active: _isActive, important: _isImportant, reminderNotificationEnabled: _isRemindersEnabled, From a5bdacf1752804ee42f32b3813c96f45fea0f47d Mon Sep 17 00:00:00 2001 From: Jens Pfahl Date: Wed, 13 Mar 2024 20:31:32 +0100 Subject: [PATCH 3/4] Ensure due OneTime schedules are sort correctly --- lib/model/ScheduledTask.dart | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/model/ScheduledTask.dart b/lib/model/ScheduledTask.dart index 69104b2..84070c9 100644 --- a/lib/model/ScheduledTask.dart +++ b/lib/model/ScheduledTask.dart @@ -125,7 +125,10 @@ class ScheduledTask extends TitleAndDescription implements Comparable { * Returns the duration in the next bigger unit then the repetition steps are defined. */ int _getRoundedDurationValue(Duration duration) { - if (schedule.repetitionStep == RepetitionStep.DAILY + if (schedule.repetitionMode == RepetitionMode.ONE_TIME) { + return duration.inHours; + } + if (schedule.repetitionStep == RepetitionStep.DAILY || schedule.repetitionStep == RepetitionStep.EVERY_OTHER_DAY || (schedule.repetitionStep == RepetitionStep.CUSTOM && schedule.customRepetition?.repetitionUnit == RepetitionUnit.DAYS) @@ -165,7 +168,7 @@ class ScheduledTask extends TitleAndDescription implements Comparable { // It can be negative if the schedule was reused after stopped or done and due date was set to a past date (which is an unusual use case). // With having this, we cannot really compare by progress since the start value is random by the users reactivation date final missingDays = missingDuration.inHours / 24; - return 1 + (missingDays * 0.5); + return 1 + (missingDays.abs() * 0.5); } else { return value; From 7ab549f1f3d6934052ea676cd60ddc0ab40cfd22 Mon Sep 17 00:00:00 2001 From: Jens Pfahl Date: Thu, 14 Mar 2024 21:03:59 +0100 Subject: [PATCH 4/4] Ready for v1.6.1 --- metadata/en-US/changelogs/10601.txt | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 metadata/en-US/changelogs/10601.txt diff --git a/metadata/en-US/changelogs/10601.txt b/metadata/en-US/changelogs/10601.txt new file mode 100644 index 0000000..a964c69 --- /dev/null +++ b/metadata/en-US/changelogs/10601.txt @@ -0,0 +1,3 @@ +* Completing fixed schedules will also move non-due schedules further +* Fix sort order of reused One-Time schedules +* Fix progress bar color when close to due \ No newline at end of file