Skip to content

Commit

Permalink
(FEAT) add wallet balance
Browse files Browse the repository at this point in the history
  • Loading branch information
sannysegue committed Jan 23, 2022
1 parent 4030dd5 commit a7411f2
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 5 deletions.
14 changes: 12 additions & 2 deletions lib/home.dart
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,24 @@ class _MyHomePageState extends State<MyHomePage> {
});
}

double _loadTotalBalance() {
var balance = 0.0;
_userTransactions.forEach((e) {
balance += e.amount;
});
return balance;
}

@override
Widget build(BuildContext context) {
return Scaffold(
body: CustomScrollView(
slivers: [
SliverList(
delegate: SliverChildListDelegate(
<Widget>[CustomAppBar(), WalletBar()])),
delegate: SliverChildListDelegate(<Widget>[
CustomAppBar(),
WalletBar(totalBalance: _loadTotalBalance()),
])),
SliverList(
delegate: SliverChildListDelegate(<Widget>[
Visibility(
Expand Down
6 changes: 5 additions & 1 deletion lib/widgets/header_wallet.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ import 'package:flutter/widgets.dart';
import 'package:flutter_svg/flutter_svg.dart';

class WalletBar extends StatefulWidget {
final double totalBalance;

WalletBar({this.totalBalance});

@override
_WalletBartState createState() => _WalletBartState();
}
Expand Down Expand Up @@ -52,7 +56,7 @@ class _WalletBartState extends State<WalletBar> {
fontFamily: 'Sanomat'),
),
Text(
"3790.50",
"${widget.totalBalance}",
style: TextStyle(
color: Color(0xFF1C1C1C),
fontSize: 18,
Expand Down
2 changes: 0 additions & 2 deletions lib/widgets/transaction_record.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import 'dart:ffi';

import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart';
import 'package:flutter_complete_guide/widgets/utils.dart';
Expand Down

0 comments on commit a7411f2

Please sign in to comment.