Fixes for wallet menu

This commit is contained in:
M 2021-12-30 21:14:48 +02:00
parent a1380af681
commit fff0d81294
2 changed files with 44 additions and 61 deletions

View file

@ -16,43 +16,71 @@ class WalletMenu {
WalletMenuItem(
title: S.current.reconnect,
image: Image.asset('assets/images/reconnect_menu.png',
height: 16, width: 16)),
height: 16, width: 16),
handler: () => _presentReconnectAlert(context)),
if (hasRescan)
WalletMenuItem(
title: S.current.rescan,
image: Image.asset('assets/images/filter_icon.png',
height: 16, width: 16, color: Palette.darkBlue)),
height: 16, width: 16, color: Palette.darkBlue),
handler: () => Navigator.of(context).pushNamed(Routes.rescan)),
WalletMenuItem(
title: S.current.wallets,
image: Image.asset('assets/images/wallet_menu.png',
height: 16, width: 16)),
height: 16, width: 16),
handler: () => Navigator.of(context).pushNamed(Routes.walletList)),
WalletMenuItem(
title: S.current.nodes,
image: Image.asset('assets/images/nodes_menu.png',
height: 16, width: 16)),
height: 16, width: 16),
handler: () => Navigator.of(context).pushNamed(Routes.nodeList)),
WalletMenuItem(
title: S.current.show_keys,
image:
Image.asset('assets/images/key_menu.png', height: 16, width: 16)),
Image.asset('assets/images/key_menu.png', height: 16, width: 16),
handler: () {
Navigator.of(context).pushNamed(Routes.auth,
arguments: (bool isAuthenticatedSuccessfully, AuthPageState auth) {
if (isAuthenticatedSuccessfully) {
auth.close();
Navigator.of(auth.context).pushNamed(Routes.showKeys);
}
});
}),
WalletMenuItem(
title: S.current.address_book_menu,
image: Image.asset('assets/images/open_book_menu.png',
height: 16, width: 16)),
height: 16, width: 16),
handler: () => Navigator.of(context).pushNamed(Routes.addressBook)),
if(!isMoneroOnly)
WalletMenuItem(
title: S.current.backup,
image: Image.asset('assets/images/restore_wallet.png',
height: 16,
width: 16,
color: Palette.darkBlue)),
height: 16,
width: 16,
color: Palette.darkBlue),
handler: () {
Navigator
.of(context)
.pushNamed(
Routes.auth,
arguments: (bool isAuthenticatedSuccessfully, AuthPageState auth) {
if (isAuthenticatedSuccessfully) {
auth.close();
Navigator.of(auth.context).pushNamed(Routes.backup);
}
});
}),
WalletMenuItem(
title: S.current.settings_title,
image: Image.asset('assets/images/settings_menu.png',
height: 16, width: 16)),
height: 16, width: 16),
handler: () => Navigator.of(context).pushNamed(Routes.settings)),
WalletMenuItem(
title: S.current.settings_support,
image: Image.asset('assets/images/question_mark.png',
height: 16, width: 16, color: Palette.darkBlue)),
height: 16, width: 16, color: Palette.darkBlue),
handler: () => Navigator.of(context).pushNamed(Routes.support)),
]);
}
@ -62,55 +90,8 @@ class WalletMenu {
final bool hasRescan;
void action(int index) {
var indx = index;
if (index > 0 && !hasRescan) {
indx += 1;
}
switch (indx) {
case 0:
_presentReconnectAlert(context);
break;
case 1:
Navigator.of(context).pushNamed(Routes.rescan);
break;
case 2:
Navigator.of(context).pushNamed(Routes.walletList);
break;
case 3:
Navigator.of(context).pushNamed(Routes.nodeList);
break;
case 4:
Navigator.of(context).pushNamed(Routes.auth,
arguments: (bool isAuthenticatedSuccessfully, AuthPageState auth) {
if (isAuthenticatedSuccessfully) {
auth.close();
Navigator.of(auth.context).pushNamed(Routes.showKeys);
}
});
break;
case 5:
Navigator.of(context).pushNamed(Routes.addressBook);
break;
case 6:
Navigator.of(context).pushNamed(Routes.auth,
arguments: (bool isAuthenticatedSuccessfully, AuthPageState auth) {
if (isAuthenticatedSuccessfully) {
auth.close();
Navigator.of(auth.context).pushNamed(Routes.backup);
}
});
break;
case 7:
Navigator.of(context).pushNamed(Routes.settings);
break;
case 8:
Navigator.of(context).pushNamed(Routes.support);
break;
default:
break;
}
final item = items[index];
item?.handler();
}
Future<void> _presentReconnectAlert(BuildContext context) async {

View file

@ -3,8 +3,10 @@ import 'package:flutter/material.dart';
class WalletMenuItem {
WalletMenuItem({
@required this.title,
@required this.image});
@required this.image,
@required this.handler});
final String title;
final Image image;
final void Function() handler;
}