From 0689419510457e39a0fa1f76641dff0617a204f2 Mon Sep 17 00:00:00 2001 From: Nico Date: Tue, 27 May 2025 23:15:33 +0200 Subject: [PATCH] redesignt strecke_u_spurbedingungen --- .../widgets/strecke_u_spurbedingungen.dart | 268 ++++++++++-------- 1 file changed, 143 insertions(+), 125 deletions(-) diff --git a/lib/screens/excursion/widgets/strecke_u_spurbedingungen.dart b/lib/screens/excursion/widgets/strecke_u_spurbedingungen.dart index d99f807..4988e5d 100644 --- a/lib/screens/excursion/widgets/strecke_u_spurbedingungen.dart +++ b/lib/screens/excursion/widgets/strecke_u_spurbedingungen.dart @@ -9,14 +9,15 @@ class StreckeUSpurbedingungen extends StatefulWidget { final TextEditingController spMittelController; final TextEditingController spSchlechtController; - const StreckeUSpurbedingungen( - {required this.kmAutoController, - required this.kmFussController, - required this.kmRadController, - required this.spGutController, - required this.spMittelController, - required this.spSchlechtController, - super.key}); + const StreckeUSpurbedingungen({ + required this.kmAutoController, + required this.kmFussController, + required this.kmRadController, + required this.spGutController, + required this.spMittelController, + required this.spSchlechtController, + super.key, + }); @override StreckeUSpurbedingungenState createState() => StreckeUSpurbedingungenState(); @@ -37,7 +38,7 @@ class StreckeUSpurbedingungenState extends State { @override void initState() { super.initState(); - // Travle Distance + // Travle Distance widget.kmAutoController.addListener(onDistanceTravledUpdated); widget.kmFussController.addListener(onDistanceTravledUpdated); widget.kmRadController.addListener(onDistanceTravledUpdated); @@ -50,9 +51,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 == "") { @@ -62,7 +63,6 @@ class StreckeUSpurbedingungenState extends State { } } - void onDistanceTravledUpdated() { try { double kmAuto = double.parse(widget.kmAutoController.text); @@ -86,138 +86,156 @@ 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 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; + // } + // } @override Widget build(BuildContext context) { return Column( children: [ - Align( - alignment: Alignment.bottomLeft, - child: Text( - AppLocalizations.of(context)!.zurueckgelegteStrecke, - style: Theme.of(context).textTheme.titleMedium, - )), - Row( - children: [ - Expanded(child: Text(AppLocalizations.of(context)!.auto)), - Expanded( - child: TextField( - keyboardType: TextInputType.number, - controller: widget.kmAutoController, - )), - Expanded(child: Center(child: Text("="))), - Expanded(child: Center(child: Text(carPercent))), - Expanded(child: Center(child: Text("%"))), - ], - ), - Row( - children: [ - Expanded(child: Text(AppLocalizations.of(context)!.zuFuss)), - Expanded( - child: TextField( - keyboardType: TextInputType.number, - controller: widget.kmFussController)), - Expanded(child: Center(child: Text("="))), - Expanded(child: Center(child: Text(footPercent))), - Expanded(child: Center(child: Text("%"))), - ], - ), - Row( - children: [ - Expanded(child: Text(AppLocalizations.of(context)!.fahrrad)), - Expanded( - child: TextField( - keyboardType: TextInputType.number, - controller: widget.kmRadController)), - Expanded(child: Center(child: Text("="))), - Expanded(child: Center(child: Text(bikePercent))), - Expanded(child: Center(child: Text("%"))), - ], - ), - const SizedBox( - height: 20, - ), - Row( - children: [ - Expanded( - flex: 1, - child: Text(AppLocalizations.of(context)!.gesamt), - ), - Expanded( - flex: 3, - child: Align( - alignment: Alignment.bottomLeft, - child: Text(totalKm), - ), - ) - ], - ), - const SizedBox( - height: 20, - ), Align( alignment: Alignment.bottomLeft, child: Text( - AppLocalizations.of(context)!.spurbedingungen, + "${AppLocalizations.of(context)!.zurueckgelegteStrecke} (km)", style: Theme.of(context).textTheme.titleMedium, ), ), + const SizedBox(height: 10), + Row( children: [ - Expanded(child: Text(AppLocalizations.of(context)!.gut)), Expanded( - child: TextField( - keyboardType: TextInputType.number, - controller: widget.spGutController)), - Expanded(child: Center(child: Text("="))), - Expanded(child: Center(child: Text(goodPercent))), - Expanded(child: Center(child: Text("%"))), + child: Padding( + padding: const EdgeInsets.all(8.0), + child: Column( + children: [ + Align( + alignment: Alignment.bottomLeft, + child: Text(AppLocalizations.of(context)!.auto), + ), + TextField( + keyboardType: TextInputType.number, + controller: widget.kmAutoController, + ), + ], + ), + ), + ), + + Expanded( + child: Padding( + padding: const EdgeInsets.all(8.0), + child: Column( + children: [ + Align( + alignment: Alignment.bottomLeft, + child: Text(AppLocalizations.of(context)!.zuFuss), + ), + TextField( + keyboardType: TextInputType.number, + controller: widget.kmFussController, + ), + ], + ), + ), + ), + + Expanded( + child: Padding( + padding: const EdgeInsets.all(8.0), + child: Column( + children: [ + Align( + alignment: Alignment.bottomLeft, + child: Text(AppLocalizations.of(context)!.fahrrad), + ), + TextField( + keyboardType: TextInputType.number, + controller: widget.kmRadController, + ), + ], + ), + ), + ), + + const SizedBox(height: 20), ], ), - Row( - children: [ - Expanded(child: Text(AppLocalizations.of(context)!.mittel)), - Expanded( - child: TextField( - keyboardType: TextInputType.number, - controller: widget.spMittelController)), - Expanded(child: Center(child: Text("="))), - Expanded(child: Center(child: Text(middlePercent))), - Expanded(child: Center(child: Text("%"))), - ], + + const SizedBox(height: 20), + + Align( + alignment: Alignment.bottomLeft, + child: Text( + "${AppLocalizations.of(context)!.spurbedingungen} (km)", + style: Theme.of(context).textTheme.titleMedium, + ), ), + const SizedBox(height: 10,), + Row( children: [ - Expanded(child: Text(AppLocalizations.of(context)!.schlecht)), Expanded( - child: TextField( - keyboardType: TextInputType.number, - controller: widget.spSchlechtController, - )), - Expanded(child: Center(child: Text("="))), - Expanded(child: Center(child: Text(badPercent))), - Expanded(child: Center(child: Text("%"))), + child: Padding( + padding: const EdgeInsets.all(8), + child: Column( + children: [ + Align(alignment: Alignment.bottomLeft, child: Text(AppLocalizations.of(context)!.gut)), + TextField( + keyboardType: TextInputType.number, + controller: widget.spGutController, + ), + ], + ), + ), + ), + Expanded( + child: Padding( + padding: const EdgeInsets.all(8), + child: Column( + children: [ + Align(alignment: Alignment.bottomLeft, child: Text(AppLocalizations.of(context)!.mittel)), + TextField( + keyboardType: TextInputType.number, + controller: widget.spMittelController, + ), + ], + ), + ), + ), + Expanded( + child: Padding( + padding: const EdgeInsets.all(8), + child: Column( + children: [ + Align(alignment: Alignment.bottomLeft, child: Text(AppLocalizations.of(context)!.schlecht)), + TextField( + keyboardType: TextInputType.number, + controller: widget.spSchlechtController, + ), + ], + ), + ), + ), ], ), ],