Lock other pages until we have an account
This commit is contained in:
parent
cf5dcfbc0f
commit
6390155f30
@ -31,11 +31,27 @@ class OkanePageItem {
|
|||||||
this.showAccountName,
|
this.showAccountName,
|
||||||
);
|
);
|
||||||
|
|
||||||
NavigationDestination toDestination() =>
|
bool _isEnabled(int? accountIndex) {
|
||||||
NavigationDestination(icon: Icon(icon), label: label);
|
if (showAccountName) {
|
||||||
|
return accountIndex != null;
|
||||||
|
}
|
||||||
|
|
||||||
NavigationRailDestination toRailDestination() =>
|
return true;
|
||||||
NavigationRailDestination(icon: Icon(icon), label: Text(label));
|
}
|
||||||
|
|
||||||
|
NavigationDestination toDestination(int? accountIndex) =>
|
||||||
|
NavigationDestination(
|
||||||
|
icon: Icon(icon),
|
||||||
|
label: label,
|
||||||
|
enabled: _isEnabled(accountIndex),
|
||||||
|
);
|
||||||
|
|
||||||
|
NavigationRailDestination toRailDestination(int? accountIndex) =>
|
||||||
|
NavigationRailDestination(
|
||||||
|
icon: Icon(icon),
|
||||||
|
label: Text(label),
|
||||||
|
disabled: !_isEnabled(accountIndex),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
final _pages = <OkanePageItem>[
|
final _pages = <OkanePageItem>[
|
||||||
@ -91,7 +107,10 @@ class OkaneNavigationRail extends StatelessWidget {
|
|||||||
(context, state) => NavigationRail(
|
(context, state) => NavigationRail(
|
||||||
onDestinationSelected:
|
onDestinationSelected:
|
||||||
(i) => context.read<CoreCubit>().setPage(_pages[i].page),
|
(i) => context.read<CoreCubit>().setPage(_pages[i].page),
|
||||||
destinations: _pages.map((p) => p.toRailDestination()).toList(),
|
destinations:
|
||||||
|
_pages
|
||||||
|
.map((p) => p.toRailDestination(state.activeAccountIndex))
|
||||||
|
.toList(),
|
||||||
selectedIndex: _pages.indexWhere((p) => p.page == state.activePage),
|
selectedIndex: _pages.indexWhere((p) => p.page == state.activePage),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
@ -108,7 +127,10 @@ class OkaneNavigationBar extends StatelessWidget {
|
|||||||
(context, state) => NavigationBar(
|
(context, state) => NavigationBar(
|
||||||
onDestinationSelected:
|
onDestinationSelected:
|
||||||
(i) => context.read<CoreCubit>().setPage(_pages[i].page),
|
(i) => context.read<CoreCubit>().setPage(_pages[i].page),
|
||||||
destinations: _pages.map((p) => p.toDestination()).toList(),
|
destinations:
|
||||||
|
_pages
|
||||||
|
.map((p) => p.toDestination(state.activeAccountIndex))
|
||||||
|
.toList(),
|
||||||
selectedIndex: _pages.indexWhere((p) => p.page == state.activePage),
|
selectedIndex: _pages.indexWhere((p) => p.page == state.activePage),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
@ -173,12 +195,13 @@ class OkaneNavigationLayout extends StatelessWidget {
|
|||||||
},
|
},
|
||||||
),
|
),
|
||||||
|
|
||||||
if (p.showAccountName)
|
if (p.showAccountName && state.activeAccountIndex != null)
|
||||||
Padding(
|
Padding(
|
||||||
padding: EdgeInsets.only(left: 8),
|
padding: EdgeInsets.only(left: 8),
|
||||||
child: Text(
|
child: Text(
|
||||||
state
|
state
|
||||||
.accounts[state.activeAccountIndex!]
|
.accounts[state
|
||||||
|
.activeAccountIndex!]
|
||||||
.name!,
|
.name!,
|
||||||
style:
|
style:
|
||||||
Theme.of(
|
Theme.of(
|
||||||
@ -195,7 +218,7 @@ class OkaneNavigationLayout extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
ScreenSize.normal => Column(
|
ScreenSize.normal => Column(
|
||||||
children: [
|
children: [
|
||||||
if (p.showAccountName)
|
if (p.showAccountName && state.activeAccountIndex != null)
|
||||||
AccountIndicator(
|
AccountIndicator(
|
||||||
accountName:
|
accountName:
|
||||||
state
|
state
|
||||||
|
@ -202,7 +202,10 @@ class _AddTransactionWidgetState extends State<AddTransactionWidget> {
|
|||||||
);
|
);
|
||||||
})
|
})
|
||||||
.toList(),
|
.toList(),
|
||||||
hint: "Beneficiary",
|
hint: switch (_selectedDirection) {
|
||||||
|
TransactionDirection.send => "Payee",
|
||||||
|
TransactionDirection.receive => "Payer",
|
||||||
|
},
|
||||||
controller: _beneficiaryTextController,
|
controller: _beneficiaryTextController,
|
||||||
selectedValue: _selectedBeneficiary,
|
selectedValue: _selectedBeneficiary,
|
||||||
onSuggestionTap: (beneficiary) {
|
onSuggestionTap: (beneficiary) {
|
||||||
@ -211,6 +214,30 @@ class _AddTransactionWidgetState extends State<AddTransactionWidget> {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|
||||||
|
Padding(
|
||||||
|
padding: const EdgeInsets.symmetric(vertical: 8),
|
||||||
|
child: SegmentedButton<TransactionDirection>(
|
||||||
|
segments: [
|
||||||
|
ButtonSegment(
|
||||||
|
value: TransactionDirection.send,
|
||||||
|
label: Text("Send"),
|
||||||
|
icon: Icon(Icons.remove),
|
||||||
|
),
|
||||||
|
ButtonSegment(
|
||||||
|
value: TransactionDirection.receive,
|
||||||
|
label: Text("Receive"),
|
||||||
|
icon: Icon(Icons.add),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
selected: <TransactionDirection>{_selectedDirection},
|
||||||
|
multiSelectionEnabled: false,
|
||||||
|
onSelectionChanged: (selection) {
|
||||||
|
setState(() => _selectedDirection = selection.first);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
|
||||||
Padding(
|
Padding(
|
||||||
padding: const EdgeInsets.symmetric(vertical: 8),
|
padding: const EdgeInsets.symmetric(vertical: 8),
|
||||||
child: TextField(
|
child: TextField(
|
||||||
@ -274,29 +301,6 @@ class _AddTransactionWidgetState extends State<AddTransactionWidget> {
|
|||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
|
||||||
Padding(
|
|
||||||
padding: const EdgeInsets.symmetric(vertical: 8),
|
|
||||||
child: SegmentedButton<TransactionDirection>(
|
|
||||||
segments: [
|
|
||||||
ButtonSegment(
|
|
||||||
value: TransactionDirection.send,
|
|
||||||
label: Text("Send"),
|
|
||||||
icon: Icon(Icons.remove),
|
|
||||||
),
|
|
||||||
ButtonSegment(
|
|
||||||
value: TransactionDirection.receive,
|
|
||||||
label: Text("Receive"),
|
|
||||||
icon: Icon(Icons.add),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
selected: <TransactionDirection>{_selectedDirection},
|
|
||||||
multiSelectionEnabled: false,
|
|
||||||
onSelectionChanged: (selection) {
|
|
||||||
setState(() => _selectedDirection = selection.first);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
),
|
|
||||||
|
|
||||||
Align(
|
Align(
|
||||||
alignment: Alignment.centerRight,
|
alignment: Alignment.centerRight,
|
||||||
child: OutlinedButton(
|
child: OutlinedButton(
|
||||||
|
Loading…
Reference in New Issue
Block a user