consistent decimal places on firo balance selection sheet

This commit is contained in:
julian 2022-11-22 07:15:08 -06:00
parent b32e15a3ea
commit b512b2cefb
3 changed files with 31 additions and 8 deletions

View file

@ -161,7 +161,7 @@ class _FiroBalanceSelectionSheetState
ConnectionState.done &&
snapshot.hasData) {
return Text(
"${snapshot.data!} ${manager.coin.ticker}",
"${snapshot.data!.toStringAsFixed(8)} ${manager.coin.ticker}",
style: STextStyles.itemSubtitle(context),
textAlign: TextAlign.left,
);
@ -251,7 +251,7 @@ class _FiroBalanceSelectionSheetState
ConnectionState.done &&
snapshot.hasData) {
return Text(
"${snapshot.data!} ${manager.coin.ticker}",
"${snapshot.data!.toStringAsFixed(8)} ${manager.coin.ticker}",
style: STextStyles.itemSubtitle(context),
textAlign: TextAlign.left,
);

View file

@ -3,14 +3,13 @@ import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:stackwallet/providers/providers.dart';
import 'package:stackwallet/providers/wallet/wallet_balance_toggle_state_provider.dart';
import 'package:stackwallet/services/coins/firo/firo_wallet.dart';
import 'package:stackwallet/utilities/constants.dart';
import 'package:stackwallet/utilities/enums/coin_enum.dart';
import 'package:stackwallet/utilities/enums/wallet_balance_toggle_state.dart';
import 'package:stackwallet/utilities/text_styles.dart';
import 'package:stackwallet/utilities/theme/stack_colors.dart';
import 'package:stackwallet/services/coins/firo/firo_wallet.dart';
class WalletBalanceToggleSheet extends ConsumerWidget {
const WalletBalanceToggleSheet({
Key? key,
@ -153,7 +152,7 @@ class WalletBalanceToggleSheet extends ConsumerWidget {
snapshot.hasData &&
snapshot.data != null) {
return Text(
"${snapshot.data!}",
"${snapshot.data!.toStringAsFixed(Constants.decimalPlacesForCoin(coin))} ${coin.ticker}",
style: STextStyles.itemSubtitle12(context)
.copyWith(
color: Theme.of(context)
@ -195,7 +194,7 @@ class WalletBalanceToggleSheet extends ConsumerWidget {
snapshot.hasData &&
snapshot.data != null) {
return Text(
"${snapshot.data!}",
"${snapshot.data!.toStringAsFixed(Constants.decimalPlacesForCoin(coin))} ${coin.ticker}",
style: STextStyles.itemSubtitle12(context)
.copyWith(
color: Theme.of(context)
@ -287,7 +286,7 @@ class WalletBalanceToggleSheet extends ConsumerWidget {
snapshot.hasData &&
snapshot.data != null) {
return Text(
"${snapshot.data!}",
"${snapshot.data!.toStringAsFixed(Constants.decimalPlacesForCoin(coin))} ${coin.ticker}",
style: STextStyles.itemSubtitle12(context)
.copyWith(
color: Theme.of(context)
@ -329,7 +328,7 @@ class WalletBalanceToggleSheet extends ConsumerWidget {
snapshot.hasData &&
snapshot.data != null) {
return Text(
"${snapshot.data!}",
"${snapshot.data!.toStringAsFixed(Constants.decimalPlacesForCoin(coin))} ${coin.ticker}",
style: STextStyles.itemSubtitle12(context)
.copyWith(
color: Theme.of(context)

View file

@ -40,6 +40,30 @@ abstract class Constants {
static const int currentHiveDbVersion = 3;
static int decimalPlacesForCoin(Coin coin) {
switch (coin) {
case Coin.bitcoin:
case Coin.litecoin:
case Coin.litecoinTestNet:
case Coin.bitcoincash:
case Coin.bitcoincashTestnet:
case Coin.dogecoin:
case Coin.firo:
case Coin.bitcoinTestNet:
case Coin.dogecoinTestNet:
case Coin.firoTestNet:
case Coin.epicCash:
case Coin.namecoin:
return decimalPlaces;
case Coin.wownero:
return decimalPlacesWownero;
case Coin.monero:
return decimalPlacesMonero;
}
}
static List<int> possibleLengthsForCoin(Coin coin) {
final List<int> values = [];
switch (coin) {