| 1 | import 'dart:io'; |
| 2 | |
| 3 | import 'package:cake_wallet/generated/i18n.dart'; |
| 4 | import 'package:cake_wallet/routes.dart'; |
| 5 | import 'package:flutter/material.dart'; |
| 6 | |
| 7 | class SettingActions { |
| 8 | final String Function(BuildContext) name; |
| 9 | final String image; |
| 10 | final Key key; |
| 11 | final void Function(BuildContext) onTap; |
| 12 | |
| 13 | SettingActions._({ |
| 14 | required this.key, |
| 15 | required this.name, |
| 16 | required this.image, |
| 17 | required this.onTap, |
| 18 | }); |
| 19 | |
| 20 | static List<SettingActions> all = [ |
| 21 | connectionSettingAction, |
| 22 | walletSettingAction, |
| 23 | addressBookSettingAction, |
| 24 | silentPaymentsSettingAction, |
| 25 | if (Platform.isIOS || Platform.isAndroid) litecoinMwebSettingAction, |
| 26 | if (Platform.isIOS || Platform.isAndroid) exportOutputsAction, |
| 27 | securityBackupSettingAction, |
| 28 | privacySettingAction, |
| 29 | displaySettingAction, |
| 30 | otherSettingAction, |
| 31 | supportSettingAction, |
| 32 | ]; |
| 33 | |
| 34 | static SettingActions silentPaymentsSettingAction = SettingActions._( |
| 35 | key: ValueKey('dashboard_page_menu_widget_silent_payment_settings_button_key'), |
| 36 | name: (context) => S.of(context).silent_payments_settings, |
| 37 | image: 'assets/images/bitcoin_menu.png', |
| 38 | onTap: (BuildContext context) { |
| 39 | Navigator.of(context).pushNamed(Routes.silentPaymentsSettings); |
| 40 | }, |
| 41 | ); |
| 42 | |
| 43 | static SettingActions exportOutputsAction = SettingActions._( |
| 44 | key: ValueKey('dashboard_page_menu_widget_export_outputs_settings_button_key'), |
| 45 | name: (context) => S.of(context).export_outputs, |
| 46 | image: 'assets/new-ui/crypto_full_icons/monero.svg', |
| 47 | onTap: (BuildContext context) { |
| 48 | Navigator.of(context) |
| 49 | .pushNamed(Routes.urqrAnimatedPage, arguments: {'export-outputs': 'export-outputs'}); |
| 50 | }, |
| 51 | ); |
| 52 | |
| 53 | static SettingActions litecoinMwebSettingAction = SettingActions._( |
| 54 | key: ValueKey('dashboard_page_menu_widget_litecoin_mweb_settings_button_key'), |
| 55 | name: (context) => S.of(context).litecoin_mweb_settings, |
| 56 | image: 'assets/images/mweb_logo.png', |
| 57 | onTap: (BuildContext context) { |
| 58 | Navigator.of(context).pushNamed(Routes.mwebSettings); |
| 59 | }, |
| 60 | ); |
| 61 | |
| 62 | static SettingActions connectionSettingAction = SettingActions._( |
| 63 | key: ValueKey('dashboard_page_menu_widget_connection_and_sync_settings_button_key'), |
| 64 | name: (context) => S.of(context).connection_sync, |
| 65 | image: 'assets/images/nodes_menu.png', |
| 66 | onTap: (BuildContext context) { |
| 67 | Navigator.of(context).pushNamed(Routes.connectionSync); |
| 68 | }, |
| 69 | ); |
| 70 | |
| 71 | static SettingActions walletSettingAction = SettingActions._( |
| 72 | key: ValueKey('dashboard_page_menu_widget_wallet_menu_button_key'), |
| 73 | name: (context) => S.of(context).wallets, |
| 74 | image: 'assets/images/wallet_menu.png', |
| 75 | onTap: (BuildContext context) { |
| 76 | Navigator.pop(context); |
| 77 | Navigator.of(context).pushNamed( |
| 78 | Routes.walletList, |
| 79 | arguments: (BuildContext context) => |
| 80 | Navigator.of(context).pushNamedAndRemoveUntil(Routes.dashboard, (route) => false), |
| 81 | ); |
| 82 | }, |
| 83 | ); |
| 84 | |
| 85 | static SettingActions addressBookSettingAction = SettingActions._( |
| 86 | key: ValueKey('dashboard_page_menu_widget_address_book_button_key'), |
| 87 | name: (context) => S.of(context).address_book_menu, |
| 88 | image: 'assets/images/open_book_menu.png', |
| 89 | onTap: (BuildContext context) { |
| 90 | Navigator.of(context).pushNamed(Routes.addressBook); |
| 91 | }, |
| 92 | ); |
| 93 | |
| 94 | static SettingActions securityBackupSettingAction = SettingActions._( |
| 95 | key: ValueKey('dashboard_page_menu_widget_security_and_backup_button_key'), |
| 96 | name: (context) => S.of(context).security_and_backup, |
| 97 | image: 'assets/images/key_menu.png', |
| 98 | onTap: (BuildContext context) { |
| 99 | Navigator.of(context).pushNamed(Routes.securityBackupPage); |
| 100 | }, |
| 101 | ); |
| 102 | |
| 103 | static SettingActions privacySettingAction = SettingActions._( |
| 104 | key: ValueKey('dashboard_page_menu_widget_privacy_settings_button_key'), |
| 105 | name: (context) => S.of(context).privacy, |
| 106 | image: 'assets/images/privacy_menu.png', |
| 107 | onTap: (BuildContext context) { |
| 108 | Navigator.of(context).pushNamed(Routes.privacyPage); |
| 109 | }, |
| 110 | ); |
| 111 | |
| 112 | static SettingActions displaySettingAction = SettingActions._( |
| 113 | key: ValueKey('dashboard_page_menu_widget_display_settings_button_key'), |
| 114 | name: (context) => S.of(context).display_settings, |
| 115 | image: 'assets/images/eye_menu.png', |
| 116 | onTap: (BuildContext context) { |
| 117 | Navigator.of(context).pushNamed(Routes.displaySettingsPage); |
| 118 | }, |
| 119 | ); |
| 120 | |
| 121 | static SettingActions otherSettingAction = SettingActions._( |
| 122 | key: ValueKey('dashboard_page_menu_widget_other_settings_button_key'), |
| 123 | name: (context) => S.of(context).other_settings, |
| 124 | image: 'assets/images/settings_menu.png', |
| 125 | onTap: (BuildContext context) { |
| 126 | Navigator.of(context).pushNamed(Routes.otherSettingsPage); |
| 127 | }, |
| 128 | ); |
| 129 | |
| 130 | static SettingActions supportSettingAction = SettingActions._( |
| 131 | key: ValueKey('dashboard_page_menu_widget_support_settings_button_key'), |
| 132 | name: (context) => S.of(context).settings_support, |
| 133 | image: 'assets/images/question_mark.png', |
| 134 | onTap: (BuildContext context) { |
| 135 | Navigator.of(context).pushNamed(Routes.support); |
| 136 | }, |
| 137 | ); |
| 138 | } |