From 2ff7085632bc9e356d652b8b81aae37983edc296 Mon Sep 17 00:00:00 2001 From: Omid Marfavi <21163286+marfavi@users.noreply.github.com> Date: Wed, 7 Feb 2024 22:33:29 +0100 Subject: [PATCH] feat(ticket): skip drink selection for some tickets (#573) when swiping a ticket, skip menu item selection if a ticket can only claim one type of drink --- .../presentation/widgets/swipe_ticket_confirm.dart | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/lib/features/ticket/presentation/widgets/swipe_ticket_confirm.dart b/lib/features/ticket/presentation/widgets/swipe_ticket_confirm.dart index fe93fa9e..2f3426ab 100644 --- a/lib/features/ticket/presentation/widgets/swipe_ticket_confirm.dart +++ b/lib/features/ticket/presentation/widgets/swipe_ticket_confirm.dart @@ -43,8 +43,12 @@ class _ModalContentState extends State<_ModalContent> late Animation _fadeInAnimation; late Animation _fadeBetweenAnimation; - late Ticket _heroTag = widget.ticket; - _TicketUseState _state = const _SelectProduct(); + late Ticket _ticket = widget.ticket; + + late _TicketUseState _state = switch (_ticket.product.eligibleMenuItems) { + [final onlyMenuItem] => _ConfirmSwipe(onlyMenuItem), + _ => const _SelectProduct(), + }; late Option _selectedMenuItem = widget.ticket.lastUsedMenuItem; @@ -107,7 +111,7 @@ class _ModalContentState extends State<_ModalContent> ], ), Hero( - tag: _heroTag, + tag: _ticket, // SingleChildScrollView to avoid the temporary overflow // error during the hero animation. child: SingleChildScrollView( @@ -255,7 +259,7 @@ class _ModalContentState extends State<_ModalContent> outerColor: AppColors.primary, onSubmit: () async { // Disable hero animation in the reverse direction - setState(() => _heroTag = const Ticket.empty()); + setState(() => _ticket = const Ticket.empty()); final ticketCubit = widget.context.read(); final receiptCubit = widget.context.read(); final productId = widget.ticket.product.id;