From 2574752ebb763c6488402911aa12a5f37e84deab Mon Sep 17 00:00:00 2001 From: Nico Date: Mon, 2 Jun 2025 20:15:42 +0200 Subject: [PATCH] input check on distance traveled and track conditions --- lib/l10n/app_de.arb | 5 +- lib/l10n/app_en.arb | 6 ++- lib/l10n/app_localizations.dart | 12 +++++ lib/l10n/app_localizations_de.dart | 8 ++- lib/l10n/app_localizations_en.dart | 6 +++ .../widgets/strecke_u_spurbedingungen.dart | 51 ++++++++++--------- untranslated.txt | 3 +- 7 files changed, 62 insertions(+), 29 deletions(-) diff --git a/lib/l10n/app_de.arb b/lib/l10n/app_de.arb index bbebeb2..c614491 100644 --- a/lib/l10n/app_de.arb +++ b/lib/l10n/app_de.arb @@ -64,7 +64,7 @@ "openMap": "Karte öffnen", "saveMap": "Speichern und Schließen", "locationDisabled": "Standort ausgeschaltet. Bitte einschalten", - "locationForbidden": "Zugriff auf Standort verweigert. Es ist empfohlen dies zu erlauben", + "locationForbidden": "Zugriff auf Standort verweigert", "map": "Karte", "markerSet": "Marker gesetzt auf", "betreuung": "Betreuung", @@ -160,5 +160,6 @@ "couldntDeterminePosition": "Position konnte nicht ermittelt werden", "trackingRunningInBackground": "Die Tracking funktion läuft im Hintergrund", "needsAlwaysLocation": "Diese app braucht die Standort berechtigung auf immer gesetzt", - "deleteWholeRouteBody": "Sind Sie sicher, dass die gesamte bisher gegangene Route gelöscht werden soll?" + "deleteWholeRouteBody": "Sind Sie sicher, dass die gesamte bisher gegangene Route gelöscht werden soll?", + "oder": "oder" } diff --git a/lib/l10n/app_en.arb b/lib/l10n/app_en.arb index ffb871a..226db87 100644 --- a/lib/l10n/app_en.arb +++ b/lib/l10n/app_en.arb @@ -667,5 +667,9 @@ "needsAlwaysLocation": "This app needs the location permission set to always", - "deleteWholeRouteBody": "Do you really want to delete the existing route?" + "deleteWholeRouteBody": "Do you really want to delete the existing route?", + + "oder": "or", + + "bedingungenGroesserAlsStrecke": "Sum of the track conditions is bigger then sum of the distance traveled" } diff --git a/lib/l10n/app_localizations.dart b/lib/l10n/app_localizations.dart index ca0a313..3c7116c 100644 --- a/lib/l10n/app_localizations.dart +++ b/lib/l10n/app_localizations.dart @@ -1072,6 +1072,18 @@ abstract class AppLocalizations { /// In en, this message translates to: /// **'Do you really want to delete the existing route?'** String get deleteWholeRouteBody; + + /// No description provided for @oder. + /// + /// In en, this message translates to: + /// **'or'** + String get oder; + + /// No description provided for @bedingungenGroesserAlsStrecke. + /// + /// In en, this message translates to: + /// **'Sum of the track conditions is bigger then sum of the distance traveled'** + String get bedingungenGroesserAlsStrecke; } class _AppLocalizationsDelegate extends LocalizationsDelegate { diff --git a/lib/l10n/app_localizations_de.dart b/lib/l10n/app_localizations_de.dart index 56d61f3..1996dc7 100644 --- a/lib/l10n/app_localizations_de.dart +++ b/lib/l10n/app_localizations_de.dart @@ -210,7 +210,7 @@ class AppLocalizationsDe extends AppLocalizations { String get locationDisabled => 'Standort ausgeschaltet. Bitte einschalten'; @override - String get locationForbidden => 'Zugriff auf Standort verweigert. Es ist empfohlen dies zu erlauben'; + String get locationForbidden => 'Zugriff auf Standort verweigert'; @override String get map => 'Karte'; @@ -496,4 +496,10 @@ class AppLocalizationsDe extends AppLocalizations { @override String get deleteWholeRouteBody => 'Sind Sie sicher, dass die gesamte bisher gegangene Route gelöscht werden soll?'; + + @override + String get oder => 'oder'; + + @override + String get bedingungenGroesserAlsStrecke => 'Sum of the track conditions is bigger then sum of the distance traveled'; } diff --git a/lib/l10n/app_localizations_en.dart b/lib/l10n/app_localizations_en.dart index 710dee6..5144ddd 100644 --- a/lib/l10n/app_localizations_en.dart +++ b/lib/l10n/app_localizations_en.dart @@ -496,4 +496,10 @@ class AppLocalizationsEn extends AppLocalizations { @override String get deleteWholeRouteBody => 'Do you really want to delete the existing route?'; + + @override + String get oder => 'or'; + + @override + String get bedingungenGroesserAlsStrecke => 'Sum of the track conditions is bigger then sum of the distance traveled'; } diff --git a/lib/screens/excursion/widgets/strecke_u_spurbedingungen.dart b/lib/screens/excursion/widgets/strecke_u_spurbedingungen.dart index cc56b36..d9570d0 100644 --- a/lib/screens/excursion/widgets/strecke_u_spurbedingungen.dart +++ b/lib/screens/excursion/widgets/strecke_u_spurbedingungen.dart @@ -1,3 +1,4 @@ +import 'package:fforte/screens/helper/snack_bar_helper.dart'; import 'package:flutter/material.dart'; import 'package:fforte/l10n/app_localizations.dart'; @@ -51,9 +52,9 @@ class StreckeUSpurbedingungenState extends State { } // Track Conditions - // widget.spGutController.addListener(onTrackConditionsUpdated); - // widget.spMittelController.addListener(onTrackConditionsUpdated); - // widget.spSchlechtController.addListener(onTrackConditionsUpdated); + widget.spGutController.addListener(onTrackConditionsUpdated); + widget.spMittelController.addListener(onTrackConditionsUpdated); + widget.spSchlechtController.addListener(onTrackConditionsUpdated); // if one of the values is "" the excursion is edited for the first time. On which value i check here is unnecessarry if (widget.spGutController.text == "") { @@ -86,27 +87,29 @@ class StreckeUSpurbedingungenState extends State { // } // } - // void onTrackConditionsUpdated() { - // try { - // double kmGood = double.parse(widget.spGutController.text); - // double kmMiddle = double.parse(widget.spMittelController.text); - // double kmBad = double.parse(widget.spSchlechtController.text); - // // double gesKm = (kmGood + kmMiddle + kmBad); - // - // // if (gesKm == 0) { - // // goodPercent = "0"; - // // middlePercent = "0"; - // // badPercent = "0"; - // // } else { - // // goodPercent = (kmGood / gesKm * 100).round().toString(); - // // middlePercent = (kmMiddle / gesKm * 100).round().toString(); - // // badPercent = (kmBad / gesKm * 100).round().toString(); - // // } - // setState(() {}); - // } catch (e) { - // return; - // } - // } + void onTrackConditionsUpdated() { + try { + double kmGood = double.parse(widget.spGutController.text); + double kmMiddle = double.parse(widget.spMittelController.text); + double kmBad = double.parse(widget.spSchlechtController.text); + + double kmAuto = double.parse(widget.kmAutoController.text); + double kmFuss = double.parse(widget.kmFussController.text); + double kmRad = double.parse(widget.kmRadController.text); + + double gesConditionsKm = (kmGood + kmMiddle + kmBad); + double gesDistanceKm = (kmAuto + kmFuss + kmRad); + + + if (gesConditionsKm > gesDistanceKm) { + SnackBarHelper.showSnackBarMessage(context, AppLocalizations.of(context)!.bedingungenGroesserAlsStrecke); + } + + setState(() {}); + } catch (e) { + return; + } + } @override Widget build(BuildContext context) { diff --git a/untranslated.txt b/untranslated.txt index 0962be1..ca13b27 100644 --- a/untranslated.txt +++ b/untranslated.txt @@ -1,5 +1,6 @@ { "de": [ - "excursion" + "excursion", + "bedingungenGroesserAlsStrecke" ] }