Skip to content

Commit

Permalink
Add the possibility to specify the number of decimal digits
Browse files Browse the repository at this point in the history
  • Loading branch information
emavgl committed Nov 5, 2023
1 parent 8138dbc commit 63b780d
Show file tree
Hide file tree
Showing 8 changed files with 97 additions and 58 deletions.
2 changes: 1 addition & 1 deletion .flutter-plugins-dependencies
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"file_picker","path":"/home/emavgl/.pub-cache/hosted/pub.dev/file_picker-6.0.0/","native_build":true,"dependencies":[]},{"name":"package_info_plus","path":"/home/emavgl/.pub-cache/hosted/pub.dev/package_info_plus-4.2.0/","native_build":true,"dependencies":[]},{"name":"path_provider_foundation","path":"/home/emavgl/.pub-cache/hosted/pub.dev/path_provider_foundation-2.3.1/","shared_darwin_source":true,"native_build":true,"dependencies":[]},{"name":"share_plus","path":"/home/emavgl/.pub-cache/hosted/pub.dev/share_plus-7.2.1/","native_build":true,"dependencies":[]},{"name":"shared_preferences_foundation","path":"/home/emavgl/.pub-cache/hosted/pub.dev/shared_preferences_foundation-2.3.4/","shared_darwin_source":true,"native_build":true,"dependencies":[]},{"name":"sqflite","path":"/home/emavgl/.pub-cache/hosted/pub.dev/sqflite-2.3.0/","native_build":true,"dependencies":[]},{"name":"url_launcher_ios","path":"/home/emavgl/.pub-cache/hosted/pub.dev/url_launcher_ios-6.1.5/","native_build":true,"dependencies":[]}],"android":[{"name":"file_picker","path":"/home/emavgl/.pub-cache/hosted/pub.dev/file_picker-6.0.0/","native_build":true,"dependencies":["flutter_plugin_android_lifecycle"]},{"name":"flutter_plugin_android_lifecycle","path":"/home/emavgl/.pub-cache/hosted/pub.dev/flutter_plugin_android_lifecycle-2.0.16/","native_build":true,"dependencies":[]},{"name":"package_info_plus","path":"/home/emavgl/.pub-cache/hosted/pub.dev/package_info_plus-4.2.0/","native_build":true,"dependencies":[]},{"name":"path_provider_android","path":"/home/emavgl/.pub-cache/hosted/pub.dev/path_provider_android-2.2.0/","native_build":true,"dependencies":[]},{"name":"share_plus","path":"/home/emavgl/.pub-cache/hosted/pub.dev/share_plus-7.2.1/","native_build":true,"dependencies":[]},{"name":"shared_preferences_android","path":"/home/emavgl/.pub-cache/hosted/pub.dev/shared_preferences_android-2.2.1/","native_build":true,"dependencies":[]},{"name":"sqflite","path":"/home/emavgl/.pub-cache/hosted/pub.dev/sqflite-2.3.0/","native_build":true,"dependencies":[]},{"name":"system_theme","path":"/home/emavgl/.pub-cache/hosted/pub.dev/system_theme-2.3.1/","native_build":true,"dependencies":[]},{"name":"url_launcher_android","path":"/home/emavgl/.pub-cache/hosted/pub.dev/url_launcher_android-6.1.0/","native_build":true,"dependencies":[]}],"macos":[{"name":"package_info_plus","path":"/home/emavgl/.pub-cache/hosted/pub.dev/package_info_plus-4.2.0/","native_build":true,"dependencies":[]},{"name":"path_provider_foundation","path":"/home/emavgl/.pub-cache/hosted/pub.dev/path_provider_foundation-2.3.1/","shared_darwin_source":true,"native_build":true,"dependencies":[]},{"name":"share_plus","path":"/home/emavgl/.pub-cache/hosted/pub.dev/share_plus-7.2.1/","native_build":true,"dependencies":[]},{"name":"shared_preferences_foundation","path":"/home/emavgl/.pub-cache/hosted/pub.dev/shared_preferences_foundation-2.3.4/","shared_darwin_source":true,"native_build":true,"dependencies":[]},{"name":"sqflite","path":"/home/emavgl/.pub-cache/hosted/pub.dev/sqflite-2.3.0/","native_build":true,"dependencies":[]},{"name":"system_theme","path":"/home/emavgl/.pub-cache/hosted/pub.dev/system_theme-2.3.1/","native_build":true,"dependencies":[]},{"name":"url_launcher_macos","path":"/home/emavgl/.pub-cache/hosted/pub.dev/url_launcher_macos-3.0.7/","native_build":true,"dependencies":[]}],"linux":[{"name":"package_info_plus","path":"/home/emavgl/.pub-cache/hosted/pub.dev/package_info_plus-4.2.0/","native_build":false,"dependencies":[]},{"name":"path_provider_linux","path":"/home/emavgl/.pub-cache/hosted/pub.dev/path_provider_linux-2.2.1/","native_build":false,"dependencies":[]},{"name":"share_plus","path":"/home/emavgl/.pub-cache/hosted/pub.dev/share_plus-7.2.1/","native_build":false,"dependencies":["url_launcher_linux"]},{"name":"shared_preferences_linux","path":"/home/emavgl/.pub-cache/hosted/pub.dev/shared_preferences_linux-2.3.2/","native_build":false,"dependencies":["path_provider_linux"]},{"name":"system_theme","path":"/home/emavgl/.pub-cache/hosted/pub.dev/system_theme-2.3.1/","native_build":true,"dependencies":[]},{"name":"url_launcher_linux","path":"/home/emavgl/.pub-cache/hosted/pub.dev/url_launcher_linux-3.0.6/","native_build":true,"dependencies":[]}],"windows":[{"name":"package_info_plus","path":"/home/emavgl/.pub-cache/hosted/pub.dev/package_info_plus-4.2.0/","native_build":false,"dependencies":[]},{"name":"path_provider_windows","path":"/home/emavgl/.pub-cache/hosted/pub.dev/path_provider_windows-2.2.1/","native_build":false,"dependencies":[]},{"name":"share_plus","path":"/home/emavgl/.pub-cache/hosted/pub.dev/share_plus-7.2.1/","native_build":true,"dependencies":["url_launcher_windows"]},{"name":"shared_preferences_windows","path":"/home/emavgl/.pub-cache/hosted/pub.dev/shared_preferences_windows-2.3.2/","native_build":false,"dependencies":["path_provider_windows"]},{"name":"system_theme","path":"/home/emavgl/.pub-cache/hosted/pub.dev/system_theme-2.3.1/","native_build":true,"dependencies":[]},{"name":"url_launcher_windows","path":"/home/emavgl/.pub-cache/hosted/pub.dev/url_launcher_windows-3.0.8/","native_build":true,"dependencies":[]}],"web":[{"name":"file_picker","path":"/home/emavgl/.pub-cache/hosted/pub.dev/file_picker-6.0.0/","dependencies":[]},{"name":"package_info_plus","path":"/home/emavgl/.pub-cache/hosted/pub.dev/package_info_plus-4.2.0/","dependencies":[]},{"name":"share_plus","path":"/home/emavgl/.pub-cache/hosted/pub.dev/share_plus-7.2.1/","dependencies":["url_launcher_web"]},{"name":"shared_preferences_web","path":"/home/emavgl/.pub-cache/hosted/pub.dev/shared_preferences_web-2.2.1/","dependencies":[]},{"name":"system_theme_web","path":"/home/emavgl/.pub-cache/hosted/pub.dev/system_theme_web-0.0.2/","dependencies":[]},{"name":"url_launcher_web","path":"/home/emavgl/.pub-cache/hosted/pub.dev/url_launcher_web-2.0.19/","dependencies":[]}]},"dependencyGraph":[{"name":"file_picker","dependencies":["flutter_plugin_android_lifecycle"]},{"name":"flutter_plugin_android_lifecycle","dependencies":[]},{"name":"package_info_plus","dependencies":[]},{"name":"path_provider","dependencies":["path_provider_android","path_provider_foundation","path_provider_linux","path_provider_windows"]},{"name":"path_provider_android","dependencies":[]},{"name":"path_provider_foundation","dependencies":[]},{"name":"path_provider_linux","dependencies":[]},{"name":"path_provider_windows","dependencies":[]},{"name":"share_plus","dependencies":["url_launcher_web","url_launcher_windows","url_launcher_linux"]},{"name":"shared_preferences","dependencies":["shared_preferences_android","shared_preferences_foundation","shared_preferences_linux","shared_preferences_web","shared_preferences_windows"]},{"name":"shared_preferences_android","dependencies":[]},{"name":"shared_preferences_foundation","dependencies":[]},{"name":"shared_preferences_linux","dependencies":["path_provider_linux"]},{"name":"shared_preferences_web","dependencies":[]},{"name":"shared_preferences_windows","dependencies":["path_provider_windows"]},{"name":"sqflite","dependencies":[]},{"name":"system_theme","dependencies":["system_theme_web"]},{"name":"system_theme_web","dependencies":[]},{"name":"url_launcher","dependencies":["url_launcher_android","url_launcher_ios","url_launcher_linux","url_launcher_macos","url_launcher_web","url_launcher_windows"]},{"name":"url_launcher_android","dependencies":[]},{"name":"url_launcher_ios","dependencies":[]},{"name":"url_launcher_linux","dependencies":[]},{"name":"url_launcher_macos","dependencies":[]},{"name":"url_launcher_web","dependencies":[]},{"name":"url_launcher_windows","dependencies":[]}],"date_created":"2023-10-29 11:55:10.461625","version":"3.10.6"}
{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"file_picker","path":"/home/emavgl/.pub-cache/hosted/pub.dev/file_picker-6.1.1/","native_build":true,"dependencies":[]},{"name":"package_info_plus","path":"/home/emavgl/.pub-cache/hosted/pub.dev/package_info_plus-4.2.0/","native_build":true,"dependencies":[]},{"name":"path_provider_foundation","path":"/home/emavgl/.pub-cache/hosted/pub.dev/path_provider_foundation-2.3.1/","shared_darwin_source":true,"native_build":true,"dependencies":[]},{"name":"share_plus","path":"/home/emavgl/.pub-cache/hosted/pub.dev/share_plus-7.2.1/","native_build":true,"dependencies":[]},{"name":"shared_preferences_foundation","path":"/home/emavgl/.pub-cache/hosted/pub.dev/shared_preferences_foundation-2.3.4/","shared_darwin_source":true,"native_build":true,"dependencies":[]},{"name":"sqflite","path":"/home/emavgl/.pub-cache/hosted/pub.dev/sqflite-2.3.0/","native_build":true,"dependencies":[]},{"name":"url_launcher_ios","path":"/home/emavgl/.pub-cache/hosted/pub.dev/url_launcher_ios-6.2.0/","native_build":true,"dependencies":[]}],"android":[{"name":"file_picker","path":"/home/emavgl/.pub-cache/hosted/pub.dev/file_picker-6.1.1/","native_build":true,"dependencies":["flutter_plugin_android_lifecycle"]},{"name":"flutter_plugin_android_lifecycle","path":"/home/emavgl/.pub-cache/hosted/pub.dev/flutter_plugin_android_lifecycle-2.0.17/","native_build":true,"dependencies":[]},{"name":"package_info_plus","path":"/home/emavgl/.pub-cache/hosted/pub.dev/package_info_plus-4.2.0/","native_build":true,"dependencies":[]},{"name":"path_provider_android","path":"/home/emavgl/.pub-cache/hosted/pub.dev/path_provider_android-2.2.1/","native_build":true,"dependencies":[]},{"name":"share_plus","path":"/home/emavgl/.pub-cache/hosted/pub.dev/share_plus-7.2.1/","native_build":true,"dependencies":[]},{"name":"shared_preferences_android","path":"/home/emavgl/.pub-cache/hosted/pub.dev/shared_preferences_android-2.2.1/","native_build":true,"dependencies":[]},{"name":"sqflite","path":"/home/emavgl/.pub-cache/hosted/pub.dev/sqflite-2.3.0/","native_build":true,"dependencies":[]},{"name":"system_theme","path":"/home/emavgl/.pub-cache/hosted/pub.dev/system_theme-2.3.1/","native_build":true,"dependencies":[]},{"name":"url_launcher_android","path":"/home/emavgl/.pub-cache/hosted/pub.dev/url_launcher_android-6.2.0/","native_build":true,"dependencies":[]}],"macos":[{"name":"package_info_plus","path":"/home/emavgl/.pub-cache/hosted/pub.dev/package_info_plus-4.2.0/","native_build":true,"dependencies":[]},{"name":"path_provider_foundation","path":"/home/emavgl/.pub-cache/hosted/pub.dev/path_provider_foundation-2.3.1/","shared_darwin_source":true,"native_build":true,"dependencies":[]},{"name":"share_plus","path":"/home/emavgl/.pub-cache/hosted/pub.dev/share_plus-7.2.1/","native_build":true,"dependencies":[]},{"name":"shared_preferences_foundation","path":"/home/emavgl/.pub-cache/hosted/pub.dev/shared_preferences_foundation-2.3.4/","shared_darwin_source":true,"native_build":true,"dependencies":[]},{"name":"sqflite","path":"/home/emavgl/.pub-cache/hosted/pub.dev/sqflite-2.3.0/","native_build":true,"dependencies":[]},{"name":"system_theme","path":"/home/emavgl/.pub-cache/hosted/pub.dev/system_theme-2.3.1/","native_build":true,"dependencies":[]},{"name":"url_launcher_macos","path":"/home/emavgl/.pub-cache/hosted/pub.dev/url_launcher_macos-3.1.0/","native_build":true,"dependencies":[]}],"linux":[{"name":"package_info_plus","path":"/home/emavgl/.pub-cache/hosted/pub.dev/package_info_plus-4.2.0/","native_build":false,"dependencies":[]},{"name":"path_provider_linux","path":"/home/emavgl/.pub-cache/hosted/pub.dev/path_provider_linux-2.2.1/","native_build":false,"dependencies":[]},{"name":"share_plus","path":"/home/emavgl/.pub-cache/hosted/pub.dev/share_plus-7.2.1/","native_build":false,"dependencies":["url_launcher_linux"]},{"name":"shared_preferences_linux","path":"/home/emavgl/.pub-cache/hosted/pub.dev/shared_preferences_linux-2.3.2/","native_build":false,"dependencies":["path_provider_linux"]},{"name":"system_theme","path":"/home/emavgl/.pub-cache/hosted/pub.dev/system_theme-2.3.1/","native_build":true,"dependencies":[]},{"name":"url_launcher_linux","path":"/home/emavgl/.pub-cache/hosted/pub.dev/url_launcher_linux-3.1.0/","native_build":true,"dependencies":[]}],"windows":[{"name":"package_info_plus","path":"/home/emavgl/.pub-cache/hosted/pub.dev/package_info_plus-4.2.0/","native_build":false,"dependencies":[]},{"name":"path_provider_windows","path":"/home/emavgl/.pub-cache/hosted/pub.dev/path_provider_windows-2.2.1/","native_build":false,"dependencies":[]},{"name":"share_plus","path":"/home/emavgl/.pub-cache/hosted/pub.dev/share_plus-7.2.1/","native_build":true,"dependencies":["url_launcher_windows"]},{"name":"shared_preferences_windows","path":"/home/emavgl/.pub-cache/hosted/pub.dev/shared_preferences_windows-2.3.2/","native_build":false,"dependencies":["path_provider_windows"]},{"name":"system_theme","path":"/home/emavgl/.pub-cache/hosted/pub.dev/system_theme-2.3.1/","native_build":true,"dependencies":[]},{"name":"url_launcher_windows","path":"/home/emavgl/.pub-cache/hosted/pub.dev/url_launcher_windows-3.1.0/","native_build":true,"dependencies":[]}],"web":[{"name":"file_picker","path":"/home/emavgl/.pub-cache/hosted/pub.dev/file_picker-6.1.1/","dependencies":[]},{"name":"package_info_plus","path":"/home/emavgl/.pub-cache/hosted/pub.dev/package_info_plus-4.2.0/","dependencies":[]},{"name":"share_plus","path":"/home/emavgl/.pub-cache/hosted/pub.dev/share_plus-7.2.1/","dependencies":["url_launcher_web"]},{"name":"shared_preferences_web","path":"/home/emavgl/.pub-cache/hosted/pub.dev/shared_preferences_web-2.2.1/","dependencies":[]},{"name":"system_theme_web","path":"/home/emavgl/.pub-cache/hosted/pub.dev/system_theme_web-0.0.2/","dependencies":[]},{"name":"url_launcher_web","path":"/home/emavgl/.pub-cache/hosted/pub.dev/url_launcher_web-2.0.19/","dependencies":[]}]},"dependencyGraph":[{"name":"file_picker","dependencies":["flutter_plugin_android_lifecycle"]},{"name":"flutter_plugin_android_lifecycle","dependencies":[]},{"name":"package_info_plus","dependencies":[]},{"name":"path_provider","dependencies":["path_provider_android","path_provider_foundation","path_provider_linux","path_provider_windows"]},{"name":"path_provider_android","dependencies":[]},{"name":"path_provider_foundation","dependencies":[]},{"name":"path_provider_linux","dependencies":[]},{"name":"path_provider_windows","dependencies":[]},{"name":"share_plus","dependencies":["url_launcher_web","url_launcher_windows","url_launcher_linux"]},{"name":"shared_preferences","dependencies":["shared_preferences_android","shared_preferences_foundation","shared_preferences_linux","shared_preferences_web","shared_preferences_windows"]},{"name":"shared_preferences_android","dependencies":[]},{"name":"shared_preferences_foundation","dependencies":[]},{"name":"shared_preferences_linux","dependencies":["path_provider_linux"]},{"name":"shared_preferences_web","dependencies":[]},{"name":"shared_preferences_windows","dependencies":["path_provider_windows"]},{"name":"sqflite","dependencies":[]},{"name":"system_theme","dependencies":["system_theme_web"]},{"name":"system_theme_web","dependencies":[]},{"name":"url_launcher","dependencies":["url_launcher_android","url_launcher_ios","url_launcher_linux","url_launcher_macos","url_launcher_web","url_launcher_windows"]},{"name":"url_launcher_android","dependencies":[]},{"name":"url_launcher_ios","dependencies":[]},{"name":"url_launcher_linux","dependencies":[]},{"name":"url_launcher_macos","dependencies":[]},{"name":"url_launcher_web","dependencies":[]},{"name":"url_launcher_windows","dependencies":[]}],"date_created":"2023-11-05 16:49:06.029763","version":"3.10.6"}
4 changes: 3 additions & 1 deletion lib/helpers/records-utility-functions.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import 'dart:collection';
import 'dart:developer';
import "package:collection/collection.dart";
import 'package:flutter/cupertino.dart';
import 'package:i18n_extension/i18n_widget.dart';
Expand Down Expand Up @@ -27,9 +28,10 @@ List<RecordsPerDay> groupRecordsByDay(List<Record?> records) {

final defaultNumberFormat = new NumberFormat("#######.0#", "en_US");

String getCurrencyValueString(double? value, {bool useLocale = true, decimalDigits = 2}) {
String getCurrencyValueString(double? value, {bool useLocale = true}) {
if (value == null) return "";
NumberFormat numberFormat;
int decimalDigits = ServiceConfig.sharedPreferences?.getInt("numDecimalDigits") ?? 2;
if (useLocale) {
try {
Locale myLocale = I18n.locale;
Expand Down
2 changes: 2 additions & 0 deletions lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,13 @@ import 'package:piggybank/services/service-config.dart';
import 'package:piggybank/shell.dart';
import 'package:flutter_localizations/flutter_localizations.dart';
import 'package:piggybank/style.dart';
import 'package:shared_preferences/shared_preferences.dart';

main() async {
WidgetsFlutterBinding.ensureInitialized();
PackageInfo packageInfo = await PackageInfo.fromPlatform();
ServiceConfig.isPremium = packageInfo.packageName.endsWith("pro");
ServiceConfig.sharedPreferences = await SharedPreferences.getInstance();
runApp(
App(
lightTheme: await MaterialThemeInstance.getLightTheme(),
Expand Down
2 changes: 1 addition & 1 deletion lib/records/edit-record-page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ class EditRecordPageState extends State<EditRecordPage> {
super.initState();
if (passedRecord != null) {
record = passedRecord;
_textEditingController.text = getCurrencyValueString(record!.value!.abs(), useLocale: false);
_textEditingController.text = getCurrencyValueString(record!.value!.abs());
if (record!.recurrencePatternId != null) {
database.getRecurrentRecordPattern(record!.recurrencePatternId).then((value) {
if (value != null) {
Expand Down
3 changes: 3 additions & 0 deletions lib/services/service-config.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import 'package:shared_preferences/shared_preferences.dart';

import 'database/database-interface.dart';
import 'database/sqlite-database.dart';

Expand All @@ -8,4 +10,5 @@ class ServiceConfig {
static final DatabaseInterface database = SqliteDatabase.instance;
static bool isPremium = false; // set in main.dart
static SharedPreferences? sharedPreferences; // set in main.dart
}
Loading

0 comments on commit 63b780d

Please sign in to comment.