Skip to content

Commit

Permalink
temp bandaid
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniela Damaschin authored and Daniela Damaschin committed May 24, 2024
1 parent 73e74ec commit 6603bb2
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 2 deletions.
24 changes: 24 additions & 0 deletions lib/features/children/details/pages/child_details_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,8 @@ class ChildDetailsPage extends StatelessWidget {
width: double.maxFinite,
color: AppTheme.givtLightBackgroundGreen,
child: ChildDetailsItem(
//ugly fix, for some reason ChildDetailsCubit doesnt update
balance: getBalance(context),
profileDetails: state.profileDetails,
),
),
Expand Down Expand Up @@ -192,6 +194,28 @@ class ChildDetailsPage extends StatelessWidget {
);
}

double getBalance(BuildContext context) {
var family = context.watch<FamilyOverviewCubit>().state;
if (family is FamilyOverviewUpdatedState) {
return family.profiles
.firstWhere((element) =>
element.id ==
(context.watch<ChildDetailsCubit>().state
as ChildDetailsFetchedState)
.profileDetails
.profile
.id)
.wallet
.balance;
}
return (context.watch<ChildDetailsCubit>().state
as ChildDetailsFetchedState)
.profileDetails
.profile
.wallet
.balance;
}

Future<void> _navigateToTopUpScreen(
BuildContext context,
) async {
Expand Down
5 changes: 3 additions & 2 deletions lib/features/children/details/widgets/child_details_item.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@ import 'package:givt_app/utils/utils.dart';
class ChildDetailsItem extends StatelessWidget {
const ChildDetailsItem({
required this.profileDetails,
required this.balance,
super.key,
});

final double balance;
final ProfileExt profileDetails;

@override
Expand Down Expand Up @@ -45,7 +46,7 @@ class ChildDetailsItem extends StatelessWidget {
),
),
Text(
'${currency.currencySymbol}${profileDetails.profile.wallet.balance.toStringAsFixed(0)}${context.l10n.childInWalletPostfix}',
'${currency.currencySymbol}${balance.toStringAsFixed(0)}${context.l10n.childInWalletPostfix}',
textAlign: TextAlign.center,
style: Theme.of(context).textTheme.titleMedium?.copyWith(
color: AppTheme.inputFieldBorderSelected,
Expand Down

0 comments on commit 6603bb2

Please sign in to comment.