From 1800070fc182e39ef25d8d8c38178566cdddc1c6 Mon Sep 17 00:00:00 2001 From: OleksandrSobol Date: Tue, 29 Sep 2020 11:45:35 +0300 Subject: [PATCH 1/5] CAKE-79 | added ability to flip balance on dashboard page; added isReversing, displayMode and savedDisplayMode to balance_view_model; added display mode to balance page --- .../dashboard/widgets/balance_page.dart | 80 +++++++++++-------- lib/utils/show_pop_up.dart | 4 +- .../dashboard/balance_view_model.dart | 18 ++++- pubspec.lock | 31 +++---- 4 files changed, 76 insertions(+), 57 deletions(-) diff --git a/lib/src/screens/dashboard/widgets/balance_page.dart b/lib/src/screens/dashboard/widgets/balance_page.dart index 4410fc3ff..5470c859d 100644 --- a/lib/src/screens/dashboard/widgets/balance_page.dart +++ b/lib/src/screens/dashboard/widgets/balance_page.dart @@ -1,6 +1,7 @@ import 'package:flutter/material.dart'; import 'package:cake_wallet/view_model/dashboard/dashboard_view_model.dart'; import 'package:flutter_mobx/flutter_mobx.dart'; +import 'package:auto_size_text/auto_size_text.dart'; class BalancePage extends StatelessWidget { BalancePage({@required this.dashboardViewModel}); @@ -11,42 +12,57 @@ class BalancePage extends StatelessWidget { Widget build(BuildContext context) { return Container( padding: EdgeInsets.all(24), - child: Column( - mainAxisAlignment: MainAxisAlignment.center, - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - Observer(builder: (_) { - return Text( - dashboardViewModel.balanceViewModel.currency.toString(), - style: TextStyle( - fontSize: 40, - fontWeight: FontWeight.bold, - color: Theme.of(context).indicatorColor, - height: 1), - ); - }), - SizedBox(height: 10), - Observer(builder: (_) { - return Text(dashboardViewModel.balanceViewModel.cryptoBalance, + child: GestureDetector( + onTapUp: (_) => dashboardViewModel.balanceViewModel.isReversing = false, + onTapDown: (_) => dashboardViewModel.balanceViewModel.isReversing = true, + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Observer(builder: (_) { + return Text( + dashboardViewModel.balanceViewModel.currency.toString(), style: TextStyle( - fontSize: 54, + fontSize: 40, fontWeight: FontWeight.bold, - color: Colors.white, - height: 1), - textAlign: TextAlign.center); - }), - SizedBox(height: 10), - Observer(builder: (_) { - return Text(dashboardViewModel.balanceViewModel.fiatBalance, - style: TextStyle( - fontSize: 18, - fontWeight: FontWeight.w500, color: Theme.of(context).indicatorColor, height: 1), - textAlign: TextAlign.center); - }), - ], - ), + ); + }), + Observer(builder: (_) { + return Text( + dashboardViewModel.balanceViewModel.displayMode.toString(), + style: TextStyle( + fontSize: 12, + fontWeight: FontWeight.w600, + color: Theme.of(context).indicatorColor, + height: 1), + ); + }), + SizedBox(height: 10), + Observer(builder: (_) { + return AutoSizeText(dashboardViewModel.balanceViewModel.cryptoBalance, + style: TextStyle( + fontSize: 54, + fontWeight: FontWeight.bold, + color: Colors.white, + height: 1), + maxLines: 1, + textAlign: TextAlign.center); + }), + SizedBox(height: 10), + Observer(builder: (_) { + return Text(dashboardViewModel.balanceViewModel.fiatBalance, + style: TextStyle( + fontSize: 18, + fontWeight: FontWeight.w500, + color: Theme.of(context).indicatorColor, + height: 1), + textAlign: TextAlign.center); + }), + ], + ), + ) ); } } diff --git a/lib/utils/show_pop_up.dart b/lib/utils/show_pop_up.dart index a97fb3762..280bcff3c 100644 --- a/lib/utils/show_pop_up.dart +++ b/lib/utils/show_pop_up.dart @@ -14,8 +14,8 @@ Future showPopUp({ context: context, builder: builder, barrierDismissible: barrierDismissible, - barrierColor: barrierColor, - useSafeArea: useSafeArea, + //barrierColor: barrierColor, + //useSafeArea: useSafeArea, useRootNavigator: useRootNavigator, routeSettings: routeSettings, child: child); diff --git a/lib/view_model/dashboard/balance_view_model.dart b/lib/view_model/dashboard/balance_view_model.dart index 58978c946..37f6e5247 100644 --- a/lib/view_model/dashboard/balance_view_model.dart +++ b/lib/view_model/dashboard/balance_view_model.dart @@ -1,5 +1,4 @@ import 'package:cake_wallet/bitcoin/bitcoin_wallet.dart'; -import 'package:cake_wallet/core/wallet_base.dart'; import 'package:cake_wallet/entities/crypto_currency.dart'; import 'package:cake_wallet/monero/monero_wallet.dart'; import 'package:cake_wallet/entities/balance_display_mode.dart'; @@ -20,19 +19,31 @@ abstract class BalanceViewModelBase with Store { @required this.appStore, @required this.settingsStore, @required this.fiatConvertationStore - }); + }) : isReversing = false; final AppStore appStore; final SettingsStore settingsStore; final FiatConversionStore fiatConvertationStore; + @observable + bool isReversing; + + @computed + BalanceDisplayMode get savedDisplayMode => settingsStore.balanceDisplayMode; + + @computed + BalanceDisplayMode get displayMode => isReversing + ? (savedDisplayMode == BalanceDisplayMode.availableBalance + ? BalanceDisplayMode.fullBalance + : BalanceDisplayMode.availableBalance) + : savedDisplayMode; + @computed double get price => fiatConvertationStore.price; @computed String get cryptoBalance { final walletBalance = _walletBalance; - final displayMode = settingsStore.balanceDisplayMode; var balance = '---'; if (displayMode == BalanceDisplayMode.availableBalance) { @@ -49,7 +60,6 @@ abstract class BalanceViewModelBase with Store { @computed String get fiatBalance { final walletBalance = _walletBalance; - final displayMode = settingsStore.balanceDisplayMode; final fiatCurrency = settingsStore.fiatCurrency; var balance = '---'; diff --git a/pubspec.lock b/pubspec.lock index f9bbbbd26..7d3081850 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -42,7 +42,7 @@ packages: name: async url: "https://pub.dartlang.org" source: hosted - version: "2.4.2" + version: "2.4.1" auto_size_text: dependency: "direct main" description: @@ -210,7 +210,7 @@ packages: name: collection url: "https://pub.dartlang.org" source: hosted - version: "1.14.13" + version: "1.14.12" connectivity: dependency: "direct main" description: @@ -252,7 +252,7 @@ packages: name: crypto url: "https://pub.dartlang.org" source: hosted - version: "2.1.5" + version: "2.1.4" csslib: dependency: transitive description: @@ -330,13 +330,6 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.0.2" - fake_async: - dependency: transitive - description: - name: fake_async - url: "https://pub.dartlang.org" - source: hosted - version: "1.1.0" ffi: dependency: transitive description: @@ -505,7 +498,7 @@ packages: name: image url: "https://pub.dartlang.org" source: hosted - version: "2.1.18" + version: "2.1.12" intl: dependency: "direct main" description: @@ -554,7 +547,7 @@ packages: name: matcher url: "https://pub.dartlang.org" source: hosted - version: "0.12.8" + version: "0.12.6" meta: dependency: transitive description: @@ -624,7 +617,7 @@ packages: name: path url: "https://pub.dartlang.org" source: hosted - version: "1.7.0" + version: "1.6.4" path_drawing: dependency: transitive description: @@ -687,7 +680,7 @@ packages: name: petitparser url: "https://pub.dartlang.org" source: hosted - version: "3.0.4" + version: "2.4.0" platform: dependency: transitive description: @@ -867,7 +860,7 @@ packages: name: stack_trace url: "https://pub.dartlang.org" source: hosted - version: "1.9.5" + version: "1.9.3" stream_channel: dependency: transitive description: @@ -902,7 +895,7 @@ packages: name: test_api url: "https://pub.dartlang.org" source: hosted - version: "0.2.17" + version: "0.2.15" time: dependency: transitive description: @@ -923,7 +916,7 @@ packages: name: typed_data url: "https://pub.dartlang.org" source: hosted - version: "1.2.0" + version: "1.1.6" url_launcher: dependency: "direct main" description: @@ -1014,7 +1007,7 @@ packages: name: xml url: "https://pub.dartlang.org" source: hosted - version: "4.5.1" + version: "3.6.1" yaml: dependency: "direct main" description: @@ -1023,5 +1016,5 @@ packages: source: hosted version: "2.2.1" sdks: - dart: ">=2.9.0-14.0.dev <3.0.0" + dart: ">=2.7.0 <3.0.0" flutter: ">=1.12.13+hotfix.5 <2.0.0" From 32b0de916e5776705919eb205752b192abdd14ed Mon Sep 17 00:00:00 2001 From: Oleksandr Sobol Date: Tue, 29 Sep 2020 22:32:19 +0300 Subject: [PATCH 2/5] CAKE-79 | fixed string resources --- lib/generated/i18n.dart | 72 +++++++++++++++++++-------------------- res/values/strings_de.arb | 6 ++-- res/values/strings_en.arb | 6 ++-- res/values/strings_es.arb | 6 ++-- res/values/strings_hi.arb | 6 ++-- res/values/strings_ja.arb | 6 ++-- res/values/strings_ko.arb | 6 ++-- res/values/strings_nl.arb | 6 ++-- res/values/strings_pl.arb | 6 ++-- res/values/strings_pt.arb | 4 +-- res/values/strings_ru.arb | 6 ++-- res/values/strings_uk.arb | 6 ++-- res/values/strings_zh.arb | 6 ++-- 13 files changed, 71 insertions(+), 71 deletions(-) diff --git a/lib/generated/i18n.dart b/lib/generated/i18n.dart index 0467ad495..7a86289b7 100644 --- a/lib/generated/i18n.dart +++ b/lib/generated/i18n.dart @@ -97,7 +97,7 @@ class S implements WidgetsLocalizations { String get faq => "FAQ"; String get fetching => "Fetching"; String get filters => "Filter"; - String get first_wallet_text => "Awesome wallet for Monero"; + String get first_wallet_text => "Awesome wallet for Monero and Bitcoin"; String get full_balance => "Full Balance"; String get hidden_balance => "Hidden Balance"; String get id => "ID: "; @@ -303,9 +303,9 @@ class S implements WidgetsLocalizations { String get widgets_restore_from_blockheight => "Restore from blockheight"; String get widgets_restore_from_date => "Restore from date"; String get widgets_seed => "Seed"; - String get xmr_available_balance => "XMR Available Balance"; - String get xmr_full_balance => "XMR Full Balance"; - String get xmr_hidden => "XMR Hidden"; + String get xmr_available_balance => "Available Balance"; + String get xmr_full_balance => "Full Balance"; + String get xmr_hidden => "Hidden"; String get yesterday => "Yesterday"; String get you_will_get => "You will get"; String get you_will_send => "You will send"; @@ -539,7 +539,7 @@ class $de extends S { @override String get restore_seed_keys_restore => "Seed / Schlüssel wiederherstellen"; @override - String get xmr_hidden => "XMR versteckt"; + String get xmr_hidden => "Versteckt"; @override String get send_xmr => "Senden XMR"; @override @@ -635,7 +635,7 @@ class $de extends S { @override String get error_text_xmr => "Der XMR-Wert kann das verfügbare Guthaben nicht überschreiten.\nDie Anzahl der Nachkommastellen muss kleiner oder gleich 12 sein"; @override - String get xmr_available_balance => "XMR verfügbares Guthaben"; + String get xmr_available_balance => "Verfügbares Guthaben"; @override String get restore_bitcoin_description_from_keys => "Stellen Sie Ihre Brieftasche aus der generierten WIF-Zeichenfolge aus Ihren privaten Schlüsseln wieder her"; @override @@ -799,7 +799,7 @@ class $de extends S { @override String get all => "ALLE"; @override - String get xmr_full_balance => "XMR Volle Balance"; + String get xmr_full_balance => "Volle Balance"; @override String get incoming => "Eingehend"; @override @@ -1181,7 +1181,7 @@ class $hi extends S { @override String get restore_seed_keys_restore => "बीज / कुंजी पुनर्स्थापित करें"; @override - String get xmr_hidden => "XMR छिपा हुआ"; + String get xmr_hidden => "छिपा हुआ"; @override String get send_xmr => "संदेश XMR"; @override @@ -1277,7 +1277,7 @@ class $hi extends S { @override String get error_text_xmr => "एक्सएमआर मूल्य उपलब्ध शेष राशि से अधिक नहीं हो सकता.\nअंश अंकों की संख्या 12 से कम या इसके बराबर होनी चाहिए"; @override - String get xmr_available_balance => "XMR उपलब्ध शेष राशि"; + String get xmr_available_balance => "उपलब्ध शेष राशि"; @override String get restore_bitcoin_description_from_keys => "अपने निजी कुंजी से उत्पन्न WIF स्ट्रिंग से अपने वॉलेट को पुनर्स्थापित करें"; @override @@ -1441,7 +1441,7 @@ class $hi extends S { @override String get all => "सब"; @override - String get xmr_full_balance => "XMR पूर्ण संतुलन"; + String get xmr_full_balance => "पूरा संतुलन"; @override String get incoming => "आने वाली"; @override @@ -1823,7 +1823,7 @@ class $ru extends S { @override String get restore_seed_keys_restore => "Восстановить из мнемонической фразы/ключей"; @override - String get xmr_hidden => "XMR Скрыто"; + String get xmr_hidden => "Скрыто"; @override String get send_xmr => "Отправить XMR"; @override @@ -1919,7 +1919,7 @@ class $ru extends S { @override String get error_text_xmr => "Значение XMR не может превышать доступный баланс.\nКоличество цифр после запятой должно быть меньше или равно 12"; @override - String get xmr_available_balance => "Доступный XMR баланс"; + String get xmr_available_balance => "Доступный баланс"; @override String get restore_bitcoin_description_from_keys => "Вы можете восстановить кошелёк с помощью WIF"; @override @@ -2083,7 +2083,7 @@ class $ru extends S { @override String get all => "ВСЕ"; @override - String get xmr_full_balance => "Весь XMR баланс"; + String get xmr_full_balance => "Весь баланс"; @override String get incoming => "Входящие"; @override @@ -2465,7 +2465,7 @@ class $ko extends S { @override String get restore_seed_keys_restore => "종자 / 키 복원"; @override - String get xmr_hidden => "XMR 숨김"; + String get xmr_hidden => "숨김"; @override String get send_xmr => "보내다 XMR"; @override @@ -2561,7 +2561,7 @@ class $ko extends S { @override String get error_text_xmr => "XMR 값은 사용 가능한 잔액을 초과 할 수 없습니다.\n소수 자릿수는 12 이하 여야합니다"; @override - String get xmr_available_balance => "XMR 사용 가능한 잔액"; + String get xmr_available_balance => "사용 가능한 잔액"; @override String get restore_bitcoin_description_from_keys => "개인 키에서 생성 된 WIF 문자열에서 지갑 복원"; @override @@ -2725,7 +2725,7 @@ class $ko extends S { @override String get all => "모든"; @override - String get xmr_full_balance => "XMR 풀 밸런스"; + String get xmr_full_balance => "풀 밸런스"; @override String get incoming => "들어오는"; @override @@ -3203,7 +3203,7 @@ class $pt extends S { @override String get error_text_xmr => "A quantia em XMR não pode exceder o saldo disponível.\nTO número de dígitos decimais deve ser menor ou igual a 12"; @override - String get xmr_available_balance => "Saldo XMR disponível"; + String get xmr_available_balance => "Saldo disponível"; @override String get restore_bitcoin_description_from_keys => "Restaure sua carteira a partir da string WIF gerada de suas chaves privadas"; @override @@ -3367,7 +3367,7 @@ class $pt extends S { @override String get all => "TUDO"; @override - String get xmr_full_balance => "Saldo XMR total"; + String get xmr_full_balance => "Saldo total"; @override String get incoming => "Recebidas"; @override @@ -3749,7 +3749,7 @@ class $uk extends S { @override String get restore_seed_keys_restore => "Відновити за допомогою мнемонічної фрази/ключів"; @override - String get xmr_hidden => "XMR Приховано"; + String get xmr_hidden => "Приховано"; @override String get send_xmr => "Відправити XMR"; @override @@ -3845,7 +3845,7 @@ class $uk extends S { @override String get error_text_xmr => "Значення XMR не може перевищувати доступний баланс.\nКількість цифр після коми повинно бути меншим або дорівнювати 12"; @override - String get xmr_available_balance => "Доступний XMR баланс"; + String get xmr_available_balance => "Доступний баланс"; @override String get restore_bitcoin_description_from_keys => "Ви можете відновити гаманець за допомогою WIF"; @override @@ -4009,7 +4009,7 @@ class $uk extends S { @override String get all => "ВСЕ"; @override - String get xmr_full_balance => "Весь XMR баланс"; + String get xmr_full_balance => "Весь баланс"; @override String get incoming => "Вхідні"; @override @@ -4391,7 +4391,7 @@ class $ja extends S { @override String get restore_seed_keys_restore => "シード/キーの復元"; @override - String get xmr_hidden => "XMR非表示"; + String get xmr_hidden => "非表示"; @override String get send_xmr => "送る XMR"; @override @@ -4487,7 +4487,7 @@ class $ja extends S { @override String get error_text_xmr => "XMR値は利用可能な残高を超えることはできません.\n小数桁数は12以下でなければなりません"; @override - String get xmr_available_balance => "XMR利用可能残高"; + String get xmr_available_balance => "利用可能残高"; @override String get restore_bitcoin_description_from_keys => "秘密鍵から生成されたWIF文字列からウォレットを復元します"; @override @@ -4651,7 +4651,7 @@ class $ja extends S { @override String get all => "すべて"; @override - String get xmr_full_balance => "XMRフルバランス"; + String get xmr_full_balance => "フルバランス"; @override String get incoming => "着信"; @override @@ -5037,7 +5037,7 @@ class $pl extends S { @override String get restore_seed_keys_restore => "Przywracanie nasion / kluczy"; @override - String get xmr_hidden => "XMR Ukryty"; + String get xmr_hidden => "Ukryty"; @override String get send_xmr => "Wysłać XMR"; @override @@ -5133,7 +5133,7 @@ class $pl extends S { @override String get error_text_xmr => "Wartość XMR nie może przekraczać dostępnego salda.\nLiczba cyfr ułamkowych musi być mniejsza lub równa 12"; @override - String get xmr_available_balance => "XMR Dostępne saldo"; + String get xmr_available_balance => "Dostępne saldo"; @override String get restore_bitcoin_description_from_keys => "Przywróć swój portfel z wygenerowanego ciągu WIF z kluczy prywatnych"; @override @@ -5297,7 +5297,7 @@ class $pl extends S { @override String get all => "WSZYSTKO"; @override - String get xmr_full_balance => "XMR Pełna równowaga"; + String get xmr_full_balance => "Pełna równowaga"; @override String get incoming => "Przychodzące"; @override @@ -5679,7 +5679,7 @@ class $es extends S { @override String get restore_seed_keys_restore => "Restauración de semillas / llaves"; @override - String get xmr_hidden => "XMR Oculto"; + String get xmr_hidden => "Oculto"; @override String get send_xmr => "Enviar XMR"; @override @@ -5775,7 +5775,7 @@ class $es extends S { @override String get error_text_xmr => "El valor XMR no puede exceder el saldo disponible.\nTEl número de dígitos de fracción debe ser menor o igual a 12"; @override - String get xmr_available_balance => "XMR Available Balance"; + String get xmr_available_balance => "Saldo disponible"; @override String get restore_bitcoin_description_from_keys => "Restaure su billetera a partir de una cadena WIF generada a partir de sus claves privadas"; @override @@ -5939,7 +5939,7 @@ class $es extends S { @override String get all => "TODOS"; @override - String get xmr_full_balance => "XMR Saldo disponible"; + String get xmr_full_balance => "Balance total"; @override String get incoming => "Entrante"; @override @@ -6321,7 +6321,7 @@ class $nl extends S { @override String get restore_seed_keys_restore => "Zaad / sleutels herstellen"; @override - String get xmr_hidden => "XMR Verborgen"; + String get xmr_hidden => "Verborgen"; @override String get send_xmr => "Sturen XMR"; @override @@ -6417,7 +6417,7 @@ class $nl extends S { @override String get error_text_xmr => "XMR-waarde kan het beschikbare saldo niet overschrijden.\nHet aantal breukcijfers moet kleiner zijn dan of gelijk zijn aan 12"; @override - String get xmr_available_balance => "XMR Beschikbaar saldo"; + String get xmr_available_balance => "Beschikbaar saldo"; @override String get restore_bitcoin_description_from_keys => "Herstel uw portemonnee van de gegenereerde WIF-string van uw privésleutels"; @override @@ -6581,7 +6581,7 @@ class $nl extends S { @override String get all => "ALLE"; @override - String get xmr_full_balance => "XMR Volledig saldo"; + String get xmr_full_balance => "Volledig saldo"; @override String get incoming => "inkomend"; @override @@ -6963,7 +6963,7 @@ class $zh extends S { @override String get restore_seed_keys_restore => "种子/密钥还原"; @override - String get xmr_hidden => "XMR Hidden"; + String get xmr_hidden => "隱"; @override String get send_xmr => "发送 XMR"; @override @@ -7059,7 +7059,7 @@ class $zh extends S { @override String get error_text_xmr => "XMR值不能超过可用余额.\n小数位数必须小于或等于12"; @override - String get xmr_available_balance => "XMR 可用余额 "; + String get xmr_available_balance => "可用余额 "; @override String get restore_bitcoin_description_from_keys => "從私鑰中生成的WIF字符串還原您的錢包"; @override @@ -7223,7 +7223,7 @@ class $zh extends S { @override String get all => "所有"; @override - String get xmr_full_balance => "XMR 全部余额"; + String get xmr_full_balance => "全部余额"; @override String get incoming => "传入"; @override diff --git a/res/values/strings_de.arb b/res/values/strings_de.arb index fd00ea39e..ae97c7815 100644 --- a/res/values/strings_de.arb +++ b/res/values/strings_de.arb @@ -33,9 +33,9 @@ "wallet_menu" : "Brieftaschen-Menü", "Blocks_remaining" : "${status} Verbleibende Blöcke", "please_try_to_connect_to_another_node" : "Bitte versuchen Sie, eine Verbindung zu einem anderen Knoten herzustellen", - "xmr_hidden" : "XMR versteckt", - "xmr_available_balance" : "XMR verfügbares Guthaben", - "xmr_full_balance" : "XMR Volle Balance", + "xmr_hidden" : "Versteckt", + "xmr_available_balance" : "Verfügbares Guthaben", + "xmr_full_balance" : "Volle Balance", "send" : "Senden", "receive" : "Erhalten", "transactions" : "Transaktionen", diff --git a/res/values/strings_en.arb b/res/values/strings_en.arb index 28b363773..41b3eefc5 100644 --- a/res/values/strings_en.arb +++ b/res/values/strings_en.arb @@ -33,9 +33,9 @@ "wallet_menu" : "Menu", "Blocks_remaining" : "${status} Blocks Remaining", "please_try_to_connect_to_another_node" : "Please try to connect to another node", - "xmr_hidden" : "XMR Hidden", - "xmr_available_balance" : "XMR Available Balance", - "xmr_full_balance" : "XMR Full Balance", + "xmr_hidden" : "Hidden", + "xmr_available_balance" : "Available Balance", + "xmr_full_balance" : "Full Balance", "send" : "Send", "receive" : "Receive", "transactions" : "Transactions", diff --git a/res/values/strings_es.arb b/res/values/strings_es.arb index 535fe09e6..3874222d5 100644 --- a/res/values/strings_es.arb +++ b/res/values/strings_es.arb @@ -33,9 +33,9 @@ "wallet_menu" : "Menú de billetera", "Blocks_remaining" : "${status} Bloques restantes", "please_try_to_connect_to_another_node" : "Intenta conectarte a otro nodo", - "xmr_hidden" : "XMR Oculto", - "xmr_available_balance" : "XMR Available Balance", - "xmr_full_balance" : "XMR Saldo disponible", + "xmr_hidden" : "Oculto", + "xmr_available_balance" : "Saldo disponible", + "xmr_full_balance" : "Balance total", "send" : "Enviar", "receive" : "Recibir", "transactions" : "Actas", diff --git a/res/values/strings_hi.arb b/res/values/strings_hi.arb index 9e1f08724..f93963d04 100644 --- a/res/values/strings_hi.arb +++ b/res/values/strings_hi.arb @@ -33,9 +33,9 @@ "wallet_menu" : "बटुआ मेनू", "Blocks_remaining" : "${status} शेष रहते हैं", "please_try_to_connect_to_another_node" : "कृपया दूसरे नोड से कनेक्ट करने का प्रयास करें", - "xmr_hidden" : "XMR छिपा हुआ", - "xmr_available_balance" : "XMR उपलब्ध शेष राशि", - "xmr_full_balance" : "XMR पूर्ण संतुलन", + "xmr_hidden" : "छिपा हुआ", + "xmr_available_balance" : "उपलब्ध शेष राशि", + "xmr_full_balance" : "पूरा संतुलन", "send" : "संदेश", "receive" : "प्राप्त करना", "transactions" : "लेन-देन", diff --git a/res/values/strings_ja.arb b/res/values/strings_ja.arb index 50a796ff4..6ddaaee76 100644 --- a/res/values/strings_ja.arb +++ b/res/values/strings_ja.arb @@ -33,9 +33,9 @@ "wallet_menu" : "ウォレットメニュー", "Blocks_remaining" : "${status} 残りのブロック", "please_try_to_connect_to_another_node" : "別のノードに接続してみてください", - "xmr_hidden" : "XMR非表示", - "xmr_available_balance" : "XMR利用可能残高", - "xmr_full_balance" : "XMRフルバランス", + "xmr_hidden" : "非表示", + "xmr_available_balance" : "利用可能残高", + "xmr_full_balance" : "フルバランス", "send" : "送る", "receive" : "受け取る", "transactions" : "取引", diff --git a/res/values/strings_ko.arb b/res/values/strings_ko.arb index 720069215..e6110dd8a 100644 --- a/res/values/strings_ko.arb +++ b/res/values/strings_ko.arb @@ -33,9 +33,9 @@ "wallet_menu" : "월렛 메뉴", "Blocks_remaining" : "${status} 남은 블록", "please_try_to_connect_to_another_node" : "다른 노드에 연결을 시도하십시오", - "xmr_hidden" : "XMR 숨김", - "xmr_available_balance" : "XMR 사용 가능한 잔액", - "xmr_full_balance" : "XMR 풀 밸런스", + "xmr_hidden" : "숨김", + "xmr_available_balance" : "사용 가능한 잔액", + "xmr_full_balance" : "풀 밸런스", "send" : "보내다", "receive" : "받다", "transactions" : "업무", diff --git a/res/values/strings_nl.arb b/res/values/strings_nl.arb index cf04367b6..c6e94461b 100644 --- a/res/values/strings_nl.arb +++ b/res/values/strings_nl.arb @@ -33,9 +33,9 @@ "wallet_menu" : "Portemonnee-menu", "Blocks_remaining" : "${status} Resterende blokken", "please_try_to_connect_to_another_node" : "Probeer verbinding te maken met een ander knooppunt", - "xmr_hidden" : "XMR Verborgen", - "xmr_available_balance" : "XMR Beschikbaar saldo", - "xmr_full_balance" : "XMR Volledig saldo", + "xmr_hidden" : "Verborgen", + "xmr_available_balance" : "Beschikbaar saldo", + "xmr_full_balance" : "Volledig saldo", "send" : "Sturen", "receive" : "Krijgen", "transactions" : "Transacties", diff --git a/res/values/strings_pl.arb b/res/values/strings_pl.arb index d7d6ae418..d2e5504f1 100644 --- a/res/values/strings_pl.arb +++ b/res/values/strings_pl.arb @@ -33,9 +33,9 @@ "wallet_menu" : "Menu portfela", "Blocks_remaining" : "${status} Bloki pozostałe", "please_try_to_connect_to_another_node" : "Spróbuj połączyć się z innym węzłem", - "xmr_hidden" : "XMR Ukryty", - "xmr_available_balance" : "XMR Dostępne saldo", - "xmr_full_balance" : "XMR Pełna równowaga", + "xmr_hidden" : "Ukryty", + "xmr_available_balance" : "Dostępne saldo", + "xmr_full_balance" : "Pełna równowaga", "send" : "Wysłać", "receive" : "Otrzymać", "transactions" : "Transakcje", diff --git a/res/values/strings_pt.arb b/res/values/strings_pt.arb index 9566cccc1..9d39b3f1a 100644 --- a/res/values/strings_pt.arb +++ b/res/values/strings_pt.arb @@ -34,8 +34,8 @@ "Blocks_remaining" : "${status} blocos restantes", "please_try_to_connect_to_another_node" : "Por favor, tente conectar-se a outro nó", "xmr_hidden" : "Esconder saldo", - "xmr_available_balance" : "Saldo XMR disponível", - "xmr_full_balance" : "Saldo XMR total", + "xmr_available_balance" : "Saldo disponível", + "xmr_full_balance" : "Saldo total", "send" : "Enviar", "receive" : "Receber", "transactions" : "Transações", diff --git a/res/values/strings_ru.arb b/res/values/strings_ru.arb index c6955eda9..891ab6a48 100644 --- a/res/values/strings_ru.arb +++ b/res/values/strings_ru.arb @@ -33,9 +33,9 @@ "wallet_menu" : "Меню кошелька", "Blocks_remaining" : "${status} Осталось блоков", "please_try_to_connect_to_another_node" : "Пожалуйста, попробуйте подключиться к другой ноде", - "xmr_hidden" : "XMR Скрыто", - "xmr_available_balance" : "Доступный XMR баланс", - "xmr_full_balance" : "Весь XMR баланс", + "xmr_hidden" : "Скрыто", + "xmr_available_balance" : "Доступный баланс", + "xmr_full_balance" : "Весь баланс", "send" : "Отправить", "receive" : "Получить", "transactions" : "Транзакции", diff --git a/res/values/strings_uk.arb b/res/values/strings_uk.arb index 5bbbc606f..2fbfadd18 100644 --- a/res/values/strings_uk.arb +++ b/res/values/strings_uk.arb @@ -33,9 +33,9 @@ "wallet_menu" : "Меню гаманця", "Blocks_remaining" : "${status} Залишилось блоків", "please_try_to_connect_to_another_node" : "Будь ласка, спробуйте підключитися до іншого вузлу", - "xmr_hidden" : "XMR Приховано", - "xmr_available_balance" : "Доступний XMR баланс", - "xmr_full_balance" : "Весь XMR баланс", + "xmr_hidden" : "Приховано", + "xmr_available_balance" : "Доступний баланс", + "xmr_full_balance" : "Весь баланс", "send" : "Відправити", "receive" : "Отримати", "transactions" : "Транзакції", diff --git a/res/values/strings_zh.arb b/res/values/strings_zh.arb index 195eff3b4..3bad6c530 100644 --- a/res/values/strings_zh.arb +++ b/res/values/strings_zh.arb @@ -33,9 +33,9 @@ "wallet_menu" : "钱包菜单", "Blocks_remaining" : "${status} 剩余的块", "please_try_to_connect_to_another_node" : "请尝试连接到另一个节点", - "xmr_hidden" : "XMR Hidden", - "xmr_available_balance" : "XMR 可用余额 ", - "xmr_full_balance" : "XMR 全部余额", + "xmr_hidden" : "隱", + "xmr_available_balance" : "可用余额 ", + "xmr_full_balance" : "全部余额", "send" : "发送", "receive" : "接收", "transactions" : "交易次数", From 2eb229b91eef92d70f5db0147af04d28653e6941 Mon Sep 17 00:00:00 2001 From: M Date: Thu, 1 Oct 2020 19:46:23 +0300 Subject: [PATCH 3/5] Fixes for gray screen bug. --- cw_monero/ios/Classes/monero_api.cpp | 4 ++++ ios/Flutter/.last_build_id | 1 - lib/di.dart | 23 ++++++++++++++++++---- lib/monero/monero_wallet.dart | 13 +++++++++++- lib/src/screens/dashboard/wallet_menu.dart | 2 +- 5 files changed, 36 insertions(+), 7 deletions(-) delete mode 100644 ios/Flutter/.last_build_id diff --git a/cw_monero/ios/Classes/monero_api.cpp b/cw_monero/ios/Classes/monero_api.cpp index b4fa5cc0a..68cf99ee9 100644 --- a/cw_monero/ios/Classes/monero_api.cpp +++ b/cw_monero/ios/Classes/monero_api.cpp @@ -175,6 +175,7 @@ extern "C" Monero::SubaddressAccount *m_account; uint64_t m_last_known_wallet_height; uint64_t m_cached_syncing_blockchain_height = 0; + std::mutex store_mutex; void change_current_wallet(Monero::Wallet *wallet) @@ -293,6 +294,7 @@ extern "C" void load_wallet(char *path, char *password, int32_t nettype) { + nice(19); Monero::NetworkType networkType = static_cast(nettype); Monero::Wallet *wallet = Monero::WalletManagerFactory::getWalletManager()->openWallet(std::string(path), std::string(password), networkType); change_current_wallet(wallet); @@ -429,7 +431,9 @@ extern "C" void store(char *path) { + store_mutex.lock(); get_current_wallet()->store(std::string(path)); + store_mutex.unlock(); } bool transaction_create(char *address, char *payment_id, char *amount, diff --git a/ios/Flutter/.last_build_id b/ios/Flutter/.last_build_id deleted file mode 100644 index 0c913ed64..000000000 --- a/ios/Flutter/.last_build_id +++ /dev/null @@ -1 +0,0 @@ -4dc2ef1ba73deeed13cd85894dacb10b \ No newline at end of file diff --git a/lib/di.dart b/lib/di.dart index d133b6ed0..aac1bfa24 100644 --- a/lib/di.dart +++ b/lib/di.dart @@ -61,6 +61,7 @@ import 'package:cake_wallet/view_model/exchange/exchange_view_model.dart'; import 'package:flutter/widgets.dart'; import 'package:get_it/get_it.dart'; import 'package:hive/hive.dart'; +import 'package:mobx/mobx.dart'; import 'package:shared_preferences/shared_preferences.dart'; import 'package:flutter_secure_storage/flutter_secure_storage.dart'; import 'package:cake_wallet/view_model/wallet_restoration_from_seed_vm.dart'; @@ -177,11 +178,25 @@ Future setup( BiometricAuth())); getIt.registerFactory( - () => AuthPage(getIt.get(), - onAuthenticationFinished: (isAuthenticated, __) { - if (isAuthenticated) { - getIt.get().allowed(); + () => AuthPage(getIt.get(), onAuthenticationFinished: + (isAuthenticated, AuthPageState authPageState) { + if (!isAuthenticated) { + return; } + final authStore = getIt.get(); + final appStore = getIt.get(); + + if (appStore.wallet != null) { + authStore.allowed(); + return; + } + + authPageState.changeProcessText('Loading the wallet'); + ReactionDisposer _reaction; + _reaction = reaction((_) => appStore.wallet, (Object _) { + _reaction?.reaction?.dispose(); + authStore.allowed(); + }); }, closable: false), instanceName: 'login'); diff --git a/lib/monero/monero_wallet.dart b/lib/monero/monero_wallet.dart index b1133dd5b..9e59a1264 100644 --- a/lib/monero/monero_wallet.dart +++ b/lib/monero/monero_wallet.dart @@ -19,6 +19,7 @@ import 'package:cake_wallet/entities/wallet_info.dart'; import 'package:cake_wallet/entities/node.dart'; import 'package:cake_wallet/entities/transaction_priority.dart'; + part 'monero_wallet.g.dart'; const moneroBlockSize = 1000; @@ -40,6 +41,7 @@ abstract class MoneroWalletBase extends WalletBase with Store { subaddress = subaddressList.subaddresses.first; address = subaddress.address; }); + _cachedRefreshHeight = 0; } @override @@ -80,6 +82,7 @@ abstract class MoneroWalletBase extends WalletBase with Store { String _filename; SyncListner _listener; ReactionDisposer _onAccountChangeReaction; + int _cachedRefreshHeight; Future init() async { await accountList.update(); @@ -177,7 +180,9 @@ abstract class MoneroWalletBase extends WalletBase with Store { @override Future save() async { + print('SAVE CALLED'); await monero_wallet.store(); + print('SAVE FINISHED'); } Future getNodeHeight() async => monero_wallet.getNodeHeight(); @@ -191,12 +196,15 @@ abstract class MoneroWalletBase extends WalletBase with Store { @override Future rescan({int height}) async { + walletInfo.restoreHeight = height; + walletInfo.isRecovery = true; monero_wallet.setRefreshFromBlockHeight(height: height); monero_wallet.rescanBlockchainAsync(); await startSync(); _askForUpdateBalance(); await _askForUpdateTransactionHistory(); await save(); + await walletInfo.save(); } void _setListeners() { @@ -284,7 +292,10 @@ abstract class MoneroWalletBase extends WalletBase with Store { await setAsRecovered(); } - await save(); + if (currentHeight - _cachedRefreshHeight > moneroBlockSize) { + _cachedRefreshHeight = currentHeight; + await save(); + } } void _onNewTransaction() { diff --git a/lib/src/screens/dashboard/wallet_menu.dart b/lib/src/screens/dashboard/wallet_menu.dart index 3d1d80026..b8639e040 100644 --- a/lib/src/screens/dashboard/wallet_menu.dart +++ b/lib/src/screens/dashboard/wallet_menu.dart @@ -87,8 +87,8 @@ class WalletMenu { rightButtonText: S.of(context).ok, leftButtonText: S.of(context).cancel, actionRightButton: () async { - await reconnect?.call(); Navigator.of(context).pop(); + await reconnect?.call(); }, actionLeftButton: () => Navigator.of(context).pop()); }); From b506f9c953307d37aadce77904e761ebe31d2681 Mon Sep 17 00:00:00 2001 From: M Date: Thu, 1 Oct 2020 19:48:31 +0300 Subject: [PATCH 4/5] Updated dependencies --- pubspec.lock | 35 +++++++++++++++++++++-------------- 1 file changed, 21 insertions(+), 14 deletions(-) diff --git a/pubspec.lock b/pubspec.lock index 9b56163ba..5513bc46f 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -42,7 +42,7 @@ packages: name: async url: "https://pub.dartlang.org" source: hosted - version: "2.4.1" + version: "2.4.2" auto_size_text: dependency: "direct main" description: @@ -210,7 +210,7 @@ packages: name: collection url: "https://pub.dartlang.org" source: hosted - version: "1.14.12" + version: "1.14.13" connectivity: dependency: "direct main" description: @@ -252,7 +252,7 @@ packages: name: crypto url: "https://pub.dartlang.org" source: hosted - version: "2.1.4" + version: "2.1.5" csslib: dependency: transitive description: @@ -330,6 +330,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.0.2" + fake_async: + dependency: transitive + description: + name: fake_async + url: "https://pub.dartlang.org" + source: hosted + version: "1.1.0" ffi: dependency: transitive description: @@ -505,7 +512,7 @@ packages: name: image url: "https://pub.dartlang.org" source: hosted - version: "2.1.12" + version: "2.1.18" intl: dependency: "direct main" description: @@ -561,7 +568,7 @@ packages: name: matcher url: "https://pub.dartlang.org" source: hosted - version: "0.12.6" + version: "0.12.8" meta: dependency: transitive description: @@ -589,7 +596,7 @@ packages: name: mobx_codegen url: "https://pub.dartlang.org" source: hosted - version: "1.1.0+1" + version: "1.1.0+2" node_interop: dependency: transitive description: @@ -631,7 +638,7 @@ packages: name: path url: "https://pub.dartlang.org" source: hosted - version: "1.6.4" + version: "1.7.0" path_drawing: dependency: transitive description: @@ -694,7 +701,7 @@ packages: name: petitparser url: "https://pub.dartlang.org" source: hosted - version: "2.4.0" + version: "3.0.4" platform: dependency: transitive description: @@ -708,7 +715,7 @@ packages: name: plugin_platform_interface url: "https://pub.dartlang.org" source: hosted - version: "1.0.2" + version: "1.0.3" pointycastle: dependency: transitive description: @@ -874,7 +881,7 @@ packages: name: stack_trace url: "https://pub.dartlang.org" source: hosted - version: "1.9.3" + version: "1.9.5" stream_channel: dependency: transitive description: @@ -909,7 +916,7 @@ packages: name: test_api url: "https://pub.dartlang.org" source: hosted - version: "0.2.15" + version: "0.2.17" time: dependency: transitive description: @@ -930,7 +937,7 @@ packages: name: typed_data url: "https://pub.dartlang.org" source: hosted - version: "1.1.6" + version: "1.2.0" url_launcher: dependency: "direct main" description: @@ -1021,7 +1028,7 @@ packages: name: xml url: "https://pub.dartlang.org" source: hosted - version: "3.6.1" + version: "4.5.1" yaml: dependency: "direct main" description: @@ -1030,5 +1037,5 @@ packages: source: hosted version: "2.2.1" sdks: - dart: ">=2.7.0 <3.0.0" + dart: ">=2.9.0-14.0.dev <3.0.0" flutter: ">=1.12.13+hotfix.5 <2.0.0" From 04e7c1884176b5e6f607d3bd0074914492e16f78 Mon Sep 17 00:00:00 2001 From: M Date: Fri, 2 Oct 2020 20:28:29 +0300 Subject: [PATCH 5/5] Fixes and improvments. --- ios/Runner.xcodeproj/project.pbxproj | 6 +- lib/monero/monero_wallet.dart | 2 - .../on_authentication_state_change.dart | 2 - .../screens/contact/contact_list_page.dart | 162 ++++++++-------- .../dashboard/widgets/transaction_raw.dart | 37 ++-- lib/src/screens/nodes/nodes_list_page.dart | 179 +++++++++--------- lib/src/screens/pin_code/pin_code_widget.dart | 4 +- lib/src/screens/send/send_page.dart | 60 +++--- .../screens/wallet_list/wallet_list_page.dart | 2 +- lib/utils/mobx.dart | 15 +- lib/utils/show_pop_up.dart | 4 +- .../node_list/node_list_view_model.dart | 5 +- lib/view_model/send/send_view_model.dart | 8 + 13 files changed, 246 insertions(+), 240 deletions(-) diff --git a/ios/Runner.xcodeproj/project.pbxproj b/ios/Runner.xcodeproj/project.pbxproj index c0d7cb8e8..a3b83428b 100644 --- a/ios/Runner.xcodeproj/project.pbxproj +++ b/ios/Runner.xcodeproj/project.pbxproj @@ -354,7 +354,7 @@ buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_ENABLE_MODULES = YES; - CURRENT_PROJECT_VERSION = 3; + CURRENT_PROJECT_VERSION = 4; DEVELOPMENT_TEAM = 32J6BB6VUS; ENABLE_BITCODE = NO; FRAMEWORK_SEARCH_PATHS = ( @@ -493,7 +493,7 @@ buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_ENABLE_MODULES = YES; - CURRENT_PROJECT_VERSION = 3; + CURRENT_PROJECT_VERSION = 4; DEVELOPMENT_TEAM = 32J6BB6VUS; ENABLE_BITCODE = NO; FRAMEWORK_SEARCH_PATHS = ( @@ -526,7 +526,7 @@ buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_ENABLE_MODULES = YES; - CURRENT_PROJECT_VERSION = 3; + CURRENT_PROJECT_VERSION = 4; DEVELOPMENT_TEAM = 32J6BB6VUS; ENABLE_BITCODE = NO; FRAMEWORK_SEARCH_PATHS = ( diff --git a/lib/monero/monero_wallet.dart b/lib/monero/monero_wallet.dart index 9e59a1264..59ac8702a 100644 --- a/lib/monero/monero_wallet.dart +++ b/lib/monero/monero_wallet.dart @@ -180,9 +180,7 @@ abstract class MoneroWalletBase extends WalletBase with Store { @override Future save() async { - print('SAVE CALLED'); await monero_wallet.store(); - print('SAVE FINISHED'); } Future getNodeHeight() async => monero_wallet.getNodeHeight(); diff --git a/lib/reactions/on_authentication_state_change.dart b/lib/reactions/on_authentication_state_change.dart index 237ef00a8..80f3b2823 100644 --- a/lib/reactions/on_authentication_state_change.dart +++ b/lib/reactions/on_authentication_state_change.dart @@ -14,8 +14,6 @@ void startAuthenticationStateChange(AuthenticationStore authenticationStore, if (state == AuthenticationState.installed) { await loadCurrentWallet(); - // await navigatorKey.currentState - // .pushNamedAndRemoveUntil(Routes.login, (_) => false); } if (state == AuthenticationState.allowed) { diff --git a/lib/src/screens/contact/contact_list_page.dart b/lib/src/screens/contact/contact_list_page.dart index c66f5f2c4..548544679 100644 --- a/lib/src/screens/contact/contact_list_page.dart +++ b/lib/src/screens/contact/contact_list_page.dart @@ -63,14 +63,14 @@ class ContactListPage extends BasePage { builder: (_) { return contactListViewModel.contacts.isNotEmpty ? SectionStandardList( - sectionCount: 1, - context: context, - itemCounter: (int sectionIndex) => contactListViewModel.contacts.length, - itemBuilder: (_, sectionIndex, index) { - final contact = contactListViewModel.contacts[index]; - final image = _getCurrencyImage(contact.type); - final content = Builder( - builder: (context) => GestureDetector( + sectionCount: 1, + context: context, + itemCounter: (int sectionIndex) => + contactListViewModel.contacts.length, + itemBuilder: (_, sectionIndex, index) { + final contact = contactListViewModel.contacts[index]; + final image = _getCurrencyImage(contact.type); + final content = GestureDetector( onTap: () async { if (!isEditable) { Navigator.of(context).pop(contact); @@ -83,94 +83,79 @@ class ContactListPage extends BasePage { if (isCopied != null && isCopied) { await Clipboard.setData( ClipboardData(text: contact.address)); - await showBar(context, - S.of(context).copied_to_clipboard); + await showBar( + context, S.of(context).copied_to_clipboard); } }, - child: Column( - children: [ - Container( - width: double.infinity, - child: Padding( - padding: const EdgeInsets.only( - left: 24, top: 16, bottom: 16, right: 24), - child: Row( - mainAxisSize: MainAxisSize.min, - mainAxisAlignment: MainAxisAlignment.start, - crossAxisAlignment: - CrossAxisAlignment.center, - children: [ - image ?? Offstage(), - Padding( - padding: image != null - ? EdgeInsets.only(left: 12) - : EdgeInsets.only(left: 0), - child: Text( - contact.name, - style: TextStyle( - fontSize: 14, - fontWeight: FontWeight.normal, - color: Theme.of(context) - .primaryTextTheme - .title - .color), - ), - ) - ], - )), - ), - ], + child: Container( + color: Colors.transparent, + padding: const EdgeInsets.only( + left: 24, top: 16, bottom: 16, right: 24), + child: Row( + mainAxisSize: MainAxisSize.min, + mainAxisAlignment: MainAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + image ?? Offstage(), + Padding( + padding: image != null + ? EdgeInsets.only(left: 12) + : EdgeInsets.only(left: 0), + child: Text( + contact.name, + style: TextStyle( + fontSize: 14, + fontWeight: FontWeight.normal, + color: Theme.of(context) + .primaryTextTheme + .title + .color), + ), + ) + ], + ), ), - ) - ); + ); - return !isEditable - ? content - : Slidable( - key: Key('${contact.key}'), - actionPane: SlidableDrawerActionPane(), - child: content, - secondaryActions: [ - IconSlideAction( - caption: S.of(context).edit, - color: Colors.blue, - icon: Icons.edit, - onTap: () async => await Navigator.of(context) - .pushNamed(Routes.addressBookAddContact, - arguments: contact), - ), - IconSlideAction( - caption: S.of(context).delete, - color: Colors.red, - icon: CupertinoIcons.delete, - onTap: () async { - final isDelete = - await showAlertDialog(context) ?? false; + return !isEditable + ? content + : Slidable( + key: Key('${contact.key}'), + actionPane: SlidableDrawerActionPane(), + child: content, + secondaryActions: [ + IconSlideAction( + caption: S.of(context).edit, + color: Colors.blue, + icon: Icons.edit, + onTap: () async => + await Navigator.of(context).pushNamed( + Routes.addressBookAddContact, + arguments: contact), + ), + IconSlideAction( + caption: S.of(context).delete, + color: Colors.red, + icon: CupertinoIcons.delete, + onTap: () async { + final isDelete = + await showAlertDialog(context) ?? + false; - if (isDelete) { - await contactListViewModel - .delete(contact); - } - }, - ), - ], - dismissal: SlidableDismissal( - child: SlidableDrawerDismissal(), - onDismissed: (actionType) async => null, - // await contactListViewModel.delete(contact), - onWillDismiss: (actionType) async => - showAlertDialog(context), - ), - ); - }, - ) + if (isDelete) { + await contactListViewModel + .delete(contact); + } + }, + ), + ]); + }, + ) : Center( child: Text( S.of(context).placeholder_contacts, textAlign: TextAlign.center, - style: TextStyle( - color: Colors.grey, - fontSize: 14), + style: TextStyle(color: Colors.grey, fontSize: 14), ), ); }, @@ -181,7 +166,8 @@ class ContactListPage extends BasePage { Image image; switch (currency) { case CryptoCurrency.xmr: - image = Image.asset('assets/images/monero_logo.png', height: 24, width: 24); + image = + Image.asset('assets/images/monero_logo.png', height: 24, width: 24); break; case CryptoCurrency.ada: image = Image.asset('assets/images/ada.png', height: 24, width: 24); diff --git a/lib/src/screens/dashboard/widgets/transaction_raw.dart b/lib/src/screens/dashboard/widgets/transaction_raw.dart index 14d07a9fc..67e13ce43 100644 --- a/lib/src/screens/dashboard/widgets/transaction_raw.dart +++ b/lib/src/screens/dashboard/widgets/transaction_raw.dart @@ -29,8 +29,21 @@ class TransactionRow extends StatelessWidget { child: Row( crossAxisAlignment: CrossAxisAlignment.center, children: [ + Container( + height: 36, + width: 36, + decoration: BoxDecoration( + shape: BoxShape.circle, + color: Theme.of(context).textTheme.overline.decorationColor + ), + child: Image.asset( + direction == TransactionDirection.incoming + ? 'assets/images/down_arrow.png' + : 'assets/images/up_arrow.png'), + ), Expanded( child: Container( + padding: const EdgeInsets.only(left: 12), height: 56, child: Column( mainAxisAlignment: MainAxisAlignment.spaceBetween, @@ -48,25 +61,11 @@ class TransactionRow extends StatelessWidget { fontSize: 16, fontWeight: FontWeight.w500, color: Colors.white)), - Container( - decoration: BoxDecoration( - borderRadius: - BorderRadius.all(Radius.circular(10)), - color: (direction == - TransactionDirection.incoming - ? Colors.green.withOpacity(0.8) - : Theme.of(context) - .accentTextTheme - .body2 - .decorationColor - .withOpacity(0.8))), - padding: EdgeInsets.only( - top: 3, bottom: 3, left: 10, right: 10), - child: Text(formattedAmount, - style: TextStyle( - fontSize: 16, - fontWeight: FontWeight.w500, - color: Colors.white))) + Text(formattedAmount, + style: TextStyle( + fontSize: 16, + fontWeight: FontWeight.w500, + color: Colors.white)) ]), Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, diff --git a/lib/src/screens/nodes/nodes_list_page.dart b/lib/src/screens/nodes/nodes_list_page.dart index b0bc8c15f..20abdae32 100644 --- a/lib/src/screens/nodes/nodes_list_page.dart +++ b/lib/src/screens/nodes/nodes_list_page.dart @@ -10,6 +10,7 @@ import 'package:cake_wallet/src/screens/nodes/widgets/node_list_row.dart'; import 'package:cake_wallet/src/widgets/standard_list.dart'; import 'package:cake_wallet/src/widgets/alert_with_two_actions.dart'; import 'package:cake_wallet/view_model/node_list/node_list_view_model.dart'; +import 'package:flutter_slidable/flutter_slidable.dart'; class NodeListPage extends BasePage { NodeListPage(this.nodeListViewModel); @@ -59,102 +60,104 @@ class NodeListPage extends BasePage { } @override - Widget body(context) { + Widget body(BuildContext context) { return Container( padding: EdgeInsets.only(top: 10), child: Observer( - builder: (_) => SectionStandardList( - sectionCount: 2, - context: context, - itemBuilder: (_, sectionIndex, index) { - return Observer(builder: (_) { - if (sectionIndex == 0) { - return NodeHeaderListRow( - title: S.of(context).add_new_node, - onTap: (_) async => await Navigator.of(context) - .pushNamed(Routes.newNode)); - } + builder: (BuildContext context) { + return nodeListViewModel.nodes.isNotEmpty + ? SectionStandardList( + sectionCount: 2, + context: context, + itemCounter: (int sectionIndex) { + if (sectionIndex == 0) { + return 1; + } - final node = nodeListViewModel.nodes[index]; - final isSelected = node.keyIndex == - nodeListViewModel.settingsStore.currentNode.keyIndex; - final nodeListRow = NodeListRow( - title: node.uri, - isSelected: isSelected, - isAlive: node.requestNode(), - onTap: (_) async { - if (isSelected) { - return; - } + return nodeListViewModel.nodes.length; + }, + itemBuilder: (_, sectionIndex, index) { + if (sectionIndex == 0) { + return NodeHeaderListRow( + title: S.of(context).add_new_node, + onTap: (_) async => await Navigator.of(context) + .pushNamed(Routes.newNode)); + } - await showPopUp( - context: context, - builder: (BuildContext context) { - // FIXME: Add translation. - return AlertWithTwoActions( - alertTitle: 'Change current node', - alertContent: - S.of(context).change_current_node(node.uri), - leftButtonText: S.of(context).cancel, - rightButtonText: S.of(context).change, - actionLeftButton: () => - Navigator.of(context).pop(), - actionRightButton: () async { - await nodeListViewModel.setAsCurrent(node); - Navigator.of(context).pop(); - }); - }); - }); + final node = nodeListViewModel.nodes[index]; + final isSelected = node.keyIndex == + nodeListViewModel.settingsStore.currentNode.keyIndex; + final nodeListRow = NodeListRow( + title: node.uri, + isSelected: isSelected, + isAlive: node.requestNode(), + onTap: (_) async { + if (isSelected) { + return; + } - final dismissibleRow = Dismissible( - key: Key('${node.keyIndex}'), - confirmDismiss: (direction) async { - return await showPopUp( - context: context, - builder: (BuildContext context) { - return AlertWithTwoActions( - alertTitle: S.of(context).remove_node, - alertContent: S.of(context).remove_node_message, - rightButtonText: S.of(context).remove, - leftButtonText: S.of(context).cancel, - actionRightButton: () => - Navigator.pop(context, true), - actionLeftButton: () => - Navigator.pop(context, false)); - }); - }, - onDismissed: (direction) async => - nodeListViewModel.delete(node), - direction: DismissDirection.endToStart, - background: Container( - padding: EdgeInsets.only(right: 10.0), - alignment: AlignmentDirectional.centerEnd, - color: Palette.red, - child: Column( - mainAxisAlignment: MainAxisAlignment.spaceEvenly, - children: [ - const Icon( - CupertinoIcons.delete, - color: Colors.white, - ), - Text( - S.of(context).delete, - style: TextStyle(color: Colors.white), - ) - ], - )), - child: nodeListRow); + await showPopUp( + context: context, + builder: (BuildContext context) { + // FIXME: Add translation. + return AlertWithTwoActions( + alertTitle: 'Change current node', + alertContent: S + .of(context) + .change_current_node(node.uri), + leftButtonText: S.of(context).cancel, + rightButtonText: S.of(context).change, + actionLeftButton: () => + Navigator.of(context).pop(), + actionRightButton: () async { + await nodeListViewModel + .setAsCurrent(node); + Navigator.of(context).pop(); + }); + }); + }); - return isSelected ? nodeListRow : dismissibleRow; - }); - }, - itemCounter: (int sectionIndex) { - if (sectionIndex == 0) { - return 1; - } + final dismissibleRow = Slidable( + key: Key('${node.keyIndex}'), + actionPane: SlidableDrawerActionPane(), + child: nodeListRow, + secondaryActions: [ + IconSlideAction( + caption: S.of(context).delete, + color: Colors.red, + icon: CupertinoIcons.delete, + onTap: () async { + final confirmed = await showPopUp( + context: context, + builder: (BuildContext context) { + return AlertWithTwoActions( + alertTitle: + S.of(context).remove_node, + alertContent: S + .of(context) + .remove_node_message, + rightButtonText: + S.of(context).remove, + leftButtonText: + S.of(context).cancel, + actionRightButton: () => + Navigator.pop(context, true), + actionLeftButton: () => + Navigator.pop(context, false)); + }) ?? + false; - return nodeListViewModel.nodes.length; - }), + if (confirmed) { + await nodeListViewModel.delete(node); + } + }, + ), + ]); + + return isSelected ? nodeListRow : dismissibleRow; + }) + : Container(); + }, ), ); } diff --git a/lib/src/screens/pin_code/pin_code_widget.dart b/lib/src/screens/pin_code/pin_code_widget.dart index 6cb0a9714..2911a3936 100644 --- a/lib/src/screens/pin_code/pin_code_widget.dart +++ b/lib/src/screens/pin_code/pin_code_widget.dart @@ -81,8 +81,8 @@ class PinCodeState extends State { } @override - Widget build(BuildContext context) => - Scaffold(key: _key, body: body(context)); + Widget build(BuildContext context) => Scaffold( + key: _key, body: body(context), resizeToAvoidBottomPadding: false); Widget body(BuildContext context) { final deleteIconImage = Image.asset( diff --git a/lib/src/screens/send/send_page.dart b/lib/src/screens/send/send_page.dart index 7a856cb43..0490463f9 100644 --- a/lib/src/screens/send/send_page.dart +++ b/lib/src/screens/send/send_page.dart @@ -25,15 +25,29 @@ import 'package:cake_wallet/src/screens/send/widgets/confirm_sending_alert.dart' import 'package:cake_wallet/src/widgets/base_text_form_field.dart'; class SendPage extends BasePage { - SendPage({@required this.sendViewModel}); + SendPage({@required this.sendViewModel}) + : _addressController = TextEditingController(), + _cryptoAmountController = TextEditingController(), + _fiatAmountController = TextEditingController(), + _formKey = GlobalKey(), + _cryptoAmountFocus = FocusNode(), + _fiatAmountFocus = FocusNode(), + _addressFocusNode = FocusNode() { + _addressFocusNode.addListener(() { + if (!_addressFocusNode.hasFocus && _addressController.text.isNotEmpty) { + getOpenaliasRecord(_addressFocusNode.context); + } + }); + } final SendViewModel sendViewModel; - final _addressController = TextEditingController(); - final _cryptoAmountController = TextEditingController(); - final _fiatAmountController = TextEditingController(); - final _formKey = GlobalKey(); - final _cryptoAmountFocus = FocusNode(); - final _fiatAmountFocus = FocusNode(); + final TextEditingController _addressController; + final TextEditingController _cryptoAmountController; + final TextEditingController _fiatAmountController; + final GlobalKey _formKey; + final FocusNode _cryptoAmountFocus; + final FocusNode _fiatAmountFocus; + final FocusNode _addressFocusNode; bool _effectsInstalled = false; @@ -105,6 +119,7 @@ class SendPage extends BasePage { child: Column( children: [ AddressTextField( + focusNode: _addressFocusNode, controller: _addressController, onURIScanned: (uri) { var address = ''; @@ -672,24 +687,23 @@ class SendPage extends BasePage { } Future getOpenaliasRecord(BuildContext context) async { - // final isOpenalias = - // await sendViewModel.isOpenaliasRecord(_addressController.text); + final record = + await sendViewModel.decodeOpenaliasRecord(_addressController.text); - // if (isOpenalias) { - // _addressController.text = sendViewModel.recordAddress; + if (record != null) { + _addressController.text = record.address; - // await showPopUp( - // context: context, - // builder: (BuildContext context) { - // return AlertWithOneAction( - // alertTitle: S.of(context).openalias_alert_title, - // alertContent: S - // .of(context) - // .openalias_alert_content(sendViewModel.recordName), - // buttonText: S.of(context).ok, - // buttonAction: () => Navigator.of(context).pop()); - // }); - // } + await showPopUp( + context: context, + builder: (BuildContext context) { + return AlertWithOneAction( + alertTitle: S.of(context).openalias_alert_title, + alertContent: + S.of(context).openalias_alert_content(record.name), + buttonText: S.of(context).ok, + buttonAction: () => Navigator.of(context).pop()); + }); + } } Future _setTransactionPriority(BuildContext context) async { diff --git a/lib/src/screens/wallet_list/wallet_list_page.dart b/lib/src/screens/wallet_list/wallet_list_page.dart index 8b55347c4..f6116b653 100644 --- a/lib/src/screens/wallet_list/wallet_list_page.dart +++ b/lib/src/screens/wallet_list/wallet_list_page.dart @@ -131,7 +131,7 @@ class WalletListBodyState extends State { wallet.name, style: TextStyle( fontSize: 22, - fontWeight: FontWeight.w600, + fontWeight: FontWeight.w500, color: Theme.of(context) .primaryTextTheme .title diff --git a/lib/utils/mobx.dart b/lib/utils/mobx.dart index 9e2316af7..7ae97d56f 100644 --- a/lib/utils/mobx.dart +++ b/lib/utils/mobx.dart @@ -61,7 +61,7 @@ extension MobxBindable on Box { } return watch().listen((event) { - if (filter != null && !filter(event.value as T)) { + if (filter != null && event.value != null && !filter(event.value as T)) { return; } @@ -80,7 +80,7 @@ extension MobxBindable on Box { } return watch().listen((event) { - if (filter != null && !filter(event.value as T)) { + if (filter != null && event.value != null && !filter(event.value as T)) { return; } @@ -124,15 +124,13 @@ extension HiveBindable on ObservableList { listen().listen((event) => dest.acceptEntityChange(event)); void acceptBoxChange(BoxEvent event, {T transformed}) { - print('---------------------'); - print('event.key: ${event.key}; event.deleted: ${event.deleted};'); if (event.deleted) { removeWhere((el) { - print('el.keyIndex ${el.keyIndex}'); - return el.keyIndex == event.key; }); - } + return el.keyIndex == event.key; + }); - print('---------------------'); + return; + } final dynamic value = transformed ?? event.value; @@ -150,6 +148,7 @@ extension HiveBindable on ObservableList { void acceptEntityChange(EntityChange event) { if (event.type == ChangeType.delete) { removeWhere((el) => el.keyIndex == event.key); + return; } final dynamic value = event.value; diff --git a/lib/utils/show_pop_up.dart b/lib/utils/show_pop_up.dart index 280bcff3c..a97fb3762 100644 --- a/lib/utils/show_pop_up.dart +++ b/lib/utils/show_pop_up.dart @@ -14,8 +14,8 @@ Future showPopUp({ context: context, builder: builder, barrierDismissible: barrierDismissible, - //barrierColor: barrierColor, - //useSafeArea: useSafeArea, + barrierColor: barrierColor, + useSafeArea: useSafeArea, useRootNavigator: useRootNavigator, routeSettings: routeSettings, child: child); diff --git a/lib/view_model/node_list/node_list_view_model.dart b/lib/view_model/node_list/node_list_view_model.dart index 2231ff7c9..3bb1d09ba 100644 --- a/lib/view_model/node_list/node_list_view_model.dart +++ b/lib/view_model/node_list/node_list_view_model.dart @@ -16,7 +16,7 @@ abstract class NodeListViewModelBase with Store { NodeListViewModelBase(this._nodeSource, this._wallet, this.settingsStore) : nodes = ObservableList() { _nodeSource.bindToList(nodes, - filter: (Node val) => val.type == _wallet.type, initialFire: true); + filter: (Node val) => val?.type == _wallet.type, initialFire: true); } final ObservableList nodes; @@ -46,7 +46,8 @@ abstract class NodeListViewModelBase with Store { await setAsCurrent(node); } - Future delete(Node node) async => _nodeSource.delete(node.key); + @action + Future delete(Node node) async => node.delete(); Future setAsCurrent(Node node) async => settingsStore.currentNode = node; diff --git a/lib/view_model/send/send_view_model.dart b/lib/view_model/send/send_view_model.dart index a37f39341..eb4ec2f4a 100644 --- a/lib/view_model/send/send_view_model.dart +++ b/lib/view_model/send/send_view_model.dart @@ -1,3 +1,4 @@ +import 'package:cake_wallet/entities/openalias_record.dart'; import 'package:intl/intl.dart'; import 'package:mobx/mobx.dart'; import 'package:cake_wallet/core/template_validator.dart'; @@ -144,6 +145,13 @@ abstract class SendViewModelBase with Store { void setTransactionPriority(TransactionPriority priority) => _settingsStore.transactionPriority = priority; + Future decodeOpenaliasRecord(String name) async { + final record = await OpenaliasRecord + .fetchAddressAndName(OpenaliasRecord.formatDomainName(name)); + + return record.name != name ? record : null; + } + @action void _updateFiatAmount() { try {