Fixed navigation
This commit is contained in:
@@ -135,8 +135,11 @@ class PaymentBackButton extends StatelessWidget {
|
||||
child: IconButton(
|
||||
icon: const Icon(Icons.arrow_back),
|
||||
onPressed: () {
|
||||
onBack?.call(pageSelector.selectedRecipient);
|
||||
pageSelector.goBackFromPayment();
|
||||
if (onBack != null) {
|
||||
onBack!(pageSelector.selectedRecipient);
|
||||
} else {
|
||||
pageSelector.goBackFromPayment();
|
||||
}
|
||||
},
|
||||
),
|
||||
);
|
||||
|
||||
@@ -18,6 +18,7 @@ class PageSelectorProvider extends ChangeNotifier {
|
||||
PayoutDestination _selected = PayoutDestination.dashboard;
|
||||
PaymentType? _type;
|
||||
bool _cameFromRecipientList = false;
|
||||
PayoutDestination? _previousDestination;
|
||||
|
||||
RecipientProvider? recipientProvider;
|
||||
WalletsProvider? walletsProvider;
|
||||
@@ -52,6 +53,7 @@ class PageSelectorProvider extends ChangeNotifier {
|
||||
if (recipientProvider != null) {
|
||||
recipientProvider!.selectRecipient(recipient);
|
||||
_cameFromRecipientList = fromList;
|
||||
_setPreviousDestination();
|
||||
_selected = PayoutDestination.payment;
|
||||
notifyListeners();
|
||||
} else {
|
||||
@@ -88,15 +90,19 @@ class PageSelectorProvider extends ChangeNotifier {
|
||||
}
|
||||
_type = type;
|
||||
_cameFromRecipientList = false;
|
||||
_setPreviousDestination();
|
||||
_selected = PayoutDestination.payment;
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
void goBackFromPayment() {
|
||||
_selected = _cameFromRecipientList
|
||||
? PayoutDestination.recipients
|
||||
: PayoutDestination.dashboard;
|
||||
_selected = _previousDestination ??
|
||||
(_cameFromRecipientList
|
||||
? PayoutDestination.recipients
|
||||
: PayoutDestination.dashboard);
|
||||
_type = null;
|
||||
_previousDestination = null;
|
||||
_cameFromRecipientList = false;
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
@@ -116,7 +122,8 @@ class PageSelectorProvider extends ChangeNotifier {
|
||||
|
||||
void startPaymentFromWallet(Wallet wallet) {
|
||||
_type = PaymentType.wallet;
|
||||
_cameFromRecipientList = true;
|
||||
_cameFromRecipientList = false;
|
||||
_setPreviousDestination();
|
||||
_selected = PayoutDestination.payment;
|
||||
notifyListeners();
|
||||
}
|
||||
@@ -171,6 +178,12 @@ class PageSelectorProvider extends ChangeNotifier {
|
||||
}
|
||||
}
|
||||
|
||||
void _setPreviousDestination() {
|
||||
if (_selected != PayoutDestination.payment) {
|
||||
_previousDestination = _selected;
|
||||
}
|
||||
}
|
||||
|
||||
Recipient? get selectedRecipient => recipientProvider?.selectedRecipient;
|
||||
Wallet? get selectedWallet => walletsProvider?.selectedWallet;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -74,7 +74,7 @@ class PageSelector extends StatelessWidget {
|
||||
final wallet = provider.walletsProvider?.selectedWallet;
|
||||
content = wallet != null
|
||||
? WalletEditPage(
|
||||
onBack: () => provider.goBackFromPayment(),
|
||||
onBack: provider.goBackFromWalletEdit,
|
||||
)
|
||||
: const Center(child: Text('No wallet selected')); //TODO Localize
|
||||
break;
|
||||
@@ -106,4 +106,4 @@ class PageSelector extends StatelessWidget {
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user