diff --git a/cw_core/lib/wallet_info.dart b/cw_core/lib/wallet_info.dart index 01bd6ad68..4e614811e 100644 --- a/cw_core/lib/wallet_info.dart +++ b/cw_core/lib/wallet_info.dart @@ -9,7 +9,7 @@ part 'wallet_info.g.dart'; class WalletInfo extends HiveObject { WalletInfo(this.id, this.name, this.type, this.isRecovery, this.restoreHeight, this.timestamp, this.dirPath, this.path, this.address, this.yatEid, - this.yatLastUsedAddressRaw) + this.yatLastUsedAddressRaw, this.showIntroCakePayCard) : _yatLastUsedAddressController = StreamController.broadcast(); factory WalletInfo.external( @@ -23,10 +23,11 @@ class WalletInfo extends HiveObject { @required String path, @required String address, String yatEid ='', - String yatLastUsedAddressRaw = ''}) { + String yatLastUsedAddressRaw = '', + bool showIntroCakePayCard}) { return WalletInfo(id, name, type, isRecovery, restoreHeight, date.millisecondsSinceEpoch ?? 0, dirPath, path, address, - yatEid, yatLastUsedAddressRaw); + yatEid, yatLastUsedAddressRaw, showIntroCakePayCard); } static const typeId = 4; @@ -68,6 +69,9 @@ class WalletInfo extends HiveObject { @HiveField(12) String yatLastUsedAddressRaw; + @HiveField(13) + bool showIntroCakePayCard; + String get yatLastUsedAddress => yatLastUsedAddressRaw; set yatLastUsedAddress(String address) { @@ -77,6 +81,13 @@ class WalletInfo extends HiveObject { String get yatEmojiId => yatEid ?? ''; + bool get isShowIntroCakePayCard { + if(showIntroCakePayCard == null) { + return type != WalletType.haven; + } + return showIntroCakePayCard; + } + DateTime get date => DateTime.fromMillisecondsSinceEpoch(timestamp); Stream get yatLastUsedAddressStream => _yatLastUsedAddressController.stream; diff --git a/lib/core/wallet_creation_service.dart b/lib/core/wallet_creation_service.dart index 9c37657f2..1fe36f374 100644 --- a/lib/core/wallet_creation_service.dart +++ b/lib/core/wallet_creation_service.dart @@ -46,6 +46,12 @@ class WalletCreationService { .any((walletInfo) => walletInfo.name.toLowerCase() == walletName); } + bool typeExists(WalletType type) { + return walletInfoSource + .values + .any((walletInfo) => walletInfo.type == type); + } + void checkIfExists(String name) { if (exists(name)) { throw Exception('Wallet with name ${name} already exists!'); diff --git a/lib/src/screens/dashboard/widgets/balance_page.dart b/lib/src/screens/dashboard/widgets/balance_page.dart index b3e68e691..3cfa30a9f 100644 --- a/lib/src/screens/dashboard/widgets/balance_page.dart +++ b/lib/src/screens/dashboard/widgets/balance_page.dart @@ -7,6 +7,9 @@ import 'package:cake_wallet/view_model/dashboard/dashboard_view_model.dart'; import 'package:flutter/scheduler.dart'; import 'package:flutter_mobx/flutter_mobx.dart'; import 'package:auto_size_text/auto_size_text.dart'; +import 'package:cake_wallet/src/widgets/introducing_card.dart'; +import 'package:cake_wallet/generated/i18n.dart'; + class BalancePage extends StatelessWidget{ BalancePage({@required this.dashboardViewModel, @required this.settingsStore}); @@ -44,6 +47,19 @@ class BalancePage extends StatelessWidget{ maxLines: 1, textAlign: TextAlign.center); })), + Observer(builder: (_) { + if (dashboardViewModel.balanceViewModel.isShowCard){ + return IntroducingCard( + title: S.of(context).introducing_cake_pay, + subTitle: S.of(context).cake_pay_learn_more, + borderColor: settingsStore.currentTheme.type == ThemeType.bright + ? Color.fromRGBO(255, 255, 255, 0.2) + : Colors.transparent, + closeCard: dashboardViewModel.balanceViewModel.disableIntroCakePayCard + ); + } + return Container (); + }), Observer(builder: (_) { return ListView.separated( physics: NeverScrollableScrollPhysics(), @@ -180,3 +196,4 @@ class BalancePage extends StatelessWidget{ ); } } + diff --git a/lib/src/widgets/introducing_card.dart b/lib/src/widgets/introducing_card.dart new file mode 100644 index 000000000..2d14465de --- /dev/null +++ b/lib/src/widgets/introducing_card.dart @@ -0,0 +1,89 @@ +import 'package:auto_size_text/auto_size_text.dart'; +import 'package:flutter/material.dart'; +import 'package:cake_wallet/palette.dart'; + +class IntroducingCard extends StatelessWidget { + IntroducingCard( + {this.borderColor, this.closeCard, this.title, this.subTitle}); + + final String title; + final String subTitle; + final Color borderColor; + final Function() closeCard; + + @override + Widget build(BuildContext context) { + return Padding( + padding: const EdgeInsets.fromLTRB(16,0,16,16), + child: Container( + width: double.infinity, + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(30.0), + border: Border.all( + color: borderColor, + width: 1, + ), + color: Theme.of(context).textTheme.title.backgroundColor), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Expanded( + flex: 1, + child: Padding( + padding: const EdgeInsets.all(24), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + AutoSizeText(title ?? '', + style: TextStyle( + fontSize: 24, + fontFamily: 'Lato', + fontWeight: FontWeight.bold, + color: Theme.of(context) + .accentTextTheme + .display3 + .backgroundColor, + height: 1), + maxLines: 1, + textAlign: TextAlign.center), + SizedBox(height: 14), + Text(subTitle ?? '', + textAlign: TextAlign.left, + style: TextStyle( + fontSize: 12, + fontFamily: 'Lato', + color: Theme.of(context) + .accentTextTheme + .display3 + .backgroundColor, + height: 1)), + ], + ), + ), + ), + Padding( + padding: const EdgeInsets.fromLTRB(0,16,16,0), + child: GestureDetector( + onTap: closeCard, + child: Container( + height: 23, + width: 23, + decoration: BoxDecoration( + color: Colors.white, shape: BoxShape.circle), + child: Center( + child: Image.asset( + 'assets/images/x.png', + color: Palette.darkBlueCraiola, + height: 15, + width: 15, + )), + ), + ), + ) + ], + ), + ), + ); + } +} diff --git a/lib/view_model/dashboard/balance_view_model.dart b/lib/view_model/dashboard/balance_view_model.dart index 7bd8a9284..aa073206f 100644 --- a/lib/view_model/dashboard/balance_view_model.dart +++ b/lib/view_model/dashboard/balance_view_model.dart @@ -39,6 +39,7 @@ abstract class BalanceViewModelBase with Store { @required this.fiatConvertationStore}) { isReversing = false; wallet ??= appStore.wallet; + isShowCard = wallet.walletInfo.isShowIntroCakePayCard; reaction((_) => appStore.wallet, _onWalletChange); } @@ -235,6 +236,9 @@ abstract class BalanceViewModelBase with Store { @computed CryptoCurrency get currency => appStore.wallet.currency; + @observable + bool isShowCard; + ReactionDisposer _onCurrentWalletChangeReaction; @action @@ -244,6 +248,15 @@ abstract class BalanceViewModelBase with Store { wallet) { this.wallet = wallet; _onCurrentWalletChangeReaction?.reaction?.dispose(); + isShowCard = wallet.walletInfo.isShowIntroCakePayCard; + } + + @action + Future disableIntroCakePayCard () async { + const cardDisplayStatus = false; + wallet.walletInfo.showIntroCakePayCard = cardDisplayStatus; + await wallet.walletInfo.save(); + isShowCard = cardDisplayStatus; } String _getFiatBalance({double price, String cryptoAmount}) { diff --git a/lib/view_model/wallet_creation_vm.dart b/lib/view_model/wallet_creation_vm.dart index 50629bb9b..ee563738e 100644 --- a/lib/view_model/wallet_creation_vm.dart +++ b/lib/view_model/wallet_creation_vm.dart @@ -37,6 +37,9 @@ abstract class WalletCreationVMBase with Store { bool nameExists(String name) => walletCreationService.exists(name); + bool typeExists(WalletType type) + => walletCreationService.typeExists(type); + Future create({dynamic options}) async { try { state = IsExecutingState(); @@ -56,7 +59,8 @@ abstract class WalletCreationVMBase with Store { restoreHeight: credentials.height ?? 0, date: DateTime.now(), path: path, - dirPath: dirPath); + dirPath: dirPath, + showIntroCakePayCard: (!walletCreationService.typeExists(type)) && type != WalletType.haven); credentials.walletInfo = walletInfo; final wallet = await process(credentials); walletInfo.address = wallet.walletAddresses.address; diff --git a/res/values/strings_de.arb b/res/values/strings_de.arb index 839d40d2a..d82b55911 100644 --- a/res/values/strings_de.arb +++ b/res/values/strings_de.arb @@ -632,5 +632,7 @@ "gift_card_is_generated": "Geschenkkarte wird generiert", "open_gift_card": "Geschenkkarte öffnen", "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", + "introducing_cake_pay": "Einführung von Cake Pay!", + "cake_pay_learn_more": "Karten sofort in der App kaufen und einlösen!\nWischen Sie nach rechts, um mehr zu erfahren!" } diff --git a/res/values/strings_en.arb b/res/values/strings_en.arb index 821b1a227..077e81772 100644 --- a/res/values/strings_en.arb +++ b/res/values/strings_en.arb @@ -632,5 +632,7 @@ "gift_card_is_generated": "Gift Card is generated", "open_gift_card": "Open Gift Card", "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", + "introducing_cake_pay": "Introducing Cake Pay!", + "cake_pay_learn_more": "Instantly purchase and redeem cards in the app!\nSwipe right to learn more!" } diff --git a/res/values/strings_es.arb b/res/values/strings_es.arb index 9f4b6d01f..79f70a7b9 100644 --- a/res/values/strings_es.arb +++ b/res/values/strings_es.arb @@ -632,5 +632,7 @@ "gift_card_is_generated": "Se genera la tarjeta de regalo", "open_gift_card": "Abrir tarjeta de regalo", "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", + "introducing_cake_pay": "¡Presentamos Cake Pay!", + "cake_pay_learn_more": "¡Compre y canjee tarjetas al instante en la aplicación!\n¡Desliza hacia la derecha para obtener más información!" } diff --git a/res/values/strings_fr.arb b/res/values/strings_fr.arb index 541f60e56..545583786 100644 --- a/res/values/strings_fr.arb +++ b/res/values/strings_fr.arb @@ -630,5 +630,7 @@ "gift_card_is_generated": "La carte-cadeau est générée", "open_gift_card": "Ouvrir la carte-cadeau", "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", + "introducing_cake_pay": "Présentation de Cake Pay!", + "cake_pay_learn_more": "Achetez et échangez instantanément des cartes dans l'application !\nBalayez vers la droite pour en savoir plus !" } diff --git a/res/values/strings_hi.arb b/res/values/strings_hi.arb index 1060ce44e..4d56e3430 100644 --- a/res/values/strings_hi.arb +++ b/res/values/strings_hi.arb @@ -632,5 +632,7 @@ "gift_card_is_generated": "गिफ्ट कार्ड जनरेट हुआ", "open_gift_card": "गिफ्ट कार्ड खोलें", "contact_support": "सहायता से संपर्क करें", - "gift_cards_unavailable": "उपहार कार्ड इस समय केवल मोनेरो, बिटकॉइन और लिटकोइन के माध्यम से खरीदने के लिए उपलब्ध हैं" + "gift_cards_unavailable": "उपहार कार्ड इस समय केवल मोनेरो, बिटकॉइन और लिटकोइन के माध्यम से खरीदने के लिए उपलब्ध हैं", + "introducing_cake_pay": "परिचय Cake Pay!", + "cake_pay_learn_more": "ऐप में तुरंत कार्ड खरीदें और रिडीम करें!\nअधिक जानने के लिए दाएं स्वाइप करें!" } diff --git a/res/values/strings_hr.arb b/res/values/strings_hr.arb index 4154c812f..db2531d51 100644 --- a/res/values/strings_hr.arb +++ b/res/values/strings_hr.arb @@ -632,5 +632,7 @@ "gift_card_is_generated": "Poklon kartica je generirana", "open_gift_card": "Otvori darovnu karticu", "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", + "introducing_cake_pay": "Predstavljamo Cake Pay!", + "cake_pay_learn_more": "Odmah kupite i iskoristite kartice u aplikaciji!\nPrijeđite prstom udesno da biste saznali više!" } diff --git a/res/values/strings_it.arb b/res/values/strings_it.arb index 0308f16a9..db0459295 100644 --- a/res/values/strings_it.arb +++ b/res/values/strings_it.arb @@ -632,5 +632,7 @@ "gift_card_is_generated": "Il buono regalo è stato generato", "open_gift_card": "Apri carta regalo", "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", + "introducing_cake_pay": "Presentazione di Cake Pay!", + "cake_pay_learn_more": "Acquista e riscatta istantaneamente le carte nell'app!\nScorri verso destra per saperne di più!" } diff --git a/res/values/strings_ja.arb b/res/values/strings_ja.arb index 33a9d20cc..c0f70cea7 100644 --- a/res/values/strings_ja.arb +++ b/res/values/strings_ja.arb @@ -632,5 +632,7 @@ "gift_card_is_generated": "ギフトカードが生成されます", "open_gift_card": "オープンギフトカード", "contact_support": "サポートに連絡する", - "gift_cards_unavailable": "現時点では、ギフトカードはMonero、Bitcoin、Litecoinからのみ購入できます。" + "gift_cards_unavailable": "現時点では、ギフトカードはMonero、Bitcoin、Litecoinからのみ購入できます。", + "introducing_cake_pay": "序章Cake Pay!", + "cake_pay_learn_more": "アプリですぐにカードを購入して引き換えましょう!\n右にスワイプして詳細をご覧ください。" } diff --git a/res/values/strings_ko.arb b/res/values/strings_ko.arb index edfa14184..da94dc1bb 100644 --- a/res/values/strings_ko.arb +++ b/res/values/strings_ko.arb @@ -632,5 +632,7 @@ "gift_card_is_generated": "기프트 카드가 생성되었습니다", "open_gift_card": "기프트 카드 열기", "contact_support": "지원팀에 문의", - "gift_cards_unavailable": "기프트 카드는 현재 Monero, Bitcoin 및 Litecoin을 통해서만 구매할 수 있습니다." + "gift_cards_unavailable": "기프트 카드는 현재 Monero, Bitcoin 및 Litecoin을 통해서만 구매할 수 있습니다.", + "introducing_cake_pay": "소개 Cake Pay!", + "cake_pay_learn_more": "앱에서 즉시 카드를 구매하고 사용하세요!\n자세히 알아보려면 오른쪽으로 스와이프하세요!" } diff --git a/res/values/strings_nl.arb b/res/values/strings_nl.arb index 35d7fccfe..75a7475e5 100644 --- a/res/values/strings_nl.arb +++ b/res/values/strings_nl.arb @@ -632,5 +632,7 @@ "gift_card_is_generated": "Cadeaukaart is gegenereerd", "open_gift_card": "Geschenkkaart openen", "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", + "introducing_cake_pay": "Introductie van Cake Pay!", + "cake_pay_learn_more": "Koop en wissel direct kaarten in de app!\nSwipe naar rechts voor meer informatie!" } diff --git a/res/values/strings_pl.arb b/res/values/strings_pl.arb index 5abf68ff5..d6c626913 100644 --- a/res/values/strings_pl.arb +++ b/res/values/strings_pl.arb @@ -632,5 +632,7 @@ "gift_card_is_generated": "Karta podarunkowa jest generowana", "open_gift_card": "Otwórz kartę podarunkową", "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", + "introducing_cake_pay": "Przedstawiamy Ciasto Pay!", + "cake_pay_learn_more": "Natychmiast kupuj i realizuj karty w aplikacji!\nPrzesuń w prawo, aby dowiedzieć się więcej!" } diff --git a/res/values/strings_pt.arb b/res/values/strings_pt.arb index 3cc7d0319..cdc8e86c0 100644 --- a/res/values/strings_pt.arb +++ b/res/values/strings_pt.arb @@ -632,5 +632,7 @@ "gift_card_is_generated": "Cartão presente é gerado", "open_gift_card": "Abrir vale-presente", "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", + "introducing_cake_pay": "Apresentando o Cake Pay!", + "cake_pay_learn_more": "Compre e resgate cartões instantaneamente no aplicativo!\nDeslize para a direita para saber mais!" } diff --git a/res/values/strings_ru.arb b/res/values/strings_ru.arb index e4a3d23d1..44dad0323 100644 --- a/res/values/strings_ru.arb +++ b/res/values/strings_ru.arb @@ -632,5 +632,7 @@ "gift_card_is_generated": "Подарочная карта сгенерирована", "open_gift_card": "Открыть подарочную карту", "contact_support": "Связаться со службой поддержки", - "gift_cards_unavailable": "В настоящее время подарочные карты можно приобрести только через Monero, Bitcoin и Litecoin." + "gift_cards_unavailable": "В настоящее время подарочные карты можно приобрести только через Monero, Bitcoin и Litecoin.", + "introducing_cake_pay": "Представляем Cake Pay!", + "cake_pay_learn_more": "Мгновенно покупайте и погашайте карты в приложении!\nПроведите вправо, чтобы узнать больше!" } diff --git a/res/values/strings_uk.arb b/res/values/strings_uk.arb index 171977721..cd5d574a9 100644 --- a/res/values/strings_uk.arb +++ b/res/values/strings_uk.arb @@ -631,5 +631,7 @@ "gift_card_is_generated": "Подарункова картка створена", "open_gift_card": "Відкрити подарункову картку", "contact_support": "Звернутися до служби підтримки", - "gift_cards_unavailable": "Наразі подарункові картки можна придбати лише через Monero, Bitcoin і Litecoin" + "gift_cards_unavailable": "Наразі подарункові картки можна придбати лише через Monero, Bitcoin і Litecoin", + "introducing_cake_pay": "Представляємо Cake Pay!", + "cake_pay_learn_more": "Миттєва купівля та погашення карток в додатку!\nПроведіть праворуч, щоб дізнатися більше!" } diff --git a/res/values/strings_zh.arb b/res/values/strings_zh.arb index ccf93bdda..f7375bdfb 100644 --- a/res/values/strings_zh.arb +++ b/res/values/strings_zh.arb @@ -630,5 +630,7 @@ "gift_card_is_generated": "礼品卡生成", "open_gift_card": "打开礼品卡", "contact_support": "联系支持", - "gift_cards_unavailable": "目前只能通过门罗币、比特币和莱特币购买礼品卡" + "gift_cards_unavailable": "目前只能通过门罗币、比特币和莱特币购买礼品卡", + "introducing_cake_pay": "介绍 Cake Pay!", + "cake_pay_learn_more": "立即在应用程序中购买和兑换卡!\n向右滑动了解更多!" }