Skip to content
This repository has been archived by the owner on Dec 20, 2024. It is now read-only.

Commit

Permalink
v1.4.1+15
Browse files Browse the repository at this point in the history
Can add decimals when setting Allowance amount
Negative zero transaction amounts no longer have negative sign
Color tweaks
  • Loading branch information
jameskokoska committed Sep 2, 2023
1 parent 31970b3 commit 89a0d2b
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 9 deletions.
2 changes: 1 addition & 1 deletion budget_simple/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ void main() async {
dataSetTranslationsApp = await openAppTranslations();
runApp(
DevicePreview(
enabled: kDebugMode,
enabled: false,
builder: (context) => InitializeApp(key: initializeAppStateKey),
),
);
Expand Down
16 changes: 14 additions & 2 deletions budget_simple/lib/widgets/increase_limit.dart
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -19,6 +20,7 @@ DateTime dayInAMonth() {
}

class _IncreaseLimitState extends State<IncreaseLimit> {
TextEditingController amountInputController = TextEditingController();
double selectedAmount = 0;
DateTime selectedUntilDate = dayInAMonth();
DateTime selectedOnDate = DateTime.now();
Expand Down Expand Up @@ -88,15 +90,20 @@ class _IncreaseLimitState extends State<IncreaseLimit> {
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: <TextInputFormatter>[
FilteringTextInputFormatter.allow(RegExp(r'[0-9]')),
FilteringTextInputFormatter.digitsOnly
FilteringTextInputFormatter.allow(RegExp(r'[0-9,.]')),
],
keyboardType: TextInputType.number,
style: const TextStyle(fontSize: 20),
Expand Down Expand Up @@ -223,3 +230,8 @@ class _IncreaseLimitState extends State<IncreaseLimit> {
);
}
}

bool containsMoreThanOneDecimalSeparator(String input) {
List<String> charList = input.split(getDecimalSeparator());
return charList.length > 2;
}
17 changes: 12 additions & 5 deletions budget_simple/lib/widgets/transaction_entry.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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),
),
Expand Down Expand Up @@ -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,
Expand All @@ -136,8 +138,6 @@ class TransactionEntry extends StatelessWidget {
fontSize: 16,
maxLines: 5,
textAlign: TextAlign.right,
textColor:
Theme.of(context).colorScheme.tertiary,
)
: const SizedBox.shrink(),
),
Expand All @@ -161,14 +161,21 @@ 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
? Colors.green[600]
: 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;
Expand Down
2 changes: 1 addition & 1 deletion budget_simple/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down

0 comments on commit 89a0d2b

Please sign in to comment.