2020-01-04 19:31:52 +00:00
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:cake_wallet/routes.dart';
|
|
|
|
import 'package:provider/provider.dart';
|
|
|
|
import 'package:cake_wallet/generated/i18n.dart';
|
2020-01-08 12:26:34 +00:00
|
|
|
import 'package:cake_wallet/src/stores/wallet/wallet_store.dart';
|
|
|
|
import 'package:cake_wallet/src/screens/auth/auth_page.dart';
|
2020-05-04 20:12:36 +00:00
|
|
|
import 'package:cake_wallet/src/widgets/alert_with_two_actions.dart';
|
2020-01-04 19:31:52 +00:00
|
|
|
|
2020-08-27 16:54:34 +00:00
|
|
|
// FIXME: terrible design
|
|
|
|
|
2020-01-04 19:31:52 +00:00
|
|
|
class WalletMenu {
|
2020-08-27 16:54:34 +00:00
|
|
|
WalletMenu(this.context, this.reconnect);
|
2020-01-08 12:26:34 +00:00
|
|
|
|
2020-01-04 19:31:52 +00:00
|
|
|
final List<String> items = [
|
|
|
|
S.current.reconnect,
|
|
|
|
S.current.wallets,
|
2020-04-21 18:23:40 +00:00
|
|
|
S.current.nodes,
|
2020-01-04 19:31:52 +00:00
|
|
|
S.current.show_seed,
|
|
|
|
S.current.show_keys,
|
2020-04-21 18:23:40 +00:00
|
|
|
S.current.address_book_menu,
|
|
|
|
S.current.settings_title
|
|
|
|
];
|
|
|
|
|
|
|
|
final List<Image> images = [
|
2020-07-31 15:29:21 +00:00
|
|
|
Image.asset('assets/images/reconnect_menu.png', height: 16, width: 16),
|
|
|
|
Image.asset('assets/images/wallet_menu.png', height: 16, width: 16),
|
|
|
|
Image.asset('assets/images/nodes_menu.png', height: 16, width: 16),
|
|
|
|
Image.asset('assets/images/eye_menu.png', height: 16, width: 16),
|
|
|
|
Image.asset('assets/images/key_menu.png', height: 16, width: 16),
|
|
|
|
Image.asset('assets/images/open_book_menu.png', height: 16, width: 16),
|
|
|
|
Image.asset('assets/images/settings_menu.png', height: 16, width: 16),
|
2020-01-04 19:31:52 +00:00
|
|
|
];
|
|
|
|
|
2020-01-08 12:26:34 +00:00
|
|
|
final BuildContext context;
|
2020-08-27 16:54:34 +00:00
|
|
|
final Future<void> Function() reconnect;
|
2020-01-04 19:31:52 +00:00
|
|
|
|
|
|
|
void action(int index) {
|
|
|
|
switch (index) {
|
|
|
|
case 0:
|
|
|
|
_presentReconnectAlert(context);
|
|
|
|
break;
|
|
|
|
case 1:
|
2020-04-21 18:23:40 +00:00
|
|
|
Navigator.of(context).pushNamed(Routes.walletList);
|
2020-01-04 19:31:52 +00:00
|
|
|
break;
|
|
|
|
case 2:
|
2020-05-04 20:12:36 +00:00
|
|
|
Navigator.of(context).pushNamed(Routes.nodeList);
|
2020-01-04 19:31:52 +00:00
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
Navigator.of(context).pushNamed(Routes.auth,
|
2020-01-08 12:26:34 +00:00
|
|
|
arguments: (bool isAuthenticatedSuccessfully, AuthPageState auth) =>
|
2020-01-04 19:31:52 +00:00
|
|
|
isAuthenticatedSuccessfully
|
2020-09-11 15:52:55 +00:00
|
|
|
? Navigator.of(auth.context).popAndPushNamed(Routes.seed, arguments: false)
|
2020-01-04 19:31:52 +00:00
|
|
|
: null);
|
|
|
|
|
|
|
|
break;
|
|
|
|
case 4:
|
|
|
|
Navigator.of(context).pushNamed(Routes.auth,
|
2020-01-08 12:26:34 +00:00
|
|
|
arguments: (bool isAuthenticatedSuccessfully, AuthPageState auth) =>
|
2020-01-04 19:31:52 +00:00
|
|
|
isAuthenticatedSuccessfully
|
|
|
|
? Navigator.of(auth.context)
|
|
|
|
.popAndPushNamed(Routes.showKeys)
|
|
|
|
: null);
|
|
|
|
break;
|
|
|
|
case 5:
|
2020-04-21 18:23:40 +00:00
|
|
|
Navigator.of(context).pushNamed(Routes.addressBook);
|
2020-01-04 19:31:52 +00:00
|
|
|
break;
|
|
|
|
case 6:
|
2020-04-21 18:23:40 +00:00
|
|
|
Navigator.of(context).pushNamed(Routes.settings);
|
2020-01-04 19:31:52 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-01-08 12:26:34 +00:00
|
|
|
Future<void> _presentReconnectAlert(BuildContext context) async {
|
|
|
|
await showDialog<void>(
|
2020-01-04 19:31:52 +00:00
|
|
|
context: context,
|
|
|
|
builder: (BuildContext context) {
|
2020-05-04 20:12:36 +00:00
|
|
|
return AlertWithTwoActions(
|
|
|
|
alertTitle: S.of(context).reconnection,
|
|
|
|
alertContent: S.of(context).reconnect_alert_text,
|
|
|
|
leftButtonText: S.of(context).ok,
|
|
|
|
rightButtonText: S.of(context).cancel,
|
2020-08-27 16:54:34 +00:00
|
|
|
actionLeftButton: () async {
|
|
|
|
await reconnect?.call();
|
2020-05-04 20:12:36 +00:00
|
|
|
Navigator.of(context).pop();
|
|
|
|
},
|
2020-08-27 16:54:34 +00:00
|
|
|
actionRightButton: () => Navigator.of(context).pop());
|
2020-01-04 19:31:52 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|