Cw 150 cake pay introduction card (#486)

* create introducing card

* add ability to close the card

* update walletInfo class

* update localization

* fix intro text

* fix card size

* show card for existing and new wallet types

* disable card for haven wallets

* fixes to PR

* fixes to PR

* fix PR
This commit is contained in:
Serhii 2022-08-30 21:03:02 +03:00 committed by GitHub
parent 5fcbf3634b
commit 7fae9cf9bb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
21 changed files with 189 additions and 19 deletions

View file

@ -9,7 +9,7 @@ part 'wallet_info.g.dart';
class WalletInfo extends HiveObject { class WalletInfo extends HiveObject {
WalletInfo(this.id, this.name, this.type, this.isRecovery, this.restoreHeight, WalletInfo(this.id, this.name, this.type, this.isRecovery, this.restoreHeight,
this.timestamp, this.dirPath, this.path, this.address, this.yatEid, this.timestamp, this.dirPath, this.path, this.address, this.yatEid,
this.yatLastUsedAddressRaw) this.yatLastUsedAddressRaw, this.showIntroCakePayCard)
: _yatLastUsedAddressController = StreamController<String>.broadcast(); : _yatLastUsedAddressController = StreamController<String>.broadcast();
factory WalletInfo.external( factory WalletInfo.external(
@ -23,10 +23,11 @@ class WalletInfo extends HiveObject {
@required String path, @required String path,
@required String address, @required String address,
String yatEid ='', String yatEid ='',
String yatLastUsedAddressRaw = ''}) { String yatLastUsedAddressRaw = '',
bool showIntroCakePayCard}) {
return WalletInfo(id, name, type, isRecovery, restoreHeight, return WalletInfo(id, name, type, isRecovery, restoreHeight,
date.millisecondsSinceEpoch ?? 0, dirPath, path, address, date.millisecondsSinceEpoch ?? 0, dirPath, path, address,
yatEid, yatLastUsedAddressRaw); yatEid, yatLastUsedAddressRaw, showIntroCakePayCard);
} }
static const typeId = 4; static const typeId = 4;
@ -68,6 +69,9 @@ class WalletInfo extends HiveObject {
@HiveField(12) @HiveField(12)
String yatLastUsedAddressRaw; String yatLastUsedAddressRaw;
@HiveField(13)
bool showIntroCakePayCard;
String get yatLastUsedAddress => yatLastUsedAddressRaw; String get yatLastUsedAddress => yatLastUsedAddressRaw;
set yatLastUsedAddress(String address) { set yatLastUsedAddress(String address) {
@ -77,6 +81,13 @@ class WalletInfo extends HiveObject {
String get yatEmojiId => yatEid ?? ''; String get yatEmojiId => yatEid ?? '';
bool get isShowIntroCakePayCard {
if(showIntroCakePayCard == null) {
return type != WalletType.haven;
}
return showIntroCakePayCard;
}
DateTime get date => DateTime.fromMillisecondsSinceEpoch(timestamp); DateTime get date => DateTime.fromMillisecondsSinceEpoch(timestamp);
Stream<String> get yatLastUsedAddressStream => _yatLastUsedAddressController.stream; Stream<String> get yatLastUsedAddressStream => _yatLastUsedAddressController.stream;

View file

@ -46,6 +46,12 @@ class WalletCreationService {
.any((walletInfo) => walletInfo.name.toLowerCase() == walletName); .any((walletInfo) => walletInfo.name.toLowerCase() == walletName);
} }
bool typeExists(WalletType type) {
return walletInfoSource
.values
.any((walletInfo) => walletInfo.type == type);
}
void checkIfExists(String name) { void checkIfExists(String name) {
if (exists(name)) { if (exists(name)) {
throw Exception('Wallet with name ${name} already exists!'); throw Exception('Wallet with name ${name} already exists!');

View file

@ -7,6 +7,9 @@ import 'package:cake_wallet/view_model/dashboard/dashboard_view_model.dart';
import 'package:flutter/scheduler.dart'; import 'package:flutter/scheduler.dart';
import 'package:flutter_mobx/flutter_mobx.dart'; import 'package:flutter_mobx/flutter_mobx.dart';
import 'package:auto_size_text/auto_size_text.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{ class BalancePage extends StatelessWidget{
BalancePage({@required this.dashboardViewModel, @required this.settingsStore}); BalancePage({@required this.dashboardViewModel, @required this.settingsStore});
@ -44,6 +47,19 @@ class BalancePage extends StatelessWidget{
maxLines: 1, maxLines: 1,
textAlign: TextAlign.center); 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: (_) { Observer(builder: (_) {
return ListView.separated( return ListView.separated(
physics: NeverScrollableScrollPhysics(), physics: NeverScrollableScrollPhysics(),
@ -180,3 +196,4 @@ class BalancePage extends StatelessWidget{
); );
} }
} }

View file

@ -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,
)),
),
),
)
],
),
),
);
}
}

View file

@ -39,6 +39,7 @@ abstract class BalanceViewModelBase with Store {
@required this.fiatConvertationStore}) { @required this.fiatConvertationStore}) {
isReversing = false; isReversing = false;
wallet ??= appStore.wallet; wallet ??= appStore.wallet;
isShowCard = wallet.walletInfo.isShowIntroCakePayCard;
reaction((_) => appStore.wallet, _onWalletChange); reaction((_) => appStore.wallet, _onWalletChange);
} }
@ -235,6 +236,9 @@ abstract class BalanceViewModelBase with Store {
@computed @computed
CryptoCurrency get currency => appStore.wallet.currency; CryptoCurrency get currency => appStore.wallet.currency;
@observable
bool isShowCard;
ReactionDisposer _onCurrentWalletChangeReaction; ReactionDisposer _onCurrentWalletChangeReaction;
@action @action
@ -244,6 +248,15 @@ abstract class BalanceViewModelBase with Store {
wallet) { wallet) {
this.wallet = wallet; this.wallet = wallet;
_onCurrentWalletChangeReaction?.reaction?.dispose(); _onCurrentWalletChangeReaction?.reaction?.dispose();
isShowCard = wallet.walletInfo.isShowIntroCakePayCard;
}
@action
Future<void> disableIntroCakePayCard () async {
const cardDisplayStatus = false;
wallet.walletInfo.showIntroCakePayCard = cardDisplayStatus;
await wallet.walletInfo.save();
isShowCard = cardDisplayStatus;
} }
String _getFiatBalance({double price, String cryptoAmount}) { String _getFiatBalance({double price, String cryptoAmount}) {

View file

@ -37,6 +37,9 @@ abstract class WalletCreationVMBase with Store {
bool nameExists(String name) bool nameExists(String name)
=> walletCreationService.exists(name); => walletCreationService.exists(name);
bool typeExists(WalletType type)
=> walletCreationService.typeExists(type);
Future<void> create({dynamic options}) async { Future<void> create({dynamic options}) async {
try { try {
state = IsExecutingState(); state = IsExecutingState();
@ -56,7 +59,8 @@ abstract class WalletCreationVMBase with Store {
restoreHeight: credentials.height ?? 0, restoreHeight: credentials.height ?? 0,
date: DateTime.now(), date: DateTime.now(),
path: path, path: path,
dirPath: dirPath); dirPath: dirPath,
showIntroCakePayCard: (!walletCreationService.typeExists(type)) && type != WalletType.haven);
credentials.walletInfo = walletInfo; credentials.walletInfo = walletInfo;
final wallet = await process(credentials); final wallet = await process(credentials);
walletInfo.address = wallet.walletAddresses.address; walletInfo.address = wallet.walletAddresses.address;

View file

@ -632,5 +632,7 @@
"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",
"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!"
} }

View file

@ -632,5 +632,7 @@
"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",
"introducing_cake_pay": "Introducing Cake Pay!",
"cake_pay_learn_more": "Instantly purchase and redeem cards in the app!\nSwipe right to learn more!"
} }

View file

@ -632,5 +632,7 @@
"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",
"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!"
} }

View file

@ -630,5 +630,7 @@
"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",
"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 !"
} }

View file

@ -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_unavailable": "उपहार कार्ड इस समय केवल मोनेरो, बिटकॉइन और लिटकोइन के माध्यम से खरीदने के लिए उपलब्ध हैं",
"introducing_cake_pay": "परिचय Cake Pay!",
"cake_pay_learn_more": "ऐप में तुरंत कार्ड खरीदें और रिडीम करें!\nअधिक जानने के लिए दाएं स्वाइप करें!"
} }

View file

@ -632,5 +632,7 @@
"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",
"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!"
} }

View file

@ -632,5 +632,7 @@
"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",
"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ù!"
} }

View file

@ -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": "現時点では、ギフトカードはMonero、Bitcoin、Litecoinからのみ購入できます。" "gift_cards_unavailable": "現時点では、ギフトカードはMonero、Bitcoin、Litecoinからのみ購入できます。",
"introducing_cake_pay": "序章Cake Pay",
"cake_pay_learn_more": "アプリですぐにカードを購入して引き換えましょう!\n右にスワイプして詳細をご覧ください。"
} }

View file

@ -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": "기프트 카드는 현재 Monero, Bitcoin 및 Litecoin을 통해서만 구매할 수 있습니다." "gift_cards_unavailable": "기프트 카드는 현재 Monero, Bitcoin 및 Litecoin을 통해서만 구매할 수 있습니다.",
"introducing_cake_pay": "소개 Cake Pay!",
"cake_pay_learn_more": "앱에서 즉시 카드를 구매하고 사용하세요!\n자세히 알아보려면 오른쪽으로 스와이프하세요!"
} }

View file

@ -632,5 +632,7 @@
"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",
"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!"
} }

View file

@ -632,5 +632,7 @@
"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",
"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!"
} }

View file

@ -632,5 +632,7 @@
"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",
"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!"
} }

View file

@ -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": "В настоящее время подарочные карты можно приобрести только через Monero, Bitcoin и Litecoin." "gift_cards_unavailable": "В настоящее время подарочные карты можно приобрести только через Monero, Bitcoin и Litecoin.",
"introducing_cake_pay": "Представляем Cake Pay!",
"cake_pay_learn_more": "Мгновенно покупайте и погашайте карты в приложении!\nПроведите вправо, чтобы узнать больше!"
} }

View file

@ -631,5 +631,7 @@
"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",
"introducing_cake_pay": "Представляємо Cake Pay!",
"cake_pay_learn_more": "Миттєва купівля та погашення карток в додатку!\nПроведіть праворуч, щоб дізнатися більше!"
} }

View file

@ -630,5 +630,7 @@
"gift_card_is_generated": "礼品卡生成", "gift_card_is_generated": "礼品卡生成",
"open_gift_card": "打开礼品卡", "open_gift_card": "打开礼品卡",
"contact_support": "联系支持", "contact_support": "联系支持",
"gift_cards_unavailable": "目前只能通过门罗币、比特币和莱特币购买礼品卡" "gift_cards_unavailable": "目前只能通过门罗币、比特币和莱特币购买礼品卡",
"introducing_cake_pay": "介绍 Cake Pay!",
"cake_pay_learn_more": "立即在应用程序中购买和兑换卡!\n向右滑动了解更多"
} }