don't show lelantus balance on mobile if zero

This commit is contained in:
julian 2024-05-08 13:26:51 -06:00
parent bf14dd09f4
commit d8f6ff23d4
2 changed files with 89 additions and 78 deletions

View file

@ -173,85 +173,91 @@ class _FiroBalanceSelectionSheetState
),
),
),
const SizedBox(
height: 16,
),
GestureDetector(
onTap: () {
final state =
ref.read(publicPrivateBalanceStateProvider.state).state;
if (state != FiroType.lelantus) {
ref.read(publicPrivateBalanceStateProvider.state).state =
FiroType.lelantus;
}
Navigator.of(context).pop();
},
child: Container(
color: Colors.transparent,
child: Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Column(
mainAxisAlignment: MainAxisAlignment.start,
children: [
SizedBox(
width: 20,
height: 20,
child: Radio(
activeColor: Theme.of(context)
.extension<StackColors>()!
.radioButtonIconEnabled,
value: FiroType.lelantus,
groupValue: ref
.watch(
publicPrivateBalanceStateProvider.state)
.state,
onChanged: (x) {
ref
.read(publicPrivateBalanceStateProvider
.state)
.state = FiroType.lelantus;
Navigator.of(context).pop();
},
),
),
],
),
const SizedBox(
width: 12,
),
Flexible(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
if (firoWallet.info.cachedBalanceSecondary.spendable.raw >
BigInt.zero)
const SizedBox(
height: 16,
),
if (firoWallet.info.cachedBalanceSecondary.spendable.raw >
BigInt.zero)
GestureDetector(
onTap: () {
final state = ref
.read(publicPrivateBalanceStateProvider.state)
.state;
if (state != FiroType.lelantus) {
ref
.read(publicPrivateBalanceStateProvider.state)
.state = FiroType.lelantus;
}
Navigator.of(context).pop();
},
child: Container(
color: Colors.transparent,
child: Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Column(
mainAxisAlignment: MainAxisAlignment.start,
children: [
// Row(
// children: [
Text(
"Lelantus balance",
style: STextStyles.titleBold12(context),
textAlign: TextAlign.left,
),
const SizedBox(
width: 2,
),
Text(
ref.watch(pAmountFormatter(coin)).format(
firoWallet.info.cachedBalanceSecondary
.spendable,
),
style: STextStyles.itemSubtitle(context),
textAlign: TextAlign.left,
SizedBox(
width: 20,
height: 20,
child: Radio(
activeColor: Theme.of(context)
.extension<StackColors>()!
.radioButtonIconEnabled,
value: FiroType.lelantus,
groupValue: ref
.watch(publicPrivateBalanceStateProvider
.state)
.state,
onChanged: (x) {
ref
.read(publicPrivateBalanceStateProvider
.state)
.state = FiroType.lelantus;
Navigator.of(context).pop();
},
),
),
],
),
// ],
// ),
)
],
const SizedBox(
width: 12,
),
Flexible(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
// Row(
// children: [
Text(
"Lelantus balance",
style: STextStyles.titleBold12(context),
textAlign: TextAlign.left,
),
const SizedBox(
width: 2,
),
Text(
ref.watch(pAmountFormatter(coin)).format(
firoWallet.info.cachedBalanceSecondary
.spendable,
),
style: STextStyles.itemSubtitle(context),
textAlign: TextAlign.left,
),
],
),
// ],
// ),
)
],
),
),
),
),
const SizedBox(
height: 16,
),

View file

@ -33,9 +33,9 @@ enum _BalanceType {
class WalletBalanceToggleSheet extends ConsumerWidget {
const WalletBalanceToggleSheet({
Key? key,
super.key,
required this.walletId,
}) : super(key: key);
});
final String walletId;
@ -46,7 +46,7 @@ class WalletBalanceToggleSheet extends ConsumerWidget {
final coin = ref.watch(pWalletCoin(walletId));
final isFiro = coin == Coin.firo || coin == Coin.firoTestNet;
Balance balance = ref.watch(pWalletBalance(walletId));
final balance = ref.watch(pWalletBalance(walletId));
_BalanceType _bal =
ref.watch(walletBalanceToggleStateProvider.state).state ==
@ -77,6 +77,11 @@ class WalletBalanceToggleSheet extends ConsumerWidget {
// already set above
break;
}
// hack to not show lelantus balance in ui if zero
if (balanceSecondary?.spendable.raw == BigInt.zero) {
balanceSecondary = null;
}
}
return Container(
@ -289,7 +294,7 @@ class WalletBalanceToggleSheet extends ConsumerWidget {
class BalanceSelector<T> extends ConsumerWidget {
const BalanceSelector({
Key? key,
super.key,
required this.title,
required this.coin,
required this.balance,
@ -297,7 +302,7 @@ class BalanceSelector<T> extends ConsumerWidget {
required this.onChanged,
required this.value,
required this.groupValue,
}) : super(key: key);
});
final String title;
final Coin coin;