Fixes for wallet menu

M committed Dec 30, 2021 at 21:14 UTC fff0d8129490a679be192f7bb4f86ca41ef5e455
2 files changed +44 -61
lib/src/screens/dashboard/wallet_menu.dart
+41 -60
@@ -16,43 +16,71 @@ class WalletMenu {
16 WalletMenuItem(
17 title: S.current.reconnect,
18 image: Image.asset('assets/images/reconnect_menu.png',
19 - height: 16, width: 16)),
19 + height: 16, width: 16),
20 + handler: () => _presentReconnectAlert(context)),
21 if (hasRescan)
22 WalletMenuItem(
23 title: S.current.rescan,
24 image: Image.asset('assets/images/filter_icon.png',
24 - height: 16, width: 16, color: Palette.darkBlue)),
25 + height: 16, width: 16, color: Palette.darkBlue),
26 + handler: () => Navigator.of(context).pushNamed(Routes.rescan)),
27 WalletMenuItem(
28 title: S.current.wallets,
29 image: Image.asset('assets/images/wallet_menu.png',
28 - height: 16, width: 16)),
30 + height: 16, width: 16),
31 + handler: () => Navigator.of(context).pushNamed(Routes.walletList)),
32 WalletMenuItem(
33 title: S.current.nodes,
34 image: Image.asset('assets/images/nodes_menu.png',
32 - height: 16, width: 16)),
35 + height: 16, width: 16),
36 + handler: () => Navigator.of(context).pushNamed(Routes.nodeList)),
37 WalletMenuItem(
38 title: S.current.show_keys,
39 image:
36 - Image.asset('assets/images/key_menu.png', height: 16, width: 16)),
40 + Image.asset('assets/images/key_menu.png', height: 16, width: 16),
41 + handler: () {
42 + Navigator.of(context).pushNamed(Routes.auth,
43 + arguments: (bool isAuthenticatedSuccessfully, AuthPageState auth) {
44 + if (isAuthenticatedSuccessfully) {
45 + auth.close();
46 + Navigator.of(auth.context).pushNamed(Routes.showKeys);
47 + }
48 + });
49 + }),
50 WalletMenuItem(
51 title: S.current.address_book_menu,
52 image: Image.asset('assets/images/open_book_menu.png',
40 - height: 16, width: 16)),
53 + height: 16, width: 16),
54 + handler: () => Navigator.of(context).pushNamed(Routes.addressBook)),
55 if(!isMoneroOnly)
56 WalletMenuItem(
57 title: S.current.backup,
58 image: Image.asset('assets/images/restore_wallet.png',
45 - height: 16,
46 - width: 16,
47 - color: Palette.darkBlue)),
59 + height: 16,
60 + width: 16,
61 + color: Palette.darkBlue),
62 + handler: () {
63 + Navigator
64 + .of(context)
65 + .pushNamed(
66 + Routes.auth,
67 + arguments: (bool isAuthenticatedSuccessfully, AuthPageState auth) {
68 + if (isAuthenticatedSuccessfully) {
69 + auth.close();
70 + Navigator.of(auth.context).pushNamed(Routes.backup);
71 + }
72 + });
73 + }),
74 WalletMenuItem(
75 title: S.current.settings_title,
76 image: Image.asset('assets/images/settings_menu.png',
51 - height: 16, width: 16)),
77 + height: 16, width: 16),
78 + handler: () => Navigator.of(context).pushNamed(Routes.settings)),
79 WalletMenuItem(
80 title: S.current.settings_support,
81 image: Image.asset('assets/images/question_mark.png',
55 - height: 16, width: 16, color: Palette.darkBlue)),
82 + height: 16, width: 16, color: Palette.darkBlue),
83 + handler: () => Navigator.of(context).pushNamed(Routes.support)),
84 ]);
85 }
86
@@ -62,55 +90,8 @@ class WalletMenu {
90 final bool hasRescan;
91
92 void action(int index) {
65 - var indx = index;
66 -
67 - if (index > 0 && !hasRescan) {
68 - indx += 1;
69 - }
70 -
71 - switch (indx) {
72 - case 0:
73 - _presentReconnectAlert(context);
74 - break;
75 - case 1:
76 - Navigator.of(context).pushNamed(Routes.rescan);
77 - break;
78 - case 2:
79 - Navigator.of(context).pushNamed(Routes.walletList);
80 - break;
81 - case 3:
82 - Navigator.of(context).pushNamed(Routes.nodeList);
83 - break;
84 - case 4:
85 - Navigator.of(context).pushNamed(Routes.auth,
86 - arguments: (bool isAuthenticatedSuccessfully, AuthPageState auth) {
87 - if (isAuthenticatedSuccessfully) {
88 - auth.close();
89 - Navigator.of(auth.context).pushNamed(Routes.showKeys);
90 - }
91 - });
92 - break;
93 - case 5:
94 - Navigator.of(context).pushNamed(Routes.addressBook);
95 - break;
96 - case 6:
97 - Navigator.of(context).pushNamed(Routes.auth,
98 - arguments: (bool isAuthenticatedSuccessfully, AuthPageState auth) {
99 - if (isAuthenticatedSuccessfully) {
100 - auth.close();
101 - Navigator.of(auth.context).pushNamed(Routes.backup);
102 - }
103 - });
104 - break;
105 - case 7:
106 - Navigator.of(context).pushNamed(Routes.settings);
107 - break;
108 - case 8:
109 - Navigator.of(context).pushNamed(Routes.support);
110 - break;
111 - default:
112 - break;
113 - }
93 + final item = items[index];
94 + item?.handler();
95 }
96
97 Future<void> _presentReconnectAlert(BuildContext context) async {
lib/src/screens/dashboard/wallet_menu_item.dart
+3 -1
@@ -3,8 +3,10 @@ import 'package:flutter/material.dart';
3 class WalletMenuItem {
4 WalletMenuItem({
5 @required this.title,
6 - @required this.image});
6 + @required this.image,
7 + @required this.handler});
8
9 final String title;
10 final Image image;
11 + final void Function() handler;
12 }
\ No newline at end of file