mirror of
https://github.com/cake-tech/cake_wallet.git
synced 2025-01-23 11:15:33 +00:00
CWA-223 | added possibility to switch balance mode in the wallet card (long press on balance value); applied switch to back side of wallet card to short address field
This commit is contained in:
parent
0b53971051
commit
00ef34ee80
1 changed files with 262 additions and 200 deletions
|
@ -22,8 +22,10 @@ class WalletCard extends StatefulWidget {
|
||||||
|
|
||||||
class WalletCardState extends State<WalletCard> {
|
class WalletCardState extends State<WalletCard> {
|
||||||
final _syncingObserverKey = GlobalKey();
|
final _syncingObserverKey = GlobalKey();
|
||||||
final _balanceObserverKey = GlobalKey();
|
|
||||||
final _addressObserverKey = GlobalKey();
|
final _addressObserverKey = GlobalKey();
|
||||||
|
final _connectionStatusObserverKey = GlobalKey();
|
||||||
|
final _balanceObserverKey = GlobalKey();
|
||||||
|
final _balanceTitleObserverKey = GlobalKey();
|
||||||
|
|
||||||
double cardWidth;
|
double cardWidth;
|
||||||
double cardHeight;
|
double cardHeight;
|
||||||
|
@ -55,6 +57,8 @@ class WalletCardState extends State<WalletCard> {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void rollCard() => setState(() => isFrontSide = !isFrontSide);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final List<Color> colorsSync = [
|
final List<Color> colorsSync = [
|
||||||
|
@ -93,12 +97,9 @@ class WalletCardState extends State<WalletCard> {
|
||||||
width: cardWidth,
|
width: cardWidth,
|
||||||
height: cardHeight,
|
height: cardHeight,
|
||||||
color: Theme.of(context).cardColor,
|
color: Theme.of(context).cardColor,
|
||||||
child: InkWell(
|
|
||||||
onTap: () => setState(() => isFrontSide = !isFrontSide),
|
|
||||||
child: isFrontSide
|
child: isFrontSide
|
||||||
? frontSide(colorsSync)
|
? frontSide(colorsSync)
|
||||||
: backSide(colorsSync)
|
: backSide(colorsSync),
|
||||||
),
|
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
|
@ -214,7 +215,9 @@ class WalletCardState extends State<WalletCard> {
|
||||||
)
|
)
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
Container(
|
GestureDetector(
|
||||||
|
onTap: () => rollCard(),
|
||||||
|
child: Container(
|
||||||
width: 98,
|
width: 98,
|
||||||
height: 32,
|
height: 32,
|
||||||
alignment: Alignment.center,
|
alignment: Alignment.center,
|
||||||
|
@ -229,73 +232,129 @@ class WalletCardState extends State<WalletCard> {
|
||||||
color: Theme.of(context).primaryTextTheme.caption.color
|
color: Theme.of(context).primaryTextTheme.caption.color
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
),
|
||||||
)
|
)
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
status is SyncedSyncStatus
|
status is SyncedSyncStatus
|
||||||
? Observer(
|
? GestureDetector(
|
||||||
key: _balanceObserverKey,
|
onTapUp: (_) => balanceStore.isReversing = false,
|
||||||
builder: (_) {
|
onTapDown: (_) => balanceStore.isReversing = true,
|
||||||
final balanceDisplayMode = settingsStore.balanceDisplayMode;
|
child: Row(
|
||||||
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(
|
|
||||||
crossAxisAlignment: CrossAxisAlignment.end,
|
crossAxisAlignment: CrossAxisAlignment.end,
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
Column(
|
Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
Text(
|
Observer(
|
||||||
balanceDisplayMode.toString(),
|
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(
|
style: TextStyle(
|
||||||
fontSize: 12,
|
fontSize: 12,
|
||||||
color: Theme.of(context).primaryTextTheme.caption.color
|
color: Theme.of(context).primaryTextTheme.caption.color
|
||||||
),
|
),
|
||||||
),
|
);
|
||||||
|
}),
|
||||||
SizedBox(height: 5),
|
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,
|
balance,
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
fontSize: 28,
|
fontSize: 28,
|
||||||
height: 1,
|
height: 1,
|
||||||
color: Theme.of(context).primaryTextTheme.title.color
|
color: Theme.of(context).primaryTextTheme.title.color
|
||||||
),
|
),
|
||||||
)
|
);
|
||||||
|
}),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
Text(
|
Observer(
|
||||||
fiatBalance,
|
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(
|
style: TextStyle(
|
||||||
fontSize: 14,
|
fontSize: 14,
|
||||||
height: 2,
|
height: 2,
|
||||||
color: Theme.of(context).primaryTextTheme.title.color
|
color: Theme.of(context).primaryTextTheme.title.color
|
||||||
),
|
),
|
||||||
)
|
|
||||||
],
|
|
||||||
);
|
);
|
||||||
}
|
})
|
||||||
|
],
|
||||||
|
)
|
||||||
)
|
)
|
||||||
: Row(
|
: Row(
|
||||||
crossAxisAlignment: CrossAxisAlignment.end,
|
crossAxisAlignment: CrossAxisAlignment.end,
|
||||||
|
@ -343,7 +402,9 @@ class WalletCardState extends State<WalletCard> {
|
||||||
double messageBoxHeight = 0;
|
double messageBoxHeight = 0;
|
||||||
double messageBoxWidth = cardWidth - 10;
|
double messageBoxWidth = cardWidth - 10;
|
||||||
|
|
||||||
return Observer(
|
return GestureDetector(
|
||||||
|
onTap: () => rollCard(),
|
||||||
|
child: Observer(
|
||||||
key: _addressObserverKey,
|
key: _addressObserverKey,
|
||||||
builder: (_) {
|
builder: (_) {
|
||||||
return Container(
|
return Container(
|
||||||
|
@ -481,6 +542,7 @@ class WalletCardState extends State<WalletCard> {
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in a new issue