mirror of
https://github.com/cake-tech/cake_wallet.git
synced 2024-12-23 03:59:23 +00:00
Notify user when a different currency is scanned
This commit is contained in:
parent
7bccf46832
commit
e5fac16ef7
19 changed files with 69 additions and 37 deletions
|
@ -232,19 +232,12 @@ class AppState extends State<App> with SingleTickerProviderStateMixin {
|
||||||
void handleDeepLinking(Uri uri) {
|
void handleDeepLinking(Uri uri) {
|
||||||
if (uri == null || !mounted) return;
|
if (uri == null || !mounted) return;
|
||||||
|
|
||||||
switch (uri.scheme) {
|
|
||||||
case "bitcoin":
|
|
||||||
case "litecoin":
|
|
||||||
case "haven":
|
|
||||||
case "monero":
|
|
||||||
default:
|
|
||||||
Navigator.pushNamed(
|
Navigator.pushNamed(
|
||||||
navigatorKey.currentContext,
|
navigatorKey.currentContext,
|
||||||
Routes.send,
|
Routes.send,
|
||||||
arguments: PaymentRequest.fromUri(uri),
|
arguments: PaymentRequest.fromUri(uri),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
Future<void> _handleInitialUri() async {
|
Future<void> _handleInitialUri() async {
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
import 'dart:ui';
|
import 'dart:ui';
|
||||||
|
import 'package:cake_wallet/src/widgets/alert_with_one_action.dart';
|
||||||
import 'package:cake_wallet/utils/payment_request.dart';
|
import 'package:cake_wallet/utils/payment_request.dart';
|
||||||
import 'package:cw_core/transaction_priority.dart';
|
import 'package:cw_core/transaction_priority.dart';
|
||||||
import 'package:cake_wallet/routes.dart';
|
import 'package:cake_wallet/routes.dart';
|
||||||
|
@ -45,8 +46,8 @@ class SendCardState extends State<SendCard>
|
||||||
SendCardState({
|
SendCardState({
|
||||||
@required this.output,
|
@required this.output,
|
||||||
@required this.sendViewModel,
|
@required this.sendViewModel,
|
||||||
PaymentRequest initialPaymentRequest})
|
this.initialPaymentRequest})
|
||||||
: addressController = TextEditingController(text: initialPaymentRequest?.address),
|
: addressController = TextEditingController(text: initialPaymentRequest?.address?.toLowerCase()),
|
||||||
cryptoAmountController = TextEditingController(text: initialPaymentRequest?.amount),
|
cryptoAmountController = TextEditingController(text: initialPaymentRequest?.amount),
|
||||||
fiatAmountController = TextEditingController(),
|
fiatAmountController = TextEditingController(),
|
||||||
noteController = TextEditingController(),
|
noteController = TextEditingController(),
|
||||||
|
@ -60,6 +61,7 @@ class SendCardState extends State<SendCard>
|
||||||
|
|
||||||
final Output output;
|
final Output output;
|
||||||
final SendViewModel sendViewModel;
|
final SendViewModel sendViewModel;
|
||||||
|
final PaymentRequest initialPaymentRequest;
|
||||||
|
|
||||||
final TextEditingController addressController;
|
final TextEditingController addressController;
|
||||||
final TextEditingController cryptoAmountController;
|
final TextEditingController cryptoAmountController;
|
||||||
|
@ -72,6 +74,27 @@ class SendCardState extends State<SendCard>
|
||||||
|
|
||||||
bool _effectsInstalled = false;
|
bool _effectsInstalled = false;
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
super.initState();
|
||||||
|
|
||||||
|
/// if the current wallet doesn't match the one in the qr code
|
||||||
|
if (initialPaymentRequest != null &&
|
||||||
|
sendViewModel.walletCurrencyName != initialPaymentRequest.scheme?.toLowerCase()) {
|
||||||
|
WidgetsBinding.instance?.addPostFrameCallback((timeStamp) {
|
||||||
|
showPopUp<void>(
|
||||||
|
context: context,
|
||||||
|
builder: (BuildContext context) {
|
||||||
|
return AlertWithOneAction(
|
||||||
|
alertTitle: S.of(context).error,
|
||||||
|
alertContent: S.of(context).unmatched_currencies,
|
||||||
|
buttonText: S.of(context).ok,
|
||||||
|
buttonAction: () => Navigator.of(context).pop());
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
super.build(context);
|
super.build(context);
|
||||||
|
@ -123,11 +146,6 @@ class SendCardState extends State<SendCard>
|
||||||
? sendViewModel.textValidator
|
? sendViewModel.textValidator
|
||||||
: sendViewModel.addressValidator;
|
: sendViewModel.addressValidator;
|
||||||
|
|
||||||
print("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@");
|
|
||||||
print("444444444444444444444444444444");
|
|
||||||
print(addressController.text);
|
|
||||||
print(cryptoAmountController.text);
|
|
||||||
|
|
||||||
return AddressTextField(
|
return AddressTextField(
|
||||||
focusNode: addressFocusNode,
|
focusNode: addressFocusNode,
|
||||||
controller: addressController,
|
controller: addressController,
|
||||||
|
@ -529,7 +547,8 @@ class SendCardState extends State<SendCard>
|
||||||
if (output.address.isNotEmpty) {
|
if (output.address.isNotEmpty) {
|
||||||
addressController.text = output.address;
|
addressController.text = output.address;
|
||||||
}
|
}
|
||||||
if (output.cryptoAmount.isNotEmpty) {
|
if (output.cryptoAmount.isNotEmpty ||
|
||||||
|
sendViewModel.walletCurrencyName != initialPaymentRequest?.scheme?.toLowerCase()) {
|
||||||
cryptoAmountController.text = output.cryptoAmount;
|
cryptoAmountController.text = output.cryptoAmount;
|
||||||
}
|
}
|
||||||
fiatAmountController.text = output.fiatAmount;
|
fiatAmountController.text = output.fiatAmount;
|
||||||
|
|
|
@ -1,18 +1,21 @@
|
||||||
class PaymentRequest {
|
class PaymentRequest {
|
||||||
PaymentRequest(this.address, this.amount);
|
PaymentRequest(this.address, this.amount, {this.scheme});
|
||||||
|
|
||||||
factory PaymentRequest.fromUri(Uri uri) {
|
factory PaymentRequest.fromUri(Uri uri) {
|
||||||
var address = "";
|
var address = "";
|
||||||
var amount = "";
|
var amount = "";
|
||||||
|
var scheme = "";
|
||||||
|
|
||||||
if (uri != null) {
|
if (uri != null) {
|
||||||
address = uri.path;
|
address = uri.path;
|
||||||
amount = uri.queryParameters['tx_amount'] ?? uri.queryParameters['amount'] ?? "";
|
amount = uri.queryParameters['tx_amount'] ?? uri.queryParameters['amount'] ?? "";
|
||||||
|
scheme = uri.scheme;
|
||||||
}
|
}
|
||||||
|
|
||||||
return PaymentRequest(address, amount);
|
return PaymentRequest(address, amount, scheme: scheme);
|
||||||
}
|
}
|
||||||
|
|
||||||
final String address;
|
final String address;
|
||||||
final String amount;
|
final String amount;
|
||||||
|
final String scheme;
|
||||||
}
|
}
|
|
@ -157,6 +157,8 @@ abstract class SendViewModelBase with Store {
|
||||||
|
|
||||||
WalletType get walletType => _wallet.type;
|
WalletType get walletType => _wallet.type;
|
||||||
|
|
||||||
|
String get walletCurrencyName => _wallet.currency.name.toLowerCase();
|
||||||
|
|
||||||
bool get hasCurrecyChanger => walletType == WalletType.haven;
|
bool get hasCurrecyChanger => walletType == WalletType.haven;
|
||||||
|
|
||||||
final WalletBase _wallet;
|
final WalletBase _wallet;
|
||||||
|
|
|
@ -632,5 +632,6 @@
|
||||||
"gift_card_is_generated": "Geschenkkarte wird generiert",
|
"gift_card_is_generated": "Geschenkkarte wird generiert",
|
||||||
"open_gift_card": "Geschenkkarte öffnen",
|
"open_gift_card": "Geschenkkarte öffnen",
|
||||||
"contact_support": "Support kontaktieren",
|
"contact_support": "Support kontaktieren",
|
||||||
"gift_cards_unavailable": "Geschenkkarten können derzeit nur über Monero, Bitcoin und Litecoin erworben werden"
|
"gift_cards_unavailable": "Geschenkkarten können derzeit nur über Monero, Bitcoin und Litecoin erworben werden",
|
||||||
|
"unmatched_currencies": "Die Währung Ihres aktuellen Wallets stimmt nicht mit der des gescannten QR überein"
|
||||||
}
|
}
|
||||||
|
|
|
@ -632,5 +632,6 @@
|
||||||
"gift_card_is_generated": "Gift Card is generated",
|
"gift_card_is_generated": "Gift Card is generated",
|
||||||
"open_gift_card": "Open Gift Card",
|
"open_gift_card": "Open Gift Card",
|
||||||
"contact_support": "Contact Support",
|
"contact_support": "Contact Support",
|
||||||
"gift_cards_unavailable": "Gift cards are available for purchase only with Monero, Bitcoin, and Litecoin at this time"
|
"gift_cards_unavailable": "Gift cards are available for purchase only with Monero, Bitcoin, and Litecoin at this time",
|
||||||
|
"unmatched_currencies": "Your current wallet's currency does not match that of the scanned QR"
|
||||||
}
|
}
|
||||||
|
|
|
@ -632,5 +632,6 @@
|
||||||
"gift_card_is_generated": "Se genera la tarjeta de regalo",
|
"gift_card_is_generated": "Se genera la tarjeta de regalo",
|
||||||
"open_gift_card": "Abrir tarjeta de regalo",
|
"open_gift_card": "Abrir tarjeta de regalo",
|
||||||
"contact_support": "Contactar con Soporte",
|
"contact_support": "Contactar con Soporte",
|
||||||
"gift_cards_unavailable": "Las tarjetas de regalo están disponibles para comprar solo a través de Monero, Bitcoin y Litecoin en este momento"
|
"gift_cards_unavailable": "Las tarjetas de regalo están disponibles para comprar solo a través de Monero, Bitcoin y Litecoin en este momento",
|
||||||
|
"unmatched_currencies": "La moneda de su billetera actual no coincide con la del QR escaneado"
|
||||||
}
|
}
|
||||||
|
|
|
@ -630,5 +630,6 @@
|
||||||
"gift_card_is_generated": "La carte-cadeau est générée",
|
"gift_card_is_generated": "La carte-cadeau est générée",
|
||||||
"open_gift_card": "Ouvrir la carte-cadeau",
|
"open_gift_card": "Ouvrir la carte-cadeau",
|
||||||
"contact_support": "Contacter l'assistance",
|
"contact_support": "Contacter l'assistance",
|
||||||
"gift_cards_unavailable": "Les cartes-cadeaux ne sont disponibles à l'achat que via Monero, Bitcoin et Litecoin pour le moment"
|
"gift_cards_unavailable": "Les cartes-cadeaux ne sont disponibles à l'achat que via Monero, Bitcoin et Litecoin pour le moment",
|
||||||
|
"unmatched_currencies": "La devise de votre portefeuille actuel ne correspond pas à celle du QR scanné"
|
||||||
}
|
}
|
||||||
|
|
|
@ -632,5 +632,6 @@
|
||||||
"gift_card_is_generated": "गिफ्ट कार्ड जनरेट हुआ",
|
"gift_card_is_generated": "गिफ्ट कार्ड जनरेट हुआ",
|
||||||
"open_gift_card": "गिफ्ट कार्ड खोलें",
|
"open_gift_card": "गिफ्ट कार्ड खोलें",
|
||||||
"contact_support": "सहायता से संपर्क करें",
|
"contact_support": "सहायता से संपर्क करें",
|
||||||
"gift_cards_unavailable": "उपहार कार्ड इस समय केवल मोनेरो, बिटकॉइन और लिटकोइन के माध्यम से खरीदने के लिए उपलब्ध हैं"
|
"gift_cards_unavailable": "उपहार कार्ड इस समय केवल मोनेरो, बिटकॉइन और लिटकोइन के माध्यम से खरीदने के लिए उपलब्ध हैं",
|
||||||
|
"unmatched_currencies": "आपके वर्तमान वॉलेट की मुद्रा स्कैन किए गए क्यूआर से मेल नहीं खाती"
|
||||||
}
|
}
|
||||||
|
|
|
@ -632,5 +632,6 @@
|
||||||
"gift_card_is_generated": "Poklon kartica je generirana",
|
"gift_card_is_generated": "Poklon kartica je generirana",
|
||||||
"open_gift_card": "Otvori darovnu karticu",
|
"open_gift_card": "Otvori darovnu karticu",
|
||||||
"contact_support": "Kontaktirajte podršku",
|
"contact_support": "Kontaktirajte podršku",
|
||||||
"gift_cards_unavailable": "Poklon kartice trenutno su dostupne za kupnju samo putem Monera, Bitcoina i Litecoina"
|
"gift_cards_unavailable": "Poklon kartice trenutno su dostupne za kupnju samo putem Monera, Bitcoina i Litecoina",
|
||||||
|
"unmatched_currencies": "Valuta vašeg trenutnog novčanika ne odgovara onoj na skeniranom QR-u"
|
||||||
}
|
}
|
||||||
|
|
|
@ -632,5 +632,6 @@
|
||||||
"gift_card_is_generated": "Il buono regalo è stato generato",
|
"gift_card_is_generated": "Il buono regalo è stato generato",
|
||||||
"open_gift_card": "Apri carta regalo",
|
"open_gift_card": "Apri carta regalo",
|
||||||
"contact_support": "Contatta l'assistenza",
|
"contact_support": "Contatta l'assistenza",
|
||||||
"gift_cards_unavailable": "Le carte regalo sono disponibili per l'acquisto solo tramite Monero, Bitcoin e Litecoin in questo momento"
|
"gift_cards_unavailable": "Le carte regalo sono disponibili per l'acquisto solo tramite Monero, Bitcoin e Litecoin in questo momento",
|
||||||
|
"unmatched_currencies": "La valuta del tuo portafoglio attuale non corrisponde a quella del QR scansionato"
|
||||||
}
|
}
|
||||||
|
|
|
@ -632,5 +632,6 @@
|
||||||
"gift_card_is_generated": "ギフトカードが生成されます",
|
"gift_card_is_generated": "ギフトカードが生成されます",
|
||||||
"open_gift_card": "オープンギフトカード",
|
"open_gift_card": "オープンギフトカード",
|
||||||
"contact_support": "サポートに連絡する",
|
"contact_support": "サポートに連絡する",
|
||||||
"gift_cards_unavailable": "現時点では、ギフトカードはMonero、Bitcoin、Litecoinからのみ購入できます。"
|
"gift_cards_unavailable": "現時点では、ギフトカードはMonero、Bitcoin、Litecoinからのみ購入できます。",
|
||||||
|
"unmatched_currencies": "現在のウォレットの通貨がスキャンされたQRの通貨と一致しません"
|
||||||
}
|
}
|
||||||
|
|
|
@ -632,5 +632,6 @@
|
||||||
"gift_card_is_generated": "기프트 카드가 생성되었습니다",
|
"gift_card_is_generated": "기프트 카드가 생성되었습니다",
|
||||||
"open_gift_card": "기프트 카드 열기",
|
"open_gift_card": "기프트 카드 열기",
|
||||||
"contact_support": "지원팀에 문의",
|
"contact_support": "지원팀에 문의",
|
||||||
"gift_cards_unavailable": "기프트 카드는 현재 Monero, Bitcoin 및 Litecoin을 통해서만 구매할 수 있습니다."
|
"gift_cards_unavailable": "기프트 카드는 현재 Monero, Bitcoin 및 Litecoin을 통해서만 구매할 수 있습니다.",
|
||||||
|
"unmatched_currencies": "현재 지갑의 통화가 스캔한 QR의 통화와 일치하지 않습니다."
|
||||||
}
|
}
|
||||||
|
|
|
@ -632,5 +632,6 @@
|
||||||
"gift_card_is_generated": "Cadeaukaart is gegenereerd",
|
"gift_card_is_generated": "Cadeaukaart is gegenereerd",
|
||||||
"open_gift_card": "Geschenkkaart openen",
|
"open_gift_card": "Geschenkkaart openen",
|
||||||
"contact_support": "Contact opnemen met ondersteuning",
|
"contact_support": "Contact opnemen met ondersteuning",
|
||||||
"gift_cards_unavailable": "Cadeaubonnen kunnen momenteel alleen worden gekocht via Monero, Bitcoin en Litecoin"
|
"gift_cards_unavailable": "Cadeaubonnen kunnen momenteel alleen worden gekocht via Monero, Bitcoin en Litecoin",
|
||||||
|
"unmatched_currencies": "De valuta van uw huidige portemonnee komt niet overeen met die van de gescande QR"
|
||||||
}
|
}
|
||||||
|
|
|
@ -632,5 +632,6 @@
|
||||||
"gift_card_is_generated": "Karta podarunkowa jest generowana",
|
"gift_card_is_generated": "Karta podarunkowa jest generowana",
|
||||||
"open_gift_card": "Otwórz kartę podarunkową",
|
"open_gift_card": "Otwórz kartę podarunkową",
|
||||||
"contact_support": "Skontaktuj się z pomocą techniczną",
|
"contact_support": "Skontaktuj się z pomocą techniczną",
|
||||||
"gift_cards_unavailable": "Karty podarunkowe można obecnie kupić tylko za pośrednictwem Monero, Bitcoin i Litecoin"
|
"gift_cards_unavailable": "Karty podarunkowe można obecnie kupić tylko za pośrednictwem Monero, Bitcoin i Litecoin",
|
||||||
|
"unmatched_currencies": "Waluta Twojego obecnego portfela nie odpowiada walucie zeskanowanego kodu QR"
|
||||||
}
|
}
|
||||||
|
|
|
@ -632,5 +632,6 @@
|
||||||
"gift_card_is_generated": "Cartão presente é gerado",
|
"gift_card_is_generated": "Cartão presente é gerado",
|
||||||
"open_gift_card": "Abrir vale-presente",
|
"open_gift_card": "Abrir vale-presente",
|
||||||
"contact_support": "Contatar Suporte",
|
"contact_support": "Contatar Suporte",
|
||||||
"gift_cards_unavailable": "Os cartões-presente estão disponíveis para compra apenas através do Monero, Bitcoin e Litecoin no momento"
|
"gift_cards_unavailable": "Os cartões-presente estão disponíveis para compra apenas através do Monero, Bitcoin e Litecoin no momento",
|
||||||
|
"unmatched_currencies": "A moeda da sua carteira atual não corresponde à do QR digitalizado"
|
||||||
}
|
}
|
||||||
|
|
|
@ -632,5 +632,6 @@
|
||||||
"gift_card_is_generated": "Подарочная карта сгенерирована",
|
"gift_card_is_generated": "Подарочная карта сгенерирована",
|
||||||
"open_gift_card": "Открыть подарочную карту",
|
"open_gift_card": "Открыть подарочную карту",
|
||||||
"contact_support": "Связаться со службой поддержки",
|
"contact_support": "Связаться со службой поддержки",
|
||||||
"gift_cards_unavailable": "В настоящее время подарочные карты можно приобрести только через Monero, Bitcoin и Litecoin."
|
"gift_cards_unavailable": "В настоящее время подарочные карты можно приобрести только через Monero, Bitcoin и Litecoin.",
|
||||||
|
"unmatched_currencies": "Валюта вашего текущего кошелька не соответствует валюте отсканированного QR-кода."
|
||||||
}
|
}
|
||||||
|
|
|
@ -631,5 +631,6 @@
|
||||||
"gift_card_is_generated": "Подарункова картка створена",
|
"gift_card_is_generated": "Подарункова картка створена",
|
||||||
"open_gift_card": "Відкрити подарункову картку",
|
"open_gift_card": "Відкрити подарункову картку",
|
||||||
"contact_support": "Звернутися до служби підтримки",
|
"contact_support": "Звернутися до служби підтримки",
|
||||||
"gift_cards_unavailable": "Наразі подарункові картки можна придбати лише через Monero, Bitcoin і Litecoin"
|
"gift_cards_unavailable": "Наразі подарункові картки можна придбати лише через Monero, Bitcoin і Litecoin",
|
||||||
|
"unmatched_currencies": "Валюта вашого гаманця не збігається з валютою сканованого QR-коду"
|
||||||
}
|
}
|
||||||
|
|
|
@ -630,5 +630,6 @@
|
||||||
"gift_card_is_generated": "礼品卡生成",
|
"gift_card_is_generated": "礼品卡生成",
|
||||||
"open_gift_card": "打开礼品卡",
|
"open_gift_card": "打开礼品卡",
|
||||||
"contact_support": "联系支持",
|
"contact_support": "联系支持",
|
||||||
"gift_cards_unavailable": "目前只能通过门罗币、比特币和莱特币购买礼品卡"
|
"gift_cards_unavailable": "目前只能通过门罗币、比特币和莱特币购买礼品卡",
|
||||||
|
"unmatched_currencies": "您当前钱包的货币与扫描的 QR 的货币不匹配"
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue