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

* feat: new bottom-sheet send flow for ledger

* refactor: use correct context in ledger bottom-sheet
This commit is contained in:
Konstantin Ullrich 2025-04-02 18:18:24 +02:00 committed by GitHub
parent 7d34494800
commit 65e771cbbe
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 24 additions and 17 deletions

View file

@ -656,20 +656,26 @@ class SendPage extends BasePage {
if (state is IsAwaitingDeviceResponseState) { if (state is IsAwaitingDeviceResponseState) {
WidgetsBinding.instance.addPostFrameCallback((_) { WidgetsBinding.instance.addPostFrameCallback((_) {
showPopUp<void>( if (!context.mounted) return;
showModalBottomSheet<void>(
context: context, context: context,
builder: (BuildContext context) { isDismissible: false,
dialogContext = context; builder: (BuildContext bottomSheetContext) => InfoBottomSheet(
return AlertWithOneAction( currentTheme: currentTheme,
alertTitle: S.of(context).proceed_on_device, titleText: S.of(bottomSheetContext).proceed_on_device,
alertContent: S.of(context).proceed_on_device_description, contentImage: 'assets/images/hardware_wallet/ledger_nano_x.png',
buttonText: S.of(context).cancel, contentImageColor:
alertBarrierDismissible: false, Theme.of(context).extension<CakeTextTheme>()!.titleColor,
buttonAction: () { content: S.of(bottomSheetContext).proceed_on_device_description,
isTwoAction: false,
actionButtonText: S.of(context).cancel,
actionButton: () {
sendViewModel.state = InitialExecutionState(); sendViewModel.state = InitialExecutionState();
Navigator.of(context).pop(); Navigator.of(bottomSheetContext).pop();
}); },
}); ),
);
}); });
} }
}); });

View file

@ -393,10 +393,11 @@ abstract class SendViewModelBase extends WalletChangeListenerViewModel with Stor
@action @action
Future<PendingTransaction?> createTransaction({ExchangeProvider? provider}) async { Future<PendingTransaction?> createTransaction({ExchangeProvider? provider}) async {
try { try {
if (wallet.isHardwareWallet)
state = IsAwaitingDeviceResponseState();
else
state = IsExecutingState(); state = IsExecutingState();
if (wallet.isHardwareWallet) state = IsAwaitingDeviceResponseState();
pendingTransaction = await wallet.createTransaction(_credentials(provider)); pendingTransaction = await wallet.createTransaction(_credentials(provider));
if (provider is ThorChainExchangeProvider) { if (provider is ThorChainExchangeProvider) {