Skip to content

Commit

Permalink
Fixed bug with homepage not updating
Browse files Browse the repository at this point in the history
  • Loading branch information
xMadKing committed Dec 24, 2023
1 parent 4c8b42b commit 80de341
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 9 deletions.
10 changes: 5 additions & 5 deletions lib/pages/homepage.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,14 @@ import 'package:smartspend/backend/wyrm/database.dart';
import 'package:smartspend/pages/myaccountpage.dart';

class HomePage extends StatefulWidget {
final User client;

const HomePage({super.key, required this.client});
const HomePage({super.key});

@override
State<HomePage> createState() => _HomePageState();
}

class _HomePageState extends State<HomePage>{
late User client;
late List<Category> categories;
Map<String, double> dataMap = {};
bool _loading = true;
Expand All @@ -33,6 +32,7 @@ class _HomePageState extends State<HomePage>{

Future<void> initArgs() async {
categories = await database.categories();
client = (await database.users()).first;
setState(() {
_loading = false;
});
Expand Down Expand Up @@ -76,15 +76,15 @@ class _HomePageState extends State<HomePage>{
for (var element in categories) {
dataMap.addEntries([MapEntry(element.categoryName, element.currentSpending.toDouble())]);
}
double width = getTotalSpending() / widget.client.monthlyIncome;
double width = getTotalSpending() / client.monthlyIncome;
Color barColor = Colors.purple.shade800;
if(width >= 0.8){
barColor = Colors.red.shade700;
if(width > 1) {
width = 1;
}
}
String name = widget.client.name;
String name = client.name;
return PopScope(
canPop: false,
child: Scaffold(
Expand Down
2 changes: 1 addition & 1 deletion lib/widgets/categorywidget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class CategoryWidget extends StatelessWidget {
Color fontColor = getFontColor();
return GestureDetector(
onTap: () {
print("HELLOTHERE");
//we can maybe add future functionality here
},
child: Container(
margin: const EdgeInsets.all(5),
Expand Down
4 changes: 1 addition & 3 deletions lib/widgets/navbar.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,7 @@ class _NavBar extends State<NavBar>{
Color bg_color = Color(0xFF1E2038);
int index = 0;
late List<Widget> options = <Widget>[
HomePage(
client: widget.client,
),
HomePage(),
AddExpensePage(),
MyAccount(),
];
Expand Down

0 comments on commit 80de341

Please sign in to comment.