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

Commit

Permalink
Fixed decimal point freeze with certain locales
Browse files Browse the repository at this point in the history
  • Loading branch information
jameskokoska committed Aug 4, 2023
1 parent d0da9ed commit 6359d97
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 85 deletions.
146 changes: 62 additions & 84 deletions budget_simple/lib/pages/home_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -62,88 +62,66 @@ class HomePageState extends State<HomePage> {
if (enableKeyboardListen == false) return false;
if (Navigator.canPop(context)) return false;
if (focusNodeTextInput.hasFocus) return false;
if (event.runtimeType == KeyDownEvent &&
event.logicalKey == LogicalKeyboardKey.digit0) {
addToAmount("0");
} else if (event.runtimeType == KeyDownEvent &&
event.logicalKey == LogicalKeyboardKey.digit1) {
addToAmount("1");
} else if (event.runtimeType == KeyDownEvent &&
event.logicalKey == LogicalKeyboardKey.digit2) {
addToAmount("2");
} else if (event.runtimeType == KeyDownEvent &&
event.logicalKey == LogicalKeyboardKey.digit3) {
addToAmount("3");
} else if (event.runtimeType == KeyDownEvent &&
event.logicalKey == LogicalKeyboardKey.digit4) {
addToAmount("4");
} else if (event.runtimeType == KeyDownEvent &&
event.logicalKey == LogicalKeyboardKey.digit5) {
addToAmount("5");
} else if (event.runtimeType == KeyDownEvent &&
event.logicalKey == LogicalKeyboardKey.digit6) {
addToAmount("6");
} else if (event.runtimeType == KeyDownEvent &&
event.logicalKey == LogicalKeyboardKey.digit7) {
addToAmount("7");
} else if (event.runtimeType == KeyDownEvent &&
event.logicalKey == LogicalKeyboardKey.digit8) {
addToAmount("8");
} else if (event.runtimeType == KeyDownEvent &&
event.logicalKey == LogicalKeyboardKey.digit9) {
addToAmount("9");
} else if (event.runtimeType == KeyDownEvent &&
event.logicalKey == LogicalKeyboardKey.numpad0) {
addToAmount("0");
} else if (event.runtimeType == KeyDownEvent &&
event.logicalKey == LogicalKeyboardKey.numpad1) {
addToAmount("1");
} else if (event.runtimeType == KeyDownEvent &&
event.logicalKey == LogicalKeyboardKey.numpad2) {
addToAmount("2");
} else if (event.runtimeType == KeyDownEvent &&
event.logicalKey == LogicalKeyboardKey.numpad3) {
addToAmount("3");
} else if (event.runtimeType == KeyDownEvent &&
event.logicalKey == LogicalKeyboardKey.numpad4) {
addToAmount("4");
} else if (event.runtimeType == KeyDownEvent &&
event.logicalKey == LogicalKeyboardKey.numpad5) {
addToAmount("5");
} else if (event.runtimeType == KeyDownEvent &&
event.logicalKey == LogicalKeyboardKey.numpad6) {
addToAmount("6");
} else if (event.runtimeType == KeyDownEvent &&
event.logicalKey == LogicalKeyboardKey.numpad7) {
addToAmount("7");
} else if (event.runtimeType == KeyDownEvent &&
event.logicalKey == LogicalKeyboardKey.numpad8) {
addToAmount("8");
} else if (event.runtimeType == KeyDownEvent &&
event.logicalKey == LogicalKeyboardKey.numpad9) {
addToAmount("9");
} else if (event.runtimeType == KeyDownEvent &&
event.logicalKey == LogicalKeyboardKey.add) {
addToAmount("+");
} else if (event.runtimeType == KeyDownEvent &&
event.logicalKey == LogicalKeyboardKey.numpadAdd) {
addToAmount("+");
} else if (event.runtimeType == KeyDownEvent &&
event.logicalKey == LogicalKeyboardKey.period) {
addToAmount(".");
} else if (event.runtimeType == KeyDownEvent &&
event.logicalKey == LogicalKeyboardKey.numpadDecimal) {
addToAmount(".");
} else if (event.runtimeType == KeyDownEvent &&
event.logicalKey == LogicalKeyboardKey.backspace) {
addToAmount("<");
} else if (event.runtimeType == KeyDownEvent &&
event.logicalKey == LogicalKeyboardKey.delete) {
addToAmount("<");
} else if (event.runtimeType == KeyDownEvent &&
event.logicalKey == LogicalKeyboardKey.enter) {
addToAmount(">");
if (event.runtimeType == KeyDownEvent) {
if (event.logicalKey == LogicalKeyboardKey.digit0) {
addToAmount("0");
} else if (event.logicalKey == LogicalKeyboardKey.digit1) {
addToAmount("1");
} else if (event.logicalKey == LogicalKeyboardKey.digit2) {
addToAmount("2");
} else if (event.logicalKey == LogicalKeyboardKey.digit3) {
addToAmount("3");
} else if (event.logicalKey == LogicalKeyboardKey.digit4) {
addToAmount("4");
} else if (event.logicalKey == LogicalKeyboardKey.digit5) {
addToAmount("5");
} else if (event.logicalKey == LogicalKeyboardKey.digit6) {
addToAmount("6");
} else if (event.logicalKey == LogicalKeyboardKey.digit7) {
addToAmount("7");
} else if (event.logicalKey == LogicalKeyboardKey.digit8) {
addToAmount("8");
} else if (event.logicalKey == LogicalKeyboardKey.digit9) {
addToAmount("9");
} else if (event.logicalKey == LogicalKeyboardKey.numpad0) {
addToAmount("0");
} else if (event.logicalKey == LogicalKeyboardKey.numpad1) {
addToAmount("1");
} else if (event.logicalKey == LogicalKeyboardKey.numpad2) {
addToAmount("2");
} else if (event.logicalKey == LogicalKeyboardKey.numpad3) {
addToAmount("3");
} else if (event.logicalKey == LogicalKeyboardKey.numpad4) {
addToAmount("4");
} else if (event.logicalKey == LogicalKeyboardKey.numpad5) {
addToAmount("5");
} else if (event.logicalKey == LogicalKeyboardKey.numpad6) {
addToAmount("6");
} else if (event.logicalKey == LogicalKeyboardKey.numpad7) {
addToAmount("7");
} else if (event.logicalKey == LogicalKeyboardKey.numpad8) {
addToAmount("8");
} else if (event.logicalKey == LogicalKeyboardKey.numpad9) {
addToAmount("9");
} else if (event.logicalKey == LogicalKeyboardKey.add) {
addToAmount("+");
} else if (event.logicalKey == LogicalKeyboardKey.numpadAdd) {
addToAmount("+");
} else if (event.logicalKey == LogicalKeyboardKey.period) {
addToAmount(".");
} else if (event.logicalKey == LogicalKeyboardKey.numpadDecimal) {
addToAmount(".");
} else if (event.logicalKey == LogicalKeyboardKey.comma) {
addToAmount(".");
} else if (event.logicalKey == LogicalKeyboardKey.backspace) {
addToAmount("<");
} else if (event.logicalKey == LogicalKeyboardKey.delete) {
addToAmount("<");
} else if (event.logicalKey == LogicalKeyboardKey.enter) {
addToAmount(">");
}
}

return false;
}

Expand Down Expand Up @@ -212,11 +190,11 @@ class HomePageState extends State<HomePage> {
showedWarningSnackbar = true;
}
}
} else if (action == ".") {
} else if (action == "." || action == ",") {
if (amountCalculated == "") {
amountCalculated += "0.";
} else if (!amountCalculated.contains(".")) {
amountCalculated += action;
amountCalculated += ".";
}
} else {
if (amountCalculated.split('.').length > 1 &&
Expand Down Expand Up @@ -619,7 +597,7 @@ class HomePageState extends State<HomePage> {
AmountButton(
constraints: constraints,
text: getDecimalSeparator(),
addToAmount: addToAmount,
addToAmount: (_) => addToAmount("."),
),
],
),
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.3.1+11
version: 1.3.2+12

environment:
sdk: '>=2.19.0-444.0.dev <3.0.0'
Expand Down

0 comments on commit 6359d97

Please sign in to comment.