CAKE-303 | added buy button for xmr wallet and applied buy alert

This commit is contained in:
OleksandrSobol 2021-04-26 21:06:21 +03:00
parent d23228ac01
commit b7cb5147e1
13 changed files with 72 additions and 29 deletions

View file

@ -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: <Widget>[
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 <void> _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<void>(
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;
}
}
}

View file

@ -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"
}

View file

@ -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"
}

View file

@ -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"
}

View file

@ -469,5 +469,7 @@
"unconfirmed" : "अपुष्ट",
"displayable" : "प्रदर्शन योग्य",
"submit_request" : "एक अनुरोध सबमिट करें"
"submit_request" : "एक अनुरोध सबमिट करें",
"buy_alert_content" : "वर्तमान में हम केवल बिटकॉइन की खरीद का समर्थन करते हैं। बिटकॉइन खरीदने के लिए, कृपया अपना बिटकॉइन वॉलेट बनाएं या स्विच करें"
}

View file

@ -469,5 +469,7 @@
"unconfirmed" : "未確認",
"displayable" : "表示可能",
"submit_request" : "リクエストを送信する"
"submit_request" : "リクエストを送信する",
"buy_alert_content" : "現在、ビットコインの購入のみをサポートしています。 ビットコインを購入するには、ビットコインウォレットを作成するか切り替えてください"
}

View file

@ -469,5 +469,7 @@
"unconfirmed" : "미확인",
"displayable" : "표시 가능",
"submit_request" : "요청을 제출"
"submit_request" : "요청을 제출",
"buy_alert_content" : "현재 우리는 비트 코인 구매 만 지원합니다. 비트 코인을 구매하려면 비트 코인 지갑을 생성하거나 전환하십시오"
}

View file

@ -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"
}

View file

@ -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"
}

View file

@ -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"
}

View file

@ -469,5 +469,7 @@
"unconfirmed" : "Неподтвержденный",
"displayable" : "Отображаемый",
"submit_request" : "отправить запрос"
"submit_request" : "отправить запрос",
"buy_alert_content" : "В настоящее время мы поддерживаем только покупку Bitcoin. Чтобы купить Bitcoin, создайте или переключитесь на ваш Bitcoin кошелек"
}

View file

@ -469,5 +469,7 @@
"unconfirmed" : "Непідтверджений",
"displayable" : "Відображуваний",
"submit_request" : "надіслати запит"
"submit_request" : "надіслати запит",
"buy_alert_content" : "На даний час ми підтримуємо тільки покупку Bitcoin. Щоб купити Bitcoin, будь ласка, створіть або переключіться на ваш Bitcoin гаманець"
}

View file

@ -469,5 +469,7 @@
"unconfirmed" : "未经证实",
"displayable" : "可显示",
"submit_request" : "提交請求"
"submit_request" : "提交請求",
"buy_alert_content" : "目前,我們僅支持購買比特幣。 要購買比特幣,請創建或切換到您的比特幣錢包"
}