mirror of
https://github.com/wger-project/flutter.git
synced 2026-02-18 00:17:48 +01:00
Merge pull request #93 from TomerPacific/fix/preset-time-session-form-31
Correct Preset Time In Session Form
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user