-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
v1.0.19 - Month leads to transactions (#19)
* v1.0.19 - Month leads to transactions * v1.0.19 - Fix DB Import bug * v1.0.19 - Update Entry Service * v1.0.19 - Make month clickable * v1.0.19 - Update App Bar
- Loading branch information
Showing
12 changed files
with
207 additions
and
138 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,138 @@ | ||
import 'package:finease/db/months.dart'; | ||
import 'package:finease/parts/card.dart'; | ||
import 'package:finease/routes/routes_name.dart'; | ||
import 'package:flutter/material.dart'; | ||
import 'package:finease/core/export.dart'; | ||
import 'package:go_router/go_router.dart'; | ||
import 'package:intl/intl.dart'; | ||
|
||
DateFormat formatter = DateFormat('MMMM yyyy'); | ||
|
||
class MonthCards extends StatelessWidget { | ||
final List<Month> months; | ||
|
||
const MonthCards({ | ||
super.key, | ||
required this.months, | ||
}); | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return ListView.builder( | ||
itemCount: months.length, | ||
itemBuilder: (context, index) => MonthCard( | ||
month: months[index], | ||
), | ||
); | ||
} | ||
} | ||
|
||
class MonthCard extends StatelessWidget { | ||
const MonthCard({ | ||
super.key, | ||
required this.month, | ||
}); | ||
|
||
final Month month; | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
DateTime startDate = month.date!; | ||
DateTime endDate = DateTime(month.date!.year, month.date!.month + 1, 1) | ||
.subtract(const Duration(seconds: 1)); | ||
|
||
return InkWell( | ||
onTap: () { | ||
context.pushNamed( | ||
RoutesName.transactionsByDate.name, | ||
extra: { | ||
'startDate': startDate.toIso8601String(), | ||
'endDate': endDate.toIso8601String(), | ||
}, | ||
); | ||
}, | ||
child: AppCard( | ||
elevation: 4, | ||
child: Padding( | ||
padding: const EdgeInsets.all(8.0), | ||
child: Column( | ||
crossAxisAlignment: CrossAxisAlignment.start, | ||
children: [ | ||
Flex( | ||
direction: Axis.horizontal, | ||
mainAxisAlignment: MainAxisAlignment.spaceAround, | ||
children: [ | ||
Text( | ||
formatter.format(month.date!), | ||
style: context.titleSmall, | ||
) | ||
], | ||
), | ||
const Divider(), | ||
Row( | ||
children: [ | ||
Expanded( | ||
child: MonthWidget( | ||
title: "Net Worth", | ||
content: month.networth!.toStringAsFixed(2), | ||
), | ||
), | ||
const SizedBox(width: 8), | ||
Expanded( | ||
child: MonthWidget( | ||
title: "Effect", | ||
content: month.effect!.toStringAsFixed(2), | ||
), | ||
), | ||
], | ||
), | ||
const SizedBox(height: 6), | ||
Row( | ||
children: [ | ||
Expanded( | ||
child: MonthWidget( | ||
title: "Income", | ||
content: month.income!.toStringAsFixed(2), | ||
), | ||
), | ||
const SizedBox(width: 8), | ||
Expanded( | ||
child: MonthWidget( | ||
title: "Expense", | ||
content: month.expense!.toStringAsFixed(2), | ||
), | ||
), | ||
], | ||
), | ||
], | ||
), | ||
), | ||
), | ||
); | ||
} | ||
} | ||
|
||
class MonthWidget extends StatelessWidget { | ||
const MonthWidget({ | ||
super.key, | ||
required this.title, | ||
required this.content, | ||
}); | ||
|
||
final String content; | ||
final String title; | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return Column( | ||
crossAxisAlignment: CrossAxisAlignment.start, | ||
children: [ | ||
Text(title), | ||
Text( | ||
content, | ||
style: context.titleLarge, | ||
), | ||
], | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.