Fixed navigation

This commit is contained in:
Arseni
2025-11-21 21:09:32 +03:00
parent acbab71a57
commit 775312d174
3 changed files with 25 additions and 9 deletions

View File

@@ -135,8 +135,11 @@ class PaymentBackButton extends StatelessWidget {
child: IconButton( child: IconButton(
icon: const Icon(Icons.arrow_back), icon: const Icon(Icons.arrow_back),
onPressed: () { onPressed: () {
onBack?.call(pageSelector.selectedRecipient); if (onBack != null) {
onBack!(pageSelector.selectedRecipient);
} else {
pageSelector.goBackFromPayment(); pageSelector.goBackFromPayment();
}
}, },
), ),
); );

View File

@@ -18,6 +18,7 @@ class PageSelectorProvider extends ChangeNotifier {
PayoutDestination _selected = PayoutDestination.dashboard; PayoutDestination _selected = PayoutDestination.dashboard;
PaymentType? _type; PaymentType? _type;
bool _cameFromRecipientList = false; bool _cameFromRecipientList = false;
PayoutDestination? _previousDestination;
RecipientProvider? recipientProvider; RecipientProvider? recipientProvider;
WalletsProvider? walletsProvider; WalletsProvider? walletsProvider;
@@ -52,6 +53,7 @@ class PageSelectorProvider extends ChangeNotifier {
if (recipientProvider != null) { if (recipientProvider != null) {
recipientProvider!.selectRecipient(recipient); recipientProvider!.selectRecipient(recipient);
_cameFromRecipientList = fromList; _cameFromRecipientList = fromList;
_setPreviousDestination();
_selected = PayoutDestination.payment; _selected = PayoutDestination.payment;
notifyListeners(); notifyListeners();
} else { } else {
@@ -88,15 +90,19 @@ class PageSelectorProvider extends ChangeNotifier {
} }
_type = type; _type = type;
_cameFromRecipientList = false; _cameFromRecipientList = false;
_setPreviousDestination();
_selected = PayoutDestination.payment; _selected = PayoutDestination.payment;
notifyListeners(); notifyListeners();
} }
void goBackFromPayment() { void goBackFromPayment() {
_selected = _cameFromRecipientList _selected = _previousDestination ??
(_cameFromRecipientList
? PayoutDestination.recipients ? PayoutDestination.recipients
: PayoutDestination.dashboard; : PayoutDestination.dashboard);
_type = null; _type = null;
_previousDestination = null;
_cameFromRecipientList = false;
notifyListeners(); notifyListeners();
} }
@@ -116,7 +122,8 @@ class PageSelectorProvider extends ChangeNotifier {
void startPaymentFromWallet(Wallet wallet) { void startPaymentFromWallet(Wallet wallet) {
_type = PaymentType.wallet; _type = PaymentType.wallet;
_cameFromRecipientList = true; _cameFromRecipientList = false;
_setPreviousDestination();
_selected = PayoutDestination.payment; _selected = PayoutDestination.payment;
notifyListeners(); notifyListeners();
} }
@@ -171,6 +178,12 @@ class PageSelectorProvider extends ChangeNotifier {
} }
} }
void _setPreviousDestination() {
if (_selected != PayoutDestination.payment) {
_previousDestination = _selected;
}
}
Recipient? get selectedRecipient => recipientProvider?.selectedRecipient; Recipient? get selectedRecipient => recipientProvider?.selectedRecipient;
Wallet? get selectedWallet => walletsProvider?.selectedWallet; Wallet? get selectedWallet => walletsProvider?.selectedWallet;
} }

View File

@@ -74,7 +74,7 @@ class PageSelector extends StatelessWidget {
final wallet = provider.walletsProvider?.selectedWallet; final wallet = provider.walletsProvider?.selectedWallet;
content = wallet != null content = wallet != null
? WalletEditPage( ? WalletEditPage(
onBack: () => provider.goBackFromPayment(), onBack: provider.goBackFromWalletEdit,
) )
: const Center(child: Text('No wallet selected')); //TODO Localize : const Center(child: Text('No wallet selected')); //TODO Localize
break; break;