|
|
@ -100,10 +100,20 @@ class _HomeScreenState extends State<HomeScreen> {
|
|
|
|
booking: widget.viewModel.bookings[index],
|
|
|
|
booking: widget.viewModel.bookings[index],
|
|
|
|
onTap: () => context.push(Routes.bookingWithId(
|
|
|
|
onTap: () => context.push(Routes.bookingWithId(
|
|
|
|
widget.viewModel.bookings[index].id)),
|
|
|
|
widget.viewModel.bookings[index].id)),
|
|
|
|
onDismissed: (_) =>
|
|
|
|
confirmDismiss: (_) async {
|
|
|
|
widget.viewModel.deleteBooking.execute(
|
|
|
|
// wait for command to complete
|
|
|
|
widget.viewModel.bookings[index].id,
|
|
|
|
await widget.viewModel.deleteBooking.execute(
|
|
|
|
),
|
|
|
|
widget.viewModel.bookings[index].id,
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
// if command completed successfully, return true
|
|
|
|
|
|
|
|
if (widget.viewModel.deleteBooking.completed) {
|
|
|
|
|
|
|
|
// removes the dismissable from the list
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
// the dismissable stays in the list
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
},
|
|
|
|
),
|
|
|
|
),
|
|
|
|
)
|
|
|
|
)
|
|
|
|
],
|
|
|
|
],
|
|
|
@ -141,19 +151,19 @@ class _Booking extends StatelessWidget {
|
|
|
|
super.key,
|
|
|
|
super.key,
|
|
|
|
required this.booking,
|
|
|
|
required this.booking,
|
|
|
|
required this.onTap,
|
|
|
|
required this.onTap,
|
|
|
|
required this.onDismissed,
|
|
|
|
required this.confirmDismiss,
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
final BookingSummary booking;
|
|
|
|
final BookingSummary booking;
|
|
|
|
final GestureTapCallback onTap;
|
|
|
|
final GestureTapCallback onTap;
|
|
|
|
final DismissDirectionCallback onDismissed;
|
|
|
|
final ConfirmDismissCallback confirmDismiss;
|
|
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
return Dismissible(
|
|
|
|
return Dismissible(
|
|
|
|
key: ValueKey(booking.id),
|
|
|
|
key: ValueKey(booking.id),
|
|
|
|
direction: DismissDirection.endToStart,
|
|
|
|
direction: DismissDirection.endToStart,
|
|
|
|
onDismissed: onDismissed,
|
|
|
|
confirmDismiss: confirmDismiss,
|
|
|
|
child: InkWell(
|
|
|
|
child: InkWell(
|
|
|
|
onTap: onTap,
|
|
|
|
onTap: onTap,
|
|
|
|
child: Padding(
|
|
|
|
child: Padding(
|
|
|
|