Skip to content

Commit

Permalink
v1.0.23 - Fix Summary page currency bug (#23)
Browse files Browse the repository at this point in the history
* v1.0.23 - Version

* v1.0.23 - Fix transaction order

* v1.0.23 - Fix non EUR preferred currency

* v1.0.23 - Fix Summary page currency bug

* v1.0.23 - Correction in Hide Alert

* v1.0.23 - Correction in Menu

* v1.0.23 - Let preferred currency change

* v1.0.23 - Improve language

* v1.0.23 - Update workflow
  • Loading branch information
Donnie authored Jan 24, 2024
1 parent 8fb5d6a commit 58524c4
Show file tree
Hide file tree
Showing 13 changed files with 119 additions and 27 deletions.
13 changes: 11 additions & 2 deletions .github/workflows/android_release.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
name: Release Android

on:
push:
tags:
- "v*.*.*"
workflow_dispatch:
inputs:
releaseRef:
Expand All @@ -17,11 +20,17 @@ jobs:
steps:
- name: Set env
run: |
echo "RELEASE_VERSION=${{ github.event.inputs.releaseRef }}" >> $GITHUB_ENV
if [ "${{ github.event.inputs.releaseRef }}" != "" ]; then
RELEASE_REF=${{ github.event.inputs.releaseRef }}
else
RELEASE_REF=${GITHUB_REF}
fi
RELEASE_VERSION=$(echo $RELEASE_REF | sed -e 's/refs\/tags\///')
echo "RELEASE_VERSION=$RELEASE_VERSION" >> $GITHUB_ENV
- uses: actions/checkout@v4
with:
ref: ${{ github.event.inputs.releaseRef }}
ref: ${{ env.RELEASE_VERSION }}

- name: Install and set up Java
uses: actions/setup-java@v3
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
<a href="https://flutter.dev/" style="text-decoration:none" area-label="flutter">
<img src="https://img.shields.io/badge/Platform-Flutter%203.16.5-blue">
</a>
<a href="https://github.com/Donnie/Finease/releases/tag/v1.0.22" style="text-decoration:none" area-label="flutter">
<img src="https://img.shields.io/badge/Version-1.0.22-orange">
<a href="https://github.com/Donnie/Finease/releases/tag/v1.0.23" style="text-decoration:none" area-label="flutter">
<img src="https://img.shields.io/badge/Version-1.0.23-orange">
</a>
<a href="https://github.com/Donnie/Finease/actions/workflows/android_release.yml" style="text-decoration:none" area-label="flutter">
<img src="https://github.com/Donnie/Finease/actions/workflows/android_release.yml/badge.svg">
Expand Down
10 changes: 2 additions & 8 deletions lib/db/currency.dart
Original file line number Diff line number Diff line change
Expand Up @@ -56,16 +56,10 @@ class CurrencyBoxService {
String baseCurrency,
String targetCurrency,
) async {
double baseRate = 1.0;
double targetRate = 1.0;
// Assuming data is always available and up-to-date.
// Retrieve the rates directly from the box.
if (baseCurrency != prefCurrency) {
baseRate = _box.get(baseCurrency) ?? 0;
}
if (targetCurrency != prefCurrency) {
targetRate = _box.get(targetCurrency) ?? 0;
}
double baseRate = _box.get(baseCurrency) ?? 0;
double targetRate = _box.get(targetCurrency) ?? 0;

// rates must be available; if not, throw an exception.
if (targetRate == 0 || baseRate == 0) {
Expand Down
8 changes: 7 additions & 1 deletion lib/db/months.dart
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,9 @@ class MonthService {
ELSE e.amount / (
SELECT cr.rate FROM rates cr
WHERE cr.currency = ac.currency
) * (
SELECT cr.rate FROM rates cr
WHERE cr.currency = ?
)
END
) FILTER (
Expand All @@ -86,6 +89,9 @@ class MonthService {
ELSE e.amount / (
SELECT cr.rate FROM rates cr
WHERE cr.currency = ac.currency
) * (
SELECT cr.rate FROM rates cr
WHERE cr.currency = ?
)
END
) FILTER (
Expand Down Expand Up @@ -125,7 +131,7 @@ class MonthService {

final results = await dbClient.rawQuery(
query,
[prefCurrency, prefCurrency, prefCurrency],
[prefCurrency, prefCurrency, prefCurrency, prefCurrency, prefCurrency],
);
currencyBoxService.close();

Expand Down
15 changes: 9 additions & 6 deletions lib/pages/edit_account/account_body.dart
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,9 @@ class EditAccountBody extends StatelessWidget {
context: context,
builder: (BuildContext dialogContext) {
return SwitchAlert(
word: "hide",
text: 'Once you hide an account, '
'you can still find it at the '
'bottom of the accounts page and unhide it.',
onChange: onChangeHidden,
);
},
Expand All @@ -141,7 +143,9 @@ class EditAccountBody extends StatelessWidget {
context: context,
builder: (BuildContext dialogContext) {
return SwitchAlert(
word: "delete",
text: 'Once you delete an account, '
'you would never get it back,'
'unless you restore from a backup!',
onChange: (val) => val ? onDelete?.call() : {},
);
},
Expand All @@ -163,18 +167,17 @@ class SwitchAlert extends StatelessWidget {
const SwitchAlert({
super.key,
required this.onChange,
required this.word,
required this.text,
});

final ValueChanged<bool> onChange;
final String word;
final String text;

@override
Widget build(BuildContext context) {
return AlertDialog(
title: const Text('Confirm'),
content: Text(
'Once you $word an account, you would never get it back, unless you restore from a backup!'),
content: Text(text),
actions: [
TextButton(
onPressed: () {
Expand Down
2 changes: 1 addition & 1 deletion lib/pages/home/entries/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class EntriesPageState extends State<EntriesPage> {
startDate: widget.startDate,
endDate: widget.endDate,
);
entriesList.sort((a, b) => (b.id!.compareTo(a.id!)));
entriesList.sort((a, b) => (b.date!.compareTo(a.date!)));

List<Entry> mergedEntries = [];
for (int i = 0; i < entriesList.length; i++) {
Expand Down
4 changes: 2 additions & 2 deletions lib/pages/home/frame/mobile.dart
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import 'package:finease/db/accounts.dart';
import 'package:finease/db/settings.dart';
import 'package:finease/pages/export.dart';
import 'package:finease/parts/export.dart';
import 'package:finease/routes/routes_name.dart';
import 'package:flutter/material.dart';
import 'package:go_router/go_router.dart';
import 'package:finease/db/accounts.dart';
import 'package:finease/db/settings.dart';

class SummaryPage extends StatefulWidget {
const SummaryPage({super.key});
Expand Down
2 changes: 1 addition & 1 deletion lib/pages/home/months/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class MonthsPageState extends State<MonthsPage> {
drawer: AppDrawer(
onRefresh: loadMonths,
scaffoldKey: scaffoldStateKey,
selectedIndex: 1,
selectedIndex: 3,
destinations: destinations,
onDestinationSelected: updateBody,
),
Expand Down
2 changes: 1 addition & 1 deletion lib/pages/settings/about.dart
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class AboutWidget extends StatelessWidget {
),
actions: [
TextButton(
child: const Text('Yus'),
child: const Text('Yus!'),
onPressed: () {
Navigator.of(context).pop();
},
Expand Down
69 changes: 69 additions & 0 deletions lib/pages/settings/currency.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
import 'package:currency_picker/currency_picker.dart';
import 'package:finease/core/extensions/text_style_extension.dart';
import 'package:finease/db/settings.dart';
import 'package:flutter/material.dart';
import 'package:finease/db/currency.dart';
import 'package:go_router/go_router.dart';

class CurrencySelectorWidget extends StatefulWidget {
final Function onChange;
const CurrencySelectorWidget({
super.key,
required this.onChange,
});

@override
CurrencySelectorWidgetState createState() => CurrencySelectorWidgetState();
}

class CurrencySelectorWidgetState extends State<CurrencySelectorWidget> {
final SettingService _settingService = SettingService();
String? currency;
String? symbol;

@override
void initState() {
super.initState();
onLoad();
}

Future<void> onLoad() async {
final curr = await _settingService.getSetting(Setting.prefCurrency);

setState(() {
currency = curr;
symbol = SupportedCurrency[curr];
});
}

void _showCurrencyPicker(BuildContext context) {
showCurrencyPicker(
context: context,
currencyFilter: SupportedCurrency.keys.toList(),
showFlag: true,
onSelect: (Currency selectedCurrency) async {
setState(() {
currency = selectedCurrency.code;
symbol = selectedCurrency.symbol;
});
await _settingService.setSetting(Setting.prefCurrency, currency!);
// ignore: use_build_context_synchronously
context.pop();
widget.onChange();
},
);
}

@override
Widget build(BuildContext context) {
return ListTile(
title: const Text("Preferred Currency"),
subtitle: Text(currency ?? ''),
leading: Text(
symbol ?? '',
style: context.titleLarge,
),
onTap: () => _showCurrencyPicker(context),
);
}
}
7 changes: 7 additions & 0 deletions lib/pages/settings/main.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import 'package:finease/pages/export.dart';
import 'package:finease/pages/settings/about.dart';
import 'package:finease/pages/settings/currency.dart';
import 'package:finease/pages/settings/toggle_encryption.dart';
import 'package:finease/parts/export.dart';
import 'package:flutter/material.dart';
Expand Down Expand Up @@ -41,6 +42,12 @@ class SettingsPage extends StatelessWidget {
padding: EdgeInsets.zero,
shrinkWrap: true,
children: [
SettingsGroup(
title: "Personalise",
options: [
CurrencySelectorWidget(onChange: onFormSubmitted),
],
),
SettingsGroup(
title: "Database",
options: [
Expand Down
8 changes: 6 additions & 2 deletions lib/pages/settings/reset_app.dart
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,18 @@ class _ResetAppWidgetState extends State<ResetAppWidget> {
context: context,
builder: (BuildContext dialogContext) => AlertDialog(
title: const Text("Reset App"),
content: const Text("Are you sure you want to wipe all data in this App? This action cannot be undone!"),
content: const Text(
'Are you sure you want to wipe '
'all data, and reset this App?'
'\n\nMake sure you export the database before!'
),
actions: <Widget>[
TextButton(
child: const Text("Cancel"),
onPressed: () => Navigator.of(dialogContext).pop(false),
),
TextButton(
child: const Text("Reset App"),
child: const Text("Reset App!"),
onPressed: () async {
await DatabaseHelper().clearDatabase().then((value) {
Navigator.of(dialogContext).pop(false);
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: finease
description: "A full stack mobile app to keep track of financial transactions"
publish_to: 'none'
version: 1.0.22
version: 1.0.23

environment:
sdk: '>=3.2.3 <4.0.0'
Expand Down

0 comments on commit 58524c4

Please sign in to comment.