From 320e61d2c2a90c50ddadcc0314fe84509703e870 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 6 Oct 2021 20:57:21 +0300 Subject: [PATCH 1/4] fix/preset-time-session-form adding default values to timeStart/end --- lib/models/workouts/session.dart | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/models/workouts/session.dart b/lib/models/workouts/session.dart index cdb3f130e..d44978c8d 100644 --- a/lib/models/workouts/session.dart +++ b/lib/models/workouts/session.dart @@ -42,10 +42,10 @@ class WorkoutSession { late String notes; @JsonKey(required: true, name: 'time_start', toJson: timeToString, fromJson: stringToTime) - late TimeOfDay timeStart; + late TimeOfDay timeStart = TimeOfDay.now(); @JsonKey(required: true, name: 'time_end', toJson: timeToString, fromJson: stringToTime) - late TimeOfDay timeEnd; + late TimeOfDay timeEnd = TimeOfDay.now(); WorkoutSession(); From e523c287adbf5d26936fbf92a98adb8814a812e8 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 6 Oct 2021 20:58:10 +0300 Subject: [PATCH 2/4] fix/preset-time-session-form making sure to use timeStart/end as values for initialTime of TimePicker and setting them as well --- lib/widgets/workouts/gym_mode.dart | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/lib/widgets/workouts/gym_mode.dart b/lib/widgets/workouts/gym_mode.dart index 64874d7db..164fd2002 100644 --- a/lib/widgets/workouts/gym_mode.dart +++ b/lib/widgets/workouts/gym_mode.dart @@ -807,11 +807,12 @@ class _SessionPageState extends State { // Open time picker final pickedTime = await showTimePicker( context: context, - initialTime: widget._start, + initialTime: _session.timeStart, ); if (pickedTime != null) { timeStartController.text = timeToString(pickedTime)!; + _session.timeStart = pickedTime; } }, onSaved: (newValue) { @@ -840,10 +841,14 @@ class _SessionPageState extends State { // Open time picker final pickedTime = await showTimePicker( context: context, - initialTime: TimeOfDay.now(), + initialTime: _session.timeEnd, ); - timeEndController.text = timeToString(pickedTime)!; + if (pickedTime != null) { + timeEndController.text = timeToString(pickedTime)!; + _session.timeEnd = pickedTime; + } + }, onSaved: (newValue) { _session.timeEnd = stringToTime(newValue); From d6928bb5d21aa78b323e3cf933be5bdcb57b0cc8 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 6 Oct 2021 21:21:22 +0300 Subject: [PATCH 3/4] fix/preset-time-session-form adding myself to authors.md --- AUTHORS.md | 1 + 1 file changed, 1 insertion(+) diff --git a/AUTHORS.md b/AUTHORS.md index 947e593ca..fa2d2b876 100644 --- a/AUTHORS.md +++ b/AUTHORS.md @@ -9,6 +9,7 @@ * Arun Muralidharan - * Khushbu Bora - * Patrick Witter - +* Tomer Ben-Rachel - ## Translators From 769043598b6ac8dc3b22bcbbd58c518b3e465f81 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 6 Oct 2021 22:16:44 +0300 Subject: [PATCH 4/4] fix/preset-time-session-form creating constructor in session to initialize timeStart/end --- lib/models/workouts/session.dart | 9 +++++++-- lib/widgets/workouts/gym_mode.dart | 2 +- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/lib/models/workouts/session.dart b/lib/models/workouts/session.dart index d44978c8d..c759dd61d 100644 --- a/lib/models/workouts/session.dart +++ b/lib/models/workouts/session.dart @@ -42,10 +42,10 @@ class WorkoutSession { late String notes; @JsonKey(required: true, name: 'time_start', toJson: timeToString, fromJson: stringToTime) - late TimeOfDay timeStart = TimeOfDay.now(); + late TimeOfDay timeStart; @JsonKey(required: true, name: 'time_end', toJson: timeToString, fromJson: stringToTime) - late TimeOfDay timeEnd = TimeOfDay.now(); + late TimeOfDay timeEnd; WorkoutSession(); @@ -59,6 +59,11 @@ class WorkoutSession { required this.timeEnd, }); + WorkoutSession.now(){ + timeStart = TimeOfDay.now(); + timeEnd = TimeOfDay.now(); + } + // Boilerplate factory WorkoutSession.fromJson(Map json) => _$WorkoutSessionFromJson(json); Map toJson() => _$WorkoutSessionToJson(this); diff --git a/lib/widgets/workouts/gym_mode.dart b/lib/widgets/workouts/gym_mode.dart index 164fd2002..9523af123 100644 --- a/lib/widgets/workouts/gym_mode.dart +++ b/lib/widgets/workouts/gym_mode.dart @@ -714,7 +714,7 @@ class _SessionPageState extends State { final timeStartController = TextEditingController(); final timeEndController = TextEditingController(); - final _session = WorkoutSession(); + final _session = WorkoutSession.now(); /// Selected impression: bad, neutral, good var selectedImpression = [false, true, false];