Skip to content

Commit

Permalink
feat(ticket): skip drink selection for some tickets (#573)
Browse files Browse the repository at this point in the history
when swiping a ticket, skip menu item selection if a ticket can only
claim one type of drink
  • Loading branch information
marfavi authored Feb 7, 2024
1 parent 65c1fb7 commit 2ff7085
Showing 1 changed file with 8 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,12 @@ class _ModalContentState extends State<_ModalContent>
late Animation<double> _fadeInAnimation;
late Animation<double> _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<MenuItem> _selectedMenuItem = widget.ticket.lastUsedMenuItem;

Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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<TicketsCubit>();
final receiptCubit = widget.context.read<ReceiptCubit>();
final productId = widget.ticket.product.id;
Expand Down

0 comments on commit 2ff7085

Please sign in to comment.