Adopt bottom-sheet send flow for ledger (#2140)

* feat: new bottom-sheet send flow for ledger * refactor: use correct context in ledger bottom-sheet

Konstantin Ullrich committed Apr 2, 2025 at 18:18 UTC 65e771cbbe9af927486a92c22799b65deb5720c6
2 files changed +24 -17
lib/src/screens/send/send_page.dart
+20 -14
@@ -656,20 +656,26 @@ class SendPage extends BasePage {
656
657 if (state is IsAwaitingDeviceResponseState) {
658 WidgetsBinding.instance.addPostFrameCallback((_) {
659 - showPopUp<void>(
660 - context: context,
661 - builder: (BuildContext context) {
662 - dialogContext = context;
663 - return AlertWithOneAction(
664 - alertTitle: S.of(context).proceed_on_device,
665 - alertContent: S.of(context).proceed_on_device_description,
666 - buttonText: S.of(context).cancel,
667 - alertBarrierDismissible: false,
668 - buttonAction: () {
669 - sendViewModel.state = InitialExecutionState();
670 - Navigator.of(context).pop();
671 - });
672 - });
659 + if (!context.mounted) return;
660 +
661 + showModalBottomSheet<void>(
662 + context: context,
663 + isDismissible: false,
664 + builder: (BuildContext bottomSheetContext) => InfoBottomSheet(
665 + currentTheme: currentTheme,
666 + titleText: S.of(bottomSheetContext).proceed_on_device,
667 + contentImage: 'assets/images/hardware_wallet/ledger_nano_x.png',
668 + contentImageColor:
669 + Theme.of(context).extension<CakeTextTheme>()!.titleColor,
670 + content: S.of(bottomSheetContext).proceed_on_device_description,
671 + isTwoAction: false,
672 + actionButtonText: S.of(context).cancel,
673 + actionButton: () {
674 + sendViewModel.state = InitialExecutionState();
675 + Navigator.of(bottomSheetContext).pop();
676 + },
677 + ),
678 + );
679 });
680 }
681 });
lib/view_model/send/send_view_model.dart
+4 -3
@@ -393,9 +393,10 @@ abstract class SendViewModelBase extends WalletChangeListenerViewModel with Stor
393 @action
394 Future<PendingTransaction?> createTransaction({ExchangeProvider? provider}) async {
395 try {
396 - state = IsExecutingState();
397 -
398 - if (wallet.isHardwareWallet) state = IsAwaitingDeviceResponseState();
396 + if (wallet.isHardwareWallet)
397 + state = IsAwaitingDeviceResponseState();
398 + else
399 + state = IsExecutingState();
400
401 pendingTransaction = await wallet.createTransaction(_credentials(provider));
402