Merge pull request #93 from TomerPacific/fix/preset-time-session-form-31

Correct Preset Time In Session Form
This commit is contained in:
Roland Geider
2021-10-07 07:59:16 +02:00
committed by GitHub
3 changed files with 15 additions and 4 deletions

View File

@@ -9,6 +9,7 @@
* Arun Muralidharan - <https://github.com/arun-muralidharan>
* Khushbu Bora - <https://github.com/KhushbuBora>
* Patrick Witter - <https://github.com/patrickwitter>
* Tomer Ben-Rachel - <https://github.com/tomerpacific>
* Thilina Herath - <https://github.com/ThilinaTCH>
## Translators

View File

@@ -59,6 +59,11 @@ class WorkoutSession {
required this.timeEnd,
});
WorkoutSession.now(){
timeStart = TimeOfDay.now();
timeEnd = TimeOfDay.now();
}
// Boilerplate
factory WorkoutSession.fromJson(Map<String, dynamic> json) => _$WorkoutSessionFromJson(json);
Map<String, dynamic> toJson() => _$WorkoutSessionToJson(this);

View File

@@ -737,7 +737,7 @@ class _SessionPageState extends State<SessionPage> {
final timeStartController = TextEditingController();
final timeEndController = TextEditingController();
final _session = WorkoutSession();
final _session = WorkoutSession.now();
/// Selected impression: bad, neutral, good
var selectedImpression = [false, true, false];
@@ -830,11 +830,12 @@ class _SessionPageState extends State<SessionPage> {
// 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) {
@@ -863,10 +864,14 @@ class _SessionPageState extends State<SessionPage> {
// 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);