From 65e771cbbe9af927486a92c22799b65deb5720c6 Mon Sep 17 00:00:00 2001 From: Konstantin Ullrich Date: Wed, 2 Apr 2025 18:18:24 +0200 Subject: [PATCH] Adopt bottom-sheet send flow for ledger (#2140) * feat: new bottom-sheet send flow for ledger * refactor: use correct context in ledger bottom-sheet --- lib/src/screens/send/send_page.dart | 34 ++++++++++++++---------- lib/view_model/send/send_view_model.dart | 7 ++--- 2 files changed, 24 insertions(+), 17 deletions(-) diff --git a/lib/src/screens/send/send_page.dart b/lib/src/screens/send/send_page.dart index 277986c3f..6d91f0001 100644 --- a/lib/src/screens/send/send_page.dart +++ b/lib/src/screens/send/send_page.dart @@ -656,20 +656,26 @@ class SendPage extends BasePage { if (state is IsAwaitingDeviceResponseState) { WidgetsBinding.instance.addPostFrameCallback((_) { - showPopUp( - context: context, - builder: (BuildContext context) { - dialogContext = context; - return AlertWithOneAction( - alertTitle: S.of(context).proceed_on_device, - alertContent: S.of(context).proceed_on_device_description, - buttonText: S.of(context).cancel, - alertBarrierDismissible: false, - buttonAction: () { - sendViewModel.state = InitialExecutionState(); - Navigator.of(context).pop(); - }); - }); + if (!context.mounted) return; + + showModalBottomSheet( + context: context, + isDismissible: false, + builder: (BuildContext bottomSheetContext) => InfoBottomSheet( + currentTheme: currentTheme, + titleText: S.of(bottomSheetContext).proceed_on_device, + contentImage: 'assets/images/hardware_wallet/ledger_nano_x.png', + contentImageColor: + Theme.of(context).extension()!.titleColor, + content: S.of(bottomSheetContext).proceed_on_device_description, + isTwoAction: false, + actionButtonText: S.of(context).cancel, + actionButton: () { + sendViewModel.state = InitialExecutionState(); + Navigator.of(bottomSheetContext).pop(); + }, + ), + ); }); } }); diff --git a/lib/view_model/send/send_view_model.dart b/lib/view_model/send/send_view_model.dart index 4ee9cb86f..4b72f9392 100644 --- a/lib/view_model/send/send_view_model.dart +++ b/lib/view_model/send/send_view_model.dart @@ -393,9 +393,10 @@ abstract class SendViewModelBase extends WalletChangeListenerViewModel with Stor @action Future createTransaction({ExchangeProvider? provider}) async { try { - state = IsExecutingState(); - - if (wallet.isHardwareWallet) state = IsAwaitingDeviceResponseState(); + if (wallet.isHardwareWallet) + state = IsAwaitingDeviceResponseState(); + else + state = IsExecutingState(); pendingTransaction = await wallet.createTransaction(_credentials(provider));