Compare commits
No commits in common. "805fc2bf1771b207462c52f49e0854affdd0ab8c" and "96e672f1d5cbd2cbda8207241dea7b7e4ea74588" have entirely different histories.
805fc2bf17
...
96e672f1d5
6 changed files with 164 additions and 286 deletions
|
@ -1,5 +1,5 @@
|
||||||
# prasule
|
# prasule
|
||||||
[![Codemagic build status](https://api.codemagic.io/apps/64faee78aae8c48abc70dbc6/64faee78aae8c48abc70dbc5/status_badge.svg)](https://codemagic.io/apps/64faee78aae8c48abc70dbc6/64faee78aae8c48abc70dbc5/latest_build) [![Bug issue count](https://img.shields.io/badge/dynamic/json?url=https%3A%2F%2Fgit.mnau.xyz%2Fapi%2Fv1%2Frepos%2Fhernik%2Fprasule%2Fissues%3Flabels%3DKind%2FBug&query=%24.length&logo=forgejo&label=bug%20issues&color=red)](https://git.mnau.xyz/hernik/prasule/issues?q=&type=all&sort=&state=open&labels=144&milestone=0&project=0&assignee=0&poster=0) [![wakatime](https://wakatime.com/badge/user/17178fab-a33c-430f-a764-7b3f26c7b966/project/bf1f40b0-c8c0-4f72-8ad6-c861ecdcc90c.svg)](https://wakatime.com/badge/user/17178fab-a33c-430f-a764-7b3f26c7b966/project/bf1f40b0-c8c0-4f72-8ad6-c861ecdcc90c) [![Commit Style: Conventional Commits](https://img.shields.io/badge/commit%20style-conventional%20commits-pink)](https://www.conventionalcommits.org/en/v1.0.0/) [![Please don't upload to GitHub](https://nogithub.codeberg.page/badge.svg)](https://nogithub.codeberg.page)
|
[![Codemagic build status](https://api.codemagic.io/apps/64faee78aae8c48abc70dbc6/64faee78aae8c48abc70dbc5/status_badge.svg)](https://codemagic.io/apps/64faee78aae8c48abc70dbc6/64faee78aae8c48abc70dbc5/latest_build) [![Bug issue count](https://img.shields.io/badge/dynamic/json?url=https%3A%2F%2Fgit.mnau.xyz%2Fapi%2Fv1%2Frepos%2Fhernik%2Fprasule%2Fissues%3Flabels%3DKind%2FBug&query=%24.length&logo=forgejo&label=bug%20issues&color=red)](https://git.mnau.xyz/hernik/prasule/issues?q=&type=all&sort=&state=open&labels=144&milestone=0&project=0&assignee=0&poster=0) [![wakatime](https://wakatime.com/badge/user/17178fab-a33c-430f-a764-7b3f26c7b966/project/bf1f40b0-c8c0-4f72-8ad6-c861ecdcc90c.svg)](https://wakatime.com/badge/user/17178fab-a33c-430f-a764-7b3f26c7b966/project/bf1f40b0-c8c0-4f72-8ad6-c861ecdcc90c)
|
||||||
|
|
||||||
Expense manager
|
Expense manager
|
||||||
|
|
||||||
|
|
|
@ -160,28 +160,6 @@ class Wallet {
|
||||||
await WalletManager.saveWallet(this);
|
await WalletManager.saveWallet(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns the current balance
|
|
||||||
///
|
|
||||||
/// Basically just takes *starterBalance* and adds all the entries to it
|
|
||||||
double calculateCurrentBalance() {
|
|
||||||
var toAdd = 0.0;
|
|
||||||
for (final e in entries) {
|
|
||||||
toAdd += (e.type == EntryType.income) ? e.data.amount : -e.data.amount;
|
|
||||||
}
|
|
||||||
return starterBalance + toAdd;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Returns the amount that was made/lost during a month
|
|
||||||
double calculateMonthStatus(int month, int year) {
|
|
||||||
var f = 0.0;
|
|
||||||
for (final e in entries.where(
|
|
||||||
(element) => element.date.year == year && element.date.month == month,
|
|
||||||
)) {
|
|
||||||
f += (e.type == EntryType.income) ? e.data.amount : -e.data.amount;
|
|
||||||
}
|
|
||||||
return f;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Empty wallet used for placeholders
|
/// Empty wallet used for placeholders
|
||||||
static final Wallet empty = Wallet(
|
static final Wallet empty = Wallet(
|
||||||
name: "Empty",
|
name: "Empty",
|
||||||
|
|
|
@ -87,8 +87,5 @@
|
||||||
"dayCounter":"{count, plural, =1{den} few{dny} many{dnů} other{dnů} }",
|
"dayCounter":"{count, plural, =1{den} few{dny} many{dnů} other{dnů} }",
|
||||||
"yearCounter":"{count, plural, =1{rok} few{rok} many{let} other{let} }",
|
"yearCounter":"{count, plural, =1{rok} few{rok} many{let} other{let} }",
|
||||||
"recurEvery":"{count, plural, =1{Opakovat každý} few{Opakovat každé} many{Opakovat každých} other{Opakovat každých}}",
|
"recurEvery":"{count, plural, =1{Opakovat každý} few{Opakovat každé} many{Opakovat každých} other{Opakovat každých}}",
|
||||||
"startingWithDate": "počínaje datem",
|
"startingWithDate": "počínaje datem"
|
||||||
"evenMoney":"Váš stav je stejný jako minulý měsíc.",
|
|
||||||
"balanceStatusA": "Váš stav je ",
|
|
||||||
"balanceStatusB": " oproti minulému měsíci."
|
|
||||||
}
|
}
|
|
@ -203,8 +203,5 @@
|
||||||
"startingWithDate": "starting",
|
"startingWithDate": "starting",
|
||||||
"@startingWithDate":{
|
"@startingWithDate":{
|
||||||
"description": "Shown after 'Recur every X Y', e.g. 'Recur every 2 month starting 20th June 2023'"
|
"description": "Shown after 'Recur every X Y', e.g. 'Recur every 2 month starting 20th June 2023'"
|
||||||
},
|
}
|
||||||
"evenMoney":"You're on the same balance as last month.",
|
|
||||||
"balanceStatusA": "Your balance is ",
|
|
||||||
"balanceStatusB": " compared to last month."
|
|
||||||
}
|
}
|
|
@ -150,10 +150,10 @@ class ExpensesLineChart extends StatelessWidget {
|
||||||
isStrokeCapRound: true,
|
isStrokeCapRound: true,
|
||||||
dotData: const FlDotData(show: false),
|
dotData: const FlDotData(show: false),
|
||||||
belowBarData: BarAreaData(),
|
belowBarData: BarAreaData(),
|
||||||
color: ((MediaQuery.of(context).platformBrightness ==
|
color:
|
||||||
Brightness.dark)
|
(MediaQuery.of(context).platformBrightness == Brightness.dark)
|
||||||
? Colors.green.shade300
|
? Colors.green.shade300
|
||||||
: Colors.green)
|
: Colors.green
|
||||||
.harmonizeWith(Theme.of(context).colorScheme.primary),
|
.harmonizeWith(Theme.of(context).colorScheme.primary),
|
||||||
spots: List.generate(
|
spots: List.generate(
|
||||||
yearly ? 12 : date.lastDay,
|
yearly ? 12 : date.lastDay,
|
||||||
|
@ -167,10 +167,10 @@ class ExpensesLineChart extends StatelessWidget {
|
||||||
isStrokeCapRound: true,
|
isStrokeCapRound: true,
|
||||||
dotData: const FlDotData(show: false),
|
dotData: const FlDotData(show: false),
|
||||||
belowBarData: BarAreaData(),
|
belowBarData: BarAreaData(),
|
||||||
color: ((MediaQuery.of(context).platformBrightness ==
|
color:
|
||||||
Brightness.dark)
|
(MediaQuery.of(context).platformBrightness == Brightness.dark)
|
||||||
? Colors.red.shade300
|
? Colors.red.shade300
|
||||||
: Colors.red)
|
: Colors.red
|
||||||
.harmonizeWith(Theme.of(context).colorScheme.primary),
|
.harmonizeWith(Theme.of(context).colorScheme.primary),
|
||||||
spots: List.generate(
|
spots: List.generate(
|
||||||
yearly
|
yearly
|
||||||
|
|
|
@ -222,86 +222,7 @@ class _HomeViewState extends State<HomeView> {
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
: Column(
|
: GroupedListView(
|
||||||
children: [
|
|
||||||
Text(
|
|
||||||
NumberFormat.compactCurrency(
|
|
||||||
locale: locale,
|
|
||||||
symbol: selectedWallet!.currency.symbol,
|
|
||||||
).format(selectedWallet!.calculateCurrentBalance()),
|
|
||||||
style: const TextStyle(
|
|
||||||
fontWeight: FontWeight.bold,
|
|
||||||
fontSize: 22,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
const SizedBox(
|
|
||||||
height: 5,
|
|
||||||
),
|
|
||||||
if (selectedWallet!.calculateMonthStatus(
|
|
||||||
DateTime.now().month,
|
|
||||||
DateTime.now().year,
|
|
||||||
) ==
|
|
||||||
0)
|
|
||||||
Text(AppLocalizations.of(context).evenMoney)
|
|
||||||
else
|
|
||||||
RichText(
|
|
||||||
text: TextSpan(
|
|
||||||
children: [
|
|
||||||
TextSpan(
|
|
||||||
text: AppLocalizations.of(context)
|
|
||||||
.balanceStatusA,
|
|
||||||
),
|
|
||||||
TextSpan(
|
|
||||||
style: TextStyle(
|
|
||||||
color: (selectedWallet!
|
|
||||||
.calculateMonthStatus(
|
|
||||||
DateTime.now().month,
|
|
||||||
DateTime.now().year,
|
|
||||||
) >
|
|
||||||
0
|
|
||||||
? ((MediaQuery.of(context)
|
|
||||||
.platformBrightness ==
|
|
||||||
Brightness.dark)
|
|
||||||
? Colors.green.shade300
|
|
||||||
: Colors.green)
|
|
||||||
.harmonizeWith(
|
|
||||||
Theme.of(context)
|
|
||||||
.colorScheme
|
|
||||||
.primary,
|
|
||||||
)
|
|
||||||
: ((MediaQuery.of(context)
|
|
||||||
.platformBrightness ==
|
|
||||||
Brightness.dark)
|
|
||||||
? Colors.red.shade300
|
|
||||||
: Colors.red)
|
|
||||||
.harmonizeWith(
|
|
||||||
Theme.of(context)
|
|
||||||
.colorScheme
|
|
||||||
.primary,
|
|
||||||
)),
|
|
||||||
),
|
|
||||||
text: NumberFormat.compactCurrency(
|
|
||||||
locale: locale,
|
|
||||||
symbol: selectedWallet!.currency.symbol,
|
|
||||||
).format(
|
|
||||||
selectedWallet!.calculateMonthStatus(
|
|
||||||
DateTime.now().month,
|
|
||||||
DateTime.now().year,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
TextSpan(
|
|
||||||
text: AppLocalizations.of(context)
|
|
||||||
.balanceStatusB,
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
const SizedBox(
|
|
||||||
height: 10,
|
|
||||||
),
|
|
||||||
Expanded(
|
|
||||||
child: GroupedListView(
|
|
||||||
groupHeaderBuilder: (element) => Text(
|
groupHeaderBuilder: (element) => Text(
|
||||||
DateFormat.yMMMM(locale).format(element.date),
|
DateFormat.yMMMM(locale).format(element.date),
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
|
@ -310,8 +231,7 @@ class _HomeViewState extends State<HomeView> {
|
||||||
),
|
),
|
||||||
elements: selectedWallet!.entries,
|
elements: selectedWallet!.entries,
|
||||||
itemComparator: (a, b) => b.date.compareTo(a.date),
|
itemComparator: (a, b) => b.date.compareTo(a.date),
|
||||||
groupBy: (e) =>
|
groupBy: (e) => DateFormat.yMMMM(locale).format(e.date),
|
||||||
DateFormat.yMMMM(locale).format(e.date),
|
|
||||||
groupComparator: (a, b) {
|
groupComparator: (a, b) {
|
||||||
// TODO: better sorting algorithm lol
|
// TODO: better sorting algorithm lol
|
||||||
final yearA = RegExp(r'\d+').firstMatch(a);
|
final yearA = RegExp(r'\d+').firstMatch(a);
|
||||||
|
@ -353,22 +273,17 @@ class _HomeViewState extends State<HomeView> {
|
||||||
.then(
|
.then(
|
||||||
(editedEntry) {
|
(editedEntry) {
|
||||||
if (editedEntry == null) return;
|
if (editedEntry == null) return;
|
||||||
selectedWallet!.entries
|
selectedWallet!.entries.remove(element);
|
||||||
.remove(element);
|
selectedWallet!.entries.add(editedEntry);
|
||||||
selectedWallet!.entries
|
WalletManager.saveWallet(selectedWallet!);
|
||||||
.add(editedEntry);
|
|
||||||
WalletManager.saveWallet(
|
|
||||||
selectedWallet!,
|
|
||||||
);
|
|
||||||
setState(() {});
|
setState(() {});
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
backgroundColor:
|
backgroundColor:
|
||||||
Theme.of(context).colorScheme.secondary,
|
Theme.of(context).colorScheme.secondary,
|
||||||
foregroundColor: Theme.of(context)
|
foregroundColor:
|
||||||
.colorScheme
|
Theme.of(context).colorScheme.onSecondary,
|
||||||
.onSecondary,
|
|
||||||
icon: Icons.edit,
|
icon: Icons.edit,
|
||||||
),
|
),
|
||||||
SlidableAction(
|
SlidableAction(
|
||||||
|
@ -381,19 +296,16 @@ class _HomeViewState extends State<HomeView> {
|
||||||
showDialog(
|
showDialog(
|
||||||
context: context,
|
context: context,
|
||||||
builder: (cx) => PlatformDialog(
|
builder: (cx) => PlatformDialog(
|
||||||
title: AppLocalizations.of(context)
|
title:
|
||||||
.sureDialog,
|
AppLocalizations.of(context).sureDialog,
|
||||||
content: Text(
|
content: Text(
|
||||||
AppLocalizations.of(context)
|
AppLocalizations.of(context).deleteSure,
|
||||||
.deleteSure,
|
|
||||||
),
|
),
|
||||||
actions: [
|
actions: [
|
||||||
PlatformButton(
|
PlatformButton(
|
||||||
text: AppLocalizations.of(context)
|
text: AppLocalizations.of(context).yes,
|
||||||
.yes,
|
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
selectedWallet?.entries
|
selectedWallet?.entries.removeWhere(
|
||||||
.removeWhere(
|
|
||||||
(e) => e.id == element.id,
|
(e) => e.id == element.id,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -405,8 +317,7 @@ class _HomeViewState extends State<HomeView> {
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
PlatformButton(
|
PlatformButton(
|
||||||
text: AppLocalizations.of(context)
|
text: AppLocalizations.of(context).no,
|
||||||
.no,
|
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
Navigator.of(cx).pop();
|
Navigator.of(cx).pop();
|
||||||
},
|
},
|
||||||
|
@ -428,8 +339,8 @@ class _HomeViewState extends State<HomeView> {
|
||||||
padding: const EdgeInsets.all(8),
|
padding: const EdgeInsets.all(8),
|
||||||
child: Icon(
|
child: Icon(
|
||||||
element.category.icon,
|
element.category.icon,
|
||||||
color: element.category.color
|
color:
|
||||||
.calculateTextColor(),
|
element.category.color.calculateTextColor(),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
@ -439,12 +350,10 @@ class _HomeViewState extends State<HomeView> {
|
||||||
children: [
|
children: [
|
||||||
TextSpan(
|
TextSpan(
|
||||||
text: NumberFormat.currency(
|
text: NumberFormat.currency(
|
||||||
symbol:
|
symbol: selectedWallet!.currency.symbol,
|
||||||
selectedWallet!.currency.symbol,
|
|
||||||
).format(element.data.amount),
|
).format(element.data.amount),
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
color: (element.type ==
|
color: (element.type == EntryType.income)
|
||||||
EntryType.income)
|
|
||||||
? (MediaQuery.of(context)
|
? (MediaQuery.of(context)
|
||||||
.platformBrightness ==
|
.platformBrightness ==
|
||||||
Brightness.dark)
|
Brightness.dark)
|
||||||
|
@ -482,9 +391,6 @@ class _HomeViewState extends State<HomeView> {
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue