From 6359d970562a5bb972c0f1d3451febf49e686c5c Mon Sep 17 00:00:00 2001 From: jameskokoska <50821962+jameskokoska@users.noreply.github.com> Date: Fri, 4 Aug 2023 09:50:09 -0400 Subject: [PATCH] Fixed decimal point freeze with certain locales --- budget_simple/lib/pages/home_page.dart | 146 +++++++++++-------------- budget_simple/pubspec.yaml | 2 +- 2 files changed, 63 insertions(+), 85 deletions(-) diff --git a/budget_simple/lib/pages/home_page.dart b/budget_simple/lib/pages/home_page.dart index 0bc097e..daeb553 100644 --- a/budget_simple/lib/pages/home_page.dart +++ b/budget_simple/lib/pages/home_page.dart @@ -62,88 +62,66 @@ class HomePageState extends State { 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; } @@ -212,11 +190,11 @@ class HomePageState extends State { 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 && @@ -619,7 +597,7 @@ class HomePageState extends State { AmountButton( constraints: constraints, text: getDecimalSeparator(), - addToAmount: addToAmount, + addToAmount: (_) => addToAmount("."), ), ], ), diff --git a/budget_simple/pubspec.yaml b/budget_simple/pubspec.yaml index cdc8ed0..3ea8124 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.3.1+11 +version: 1.3.2+12 environment: sdk: '>=2.19.0-444.0.dev <3.0.0'