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;
context: context,
builder: (BuildContext context) { showModalBottomSheet<void>(
dialogContext = context; context: context,
return AlertWithOneAction( isDismissible: false,
alertTitle: S.of(context).proceed_on_device, builder: (BuildContext bottomSheetContext) => InfoBottomSheet(
alertContent: S.of(context).proceed_on_device_description, currentTheme: currentTheme,
buttonText: S.of(context).cancel, titleText: S.of(bottomSheetContext).proceed_on_device,
alertBarrierDismissible: false, contentImage: 'assets/images/hardware_wallet/ledger_nano_x.png',
buttonAction: () { contentImageColor:
sendViewModel.state = InitialExecutionState(); Theme.of(context).extension<CakeTextTheme>()!.titleColor,
Navigator.of(context).pop(); content: S.of(bottomSheetContext).proceed_on_device_description,
}); isTwoAction: false,
}); actionButtonText: S.of(context).cancel,
actionButton: () {
sendViewModel.state = InitialExecutionState();
Navigator.of(bottomSheetContext).pop();
},
),
);
}); });
} }
}); });

View file

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