mirror of
https://github.com/cake-tech/cake_wallet.git
synced 2024-12-22 19:49:22 +00:00
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:
parent
5fcbf3634b
commit
7fae9cf9bb
21 changed files with 189 additions and 19 deletions
|
@ -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<String>.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<String> get yatLastUsedAddressStream => _yatLastUsedAddressController.stream;
|
||||
|
|
|
@ -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!');
|
||||
|
|
|
@ -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{
|
|||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
89
lib/src/widgets/introducing_card.dart
Normal file
89
lib/src/widgets/introducing_card.dart
Normal 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,
|
||||
)),
|
||||
),
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
|
@ -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<void> disableIntroCakePayCard () async {
|
||||
const cardDisplayStatus = false;
|
||||
wallet.walletInfo.showIntroCakePayCard = cardDisplayStatus;
|
||||
await wallet.walletInfo.save();
|
||||
isShowCard = cardDisplayStatus;
|
||||
}
|
||||
|
||||
String _getFiatBalance({double price, String cryptoAmount}) {
|
||||
|
|
|
@ -37,6 +37,9 @@ abstract class WalletCreationVMBase with Store {
|
|||
bool nameExists(String name)
|
||||
=> walletCreationService.exists(name);
|
||||
|
||||
bool typeExists(WalletType type)
|
||||
=> walletCreationService.typeExists(type);
|
||||
|
||||
Future<void> 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;
|
||||
|
|
|
@ -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!"
|
||||
}
|
||||
|
|
|
@ -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!"
|
||||
}
|
||||
|
|
|
@ -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!"
|
||||
}
|
||||
|
|
|
@ -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 !"
|
||||
}
|
||||
|
|
|
@ -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अधिक जानने के लिए दाएं स्वाइप करें!"
|
||||
}
|
||||
|
|
|
@ -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!"
|
||||
}
|
||||
|
|
|
@ -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ù!"
|
||||
}
|
||||
|
|
|
@ -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右にスワイプして詳細をご覧ください。"
|
||||
}
|
||||
|
|
|
@ -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자세히 알아보려면 오른쪽으로 스와이프하세요!"
|
||||
}
|
||||
|
|
|
@ -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!"
|
||||
}
|
||||
|
|
|
@ -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!"
|
||||
}
|
||||
|
|
|
@ -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!"
|
||||
}
|
||||
|
|
|
@ -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Проведите вправо, чтобы узнать больше!"
|
||||
}
|
||||
|
|
|
@ -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Проведіть праворуч, щоб дізнатися більше!"
|
||||
}
|
||||
|
|
|
@ -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向右滑动了解更多!"
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue