diff options
| author | Aldrik Ramaekers <aldrik@amftech.nl> | 2022-08-16 20:54:02 +0200 |
|---|---|---|
| committer | Aldrik Ramaekers <aldrik@amftech.nl> | 2022-08-16 20:54:02 +0200 |
| commit | 72aa769bc32bb920bd255e68d6ad508e8543a398 (patch) | |
| tree | 375f33dea71fe0c31a6827797d9fe62df05a5f72 /lib/pages/add_shift_page.dart | |
| parent | 9144664c98824924e3d7668557a4455693bcf7f6 (diff) | |
poop
Diffstat (limited to 'lib/pages/add_shift_page.dart')
| -rw-r--r-- | lib/pages/add_shift_page.dart | 23 |
1 files changed, 10 insertions, 13 deletions
diff --git a/lib/pages/add_shift_page.dart b/lib/pages/add_shift_page.dart index d81ae3e..21bdbf0 100644 --- a/lib/pages/add_shift_page.dart +++ b/lib/pages/add_shift_page.dart @@ -9,6 +9,8 @@ class AddShiftPage extends StatefulWidget { final int pageNr; final int pageIndex; final DateTime mondayOfWeek; + final Function updateParent; + @override _AddShiftPageState createState() => _AddShiftPageState(); @@ -17,6 +19,7 @@ class AddShiftPage extends StatefulWidget { required this.pageNr, required this.pageIndex, required this.mondayOfWeek, + required this.updateParent, }) : super(key: key); } @@ -29,7 +32,7 @@ class _AddShiftPageState extends State<AddShiftPage> { String dropdownValue = 'Maandag'; List<bool> isSelected = [false, true, false]; - void addShift() { + Future<void> addShift() async { DateTime startDate = widget.mondayOfWeek; switch (dropdownValue) { case 'Maandag': @@ -74,17 +77,9 @@ class _AddShiftPageState extends State<AddShiftPage> { 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(agendaWeekNr: widget.pageIndex)), - (Route<dynamic> route) => false, - ); + await shiftProvider.addShift(Shift(start: startDate, type: type)); + widget.updateParent(); + Navigator.pop(context); } @override @@ -152,7 +147,9 @@ class _AddShiftPageState extends State<AddShiftPage> { Padding( padding: const EdgeInsets.all(20), ), - TextButton(onPressed: () => {addShift()}, child: Text('Toevoegen')), + TextButton( + onPressed: () async => {await addShift()}, + child: Text('Toevoegen')), ], ))); } |
