mirror of
https://github.com/cake-tech/cake_wallet.git
synced 2024-11-17 09:47:35 +00:00
Merge pull request #70 from cake-tech/CWA-223-card-switcher
CWA-223 | added possibility to switch balance mode in the wallet card…
This commit is contained in:
commit
fead38e8a3
1 changed files with 262 additions and 200 deletions
|
@ -22,8 +22,10 @@ class WalletCard extends StatefulWidget {
|
|||
|
||||
class WalletCardState extends State<WalletCard> {
|
||||
final _syncingObserverKey = GlobalKey();
|
||||
final _balanceObserverKey = GlobalKey();
|
||||
final _addressObserverKey = GlobalKey();
|
||||
final _connectionStatusObserverKey = GlobalKey();
|
||||
final _balanceObserverKey = GlobalKey();
|
||||
final _balanceTitleObserverKey = GlobalKey();
|
||||
|
||||
double cardWidth;
|
||||
double cardHeight;
|
||||
|
@ -55,6 +57,8 @@ class WalletCardState extends State<WalletCard> {
|
|||
);
|
||||
}
|
||||
|
||||
void rollCard() => setState(() => isFrontSide = !isFrontSide);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final List<Color> colorsSync = [
|
||||
|
@ -93,12 +97,9 @@ class WalletCardState extends State<WalletCard> {
|
|||
width: cardWidth,
|
||||
height: cardHeight,
|
||||
color: Theme.of(context).cardColor,
|
||||
child: InkWell(
|
||||
onTap: () => setState(() => isFrontSide = !isFrontSide),
|
||||
child: isFrontSide
|
||||
? frontSide(colorsSync)
|
||||
: backSide(colorsSync)
|
||||
),
|
||||
: backSide(colorsSync),
|
||||
),
|
||||
)
|
||||
),
|
||||
|
@ -214,7 +215,9 @@ class WalletCardState extends State<WalletCard> {
|
|||
)
|
||||
],
|
||||
),
|
||||
Container(
|
||||
GestureDetector(
|
||||
onTap: () => rollCard(),
|
||||
child: Container(
|
||||
width: 98,
|
||||
height: 32,
|
||||
alignment: Alignment.center,
|
||||
|
@ -229,73 +232,129 @@ class WalletCardState extends State<WalletCard> {
|
|||
color: Theme.of(context).primaryTextTheme.caption.color
|
||||
),
|
||||
),
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
status is SyncedSyncStatus
|
||||
? Observer(
|
||||
key: _balanceObserverKey,
|
||||
builder: (_) {
|
||||
final balanceDisplayMode = settingsStore.balanceDisplayMode;
|
||||
final symbol = settingsStore
|
||||
.fiatCurrency
|
||||
.toString();
|
||||
var balance = '---';
|
||||
var fiatBalance = '---';
|
||||
|
||||
if (balanceDisplayMode ==
|
||||
BalanceDisplayMode.availableBalance) {
|
||||
balance =
|
||||
balanceStore.unlockedBalance ??
|
||||
'0.0';
|
||||
fiatBalance =
|
||||
'$symbol ${balanceStore.fiatUnlockedBalance}';
|
||||
}
|
||||
|
||||
if (balanceDisplayMode ==
|
||||
BalanceDisplayMode.fullBalance) {
|
||||
balance =
|
||||
balanceStore.fullBalance ?? '0.0';
|
||||
fiatBalance =
|
||||
'$symbol ${balanceStore.fiatFullBalance}';
|
||||
}
|
||||
|
||||
return Row(
|
||||
? GestureDetector(
|
||||
onTapUp: (_) => balanceStore.isReversing = false,
|
||||
onTapDown: (_) => balanceStore.isReversing = true,
|
||||
child: Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.end,
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: <Widget>[
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: <Widget>[
|
||||
Text(
|
||||
balanceDisplayMode.toString(),
|
||||
Observer(
|
||||
key: _balanceTitleObserverKey,
|
||||
builder: (_) {
|
||||
final savedDisplayMode =
|
||||
settingsStore.balanceDisplayMode;
|
||||
final displayMode = balanceStore
|
||||
.isReversing
|
||||
? (savedDisplayMode ==
|
||||
BalanceDisplayMode
|
||||
.availableBalance
|
||||
? BalanceDisplayMode.fullBalance
|
||||
: BalanceDisplayMode
|
||||
.availableBalance)
|
||||
: savedDisplayMode;
|
||||
|
||||
return Text(
|
||||
displayMode.toString(),
|
||||
style: TextStyle(
|
||||
fontSize: 12,
|
||||
color: Theme.of(context).primaryTextTheme.caption.color
|
||||
),
|
||||
),
|
||||
);
|
||||
}),
|
||||
SizedBox(height: 5),
|
||||
Text(
|
||||
Observer(
|
||||
key: _connectionStatusObserverKey,
|
||||
builder: (_) {
|
||||
final savedDisplayMode =
|
||||
settingsStore.balanceDisplayMode;
|
||||
var balance = '---';
|
||||
final displayMode = balanceStore
|
||||
.isReversing
|
||||
? (savedDisplayMode ==
|
||||
BalanceDisplayMode
|
||||
.availableBalance
|
||||
? BalanceDisplayMode.fullBalance
|
||||
: BalanceDisplayMode
|
||||
.availableBalance)
|
||||
: savedDisplayMode;
|
||||
|
||||
if (displayMode ==
|
||||
BalanceDisplayMode.availableBalance) {
|
||||
balance =
|
||||
balanceStore.unlockedBalance ??
|
||||
'0.0';
|
||||
}
|
||||
|
||||
if (displayMode ==
|
||||
BalanceDisplayMode.fullBalance) {
|
||||
balance =
|
||||
balanceStore.fullBalance ?? '0.0';
|
||||
}
|
||||
|
||||
return Text(
|
||||
balance,
|
||||
style: TextStyle(
|
||||
fontSize: 28,
|
||||
height: 1,
|
||||
color: Theme.of(context).primaryTextTheme.title.color
|
||||
),
|
||||
)
|
||||
);
|
||||
}),
|
||||
],
|
||||
),
|
||||
Text(
|
||||
fiatBalance,
|
||||
Observer(
|
||||
key: _balanceObserverKey,
|
||||
builder: (_) {
|
||||
final savedDisplayMode =
|
||||
settingsStore.balanceDisplayMode;
|
||||
final displayMode =
|
||||
balanceStore.isReversing
|
||||
? (savedDisplayMode ==
|
||||
BalanceDisplayMode
|
||||
.availableBalance
|
||||
? BalanceDisplayMode
|
||||
.fullBalance
|
||||
: BalanceDisplayMode
|
||||
.availableBalance)
|
||||
: savedDisplayMode;
|
||||
final symbol = settingsStore
|
||||
.fiatCurrency
|
||||
.toString();
|
||||
var balance = '---';
|
||||
|
||||
if (displayMode ==
|
||||
BalanceDisplayMode
|
||||
.availableBalance) {
|
||||
balance =
|
||||
'$symbol ${balanceStore.fiatUnlockedBalance}';
|
||||
}
|
||||
|
||||
if (displayMode ==
|
||||
BalanceDisplayMode.fullBalance) {
|
||||
balance =
|
||||
'$symbol ${balanceStore.fiatFullBalance}';
|
||||
}
|
||||
|
||||
return Text(
|
||||
balance,
|
||||
style: TextStyle(
|
||||
fontSize: 14,
|
||||
height: 2,
|
||||
color: Theme.of(context).primaryTextTheme.title.color
|
||||
),
|
||||
)
|
||||
],
|
||||
);
|
||||
}
|
||||
})
|
||||
],
|
||||
)
|
||||
)
|
||||
: Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.end,
|
||||
|
@ -343,7 +402,9 @@ class WalletCardState extends State<WalletCard> {
|
|||
double messageBoxHeight = 0;
|
||||
double messageBoxWidth = cardWidth - 10;
|
||||
|
||||
return Observer(
|
||||
return GestureDetector(
|
||||
onTap: () => rollCard(),
|
||||
child: Observer(
|
||||
key: _addressObserverKey,
|
||||
builder: (_) {
|
||||
return Container(
|
||||
|
@ -481,6 +542,7 @@ class WalletCardState extends State<WalletCard> {
|
|||
),
|
||||
);
|
||||
}
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue