diff --git a/assets/images/2.0x/copy_content.png b/assets/images/2.0x/copy_content.png new file mode 100644 index 000000000..cf639846a Binary files /dev/null and b/assets/images/2.0x/copy_content.png differ diff --git a/assets/images/2.0x/share.png b/assets/images/2.0x/share.png new file mode 100644 index 000000000..dc4610066 Binary files /dev/null and b/assets/images/2.0x/share.png differ diff --git a/assets/images/3.0x/copy_content.png b/assets/images/3.0x/copy_content.png new file mode 100644 index 000000000..eb5f094b6 Binary files /dev/null and b/assets/images/3.0x/copy_content.png differ diff --git a/assets/images/3.0x/share.png b/assets/images/3.0x/share.png new file mode 100644 index 000000000..8958ae5ed Binary files /dev/null and b/assets/images/3.0x/share.png differ diff --git a/assets/images/copy_content.png b/assets/images/copy_content.png new file mode 100644 index 000000000..9a433437a Binary files /dev/null and b/assets/images/copy_content.png differ diff --git a/assets/images/share.png b/assets/images/share.png new file mode 100644 index 000000000..da95e38ba Binary files /dev/null and b/assets/images/share.png differ diff --git a/lib/generated/i18n.dart b/lib/generated/i18n.dart index a6c0227d3..7a53e3bb6 100644 --- a/lib/generated/i18n.dart +++ b/lib/generated/i18n.dart @@ -23,6 +23,7 @@ class S implements WidgetsLocalizations { String get account => "Account"; String get accounts => "Accounts"; + String get accounts_subaddresses => "Accounts and subaddresses"; String get add => "Add"; String get add_new_node => "Add new node"; String get add_new_word => "Add new word"; @@ -48,6 +49,7 @@ class S implements WidgetsLocalizations { String get change_currency => "Change Currency"; String get change_exchange_provider => "Change Exchange Provider"; String get change_language => "Change language"; + String get choose_account => "Choose account"; String get choose_wallet_currency => "Please choose wallet currency:"; String get clear => "Clear"; String get confirm => "Confirm"; @@ -60,6 +62,7 @@ class S implements WidgetsLocalizations { String get copy_address => "Copy Address"; String get copy_id => "Copy ID"; String get create_new => "Create New Wallet"; + String get create_new_account => "Create new account"; String get delete => "Delete"; String get digit_pin => "-digit PIN"; String get edit => "Edit"; @@ -126,6 +129,7 @@ class S implements WidgetsLocalizations { String get remove => "Remove"; String get remove_node => "Remove node"; String get remove_node_message => "Are you sure that you want to remove selected node?"; + String get rename => "Rename"; String get rescan => "Rescan"; String get reset => "Reset"; String get restore_active_seed => "Active seed"; @@ -448,6 +452,8 @@ class $de extends S { @override String get trade_details_fetching => "Holen"; @override + String get create_new_account => "Neues Konto erstellen"; + @override String get buy => "Kaufen"; @override String get confirm_sending => "Bestätigen Sie das Senden"; @@ -598,6 +604,8 @@ class $de extends S { @override String get change_language => "Sprache ändern"; @override + String get accounts_subaddresses => "Konten und Unteradressen"; + @override String get wallet_name => "Walletname"; @override String get error_text_payment_id => "Die Zahlungs-ID kann nur 16 bis 64 hexadezimale Zeichen enthalten"; @@ -686,6 +694,8 @@ class $de extends S { @override String get settings_fee_priority => "Gebührenpriorität"; @override + String get rename => "Umbenennen"; + @override String get restore_active_seed => "Aktives Seed"; @override String get settings_personal => "persönlich"; @@ -712,6 +722,8 @@ class $de extends S { @override String get spend_key_private => "Schlüssel ausgeben (geheim)"; @override + String get choose_account => "Konto auswählen"; + @override String get settings_only_trades => "Nur Trades"; @override String get trade_state_to_be_created => "Geschaffen werden"; @@ -1032,6 +1044,8 @@ class $hi extends S { @override String get trade_details_fetching => "ला रहा है"; @override + String get create_new_account => "नया खाता बनाएँ"; + @override String get buy => "खरीदें"; @override String get confirm_sending => "भेजने की पुष्टि करें"; @@ -1182,6 +1196,8 @@ class $hi extends S { @override String get change_language => "भाषा बदलो"; @override + String get accounts_subaddresses => "लेखा और उपदेस"; + @override String get wallet_name => "बटुए का नाम"; @override String get error_text_payment_id => "पेमेंट आईडी केवल हेक्स में 16 से 64 चार्ट तक हो सकती है"; @@ -1270,6 +1286,8 @@ class $hi extends S { @override String get settings_fee_priority => "शुल्क प्राथमिकता"; @override + String get rename => "नाम बदलें"; + @override String get restore_active_seed => "सक्रिय बीज"; @override String get settings_personal => "निजी"; @@ -1296,6 +1314,8 @@ class $hi extends S { @override String get spend_key_private => "खर्च करना (निजी)"; @override + String get choose_account => "खाता चुनें"; + @override String get settings_only_trades => "केवल ट्रेड करता है"; @override String get trade_state_to_be_created => "बनाए जाने के लिए"; @@ -1616,6 +1636,8 @@ class $ru extends S { @override String get trade_details_fetching => "Получение"; @override + String get create_new_account => "Создать новый аккаунт"; + @override String get buy => "Купить"; @override String get confirm_sending => "Подтвердить отправку"; @@ -1766,6 +1788,8 @@ class $ru extends S { @override String get change_language => "Изменить язык"; @override + String get accounts_subaddresses => "Аккаунты и субадреса"; + @override String get wallet_name => "Имя кошелька"; @override String get error_text_payment_id => "Идентификатор платежа может содержать от 16 до 64 символов в hex"; @@ -1854,6 +1878,8 @@ class $ru extends S { @override String get settings_fee_priority => "Приоритет транзакции"; @override + String get rename => "Переименовать"; + @override String get restore_active_seed => "Активная мнемоническая фраза"; @override String get settings_personal => "Персональные"; @@ -1880,6 +1906,8 @@ class $ru extends S { @override String get spend_key_private => "Приватный ключ траты"; @override + String get choose_account => "Выберите аккаунт"; + @override String get settings_only_trades => "Сделки"; @override String get trade_state_to_be_created => "Будет создана"; @@ -2200,6 +2228,8 @@ class $ko extends S { @override String get trade_details_fetching => "가져 오는 중"; @override + String get create_new_account => "새 계정을 만들"; + @override String get buy => "구입"; @override String get confirm_sending => "전송 확인"; @@ -2350,6 +2380,8 @@ class $ko extends S { @override String get change_language => "언어 변경"; @override + String get accounts_subaddresses => "계정 및 하위 주소"; + @override String get wallet_name => "지갑 이름"; @override String get error_text_payment_id => "지불 ID는 16 ~ 64 자의 16 진 문자 만 포함 할 수 있습니다"; @@ -2438,6 +2470,8 @@ class $ko extends S { @override String get settings_fee_priority => "수수료 우선"; @override + String get rename => "이름 바꾸기"; + @override String get restore_active_seed => "활성 종자"; @override String get settings_personal => "개인적인"; @@ -2464,6 +2498,8 @@ class $ko extends S { @override String get spend_key_private => "지출 키 (은밀한)"; @override + String get choose_account => "계정을 선택하십시오"; + @override String get settings_only_trades => "거래 만"; @override String get trade_state_to_be_created => "만들려면"; @@ -2784,6 +2820,8 @@ class $pt extends S { @override String get trade_details_fetching => "Buscando"; @override + String get create_new_account => "Criar nova conta"; + @override String get buy => "Comprar"; @override String get confirm_sending => "Confirmar o envio"; @@ -2934,6 +2972,8 @@ class $pt extends S { @override String get change_language => "Mudar idioma"; @override + String get accounts_subaddresses => "Contas e sub-endereços"; + @override String get wallet_name => "Nome da carteira"; @override String get error_text_payment_id => "O ID de pagamento pode conter apenas de 16 a 64 caracteres em hexadecimal"; @@ -3022,6 +3062,8 @@ class $pt extends S { @override String get settings_fee_priority => "Prioridade da taxa"; @override + String get rename => "Renomear"; + @override String get restore_active_seed => "Semente ativa"; @override String get settings_personal => "Pessoal"; @@ -3048,6 +3090,8 @@ class $pt extends S { @override String get spend_key_private => "Chave de gastos (privada)"; @override + String get choose_account => "Escolha uma conta"; + @override String get settings_only_trades => "Somente trocas"; @override String get trade_state_to_be_created => "A ser criada"; @@ -3298,7 +3342,7 @@ class $uk extends S { @override String get transaction_details_recipient_address => "Адреса отримувача"; @override - String get receive_amount => "Баланс"; + String get receive_amount => "Сума"; @override String get settings_allow_biometrical_authentication => "Включити біометричну аутентифікацію"; @override @@ -3368,6 +3412,8 @@ class $uk extends S { @override String get trade_details_fetching => "Отримання"; @override + String get create_new_account => "Створити новий акаунт"; + @override String get buy => "Купити"; @override String get confirm_sending => "Підтвердити відправлення"; @@ -3518,6 +3564,8 @@ class $uk extends S { @override String get change_language => "Змінити мову"; @override + String get accounts_subaddresses => "Акаунти та субадреси"; + @override String get wallet_name => "Ім'я гаманця"; @override String get error_text_payment_id => "Ідентифікатор платежу може містити від 16 до 64 символів в hex"; @@ -3606,6 +3654,8 @@ class $uk extends S { @override String get settings_fee_priority => "Пріоритет транзакції"; @override + String get rename => "Перейменувати"; + @override String get restore_active_seed => "Активна мнемонічна фраза"; @override String get settings_personal => "Персональні"; @@ -3632,6 +3682,8 @@ class $uk extends S { @override String get spend_key_private => "Приватний ключ витрати"; @override + String get choose_account => "Оберіть акаунт"; + @override String get settings_only_trades => "Операції"; @override String get trade_state_to_be_created => "Буде створена"; @@ -3952,6 +4004,8 @@ class $ja extends S { @override String get trade_details_fetching => "フェッチング"; @override + String get create_new_account => "新しいアカウントを作成する"; + @override String get buy => "購入"; @override String get confirm_sending => "送信を確認"; @@ -4102,6 +4156,8 @@ class $ja extends S { @override String get change_language => "言語を変えてください"; @override + String get accounts_subaddresses => "アカウントとサブアドレス"; + @override String get wallet_name => "ウォレット名"; @override String get error_text_payment_id => "支払いIDには、16進数で16〜64文字しか含めることができません"; @@ -4190,6 +4246,8 @@ class $ja extends S { @override String get settings_fee_priority => "料金優先"; @override + String get rename => "リネーム"; + @override String get restore_active_seed => "アクティブシード"; @override String get settings_personal => "パーソナル"; @@ -4216,6 +4274,8 @@ class $ja extends S { @override String get spend_key_private => "キーを使う (プライベート)"; @override + String get choose_account => "アカウントを選択"; + @override String get settings_only_trades => "取引のみ"; @override String get trade_state_to_be_created => "作成される"; @@ -4540,6 +4600,8 @@ class $pl extends S { @override String get trade_details_fetching => "Ujmujący"; @override + String get create_new_account => "Stwórz nowe konto"; + @override String get buy => "Kup"; @override String get confirm_sending => "Potwierdź wysłanie"; @@ -4690,6 +4752,8 @@ class $pl extends S { @override String get change_language => "Zmień język"; @override + String get accounts_subaddresses => "Konta i podadresy"; + @override String get wallet_name => "Nazwa portfela"; @override String get error_text_payment_id => "ID może zawierać od 16 do 64 znaków w formacie szesnastkowym"; @@ -4778,6 +4842,8 @@ class $pl extends S { @override String get settings_fee_priority => "Priorytet opłaty"; @override + String get rename => "Przemianować"; + @override String get restore_active_seed => "Aktywne nasiona"; @override String get settings_personal => "Osobisty"; @@ -4804,6 +4870,8 @@ class $pl extends S { @override String get spend_key_private => "Wydaj klucz (prywatny)"; @override + String get choose_account => "Wybierz konto"; + @override String get settings_only_trades => "Tylko transakcje"; @override String get trade_state_to_be_created => "Zostać stworzonym"; @@ -5124,6 +5192,8 @@ class $es extends S { @override String get trade_details_fetching => "Cargando"; @override + String get create_new_account => "Crear una nueva cuenta"; + @override String get buy => "Comprar"; @override String get confirm_sending => "Confirmar envío"; @@ -5274,6 +5344,8 @@ class $es extends S { @override String get change_language => "Cambiar idioma"; @override + String get accounts_subaddresses => "Cuentas y subdirecciones"; + @override String get wallet_name => "Nombre de la billetera"; @override String get error_text_payment_id => "La ID de pago solo puede contener de 16 a 64 caracteres en hexadecimal"; @@ -5362,6 +5434,8 @@ class $es extends S { @override String get settings_fee_priority => "Prioridad de tasa"; @override + String get rename => "Rebautizar"; + @override String get restore_active_seed => "Semilla activa"; @override String get settings_personal => "Personal"; @@ -5388,6 +5462,8 @@ class $es extends S { @override String get spend_key_private => "Spend clave (privado)"; @override + String get choose_account => "Elegir cuenta"; + @override String get settings_only_trades => "Solo comercia"; @override String get trade_state_to_be_created => "Ser creado"; @@ -5708,6 +5784,8 @@ class $nl extends S { @override String get trade_details_fetching => "Ophalen"; @override + String get create_new_account => "Creëer een nieuw account"; + @override String get buy => "Kopen"; @override String get confirm_sending => "Bevestig verzending"; @@ -5858,6 +5936,8 @@ class $nl extends S { @override String get change_language => "Verander de taal"; @override + String get accounts_subaddresses => "Accounts en subadressen"; + @override String get wallet_name => "Portemonnee naam"; @override String get error_text_payment_id => "Betalings-ID kan alleen 16 tot 64 tekens bevatten in hexadecimale volgorde"; @@ -5946,6 +6026,8 @@ class $nl extends S { @override String get settings_fee_priority => "Tariefprioriteit"; @override + String get rename => "Hernoemen"; + @override String get restore_active_seed => "Actief zaad"; @override String get settings_personal => "Persoonlijk"; @@ -5972,6 +6054,8 @@ class $nl extends S { @override String get spend_key_private => "Sleutel uitgeven (privaat)"; @override + String get choose_account => "Kies account"; + @override String get settings_only_trades => "Alleen handel"; @override String get trade_state_to_be_created => "Om gecreëerd te worden"; @@ -6292,6 +6376,8 @@ class $zh extends S { @override String get trade_details_fetching => "正在取得"; @override + String get create_new_account => "建立新帳戶"; + @override String get buy => "購買"; @override String get confirm_sending => "确认发送"; @@ -6442,6 +6528,8 @@ class $zh extends S { @override String get change_language => "改變語言"; @override + String get accounts_subaddresses => "帳戶和子地址"; + @override String get wallet_name => "钱包名称"; @override String get error_text_payment_id => "付款ID只能包含16到64个字符(十六进制)"; @@ -6530,6 +6618,8 @@ class $zh extends S { @override String get settings_fee_priority => "费用优先"; @override + String get rename => "改名"; + @override String get restore_active_seed => "活性種子"; @override String get settings_personal => "个人"; @@ -6556,6 +6646,8 @@ class $zh extends S { @override String get spend_key_private => "支出金钥 (私人的)"; @override + String get choose_account => "選擇帳號"; + @override String get settings_only_trades => "只交易"; @override String get trade_state_to_be_created => "待创建"; diff --git a/lib/router.dart b/lib/router.dart index f2c0a554a..ff66ef627 100644 --- a/lib/router.dart +++ b/lib/router.dart @@ -68,7 +68,6 @@ import 'package:cake_wallet/src/screens/disclaimer/disclaimer_page.dart'; import 'package:cake_wallet/src/screens/seed_language/seed_language_page.dart'; import 'package:cake_wallet/src/screens/transaction_details/transaction_details_page.dart'; import 'package:cake_wallet/src/screens/accounts/account_page.dart'; -import 'package:cake_wallet/src/screens/accounts/account_list_page.dart'; import 'package:cake_wallet/src/screens/address_book/address_book_page.dart'; import 'package:cake_wallet/src/screens/address_book/contact_page.dart'; import 'package:cake_wallet/src/screens/show_keys/show_keys_page.dart'; @@ -242,7 +241,10 @@ class Router { builder: (_) => MultiProvider(providers: [ Provider( create: (_) => - SubaddressListStore(walletService: walletService)) + SubaddressListStore(walletService: walletService)), + Provider( + create: (_) => + AccountListStore(walletService: walletService)) ], child: ReceivePage())); case Routes.transactionDetails: @@ -256,7 +258,7 @@ class Router { builder: (_) => Provider( create: (_) => SubadrressCreationStore(walletService: walletService), - child: NewSubaddressPage())); + child: NewSubaddressPage(subaddress: settings.arguments as Subaddress,))); case Routes.disclaimer: return CupertinoPageRoute(builder: (_) => DisclaimerPage()); @@ -325,17 +327,6 @@ class Router { authenticationStore: authenticationStore); }); - case Routes.accountList: - return MaterialPageRoute( - builder: (context) { - return MultiProvider(providers: [ - Provider( - create: (_) => - AccountListStore(walletService: walletService)), - ], child: AccountListPage()); - }, - fullscreenDialog: true); - case Routes.accountCreation: return CupertinoPageRoute(builder: (context) { return Provider( diff --git a/lib/routes.dart b/lib/routes.dart index 9fc3a941f..87c587da5 100644 --- a/lib/routes.dart +++ b/lib/routes.dart @@ -25,7 +25,6 @@ class Routes { static const newNode = '/new_node_list'; static const login = '/login'; static const splash = '/splash'; - static const accountList = '/account_list'; static const accountCreation = '/account_new'; static const addressBook = '/address_book'; static const pickerAddressBook = '/picker_address_book'; diff --git a/lib/src/domain/monero/subaddress_list.dart b/lib/src/domain/monero/subaddress_list.dart index 88af93740..5da67b39f 100644 --- a/lib/src/domain/monero/subaddress_list.dart +++ b/lib/src/domain/monero/subaddress_list.dart @@ -50,7 +50,7 @@ class SubaddressList { {int accountIndex, int addressIndex, String label}) async { await subaddress_list.setLabelForSubaddress( accountIndex: accountIndex, addressIndex: addressIndex, label: label); - await update(); + await update(accountIndex: accountIndex); } Future refresh({int accountIndex}) async { diff --git a/lib/src/screens/accounts/account_list_page.dart b/lib/src/screens/accounts/account_list_page.dart index 00be33fe5..3abcfe126 100644 --- a/lib/src/screens/accounts/account_list_page.dart +++ b/lib/src/screens/accounts/account_list_page.dart @@ -1,120 +1,153 @@ +import 'dart:ui'; import 'package:provider/provider.dart'; import 'package:flutter/material.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter_mobx/flutter_mobx.dart'; -import 'package:flutter_slidable/flutter_slidable.dart'; import 'package:cake_wallet/palette.dart'; import 'package:cake_wallet/routes.dart'; import 'package:cake_wallet/generated/i18n.dart'; import 'package:cake_wallet/src/stores/account_list/account_list_store.dart'; +import 'package:cake_wallet/src/screens/accounts/widgets/account_tile.dart'; import 'package:cake_wallet/src/stores/wallet/wallet_store.dart'; -import 'package:cake_wallet/src/screens/base_page.dart'; -class AccountListPage extends BasePage { - @override - String get title => S.current.accounts; +class AccountListPage extends StatefulWidget { + AccountListPage({@required this.accountListStore}); + + final AccountListStore accountListStore; @override - Widget trailing(BuildContext context) { - final accountListStore = Provider.of(context); + AccountListPageForm createState() => AccountListPageForm(accountListStore); +} - return Container( - width: 28.0, - height: 28.0, - decoration: BoxDecoration( - shape: BoxShape.circle, color: Theme.of(context).selectedRowColor), - child: Stack( - alignment: Alignment.center, - children: [ - Icon(Icons.add, color: Palette.violet, size: 22.0), - ButtonTheme( - minWidth: 28.0, - height: 28.0, - child: FlatButton( - shape: CircleBorder(), - onPressed: () async { - await Navigator.of(context) - .pushNamed(Routes.accountCreation); - accountListStore.updateAccountList(); - }, - child: Offstage()), - ) - ], - )); - } +class AccountListPageForm extends State { + AccountListPageForm(this.accountListStore); + + final AccountListStore accountListStore; @override - Widget body(BuildContext context) { - final accountListStore = Provider.of(context); + Widget build(BuildContext context) { final walletStore = Provider.of(context); - final currentColor = Theme.of(context).selectedRowColor; - final notCurrentColor = Theme.of(context).backgroundColor; - - return Container( - padding: EdgeInsets.only(top: 10, bottom: 20), - child: Observer(builder: (_) { - final accounts = accountListStore.accounts; - return ListView.builder( - itemCount: accounts == null ? 0 : accounts.length, - itemBuilder: (BuildContext context, int index) { - final account = accounts[index]; - - return Observer(builder: (_) { - final isCurrent = walletStore.account.id == account.id; - - return Slidable( - key: Key(account.id.toString()), - actionPane: SlidableDrawerActionPane(), - child: Container( - color: isCurrent ? currentColor : notCurrentColor, - child: Column( - children: [ - ListTile( - title: Text( - account.label, - style: TextStyle( - fontSize: 16.0, - color: Theme.of(context) - .primaryTextTheme - .headline - .color), - ), - onTap: () { - if (isCurrent) { - return; - } - - walletStore.setAccount(account); - Navigator.of(context).pop(); - }, - ), - Divider( - color: Theme.of(context).dividerTheme.color, - height: 1.0, - ) - ], + return GestureDetector( + onTap: () => Navigator.of(context).pop(), + child: Container( + color: Colors.transparent, + child: BackdropFilter( + filter: ImageFilter.blur(sigmaX: 3.0, sigmaY: 3.0), + child: Container( + decoration: BoxDecoration(color: PaletteDark.historyPanel.withOpacity(0.75)), + child: Center( + child: Column( + mainAxisSize: MainAxisSize.min, + children: [ + Container( + padding: EdgeInsets.only(left: 24, right: 24), + child: Text( + S.of(context).choose_account, + textAlign: TextAlign.center, + style: TextStyle( + fontSize: 18, + fontWeight: FontWeight.bold, + decoration: TextDecoration.none, + color: Colors.white + ), ), ), - secondaryActions: [ - IconSlideAction( - caption: S.of(context).edit, - color: Colors.blue, - icon: Icons.edit, - onTap: () async { - await Navigator.of(context).pushNamed( - Routes.accountCreation, - arguments: account); - // await accountListStore.updateAccountList().then((_) { - // if (isCurrent) walletStore.setAccount(accountListStore.accounts[index]); - // }); - }, - ) - ], - ); - }); - }); - }), + Padding( + padding: EdgeInsets.only(left: 24, right: 24, top: 24), + child: GestureDetector( + onTap: () => null, + child: ClipRRect( + borderRadius: BorderRadius.all(Radius.circular(14)), + child: Container( + height: 296, + color: PaletteDark.menuList, + child: Column( + children: [ + Expanded( + child: Observer( + builder: (_) { + final accounts = accountListStore.accounts; + + return ListView.separated( + separatorBuilder: (context, index) => Divider( + color: PaletteDark.mainBackgroundColor, + height: 1, + ), + itemCount: accounts == null ? 0 : accounts.length, + itemBuilder: (context, index) { + final account = accounts[index]; + + return Observer( + builder: (_) { + final isCurrent = walletStore.account.id == account.id; + + return AccountTile( + isCurrent: isCurrent, + accountName: account.label, + onTap: () { + if (isCurrent) { + return; + } + + walletStore.setAccount(account); + Navigator.of(context).pop(); + } + ); + } + ); + }, + ); + } + ) + ), + GestureDetector( + onTap: () async { + await Navigator.of(context) + .pushNamed(Routes.accountCreation); + accountListStore.updateAccountList(); + }, + child: Container( + height: 62, + color: Colors.white, + padding: EdgeInsets.only(left: 24, right: 24), + child: Center( + child: Row( + mainAxisSize: MainAxisSize.min, + children: [ + Icon( + Icons.add, + color: PaletteDark.historyPanel, + ), + Padding( + padding: EdgeInsets.only(left: 5), + child: Text( + S.of(context).create_new_account, + style: TextStyle( + fontSize: 15, + fontWeight: FontWeight.w600, + color: PaletteDark.historyPanel, + decoration: TextDecoration.none, + ), + ), + ) + ], + ), + ), + ), + ) + ], + ), + ), + ), + ), + ) + ], + ), + ), + ), + ), + ), ); } } diff --git a/lib/src/screens/accounts/account_page.dart b/lib/src/screens/accounts/account_page.dart index 4c4011aa9..4498857a4 100644 --- a/lib/src/screens/accounts/account_page.dart +++ b/lib/src/screens/accounts/account_page.dart @@ -8,6 +8,7 @@ import 'package:cake_wallet/src/widgets/primary_button.dart'; import 'package:cake_wallet/src/screens/base_page.dart'; import 'package:cake_wallet/src/domain/monero/account.dart'; import 'package:cake_wallet/palette.dart'; +import 'package:cake_wallet/src/widgets/base_text_form_field.dart'; class AccountPage extends BasePage { AccountPage({this.account}); @@ -15,7 +16,10 @@ class AccountPage extends BasePage { final Account account; @override - String get title => 'Account'; + String get title => S.current.account; + + @override + Color get backgroundColor => PaletteDark.historyPanel; @override Widget body(BuildContext context) => AccountForm(account); @@ -50,30 +54,31 @@ class AccountFormState extends State { Widget build(BuildContext context) { final accountListStore = Provider.of(context); + _textController.addListener(() { + if (_textController.text.isNotEmpty) { + accountListStore.setDisabledStatus(false); + } else { + accountListStore.setDisabledStatus(true); + } + }); + return Form( key: _formKey, child: Container( - padding: EdgeInsets.all(20.0), + color: PaletteDark.historyPanel, + padding: EdgeInsets.all(24.0), child: Column( children: [ Expanded( child: Center( - child: TextFormField( - decoration: InputDecoration( - hintStyle: TextStyle(color: Theme.of(context).hintColor), + child: BaseTextFormField( + controller: _textController, hintText: S.of(context).account, - focusedBorder: UnderlineInputBorder( - borderSide: - BorderSide(color: Palette.cakeGreen, width: 2.0)), - enabledBorder: UnderlineInputBorder( - borderSide: BorderSide( - color: Theme.of(context).focusColor, width: 1.0))), - controller: _textController, - validator: (value) { - accountListStore.validateAccountName(value); - return accountListStore.errorMessage; - }, - ), + validator: (value) { + accountListStore.validateAccountName(value); + return accountListStore.errorMessage; + }, + ) )), Observer( builder: (_) => LoadingPrimaryButton( @@ -93,13 +98,11 @@ class AccountFormState extends State { Navigator.of(context).pop(_textController.text); }, text: - widget.account != null ? 'Rename' : S.of(context).add, - color: Theme.of(context) - .primaryTextTheme - .button - .backgroundColor, - textColor: Theme.of(context).primaryTextTheme.button.color, + widget.account != null ? S.of(context).rename : S.of(context).add, + color: Colors.green, + textColor: Colors.white, isLoading: accountListStore.isAccountCreating, + isDisabled: accountListStore.isDisabledStatus, )) ], ), diff --git a/lib/src/screens/accounts/widgets/account_tile.dart b/lib/src/screens/accounts/widgets/account_tile.dart new file mode 100644 index 000000000..ba98d73ab --- /dev/null +++ b/lib/src/screens/accounts/widgets/account_tile.dart @@ -0,0 +1,39 @@ +import 'package:flutter/material.dart'; +import 'package:cake_wallet/palette.dart'; + +class AccountTile extends StatelessWidget { + AccountTile({ + @required this.isCurrent, + @required this.accountName, + @required this.onTap + }); + + final bool isCurrent; + final String accountName; + final VoidCallback onTap; + + @override + Widget build(BuildContext context) { + final color = isCurrent ? PaletteDark.menuHeader : Colors.transparent; + final textColor = isCurrent ? Colors.blue : Colors.white; + + return GestureDetector( + onTap: onTap, + child: Container( + height: 77, + padding: EdgeInsets.only(left: 24, right: 24), + alignment: Alignment.centerLeft, + color: color, + child: Text( + accountName, + style: TextStyle( + fontSize: 18, + fontWeight: FontWeight.bold, + color: textColor, + decoration: TextDecoration.none, + ), + ), + ), + ); + } +} \ No newline at end of file diff --git a/lib/src/screens/dashboard/widgets/wallet_card.dart b/lib/src/screens/dashboard/widgets/wallet_card.dart index 4c4f7a511..73a2aa2d3 100644 --- a/lib/src/screens/dashboard/widgets/wallet_card.dart +++ b/lib/src/screens/dashboard/widgets/wallet_card.dart @@ -12,7 +12,8 @@ import 'package:flutter_mobx/flutter_mobx.dart'; import 'package:cake_wallet/palette.dart'; import 'package:cake_wallet/generated/i18n.dart'; import 'package:cake_wallet/src/domain/common/sync_status.dart'; -import 'package:cake_wallet/src/screens/receive/qr_image.dart'; +import 'package:cake_wallet/src/screens/receive/widgets/qr_image.dart'; +import 'package:cake_wallet/routes.dart'; class WalletCard extends StatefulWidget { @override @@ -425,12 +426,14 @@ class WalletCardState extends State { color: PaletteDark.walletCardSubAddressField ), child: InkWell( - onTap: () {}, + onTap: () => Navigator.of(context, + rootNavigator: true) + .pushNamed(Routes.receive), child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Text( - S.current.subaddresses, + S.of(context).accounts_subaddresses, style: TextStyle( fontSize: 14, color: Colors.white diff --git a/lib/src/screens/exchange_trade/exchange_trade_page.dart b/lib/src/screens/exchange_trade/exchange_trade_page.dart index 418b4e7d9..8409f9838 100644 --- a/lib/src/screens/exchange_trade/exchange_trade_page.dart +++ b/lib/src/screens/exchange_trade/exchange_trade_page.dart @@ -13,7 +13,7 @@ import 'package:cake_wallet/src/stores/send/send_store.dart'; import 'package:cake_wallet/src/stores/send/sending_state.dart'; import 'package:cake_wallet/src/stores/wallet/wallet_store.dart'; import 'package:cake_wallet/src/screens/exchange_trade/widgets/copy_button.dart'; -import 'package:cake_wallet/src/screens/receive/qr_image.dart'; +import 'package:cake_wallet/src/screens/receive/widgets/qr_image.dart'; import 'package:cake_wallet/src/screens/base_page.dart'; import 'package:cake_wallet/src/screens/exchange_trade/widgets/timer_widget.dart'; import 'package:cake_wallet/src/widgets/primary_button.dart'; diff --git a/lib/src/screens/receive/receive_page.dart b/lib/src/screens/receive/receive_page.dart index 718f2bb1c..91db780d3 100644 --- a/lib/src/screens/receive/receive_page.dart +++ b/lib/src/screens/receive/receive_page.dart @@ -3,18 +3,26 @@ import 'package:flutter/cupertino.dart'; import 'package:flutter/services.dart'; import 'package:flutter_mobx/flutter_mobx.dart'; import 'package:esys_flutter_share/esys_flutter_share.dart'; +import 'package:flutter_slidable/flutter_slidable.dart'; import 'package:provider/provider.dart'; import 'package:cake_wallet/routes.dart'; import 'package:cake_wallet/palette.dart'; import 'package:cake_wallet/generated/i18n.dart'; import 'package:cake_wallet/src/stores/subaddress_list/subaddress_list_store.dart'; import 'package:cake_wallet/src/stores/wallet/wallet_store.dart'; -import 'package:cake_wallet/src/screens/receive/qr_image.dart'; +import 'package:cake_wallet/src/screens/receive/widgets/qr_image.dart'; import 'package:cake_wallet/src/screens/base_page.dart'; +import 'package:cake_wallet/src/screens/accounts/account_list_page.dart'; +import 'package:cake_wallet/src/stores/account_list/account_list_store.dart'; +import 'package:cake_wallet/src/screens/receive/widgets/header_tile.dart'; +import 'package:cake_wallet/src/widgets/base_text_form_field.dart'; class ReceivePage extends BasePage { @override - bool get isModalBackButton => true; + Color get backgroundColor => PaletteDark.mainBackgroundColor; + + @override + bool get resizeToAvoidBottomPadding => false; @override String get title => S.current.receive; @@ -22,6 +30,7 @@ class ReceivePage extends BasePage { @override Widget trailing(BuildContext context) { final walletStore = Provider.of(context); + final shareImage = Image.asset('assets/images/share.png'); return SizedBox( height: 37.0, @@ -33,18 +42,14 @@ class ReceivePage extends BasePage { splashColor: Colors.transparent, padding: EdgeInsets.all(0), onPressed: () => Share.text( - 'Share address', walletStore.subaddress.address, 'text/plain'), - child: Icon( - Icons.share, - size: 30.0, - )), + S.current.share_address, walletStore.subaddress.address, 'text/plain'), + child: shareImage), ), ); } @override - Widget body(BuildContext context) => - SingleChildScrollView(child: ReceiveBody()); + Widget body(BuildContext context) => ReceiveBody(); } class ReceiveBody extends StatefulWidget { @@ -66,9 +71,15 @@ class ReceiveBodyState extends State { Widget build(BuildContext context) { final walletStore = Provider.of(context); final subaddressListStore = Provider.of(context); + final accountListStore = Provider.of(context); - final currentColor = Theme.of(context).selectedRowColor; - final notCurrentColor = Theme.of(context).scaffoldBackgroundColor; + final copyImage = Image.asset('assets/images/copy_content.png'); + + final currentColor = PaletteDark.menuList; + final notCurrentColor = PaletteDark.historyPanel; + + final currentTextColor = Colors.blue; + final notCurrentTextColor = PaletteDark.walletCardText; amountController.addListener(() { if (_formKey.currentState.validate()) { @@ -78,202 +89,227 @@ class ReceiveBodyState extends State { } }); - return SafeArea( - child: SingleChildScrollView( - child: Column( - children: [ - Container( - padding: EdgeInsets.all(35.0), - color: Theme.of(context).backgroundColor, - child: Column( - children: [ - Observer(builder: (_) { - return Row( - children: [ - Spacer( - flex: 1, - ), - Flexible( - flex: 2, + return Container( + height: MediaQuery.of(context).size.height, + width: MediaQuery.of(context).size.width, + color: PaletteDark.mainBackgroundColor, + padding: EdgeInsets.only(top: 24), + child: SingleChildScrollView( + child: Column( + children: [ + Observer(builder: (_) { + return Row( + children: [ + Spacer( + flex: 1, + ), + Flexible( + flex: 2, + child: Center( child: AspectRatio( aspectRatio: 1.0, - child: Container( - padding: EdgeInsets.all(5), - color: Colors.white, - child: QrImage( - data: walletStore.subaddress.address + - walletStore.amountValue, - backgroundColor: Colors.transparent, - ), - ), - )), - Spacer( - flex: 1, - ) - ], - ); - }), - Observer(builder: (_) { - return Row( - children: [ - Expanded( - child: Container( - padding: EdgeInsets.all(20.0), - child: Center( - child: GestureDetector( - onTap: () { - Clipboard.setData(ClipboardData( - text: walletStore.subaddress.address)); - Scaffold.of(context).showSnackBar(SnackBar( - content: Text( - S.of(context).copied_to_clipboard, - style: TextStyle(color: Colors.white), - ), - backgroundColor: Colors.green, - )); - }, - child: Text( - walletStore.subaddress.address, - textAlign: TextAlign.center, - style: TextStyle( - fontSize: 14.0, - fontWeight: FontWeight.w600, - color: Theme.of(context) - .primaryTextTheme - .title - .color), + child: QrImage( + data: walletStore.subaddress.address + + walletStore.amountValue, + backgroundColor: Colors.transparent, + foregroundColor: PaletteDark.walletCardText, ), ), - ), - )) - ], - ); - }), - Row( + )), + Spacer( + flex: 1, + ) + ], + ); + }), + Padding( + padding: EdgeInsets.all(24), + child: Row( children: [ Expanded( child: Form( key: _formKey, - child: TextFormField( - keyboardType: - TextInputType.numberWithOptions(decimal: true), + child: BaseTextFormField( + controller: amountController, + keyboardType: TextInputType.numberWithOptions(decimal: true), inputFormatters: [ BlacklistingTextInputFormatter( RegExp('[\\-|\\ |\\,]')) ], - style: TextStyle( - fontSize: 14.0, - ), - decoration: InputDecoration( - hintStyle: TextStyle( - color: Theme.of(context).hintColor), - hintText: S.of(context).amount, - focusedBorder: UnderlineInputBorder( - borderSide: BorderSide( - color: Palette.cakeGreen, width: 2.0)), - enabledBorder: UnderlineInputBorder( - borderSide: BorderSide( - color: Theme.of(context).focusColor, - width: 1.0))), + textAlign: TextAlign.center, + hintText: S.of(context).receive_amount, + borderColor: PaletteDark.walletCardText, validator: (value) { walletStore.validateAmount(value); return walletStore.errorMessage; }, autovalidate: true, - controller: amountController, - ))) - ], - ) - ], - ), - ), - Row( - children: [ - Expanded( - child: Container( - color: Theme.of(context).accentTextTheme.headline.color, - child: Column( - children: [ - ListTile( - title: Text( - S.of(context).subaddresses, - style: TextStyle( - fontSize: 16.0, - color: Theme.of(context) - .primaryTextTheme - .headline - .color), - ), - trailing: Container( - width: 28.0, - height: 28.0, - decoration: BoxDecoration( - color: Theme.of(context).selectedRowColor, - shape: BoxShape.circle), - child: InkWell( - onTap: () => Navigator.of(context) - .pushNamed(Routes.newSubaddress), - borderRadius: BorderRadius.all(Radius.circular(14.0)), - child: Icon( - Icons.add, - color: Palette.violet, - size: 22.0, - ), - ), - ), - ), - Divider( - color: Theme.of(context).dividerTheme.color, - height: 1.0, + ) + ) ) ], ), - )) + ), + Padding( + padding: EdgeInsets.only(left: 24, right: 24, bottom: 24), + child: Observer( + builder: (_) => GestureDetector( + onTap: () { + Clipboard.setData(ClipboardData( + text: walletStore.subaddress.address)); + Scaffold.of(context).showSnackBar(SnackBar( + content: Text( + S.of(context).copied_to_clipboard, + style: TextStyle(color: Colors.white), + ), + backgroundColor: Colors.green, + duration: Duration(milliseconds: 500), + )); + }, + child: Container( + height: 48, + padding: EdgeInsets.only(left: 24, right: 24), + decoration: BoxDecoration( + borderRadius: BorderRadius.all(Radius.circular(27)), + color: PaletteDark.walletCardSubAddressField + ), + child: Row( + mainAxisSize: MainAxisSize.max, + children: [ + Expanded( + child: Text( + walletStore.subaddress.address, + maxLines: 1, + overflow: TextOverflow.ellipsis, + style: TextStyle( + fontSize: 14, + fontWeight: FontWeight.w600, + color: Colors.white + ), + ), + ), + Padding( + padding: EdgeInsets.only(left: 12), + child: copyImage, + ) + ], + ), + ), + ) + ), + ), + Container( + decoration: BoxDecoration( + borderRadius: BorderRadius.only( + topLeft: Radius.circular(24), + topRight: Radius.circular(24), + ), + color: PaletteDark.historyPanel, + ), + child: Observer( + builder: (_) => ListView.separated( + separatorBuilder: (context, index) => Divider( + height: 1, + color: PaletteDark.menuList, + ), + shrinkWrap: true, + physics: NeverScrollableScrollPhysics(), + itemCount: subaddressListStore.subaddresses.length + 2, + itemBuilder: (context, index) { + + if (index == 0) { + return HeaderTile( + onTap: () async { + await showDialog( + context: context, + builder: (BuildContext context) { + return AccountListPage(accountListStore: accountListStore); + } + ); + }, + title: walletStore.account.label, + icon: Icon( + Icons.arrow_forward_ios, + size: 14, + color: Colors.white, + ) + ); + } + + if (index == 1) { + return HeaderTile( + onTap: () => Navigator.of(context) + .pushNamed(Routes.newSubaddress), + title: S.of(context).subaddresses, + icon: Icon( + Icons.add, + size: 20, + color: Colors.white, + ) + ); + } + + index -= 2; + + return Observer( + builder: (_) { + final subaddress = subaddressListStore.subaddresses[index]; + final isCurrent = + walletStore.subaddress.address == subaddress.address; + + final label = subaddress.label.isNotEmpty + ? subaddress.label + : subaddress.address; + + final content = InkWell( + onTap: () => walletStore.setSubaddress(subaddress), + child: Container( + color: isCurrent ? currentColor : notCurrentColor, + padding: EdgeInsets.only( + left: 24, + right: 24, + top: 28, + bottom: 28 + ), + child: Text( + label, + style: TextStyle( + fontSize: subaddress.label.isNotEmpty + ? 18 : 10, + fontWeight: FontWeight.bold, + color: isCurrent + ? currentTextColor + : notCurrentTextColor, + ), + ), + ), + ); + + return isCurrent + ? content + : Slidable( + key: Key(subaddress.address), + actionPane: SlidableDrawerActionPane(), + child: content, + secondaryActions: [ + IconSlideAction( + caption: S.of(context).edit, + color: PaletteDark.walletCardSubAddressField, + icon: Icons.edit, + onTap: () => Navigator.of(context) + .pushNamed(Routes.newSubaddress, arguments: subaddress), + ) + ] + ); + } + ); + } + ) + ), + ), ], ), - Observer(builder: (_) { - return ListView.separated( - shrinkWrap: true, - physics: NeverScrollableScrollPhysics(), - itemCount: subaddressListStore.subaddresses.length, - separatorBuilder: (context, i) { - return Divider( - color: Theme.of(context).dividerTheme.color, - height: 1.0, - ); - }, - itemBuilder: (context, i) { - return Observer(builder: (_) { - final subaddress = subaddressListStore.subaddresses[i]; - final isCurrent = - walletStore.subaddress.address == subaddress.address; - final label = subaddress.label.isNotEmpty - ? subaddress.label - : subaddress.address; - - return InkWell( - onTap: () => walletStore.setSubaddress(subaddress), - child: Container( - color: isCurrent ? currentColor : notCurrentColor, - child: Column(children: [ - ListTile( - title: Text( - label, - style: TextStyle( - fontSize: 16.0, - color: Theme.of(context) - .primaryTextTheme - .headline - .color), - ), - ) - ]), - ), - ); - }); - }); - }) - ], - ))); + ) + ); } -} +} \ No newline at end of file diff --git a/lib/src/screens/receive/widgets/header_tile.dart b/lib/src/screens/receive/widgets/header_tile.dart new file mode 100644 index 000000000..74ab84e84 --- /dev/null +++ b/lib/src/screens/receive/widgets/header_tile.dart @@ -0,0 +1,53 @@ +import 'package:flutter/material.dart'; +import 'package:cake_wallet/palette.dart'; + +class HeaderTile extends StatelessWidget { + HeaderTile({ + @required this.onTap, + @required this.title, + @required this.icon + }); + + final VoidCallback onTap; + final String title; + final Icon icon; + + @override + Widget build(BuildContext context) { + return GestureDetector( + onTap: onTap, + child: Container( + padding: EdgeInsets.only( + left: 24, + right: 24, + top: 24, + bottom: 24 + ), + color: Colors.transparent, + child: Row( + mainAxisSize: MainAxisSize.max, + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Text( + title, + style: TextStyle( + fontSize: 18, + fontWeight: FontWeight.bold, + color: Colors.white + ), + ), + Container( + height: 32, + width: 32, + decoration: BoxDecoration( + shape: BoxShape.circle, + color: PaletteDark.menuList + ), + child: icon, + ) + ], + ), + ), + ); + } +} \ No newline at end of file diff --git a/lib/src/screens/receive/qr_image.dart b/lib/src/screens/receive/widgets/qr_image.dart similarity index 90% rename from lib/src/screens/receive/qr_image.dart rename to lib/src/screens/receive/widgets/qr_image.dart index 7beb689d2..fceb61518 100644 --- a/lib/src/screens/receive/qr_image.dart +++ b/lib/src/screens/receive/widgets/qr_image.dart @@ -1,6 +1,6 @@ import 'package:flutter/material.dart'; import 'package:qr/qr.dart'; -import 'package:cake_wallet/src/screens/receive/qr_painter.dart'; +import 'package:cake_wallet/src/screens/receive/widgets/qr_painter.dart'; class QrImage extends StatelessWidget { QrImage({ diff --git a/lib/src/screens/receive/qr_painter.dart b/lib/src/screens/receive/widgets/qr_painter.dart similarity index 100% rename from lib/src/screens/receive/qr_painter.dart rename to lib/src/screens/receive/widgets/qr_painter.dart diff --git a/lib/src/screens/subaddress/new_subaddress_page.dart b/lib/src/screens/subaddress/new_subaddress_page.dart index 58d774568..25dd46b03 100644 --- a/lib/src/screens/subaddress/new_subaddress_page.dart +++ b/lib/src/screens/subaddress/new_subaddress_page.dart @@ -1,3 +1,4 @@ +import 'package:cake_wallet/src/domain/monero/subaddress.dart'; import 'package:mobx/mobx.dart'; import 'package:provider/provider.dart'; import 'package:flutter/cupertino.dart'; @@ -9,13 +10,21 @@ import 'package:cake_wallet/src/stores/subaddress_creation/subaddress_creation_s import 'package:cake_wallet/src/widgets/primary_button.dart'; import 'package:cake_wallet/src/screens/base_page.dart'; import 'package:cake_wallet/palette.dart'; +import 'package:cake_wallet/src/widgets/base_text_form_field.dart'; class NewSubaddressPage extends BasePage { + NewSubaddressPage({this.subaddress}); + + final Subaddress subaddress; + @override String get title => S.current.new_subaddress_title; @override - Widget body(BuildContext context) => NewSubaddressForm(); + Color get backgroundColor => PaletteDark.historyPanel; + + @override + Widget body(BuildContext context) => NewSubaddressForm(subaddress); @override Widget build(BuildContext context) { @@ -34,65 +43,93 @@ class NewSubaddressPage extends BasePage { } class NewSubaddressForm extends StatefulWidget { + NewSubaddressForm(this.subaddress); + + final Subaddress subaddress; + @override - NewSubaddressFormState createState() => NewSubaddressFormState(); + NewSubaddressFormState createState() => NewSubaddressFormState(subaddress); } class NewSubaddressFormState extends State { + NewSubaddressFormState(this.subaddress); + final _formKey = GlobalKey(); final _labelController = TextEditingController(); + final Subaddress subaddress; + + @override + void initState() { + if (subaddress != null) _labelController.text = subaddress.label; + super.initState(); + } + + @override + void dispose() { + _labelController.dispose(); + super.dispose(); + } @override Widget build(BuildContext context) { final subaddressCreationStore = Provider.of(context); + _labelController.addListener(() { + if (_labelController.text.isNotEmpty) { + subaddressCreationStore.setDisabledStatus(false); + } else { + subaddressCreationStore.setDisabledStatus(true); + } + }); + return Form( key: _formKey, - child: Stack(children: [ - Center( - child: Padding( - padding: EdgeInsets.only(left: 35, right: 35), - child: TextFormField( - controller: _labelController, - decoration: InputDecoration( - hintStyle: TextStyle(color: Theme.of(context).hintColor), - hintText: S.of(context).new_subaddress_label_name, - focusedBorder: UnderlineInputBorder( - borderSide: - BorderSide(color: Palette.cakeGreen, width: 2.0)), - enabledBorder: UnderlineInputBorder( - borderSide: BorderSide( - color: Theme.of(context).focusColor, - width: 1.0))), - validator: (value) { - subaddressCreationStore.validateSubaddressName(value); - return subaddressCreationStore.errorMessage; - }), - ), - ), - Positioned( - bottom: 20, - left: 20, - right: 20, - child: Observer( + child: Container( + color: PaletteDark.historyPanel, + padding: EdgeInsets.all(24.0), + child: Column( + children: [ + Expanded( + child: Center( + child: BaseTextFormField( + controller: _labelController, + hintText: S.of(context).new_subaddress_label_name, + validator: (value) { + subaddressCreationStore.validateSubaddressName(value); + return subaddressCreationStore.errorMessage; + } + ) + ) + ), + Observer( builder: (_) => LoadingPrimaryButton( onPressed: () async { if (_formKey.currentState.validate()) { - await subaddressCreationStore.add( - label: _labelController.text); - Navigator.of(context).pop(); + if (subaddress != null) { + await subaddressCreationStore.setLabel( + addressIndex: subaddress.id, + label: _labelController.text + ); + } else { + await subaddressCreationStore.add( + label: _labelController.text); + } } }, - text: S.of(context).new_subaddress_create, - color: Theme.of(context) - .accentTextTheme - .button - .backgroundColor, - textColor: Theme.of(context).primaryTextTheme.button.color, + text: subaddress != null + ? S.of(context).rename + : S.of(context).new_subaddress_create, + color: Colors.green, + textColor: Colors.white, isLoading: - subaddressCreationStore.state is SubaddressIsCreating), - )) - ])); + subaddressCreationStore.state is SubaddressIsCreating, + isDisabled: subaddressCreationStore.isDisabledStatus, + ), + ) + ], + ), + ) + ); } } diff --git a/lib/src/stores/account_list/account_list_store.dart b/lib/src/stores/account_list/account_list_store.dart index e6361d5a7..af72175f7 100644 --- a/lib/src/stores/account_list/account_list_store.dart +++ b/lib/src/stores/account_list/account_list_store.dart @@ -16,6 +16,7 @@ abstract class AcountListStoreBase with Store { AcountListStoreBase({@required WalletService walletService}) { accounts = []; isAccountCreating = false; + isDisabledStatus = true; if (walletService.currentWallet != null) { _onWalletChanged(walletService.currentWallet); @@ -37,10 +38,18 @@ abstract class AcountListStoreBase with Store { @observable bool isAccountCreating; + @observable + bool isDisabledStatus; + AccountList _accountList; StreamSubscription _onWalletChangeSubscription; StreamSubscription> _onAccountsChangeSubscription; + @action + void setDisabledStatus(bool isDisabled) { + isDisabledStatus = isDisabled; + } + @override void dispose() { _onWalletChangeSubscription.cancel(); diff --git a/lib/src/stores/subaddress_creation/subaddress_creation_store.dart b/lib/src/stores/subaddress_creation/subaddress_creation_store.dart index 0314e9ac9..ab294f7c4 100644 --- a/lib/src/stores/subaddress_creation/subaddress_creation_store.dart +++ b/lib/src/stores/subaddress_creation/subaddress_creation_store.dart @@ -17,6 +17,7 @@ class SubadrressCreationStore = SubadrressCreationStoreBase abstract class SubadrressCreationStoreBase with Store { SubadrressCreationStoreBase({@required WalletService walletService}) { state = SubaddressCreationStateInitial(); + isDisabledStatus = true; if (walletService.currentWallet != null) { _onWalletChanged(walletService.currentWallet); @@ -26,6 +27,7 @@ abstract class SubadrressCreationStoreBase with Store { walletService.onWalletChange.listen(_onWalletChanged); } + @observable SubaddressCreationState state; @observable @@ -34,11 +36,19 @@ abstract class SubadrressCreationStoreBase with Store { @observable String errorMessage; + @observable + bool isDisabledStatus; + SubaddressList _subaddressList; StreamSubscription _onWalletChangeSubscription; StreamSubscription _onAccountChangeSubscription; Account _account; + @action + void setDisabledStatus(bool isDisabled) { + isDisabledStatus = isDisabled; + } + @override void dispose() { _onWalletChangeSubscription.cancel(); @@ -61,6 +71,20 @@ abstract class SubadrressCreationStoreBase with Store { } } + Future setLabel({int addressIndex, String label}) async { + try { + state = SubaddressIsCreating(); + await _subaddressList.setLabelSubaddress( + accountIndex: _account.id, + addressIndex: addressIndex, + label: label + ); + state = SubaddressCreatedSuccessfully(); + } catch (e) { + state = SubaddressCreationFailure(error: e.toString()); + } + } + Future _onWalletChanged(Wallet wallet) async { if (wallet is MoneroWallet) { _account = wallet.account; diff --git a/lib/src/widgets/base_text_form_field.dart b/lib/src/widgets/base_text_form_field.dart new file mode 100644 index 000000000..5b76475b6 --- /dev/null +++ b/lib/src/widgets/base_text_form_field.dart @@ -0,0 +1,70 @@ +import 'package:flutter/material.dart'; +import 'package:cake_wallet/palette.dart'; +import 'package:flutter/services.dart'; + +class BaseTextFormField extends StatelessWidget { + BaseTextFormField({ + this.controller, + this.keyboardType = TextInputType.text, + this.textInputAction = TextInputAction.done, + this.textAlign = TextAlign.start, + this.autovalidate = false, + this.hintText = '', + this.maxLines = 1, + this.inputFormatters, + this.textColor = Colors.white, + this.hintColor = PaletteDark.walletCardText, + this.borderColor = PaletteDark.menuList, + this.validator + }); + + final TextEditingController controller; + final TextInputType keyboardType; + final TextInputAction textInputAction; + final TextAlign textAlign; + final bool autovalidate; + final String hintText; + final int maxLines; + final List inputFormatters; + final Color textColor; + final Color hintColor; + final Color borderColor; + final FormFieldValidator validator; + + @override + Widget build(BuildContext context) { + return TextFormField( + controller: controller, + keyboardType: keyboardType, + textInputAction: textInputAction, + textAlign: textAlign, + autovalidate: autovalidate, + maxLines: maxLines, + inputFormatters: inputFormatters, + style: TextStyle( + fontSize: 16.0, + color: textColor + ), + decoration: InputDecoration( + hintStyle: TextStyle( + color: hintColor, + fontSize: 16 + ), + hintText: hintText, + focusedBorder: UnderlineInputBorder( + borderSide: BorderSide( + color: borderColor, + width: 1.0 + ) + ), + enabledBorder: UnderlineInputBorder( + borderSide: BorderSide( + color: borderColor, + width: 1.0 + ) + ) + ), + validator: validator, + ); + } +} \ No newline at end of file diff --git a/res/values/strings_de.arb b/res/values/strings_de.arb index d73782715..b77e8895a 100644 --- a/res/values/strings_de.arb +++ b/res/values/strings_de.arb @@ -134,6 +134,10 @@ "share_address" : "Adresse teilen ", "receive_amount" : "Menge", "subaddresses" : "Unteradressen", + "rename" : "Umbenennen", + "choose_account" : "Konto auswählen", + "create_new_account" : "Neues Konto erstellen", + "accounts_subaddresses" : "Konten und Unteradressen", "restore_restore_wallet" : "Wallet wiederherstellen", diff --git a/res/values/strings_en.arb b/res/values/strings_en.arb index 218aaa582..aef9ff285 100644 --- a/res/values/strings_en.arb +++ b/res/values/strings_en.arb @@ -134,6 +134,10 @@ "share_address" : "Share address", "receive_amount" : "Amount", "subaddresses" : "Subaddresses", + "rename" : "Rename", + "choose_account" : "Choose account", + "create_new_account" : "Create new account", + "accounts_subaddresses" : "Accounts and subaddresses", "restore_restore_wallet" : "Restore Wallet", diff --git a/res/values/strings_es.arb b/res/values/strings_es.arb index 0231d495a..4faff30a9 100644 --- a/res/values/strings_es.arb +++ b/res/values/strings_es.arb @@ -134,6 +134,10 @@ "share_address" : "Compartir dirección", "receive_amount" : "Cantidad", "subaddresses" : "Subdirecciones", + "rename" : "Rebautizar", + "choose_account" : "Elegir cuenta", + "create_new_account" : "Crear una nueva cuenta", + "accounts_subaddresses" : "Cuentas y subdirecciones", "restore_restore_wallet" : "Recuperar Cartera", diff --git a/res/values/strings_hi.arb b/res/values/strings_hi.arb index 58b329d1a..bcb253a3c 100644 --- a/res/values/strings_hi.arb +++ b/res/values/strings_hi.arb @@ -134,6 +134,10 @@ "share_address" : "पता साझा करें", "receive_amount" : "रकम", "subaddresses" : "उप पते", + "rename" : "नाम बदलें", + "choose_account" : "खाता चुनें", + "create_new_account" : "नया खाता बनाएँ", + "accounts_subaddresses" : "लेखा और उपदेस", "restore_restore_wallet" : "वॉलेट को पुनर्स्थापित करें", diff --git a/res/values/strings_ja.arb b/res/values/strings_ja.arb index bab090edf..052cbeb4b 100644 --- a/res/values/strings_ja.arb +++ b/res/values/strings_ja.arb @@ -134,6 +134,10 @@ "share_address" : "住所を共有する", "receive_amount" : "量", "subaddresses" : "サブアドレス", + "rename" : "リネーム", + "choose_account" : "アカウントを選択", + "create_new_account" : "新しいアカウントを作成する", + "accounts_subaddresses" : "アカウントとサブアドレス", "restore_restore_wallet" : "ウォレットを復元", diff --git a/res/values/strings_ko.arb b/res/values/strings_ko.arb index bc49d48de..5d7004ac1 100644 --- a/res/values/strings_ko.arb +++ b/res/values/strings_ko.arb @@ -134,6 +134,10 @@ "share_address" : "주소 공유", "receive_amount" : "양", "subaddresses" : "하위 주소", + "rename" : "이름 바꾸기", + "choose_account" : "계정을 선택하십시오", + "create_new_account" : "새 계정을 만들", + "accounts_subaddresses" : "계정 및 하위 주소", "restore_restore_wallet" : "월렛 복원", diff --git a/res/values/strings_nl.arb b/res/values/strings_nl.arb index 24844e3b5..0ca148a9b 100644 --- a/res/values/strings_nl.arb +++ b/res/values/strings_nl.arb @@ -134,6 +134,10 @@ "share_address" : "Deel adres", "receive_amount" : "Bedrag", "subaddresses" : "Subadressen", + "rename" : "Hernoemen", + "choose_account" : "Kies account", + "create_new_account" : "Creëer een nieuw account", + "accounts_subaddresses" : "Accounts en subadressen", "restore_restore_wallet" : "Portemonnee herstellen", diff --git a/res/values/strings_pl.arb b/res/values/strings_pl.arb index 1f9f69dc8..238a45e5d 100644 --- a/res/values/strings_pl.arb +++ b/res/values/strings_pl.arb @@ -134,6 +134,10 @@ "share_address" : "Udostępnij adres", "receive_amount" : "Ilość", "subaddresses" : "Podadresy", + "rename" : "Przemianować", + "choose_account" : "Wybierz konto", + "create_new_account" : "Stwórz nowe konto", + "accounts_subaddresses" : "Konta i podadresy", "restore_restore_wallet" : "Przywróć portfel", diff --git a/res/values/strings_pt.arb b/res/values/strings_pt.arb index 599965f11..8c62df0b8 100644 --- a/res/values/strings_pt.arb +++ b/res/values/strings_pt.arb @@ -134,6 +134,10 @@ "share_address" : "Compartilhar endereço", "receive_amount" : "Quantia", "subaddresses" : "Sub-endereços", + "rename" : "Renomear", + "choose_account" : "Escolha uma conta", + "create_new_account" : "Criar nova conta", + "accounts_subaddresses" : "Contas e sub-endereços", "restore_restore_wallet" : "Restaurar carteira", diff --git a/res/values/strings_ru.arb b/res/values/strings_ru.arb index c9889526d..3b3403933 100644 --- a/res/values/strings_ru.arb +++ b/res/values/strings_ru.arb @@ -134,6 +134,10 @@ "share_address" : "Поделиться адресом", "receive_amount" : "Сумма", "subaddresses" : "Субадреса", + "rename" : "Переименовать", + "choose_account" : "Выберите аккаунт", + "create_new_account" : "Создать новый аккаунт", + "accounts_subaddresses" : "Аккаунты и субадреса", "restore_restore_wallet" : "Восстановить кошелёк", diff --git a/res/values/strings_uk.arb b/res/values/strings_uk.arb index 1758acc96..919182599 100644 --- a/res/values/strings_uk.arb +++ b/res/values/strings_uk.arb @@ -132,8 +132,12 @@ "share_address" : "Поділитися адресою", - "receive_amount" : "Баланс", + "receive_amount" : "Сума", "subaddresses" : "Субадреси", + "rename" : "Перейменувати", + "choose_account" : "Оберіть акаунт", + "create_new_account" : "Створити новий акаунт", + "accounts_subaddresses" : "Акаунти та субадреси", "restore_restore_wallet" : "Відновити гаманець", diff --git a/res/values/strings_zh.arb b/res/values/strings_zh.arb index 01c75bb28..42903afb7 100644 --- a/res/values/strings_zh.arb +++ b/res/values/strings_zh.arb @@ -134,6 +134,10 @@ "share_address" : "分享地址", "receive_amount" : "量", "subaddresses" : "子地址", + "rename" : "改名", + "choose_account" : "選擇帳號", + "create_new_account" : "建立新帳戶", + "accounts_subaddresses" : "帳戶和子地址", "restore_restore_wallet" : "恢复钱包",