fix: Firo total displayed on managed favourite list card

This commit is contained in:
julian 2023-05-25 10:10:07 -06:00
parent 3189203419
commit 6a92657f50

View file

@ -4,8 +4,10 @@ import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:flutter_svg/svg.dart'; import 'package:flutter_svg/svg.dart';
import 'package:stackwallet/providers/providers.dart'; import 'package:stackwallet/providers/providers.dart';
import 'package:stackwallet/services/coins/firo/firo_wallet.dart';
import 'package:stackwallet/themes/coin_icon_provider.dart'; import 'package:stackwallet/themes/coin_icon_provider.dart';
import 'package:stackwallet/themes/stack_colors.dart'; import 'package:stackwallet/themes/stack_colors.dart';
import 'package:stackwallet/utilities/amount/amount.dart';
import 'package:stackwallet/utilities/constants.dart'; import 'package:stackwallet/utilities/constants.dart';
import 'package:stackwallet/utilities/enums/coin_enum.dart'; import 'package:stackwallet/utilities/enums/coin_enum.dart';
import 'package:stackwallet/utilities/text_styles.dart'; import 'package:stackwallet/utilities/text_styles.dart';
@ -34,6 +36,28 @@ class _ManagedFavoriteCardState extends ConsumerState<ManagedFavorite> {
final isDesktop = Util.isDesktop; final isDesktop = Util.isDesktop;
final balance = ref.watch(
walletsChangeNotifierProvider.select(
(value) => value.getManager(widget.walletId).balance,
),
);
Amount total = balance.total;
if (manager.coin == Coin.firo || manager.coin == Coin.firoTestNet) {
final balancePrivate = ref.watch(
walletsChangeNotifierProvider.select(
(value) => (value
.getManager(
widget.walletId,
)
.wallet as FiroWallet)
.balancePrivate,
),
);
total += balancePrivate.total;
}
return RoundedWhiteContainer( return RoundedWhiteContainer(
padding: EdgeInsets.all(isDesktop ? 0 : 4.0), padding: EdgeInsets.all(isDesktop ? 0 : 4.0),
child: RawMaterialButton( child: RawMaterialButton(
@ -107,7 +131,7 @@ class _ManagedFavoriteCardState extends ConsumerState<ManagedFavorite> {
), ),
Expanded( Expanded(
child: Text( child: Text(
"${manager.balance.total.localizedStringAsFixed( "${total.localizedStringAsFixed(
locale: ref.watch( locale: ref.watch(
localeServiceChangeNotifierProvider.select( localeServiceChangeNotifierProvider.select(
(value) => value.locale, (value) => value.locale,
@ -150,7 +174,7 @@ class _ManagedFavoriteCardState extends ConsumerState<ManagedFavorite> {
height: 2, height: 2,
), ),
Text( Text(
"${manager.balance.total.localizedStringAsFixed( "${total.localizedStringAsFixed(
locale: ref.watch( locale: ref.watch(
localeServiceChangeNotifierProvider.select( localeServiceChangeNotifierProvider.select(
(value) => value.locale, (value) => value.locale,