mirror of
https://github.com/Such-Software/hash-wallet.git
synced 2026-10-22 06:28:39 +02: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:
@@ -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{
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user