Update send_page.dart (#2154)

This commit is contained in:
Serhii 2025-04-03 17:34:07 +03:00 committed by GitHub
parent 7a5999d90e
commit 2b493ff6dc
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -496,7 +496,7 @@ class SendPage extends BasePage {
bitcoin!.updateFeeRates(sendViewModel.wallet); bitcoin!.updateFeeRates(sendViewModel.wallet);
} }
reaction((_) => sendViewModel.state, (ExecutionState state) { reaction((_) => sendViewModel.state, (ExecutionState state) async {
if (dialogContext != null && dialogContext?.mounted == true) { if (dialogContext != null && dialogContext?.mounted == true) {
Navigator.of(dialogContext!).pop(); Navigator.of(dialogContext!).pop();
} }
@ -525,6 +525,14 @@ class SendPage extends BasePage {
} }
if (state is IsExecutingState) { if (state is IsExecutingState) {
// wait a bit to avoid showing the loading dialog if transaction is failed
await Future.delayed(const Duration(milliseconds: 300));
final currentState = sendViewModel.state;
if (currentState is ExecutedSuccessfullyState || currentState is FailureState) {
return;
}
WidgetsBinding.instance.addPostFrameCallback((_) { WidgetsBinding.instance.addPostFrameCallback((_) {
if (context.mounted) { if (context.mounted) {
showModalBottomSheet<void>( showModalBottomSheet<void>(
@ -590,18 +598,22 @@ class SendPage extends BasePage {
newContactAddress = null; newContactAddress = null;
} }
bool showContactSheet = (newContactAddress != null && sendViewModel.showAddressBookPopup);
await showModalBottomSheet<void>( await showModalBottomSheet<void>(
context: context, context: context,
isDismissible: false, isDismissible: false,
builder: (BuildContext bottomSheetContext) { builder: (BuildContext bottomSheetContext) {
return newContactAddress != null && sendViewModel.showAddressBookPopup return showContactSheet
? InfoBottomSheet( ? InfoBottomSheet(
currentTheme: currentTheme, currentTheme: currentTheme,
showDontAskMeCheckbox: true, showDontAskMeCheckbox: true,
onCheckboxChanged: (value) => sendViewModel.setShowAddressBookPopup(!value), onCheckboxChanged: (value) => sendViewModel.setShowAddressBookPopup(!value),
titleText: S.of(bottomSheetContext).transaction_sent, titleText: S.of(bottomSheetContext).transaction_sent,
contentImage: 'assets/images/contact_icon.svg', contentImage: 'assets/images/contact_icon.svg',
contentImageColor: Theme.of(context).extension<CakeTextTheme>()!.titleColor, contentImageColor: Theme.of(context)
.extension<CakeTextTheme>()!
.titleColor,
content: S.of(bottomSheetContext).add_contact_to_address_book, content: S.of(bottomSheetContext).add_contact_to_address_book,
isTwoAction: true, isTwoAction: true,
leftButtonText: 'No', leftButtonText: 'No',
@ -633,7 +645,8 @@ class SendPage extends BasePage {
.pushNamedAndRemoveUntil(Routes.dashboard, (route) => false); .pushNamedAndRemoveUntil(Routes.dashboard, (route) => false);
RequestReviewHandler.requestReview(); RequestReviewHandler.requestReview();
newContactAddress = null; newContactAddress = null;
}); },
);
}, },
); );