diff options
| author | Aldrik Ramaekers <aldrik@amftech.nl> | 2022-08-16 15:14:43 +0200 |
|---|---|---|
| committer | Aldrik Ramaekers <aldrik@amftech.nl> | 2022-08-16 15:14:43 +0200 |
| commit | 9144664c98824924e3d7668557a4455693bcf7f6 (patch) | |
| tree | 5427daae2a5aa20a99809da44d11e33d0fe800a0 /lib/pages/add_shift_page.dart | |
| parent | 00bf8823311c067f5b0e9a785a5048e6bd8ad122 (diff) | |
saving and reading
Diffstat (limited to 'lib/pages/add_shift_page.dart')
| -rw-r--r-- | lib/pages/add_shift_page.dart | 33 |
1 files changed, 25 insertions, 8 deletions
diff --git a/lib/pages/add_shift_page.dart b/lib/pages/add_shift_page.dart index 64b6142..d81ae3e 100644 --- a/lib/pages/add_shift_page.dart +++ b/lib/pages/add_shift_page.dart @@ -32,6 +32,9 @@ class _AddShiftPageState extends State<AddShiftPage> { void addShift() { DateTime startDate = widget.mondayOfWeek; switch (dropdownValue) { + case 'Maandag': + startDate = startDate.add(Duration(days: 0)); + break; case 'Dinsdag': startDate = startDate.add(Duration(days: 1)); break; @@ -52,20 +55,34 @@ class _AddShiftPageState extends State<AddShiftPage> { break; } - shiftProvider.addShift(Shift( - start: startDate, - type: isSelected[0] - ? ShiftType.Dagrit - : isSelected[1] - ? ShiftType.Avondrit - : ShiftType.Terugscannen)); + ShiftType type = ShiftType.Dagrit; + if (isSelected[1]) type = ShiftType.Avondrit; + if (isSelected[2]) type = ShiftType.Terugscannen; + + switch (type) { + case ShiftType.Dagrit: + startDate = startDate.add(Duration(hours: 10)); + break; + case ShiftType.Avondrit: + startDate = startDate.add(Duration( + hours: startDate.weekday == 6 ? 15 : 17, + minutes: startDate.weekday == 6 ? 30 : 0)); + break; + case ShiftType.Terugscannen: + startDate = startDate.add( + Duration(hours: startDate.weekday == 6 ? 13 : 14, minutes: 30)); + break; + } + + shiftProvider.addShift(Shift(start: startDate, type: type)); Navigator.pop(context, true); // Previous page will not refresh without this. Navigator.pushAndRemoveUntil( context, - MaterialPageRoute(builder: (context) => HomePage()), + MaterialPageRoute( + builder: (context) => HomePage(agendaWeekNr: widget.pageIndex)), (Route<dynamic> route) => false, ); } |
