input check on distance traveled and track conditions
This commit is contained in:
@@ -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<StreckeUSpurbedingungen> {
|
||||
}
|
||||
|
||||
// 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<StreckeUSpurbedingungen> {
|
||||
// }
|
||||
// }
|
||||
|
||||
// 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) {
|
||||
|
||||
Reference in New Issue
Block a user