From 72aa769bc32bb920bd255e68d6ad508e8543a398 Mon Sep 17 00:00:00 2001 From: Aldrik Ramaekers Date: Tue, 16 Aug 2022 20:54:02 +0200 Subject: poop --- lib/pages/add_shift_page.dart | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) (limited to 'lib/pages/add_shift_page.dart') 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 { String dropdownValue = 'Maandag'; List isSelected = [false, true, false]; - void addShift() { + Future addShift() async { DateTime startDate = widget.mondayOfWeek; switch (dropdownValue) { case 'Maandag': @@ -74,17 +77,9 @@ class _AddShiftPageState extends State { 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 route) => false, - ); + await shiftProvider.addShift(Shift(start: startDate, type: type)); + widget.updateParent(); + Navigator.pop(context); } @override @@ -152,7 +147,9 @@ class _AddShiftPageState extends State { Padding( padding: const EdgeInsets.all(20), ), - TextButton(onPressed: () => {addShift()}, child: Text('Toevoegen')), + TextButton( + onPressed: () async => {await addShift()}, + child: Text('Toevoegen')), ], ))); } -- cgit v1.2.3-70-g09d2