Skip to content

Commit

Permalink
Downgrade to v0.1.0 + Fix Recurring list
Browse files Browse the repository at this point in the history
- Downgrade the app version from 1.0.0 to 0.1.0 for the beta
- Reintroduce the recurring transactions list with some ui improvements
  • Loading branch information
lucaantonelli committed Nov 27, 2024
1 parent 7ee4d6f commit 3ba7f16
Show file tree
Hide file tree
Showing 4 changed files with 250 additions and 245 deletions.
91 changes: 47 additions & 44 deletions lib/pages/planning_page/planning_page.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import 'package:flutter/material.dart';
import 'manage_budget_page.dart';
import 'widget/budget_card.dart';
import 'widget/recurring_payments_list.dart';

class PlanningPage extends StatefulWidget {
const PlanningPage({super.key});
Expand All @@ -24,50 +25,52 @@ class _PlanningPageState extends State<PlanningPage> {
@override
Widget build(BuildContext context) {
return Container(
key: _key,
color: Colors.white,
child: ListView(
padding: const EdgeInsetsDirectional.all(10),
key: _key,
color: Colors.white,
child: ListView(
padding: const EdgeInsetsDirectional.all(10),
children: [
Row(
children: [
Row(
children: [
Text("Monthly budget",
style: Theme.of(context).textTheme.titleLarge),
const Spacer(),
GestureDetector(
onTap: () {
showModalBottomSheet(
context: context,
isScrollControlled: true,
shape: const RoundedRectangleBorder(
borderRadius: BorderRadius.only(
topLeft: Radius.circular(20.0),
topRight: Radius.circular(20.0),
),
),
elevation: 10,
builder: (BuildContext context) {
return FractionallySizedBox(
heightFactor: 0.9,
child: ManageBudgetPage(
onRefreshBudgets: _forceRefresh));
},
);
},
child: Row(children: [
Text("MANAGE",
style: Theme.of(context).textTheme.labelLarge),
const SizedBox(width: 5),
const Icon(Icons.edit, size: 13)
]))
],
),
const SizedBox(height: 10),
BudgetCard(_forceRefresh),
const SizedBox(height: 20),
Text("Recurring payments",
style: Theme.of(context).textTheme.titleLarge),
const SizedBox(height: 10),
]));
Text("Monthly budget", style: Theme.of(context).textTheme.titleLarge),
const Spacer(),
GestureDetector(
onTap: () {
showModalBottomSheet(
context: context,
isScrollControlled: true,
shape: const RoundedRectangleBorder(
borderRadius: BorderRadius.only(
topLeft: Radius.circular(20.0),
topRight: Radius.circular(20.0),
),
),
elevation: 10,
builder: (BuildContext context) {
return FractionallySizedBox(
heightFactor: 0.9,
child: ManageBudgetPage(onRefreshBudgets: _forceRefresh));
},
);
},
child: Row(
children: [
Text("MANAGE", style: Theme.of(context).textTheme.labelLarge),
const SizedBox(width: 5),
const Icon(Icons.edit, size: 13)
],
),
)
],
),
const SizedBox(height: 10),
BudgetCard(_forceRefresh),
const SizedBox(height: 20),
Text("Recurring payments", style: Theme.of(context).textTheme.titleLarge),
const SizedBox(height: 10),
RecurringPaymentSection(),
],
),
);
}
}
246 changes: 126 additions & 120 deletions lib/pages/planning_page/widget/recurring_payment_card.dart
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,8 @@ class RecurringPaymentCard extends ConsumerWidget with Functions {

String getNextText() {
final now = DateTime.now();
final daysPassed = now
.difference(transaction.lastInsertion ?? transaction.fromDate)
.inDays;
final daysInterval =
recurrenceMap[parseRecurrence(transaction.recurrency)]!.days;
final daysPassed = now.difference(transaction.lastInsertion ?? transaction.fromDate).inDays;
final daysInterval = recurrenceMap[parseRecurrence(transaction.recurrency)]!.days;
final daysUntilNextTransaction = daysInterval - (daysPassed % daysInterval);
return daysUntilNextTransaction.toString();
}
Expand All @@ -37,132 +34,141 @@ class RecurringPaymentCard extends ConsumerWidget with Functions {
final accounts = ref.watch(accountsProvider).value;
final currencyState = ref.watch(currencyStateNotifier);

var cat = categories
?.firstWhere((element) => element.id == transaction.idCategory);
var cat = categories?.firstWhere((element) => element.id == transaction.idCategory);

return cat != null
? Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(4),
color: categoryColorList[cat.color].withOpacity(0.1),
borderRadius: BorderRadius.circular(8),
color: white,
boxShadow: [defaultShadow],
),
padding: const EdgeInsets.symmetric(
horizontal: 8.0,
vertical: 16.0,
),
child: Column(children: [
Row(children: [
Container(
decoration: BoxDecoration(
shape: BoxShape.circle,
color: Theme.of(context).colorScheme.secondary,
),
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Icon(
iconList[cat.symbol],
size: 25.0,
color: const Color(0xFFFFFFFF),
),
),
),
const SizedBox(width: 10),
Expanded(
flex: 4,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.start,
children: [
Text(transaction.recurrency,
style: const TextStyle(
fontWeight: FontWeight.w200, fontSize: 10)),
const SizedBox(height: 10),
Text(transaction.note,
style: const TextStyle(
fontWeight: FontWeight.w900, fontSize: 16)),
const SizedBox(height: 10),
Text(cat.name),
],
)),
Expanded(
flex: 2,
child: Column(
crossAxisAlignment: CrossAxisAlignment.end,
mainAxisAlignment: MainAxisAlignment.end,
children: [
Text("In ${getNextText()} days"),
const SizedBox(height: 10),
Text(
"-${transaction.amount}${currencyState.selectedCurrency.symbol}",
style: const TextStyle(color: Colors.red)),
const SizedBox(height: 10),
Text(accounts!
.firstWhere((element) =>
element.id == transaction.idBankAccount)
.name)
],
))
]),
Row(
child: Container(
padding: const EdgeInsets.symmetric(horizontal: 8.0, vertical: 16.0),
decoration: BoxDecoration(
color: categoryColorList[cat.color].withOpacity(0.2),
borderRadius: BorderRadius.circular(8),
),
child: Column(
children: [
Expanded(
flex: 4,
child: Container(
Row(
children: [
Container(
decoration: BoxDecoration(
shape: BoxShape.circle,
color: categoryColorList[cat.color],
),
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Icon(
iconList[cat.symbol],
size: 25.0,
color: white,
),
),
),
const SizedBox(width: 10),
Expanded(
flex: 4,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.start,
children: [
Text(transaction.recurrency,
style:
const TextStyle(fontWeight: FontWeight.w200, fontSize: 10)),
const SizedBox(height: 10),
Text(transaction.note,
style:
const TextStyle(fontWeight: FontWeight.w900, fontSize: 16)),
const SizedBox(height: 10),
Text(cat.name),
],
)),
Expanded(
flex: 2,
child: Column(
crossAxisAlignment: CrossAxisAlignment.end,
mainAxisAlignment: MainAxisAlignment.end,
children: [
Text("In ${getNextText()} days"),
const SizedBox(height: 10),
Text("-${transaction.amount}${currencyState.selectedCurrency.symbol}",
style: const TextStyle(color: Colors.red)),
const SizedBox(height: 10),
Text(accounts!
.firstWhere((element) => element.id == transaction.idBankAccount)
.name)
],
),
)
],
),
Row(
children: [
Expanded(
flex: 4,
child: Container(
alignment: Alignment.centerLeft,
child: ElevatedButton(
onPressed: () => {
showModalBottomSheet(
context: context,
shape: const RoundedRectangleBorder(
borderRadius: BorderRadius.only(
topLeft: Radius.circular(20.0),
topRight: Radius.circular(20.0),
),
),
elevation: 10,
builder: (BuildContext context) {
return ListView(
scrollDirection: Axis.vertical,
padding: const EdgeInsets.symmetric(
vertical: 20, horizontal: 10),
children: [
OlderRecurringPayments(
transaction: transaction)
]);
},
)
},
style: ElevatedButton.styleFrom(
elevation: 0,
padding: const EdgeInsets.all(8),
backgroundColor: Colors.white,
onPressed: () => {
showModalBottomSheet(
context: context,
shape: const RoundedRectangleBorder(
borderRadius: BorderRadius.only(
topLeft: Radius.circular(20.0),
topRight: Radius.circular(20.0),
),
),
elevation: 10,
builder: (BuildContext context) {
return ListView(
scrollDirection: Axis.vertical,
padding:
const EdgeInsets.symmetric(vertical: 20, horizontal: 10),
children: [
OlderRecurringPayments(transaction: transaction),
],
);
},
)
},
style: ElevatedButton.styleFrom(
elevation: 0,
padding: const EdgeInsets.all(8),
backgroundColor: Colors.white,
),
child: const Wrap(
crossAxisAlignment: WrapCrossAlignment.center,
children: [
Icon(Icons.checklist_rtl_outlined, color: blue4),
SizedBox(width: 10),
Text(
"See older payments",
style: TextStyle(color: blue4, fontSize: 14),
),
],
),
),
),
),
transaction.toDate != null
? Expanded(
flex: 2,
child: Container(
alignment: Alignment.centerRight,
child: Text(
"Until ${dateToString(transaction.toDate!)}",
style: const TextStyle(fontSize: 8),
),
),
child: const Wrap(
crossAxisAlignment: WrapCrossAlignment.center,
children: [
Icon(Icons.checklist_rtl_outlined,
color: blue4),
SizedBox(width: 10),
Text(
"See older payments",
style:
TextStyle(color: blue4, fontSize: 14),
),
])))),
transaction.toDate != null
? Expanded(
flex: 2,
child: Container(
alignment: Alignment.centerRight,
child: Text(
"Until ${dateToString(transaction.toDate!)}",
style: const TextStyle(fontSize: 8),
)))
: Container(),
)
: Container(),
],
),
],
)
]),
),
),
)
: const SizedBox.shrink();
}
Expand Down
Loading

0 comments on commit 3ba7f16

Please sign in to comment.