diff --git a/budget_simple/lib/main.dart b/budget_simple/lib/main.dart index f39b840..6186ba9 100644 --- a/budget_simple/lib/main.dart +++ b/budget_simple/lib/main.dart @@ -63,7 +63,7 @@ void main() async { dataSetTranslationsApp = await openAppTranslations(); runApp( DevicePreview( - enabled: kDebugMode, + enabled: false, builder: (context) => InitializeApp(key: initializeAppStateKey), ), ); diff --git a/budget_simple/lib/widgets/increase_limit.dart b/budget_simple/lib/widgets/increase_limit.dart index d6f332d..81f89b6 100644 --- a/budget_simple/lib/widgets/increase_limit.dart +++ b/budget_simple/lib/widgets/increase_limit.dart @@ -1,5 +1,6 @@ import 'package:budget_simple/database/tables.dart'; import 'package:budget_simple/struct/database_global.dart'; +import 'package:budget_simple/struct/functions.dart'; import 'package:budget_simple/widgets/tappable.dart'; import 'package:budget_simple/widgets/text_font.dart'; import 'package:flutter/material.dart'; @@ -19,6 +20,7 @@ DateTime dayInAMonth() { } class _IncreaseLimitState extends State { + TextEditingController amountInputController = TextEditingController(); double selectedAmount = 0; DateTime selectedUntilDate = dayInAMonth(); DateTime selectedOnDate = DateTime.now(); @@ -88,15 +90,20 @@ class _IncreaseLimitState extends State { child: IntrinsicWidth( child: TextFormField( autofocus: true, + controller: amountInputController, onChanged: (value) { + if (getDecimalSeparator() == ",") { + value = value.replaceAll(",", "."); + } else if (getDecimalSeparator() == ".") { + value = value.replaceAll(",", ""); + } setState(() { selectedAmount = double.tryParse(value) ?? 0; }); }, textAlign: TextAlign.center, inputFormatters: [ - FilteringTextInputFormatter.allow(RegExp(r'[0-9]')), - FilteringTextInputFormatter.digitsOnly + FilteringTextInputFormatter.allow(RegExp(r'[0-9,.]')), ], keyboardType: TextInputType.number, style: const TextStyle(fontSize: 20), @@ -223,3 +230,8 @@ class _IncreaseLimitState extends State { ); } } + +bool containsMoreThanOneDecimalSeparator(String input) { + List charList = input.split(getDecimalSeparator()); + return charList.length > 2; +} diff --git a/budget_simple/lib/widgets/transaction_entry.dart b/budget_simple/lib/widgets/transaction_entry.dart index a6c8874..c9ff31d 100644 --- a/budget_simple/lib/widgets/transaction_entry.dart +++ b/budget_simple/lib/widgets/transaction_entry.dart @@ -33,7 +33,8 @@ class TransactionEntry extends StatelessWidget { maxLines: 2, fontSize: 22, fontWeight: FontWeight.bold, - text: currency.format(transaction.amount * -1), + text: currency + .format(removeNegativeZero(transaction.amount * -1)), textColor: getTransactionAmountColor( context, transaction.amount * -1), ), @@ -120,7 +121,8 @@ class TransactionEntry extends StatelessWidget { crossAxisAlignment: CrossAxisAlignment.end, children: [ TextFont( - text: currency.format(transaction.amount * -1), + text: currency.format( + removeNegativeZero(transaction.amount * -1)), fontSize: 22, fontWeight: FontWeight.bold, textAlign: TextAlign.right, @@ -136,8 +138,6 @@ class TransactionEntry extends StatelessWidget { fontSize: 16, maxLines: 5, textAlign: TextAlign.right, - textColor: - Theme.of(context).colorScheme.tertiary, ) : const SizedBox.shrink(), ), @@ -161,6 +161,13 @@ class TransactionEntry extends StatelessWidget { } } +double? removeNegativeZero(double number) { + if (number.abs() == 0) { + return 0; + } + return number; +} + Color? getTransactionAmountColor(BuildContext context, double amount) { if (amount > 0) { return Theme.of(context).brightness == Brightness.light @@ -168,7 +175,7 @@ Color? getTransactionAmountColor(BuildContext context, double amount) { : Colors.green[300]; } else if (amount < 0) { return Theme.of(context).brightness == Brightness.light - ? Colors.red[400] + ? const Color(0xFFCE5959) : Colors.red[300]; } return null; diff --git a/budget_simple/pubspec.yaml b/budget_simple/pubspec.yaml index 6c6f7b4..bdf167a 100644 --- a/budget_simple/pubspec.yaml +++ b/budget_simple/pubspec.yaml @@ -2,7 +2,7 @@ name: budget_simple description: A simple budget app. publish_to: 'none' # Remove this line if you wish to publish to pub.dev -version: 1.4.0+14 +version: 1.4.1+15 environment: sdk: '>=2.19.0-444.0.dev <3.0.0'