From b7cb5147e1f8188887d8de6178d2e830e2923fc8 Mon Sep 17 00:00:00 2001 From: OleksandrSobol Date: Mon, 26 Apr 2021 21:06:21 +0300 Subject: [PATCH 1/3] CAKE-303 | added buy button for xmr wallet and applied buy alert --- lib/src/screens/dashboard/dashboard_page.dart | 53 +++++++++++++------ res/values/strings_de.arb | 4 +- res/values/strings_en.arb | 4 +- res/values/strings_es.arb | 4 +- res/values/strings_hi.arb | 4 +- res/values/strings_ja.arb | 4 +- res/values/strings_ko.arb | 4 +- res/values/strings_nl.arb | 4 +- res/values/strings_pl.arb | 4 +- res/values/strings_pt.arb | 4 +- res/values/strings_ru.arb | 4 +- res/values/strings_uk.arb | 4 +- res/values/strings_zh.arb | 4 +- 13 files changed, 72 insertions(+), 29 deletions(-) diff --git a/lib/src/screens/dashboard/dashboard_page.dart b/lib/src/screens/dashboard/dashboard_page.dart index 172483ed0..be540164e 100644 --- a/lib/src/screens/dashboard/dashboard_page.dart +++ b/lib/src/screens/dashboard/dashboard_page.dart @@ -1,7 +1,9 @@ import 'package:cake_wallet/entities/wallet_type.dart'; import 'package:cake_wallet/generated/i18n.dart'; import 'package:cake_wallet/routes.dart'; +import 'package:cake_wallet/src/widgets/alert_with_one_action.dart'; import 'package:cake_wallet/themes/theme_base.dart'; +import 'package:cake_wallet/utils/show_pop_up.dart'; import 'package:flutter/material.dart'; import 'package:flutter/cupertino.dart'; import 'package:cake_wallet/view_model/dashboard/dashboard_view_model.dart'; @@ -42,7 +44,7 @@ class DashboardPage extends BasePage { child: scaffold); @override - bool get resizeToAvoidBottomPadding => false; + bool get resizeToAvoidBottomInset => false; @override Widget get endDrawer => MenuWidget(walletViewModel); @@ -114,7 +116,7 @@ class DashboardPage extends BasePage { )), Container( padding: EdgeInsets.only(left: 45, right: 45, bottom: 24), - child: Observer(builder: (_) => Row( + child: Row( mainAxisAlignment: MainAxisAlignment.spaceAround, children: [ ActionButton( @@ -125,7 +127,7 @@ class DashboardPage extends BasePage { image: exchangeImage, title: S.of(context).exchange, route: Routes.exchange), - if (walletViewModel.type == WalletType.bitcoin) Observer( + Observer( builder: (_) => Stack( clipBehavior: Clip.none, alignment: Alignment.topCenter, @@ -143,23 +145,11 @@ class DashboardPage extends BasePage { title: S.of(context).buy, onClick: walletViewModel.isRunningWebView ? null - : () async { - try { - walletViewModel.isRunningWebView = true; - final url = - await walletViewModel.wyreViewModel.wyreUrl; - await Navigator.of(context) - .pushNamed(Routes.wyre, arguments: url); - walletViewModel.isRunningWebView = false; - } catch(e) { - print(e.toString()); - walletViewModel.isRunningWebView = false; - } - }) + : () async => await _onClickBuyButton(context)) ], )), ], - )), + ), ) ], )); @@ -176,4 +166,33 @@ class DashboardPage extends BasePage { _isEffectsInstalled = true; } + + Future _onClickBuyButton(BuildContext context) async { + final walletType = walletViewModel.type; + + switch (walletType) { + case WalletType.bitcoin: + try { + walletViewModel.isRunningWebView = true; + final url = await walletViewModel.wyreViewModel.wyreUrl; + await Navigator.of(context).pushNamed(Routes.wyre, arguments: url); + walletViewModel.isRunningWebView = false; + } catch(e) { + print(e.toString()); + walletViewModel.isRunningWebView = false; + } + break; + default: + await showPopUp( + context: context, + builder: (BuildContext context) { + return AlertWithOneAction( + alertTitle: S.of(context).buy, + alertContent: S.of(context).buy_alert_content, + buttonText: S.of(context).ok, + buttonAction: () => Navigator.of(context).pop()); + }); + break; + } + } } diff --git a/res/values/strings_de.arb b/res/values/strings_de.arb index 6d1d66b84..5ad965141 100644 --- a/res/values/strings_de.arb +++ b/res/values/strings_de.arb @@ -469,5 +469,7 @@ "unconfirmed" : "Unbestätigt", "displayable" : "Anzeigebar", - "submit_request" : "Einen Antrag stellen" + "submit_request" : "Einen Antrag stellen", + + "buy_alert_content" : "Derzeit unterstützen wir nur den Kauf von Bitcoin. Um Bitcoin zu kaufen, erstellen Sie bitte Ihre Bitcoin-Brieftasche oder wechseln Sie zu dieser" } \ No newline at end of file diff --git a/res/values/strings_en.arb b/res/values/strings_en.arb index b0d98b7c9..d7a9513ab 100644 --- a/res/values/strings_en.arb +++ b/res/values/strings_en.arb @@ -469,5 +469,7 @@ "unconfirmed" : "Unconfirmed", "displayable" : "Displayable", - "submit_request" : "submit a request" + "submit_request" : "submit a request", + + "buy_alert_content" : "Currently we only support the purchase of Bitcoin. To buy Bitcoin, please create or switch to your Bitcoin wallet" } \ No newline at end of file diff --git a/res/values/strings_es.arb b/res/values/strings_es.arb index 190ad4304..d6a68c50d 100644 --- a/res/values/strings_es.arb +++ b/res/values/strings_es.arb @@ -469,5 +469,7 @@ "unconfirmed" : "Inconfirmado", "displayable" : "Visualizable", - "submit_request" : "presentar una solicitud" + "submit_request" : "presentar una solicitud", + + "buy_alert_content" : "Actualmente solo apoyamos la compra de Bitcoin. Para comprar Bitcoin, cree o cambie a su billetera Bitcoin" } \ No newline at end of file diff --git a/res/values/strings_hi.arb b/res/values/strings_hi.arb index 6eac14e99..9998155f1 100644 --- a/res/values/strings_hi.arb +++ b/res/values/strings_hi.arb @@ -469,5 +469,7 @@ "unconfirmed" : "अपुष्ट", "displayable" : "प्रदर्शन योग्य", - "submit_request" : "एक अनुरोध सबमिट करें" + "submit_request" : "एक अनुरोध सबमिट करें", + + "buy_alert_content" : "वर्तमान में हम केवल बिटकॉइन की खरीद का समर्थन करते हैं। बिटकॉइन खरीदने के लिए, कृपया अपना बिटकॉइन वॉलेट बनाएं या स्विच करें" } \ No newline at end of file diff --git a/res/values/strings_ja.arb b/res/values/strings_ja.arb index 291d5afd3..c380d51a3 100644 --- a/res/values/strings_ja.arb +++ b/res/values/strings_ja.arb @@ -469,5 +469,7 @@ "unconfirmed" : "未確認", "displayable" : "表示可能", - "submit_request" : "リクエストを送信する" + "submit_request" : "リクエストを送信する", + + "buy_alert_content" : "現在、ビットコインの購入のみをサポートしています。 ビットコインを購入するには、ビットコインウォレットを作成するか切り替えてください" } \ No newline at end of file diff --git a/res/values/strings_ko.arb b/res/values/strings_ko.arb index 781df8d8a..09b6f427a 100644 --- a/res/values/strings_ko.arb +++ b/res/values/strings_ko.arb @@ -469,5 +469,7 @@ "unconfirmed" : "미확인", "displayable" : "표시 가능", - "submit_request" : "요청을 제출" + "submit_request" : "요청을 제출", + + "buy_alert_content" : "현재 우리는 비트 코인 구매 만 지원합니다. 비트 코인을 구매하려면 비트 코인 지갑을 생성하거나 전환하십시오" } \ No newline at end of file diff --git a/res/values/strings_nl.arb b/res/values/strings_nl.arb index 9a6183efb..81e599b49 100644 --- a/res/values/strings_nl.arb +++ b/res/values/strings_nl.arb @@ -469,5 +469,7 @@ "unconfirmed" : "Niet bevestigd", "displayable" : "Weer te geven", - "submit_request" : "een verzoek indienen" + "submit_request" : "een verzoek indienen", + + "buy_alert_content" : "Momenteel ondersteunen we alleen de aankoop van Bitcoin. Om Bitcoin te kopen, moet u uw Bitcoin-portemonnee aanmaken of naar uw Bitcoin-portemonnee overschakelen" } \ No newline at end of file diff --git a/res/values/strings_pl.arb b/res/values/strings_pl.arb index 6db66958e..6e8ad95d7 100644 --- a/res/values/strings_pl.arb +++ b/res/values/strings_pl.arb @@ -469,5 +469,7 @@ "unconfirmed" : "Niepotwierdzony", "displayable" : "Wyświetlane", - "submit_request" : "złożyć wniosek" + "submit_request" : "złożyć wniosek", + + "buy_alert_content" : "Obecnie obsługujemy tylko zakup Bitcoinów. Aby kupić Bitcoin, utwórz lub przełącz się na swój portfel Bitcoin" } \ No newline at end of file diff --git a/res/values/strings_pt.arb b/res/values/strings_pt.arb index 631be8f42..d8e480b94 100644 --- a/res/values/strings_pt.arb +++ b/res/values/strings_pt.arb @@ -469,5 +469,7 @@ "unconfirmed" : "Não confirmado", "displayable" : "Exibível", - "submit_request" : "enviar um pedido" + "submit_request" : "enviar um pedido", + + "buy_alert_content" : "Atualmente, apoiamos apenas a compra de Bitcoin. Para comprar Bitcoin, crie ou mude para sua carteira Bitcoin" } \ No newline at end of file diff --git a/res/values/strings_ru.arb b/res/values/strings_ru.arb index 333a823d8..16c1188ad 100644 --- a/res/values/strings_ru.arb +++ b/res/values/strings_ru.arb @@ -469,5 +469,7 @@ "unconfirmed" : "Неподтвержденный", "displayable" : "Отображаемый", - "submit_request" : "отправить запрос" + "submit_request" : "отправить запрос", + + "buy_alert_content" : "В настоящее время мы поддерживаем только покупку Bitcoin. Чтобы купить Bitcoin, создайте или переключитесь на ваш Bitcoin кошелек" } \ No newline at end of file diff --git a/res/values/strings_uk.arb b/res/values/strings_uk.arb index cc10a2d89..1a2b53357 100644 --- a/res/values/strings_uk.arb +++ b/res/values/strings_uk.arb @@ -469,5 +469,7 @@ "unconfirmed" : "Непідтверджений", "displayable" : "Відображуваний", - "submit_request" : "надіслати запит" + "submit_request" : "надіслати запит", + + "buy_alert_content" : "На даний час ми підтримуємо тільки покупку Bitcoin. Щоб купити Bitcoin, будь ласка, створіть або переключіться на ваш Bitcoin гаманець" } \ No newline at end of file diff --git a/res/values/strings_zh.arb b/res/values/strings_zh.arb index 639babcbc..055706527 100644 --- a/res/values/strings_zh.arb +++ b/res/values/strings_zh.arb @@ -469,5 +469,7 @@ "unconfirmed" : "未经证实", "displayable" : "可显示", - "submit_request" : "提交請求" + "submit_request" : "提交請求", + + "buy_alert_content" : "目前,我們僅支持購買比特幣。 要購買比特幣,請創建或切換到您的比特幣錢包" } \ No newline at end of file From bc0b50af5e4a33f9ba0ddc7979016091bcaa6e40 Mon Sep 17 00:00:00 2001 From: M Date: Mon, 10 May 2021 19:35:22 +0300 Subject: [PATCH 2/3] Update dashboard_page.dart --- lib/src/screens/dashboard/dashboard_page.dart | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/lib/src/screens/dashboard/dashboard_page.dart b/lib/src/screens/dashboard/dashboard_page.dart index be540164e..a517a4da2 100644 --- a/lib/src/screens/dashboard/dashboard_page.dart +++ b/lib/src/screens/dashboard/dashboard_page.dart @@ -171,18 +171,7 @@ class DashboardPage extends BasePage { final walletType = walletViewModel.type; switch (walletType) { - case WalletType.bitcoin: - try { - walletViewModel.isRunningWebView = true; - final url = await walletViewModel.wyreViewModel.wyreUrl; - await Navigator.of(context).pushNamed(Routes.wyre, arguments: url); - walletViewModel.isRunningWebView = false; - } catch(e) { - print(e.toString()); - walletViewModel.isRunningWebView = false; - } - break; - default: + case WalletType.monero: await showPopUp( context: context, builder: (BuildContext context) { @@ -193,6 +182,17 @@ class DashboardPage extends BasePage { buttonAction: () => Navigator.of(context).pop()); }); break; + default: + try { + walletViewModel.isRunningWebView = true; + final url = await walletViewModel.wyreViewModel.wyreUrl; + await Navigator.of(context).pushNamed(Routes.wyre, arguments: url); + walletViewModel.isRunningWebView = false; + } catch(e) { + print(e.toString()); + walletViewModel.isRunningWebView = false; + } + break; } } } From f2f5e03a54702402bc23ab2b7fbcf016322ab1dd Mon Sep 17 00:00:00 2001 From: M Date: Mon, 10 May 2021 19:35:57 +0300 Subject: [PATCH 3/3] Update dashboard_page.dart --- lib/src/screens/dashboard/dashboard_page.dart | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/src/screens/dashboard/dashboard_page.dart b/lib/src/screens/dashboard/dashboard_page.dart index a517a4da2..400b34060 100644 --- a/lib/src/screens/dashboard/dashboard_page.dart +++ b/lib/src/screens/dashboard/dashboard_page.dart @@ -188,8 +188,7 @@ class DashboardPage extends BasePage { final url = await walletViewModel.wyreViewModel.wyreUrl; await Navigator.of(context).pushNamed(Routes.wyre, arguments: url); walletViewModel.isRunningWebView = false; - } catch(e) { - print(e.toString()); + } catch(_) { walletViewModel.isRunningWebView = false; } break;