redesignt strecke_u_spurbedingungen
This commit is contained in:
@@ -9,14 +9,15 @@ class StreckeUSpurbedingungen extends StatefulWidget {
|
|||||||
final TextEditingController spMittelController;
|
final TextEditingController spMittelController;
|
||||||
final TextEditingController spSchlechtController;
|
final TextEditingController spSchlechtController;
|
||||||
|
|
||||||
const StreckeUSpurbedingungen(
|
const StreckeUSpurbedingungen({
|
||||||
{required this.kmAutoController,
|
required this.kmAutoController,
|
||||||
required this.kmFussController,
|
required this.kmFussController,
|
||||||
required this.kmRadController,
|
required this.kmRadController,
|
||||||
required this.spGutController,
|
required this.spGutController,
|
||||||
required this.spMittelController,
|
required this.spMittelController,
|
||||||
required this.spSchlechtController,
|
required this.spSchlechtController,
|
||||||
super.key});
|
super.key,
|
||||||
|
});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
StreckeUSpurbedingungenState createState() => StreckeUSpurbedingungenState();
|
StreckeUSpurbedingungenState createState() => StreckeUSpurbedingungenState();
|
||||||
@@ -50,9 +51,9 @@ class StreckeUSpurbedingungenState extends State<StreckeUSpurbedingungen> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Track Conditions
|
// Track Conditions
|
||||||
widget.spGutController.addListener(onTrackConditionsUpdated);
|
// widget.spGutController.addListener(onTrackConditionsUpdated);
|
||||||
widget.spMittelController.addListener(onTrackConditionsUpdated);
|
// widget.spMittelController.addListener(onTrackConditionsUpdated);
|
||||||
widget.spSchlechtController.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 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 == "") {
|
if (widget.spGutController.text == "") {
|
||||||
@@ -62,7 +63,6 @@ class StreckeUSpurbedingungenState extends State<StreckeUSpurbedingungen> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void onDistanceTravledUpdated() {
|
void onDistanceTravledUpdated() {
|
||||||
try {
|
try {
|
||||||
double kmAuto = double.parse(widget.kmAutoController.text);
|
double kmAuto = double.parse(widget.kmAutoController.text);
|
||||||
@@ -86,27 +86,27 @@ class StreckeUSpurbedingungenState extends State<StreckeUSpurbedingungen> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void onTrackConditionsUpdated() {
|
// void onTrackConditionsUpdated() {
|
||||||
try {
|
// try {
|
||||||
double kmGood = double.parse(widget.spGutController.text);
|
// double kmGood = double.parse(widget.spGutController.text);
|
||||||
double kmMiddle = double.parse(widget.spMittelController.text);
|
// double kmMiddle = double.parse(widget.spMittelController.text);
|
||||||
double kmBad = double.parse(widget.spSchlechtController.text);
|
// double kmBad = double.parse(widget.spSchlechtController.text);
|
||||||
double gesKm = (kmGood + kmMiddle + kmBad);
|
// // double gesKm = (kmGood + kmMiddle + kmBad);
|
||||||
|
//
|
||||||
if (gesKm == 0) {
|
// // if (gesKm == 0) {
|
||||||
goodPercent = "0";
|
// // goodPercent = "0";
|
||||||
middlePercent = "0";
|
// // middlePercent = "0";
|
||||||
badPercent = "0";
|
// // badPercent = "0";
|
||||||
} else {
|
// // } else {
|
||||||
goodPercent = (kmGood / gesKm * 100).round().toString();
|
// // goodPercent = (kmGood / gesKm * 100).round().toString();
|
||||||
middlePercent = (kmMiddle / gesKm * 100).round().toString();
|
// // middlePercent = (kmMiddle / gesKm * 100).round().toString();
|
||||||
badPercent = (kmBad / gesKm * 100).round().toString();
|
// // badPercent = (kmBad / gesKm * 100).round().toString();
|
||||||
}
|
// // }
|
||||||
setState(() {});
|
// setState(() {});
|
||||||
} catch (e) {
|
// } catch (e) {
|
||||||
return;
|
// return;
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
@@ -115,109 +115,127 @@ class StreckeUSpurbedingungenState extends State<StreckeUSpurbedingungen> {
|
|||||||
Align(
|
Align(
|
||||||
alignment: Alignment.bottomLeft,
|
alignment: Alignment.bottomLeft,
|
||||||
child: Text(
|
child: Text(
|
||||||
AppLocalizations.of(context)!.zurueckgelegteStrecke,
|
"${AppLocalizations.of(context)!.zurueckgelegteStrecke} (km)",
|
||||||
style: Theme.of(context).textTheme.titleMedium,
|
style: Theme.of(context).textTheme.titleMedium,
|
||||||
)),
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 10),
|
||||||
|
|
||||||
Row(
|
Row(
|
||||||
children: [
|
children: [
|
||||||
Expanded(child: Text(AppLocalizations.of(context)!.auto)),
|
|
||||||
Expanded(
|
Expanded(
|
||||||
child: TextField(
|
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,
|
keyboardType: TextInputType.number,
|
||||||
controller: widget.kmAutoController,
|
controller: widget.kmAutoController,
|
||||||
)),
|
),
|
||||||
Expanded(child: Center(child: Text("="))),
|
|
||||||
Expanded(child: Center(child: Text(carPercent))),
|
|
||||||
Expanded(child: Center(child: Text("%"))),
|
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
Row(
|
),
|
||||||
|
),
|
||||||
|
|
||||||
|
Expanded(
|
||||||
|
child: Padding(
|
||||||
|
padding: const EdgeInsets.all(8.0),
|
||||||
|
child: Column(
|
||||||
children: [
|
children: [
|
||||||
Expanded(child: Text(AppLocalizations.of(context)!.zuFuss)),
|
Align(
|
||||||
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,
|
alignment: Alignment.bottomLeft,
|
||||||
child: Text(totalKm),
|
child: Text(AppLocalizations.of(context)!.zuFuss),
|
||||||
|
),
|
||||||
|
TextField(
|
||||||
|
keyboardType: TextInputType.number,
|
||||||
|
controller: widget.kmFussController,
|
||||||
),
|
),
|
||||||
)
|
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
const SizedBox(
|
|
||||||
height: 20,
|
|
||||||
),
|
),
|
||||||
|
),
|
||||||
|
|
||||||
|
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),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
|
||||||
|
const SizedBox(height: 20),
|
||||||
|
|
||||||
Align(
|
Align(
|
||||||
alignment: Alignment.bottomLeft,
|
alignment: Alignment.bottomLeft,
|
||||||
child: Text(
|
child: Text(
|
||||||
AppLocalizations.of(context)!.spurbedingungen,
|
"${AppLocalizations.of(context)!.spurbedingungen} (km)",
|
||||||
style: Theme.of(context).textTheme.titleMedium,
|
style: Theme.of(context).textTheme.titleMedium,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
const SizedBox(height: 10,),
|
||||||
|
|
||||||
Row(
|
Row(
|
||||||
children: [
|
children: [
|
||||||
Expanded(child: Text(AppLocalizations.of(context)!.gut)),
|
|
||||||
Expanded(
|
Expanded(
|
||||||
child: TextField(
|
child: Padding(
|
||||||
|
padding: const EdgeInsets.all(8),
|
||||||
|
child: Column(
|
||||||
|
children: [
|
||||||
|
Align(alignment: Alignment.bottomLeft, child: Text(AppLocalizations.of(context)!.gut)),
|
||||||
|
TextField(
|
||||||
keyboardType: TextInputType.number,
|
keyboardType: TextInputType.number,
|
||||||
controller: widget.spGutController)),
|
controller: widget.spGutController,
|
||||||
Expanded(child: Center(child: Text("="))),
|
),
|
||||||
Expanded(child: Center(child: Text(goodPercent))),
|
|
||||||
Expanded(child: Center(child: Text("%"))),
|
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
Row(
|
),
|
||||||
children: [
|
),
|
||||||
Expanded(child: Text(AppLocalizations.of(context)!.mittel)),
|
|
||||||
Expanded(
|
Expanded(
|
||||||
child: TextField(
|
child: Padding(
|
||||||
|
padding: const EdgeInsets.all(8),
|
||||||
|
child: Column(
|
||||||
|
children: [
|
||||||
|
Align(alignment: Alignment.bottomLeft, child: Text(AppLocalizations.of(context)!.mittel)),
|
||||||
|
TextField(
|
||||||
keyboardType: TextInputType.number,
|
keyboardType: TextInputType.number,
|
||||||
controller: widget.spMittelController)),
|
controller: widget.spMittelController,
|
||||||
Expanded(child: Center(child: Text("="))),
|
),
|
||||||
Expanded(child: Center(child: Text(middlePercent))),
|
|
||||||
Expanded(child: Center(child: Text("%"))),
|
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
Row(
|
),
|
||||||
children: [
|
),
|
||||||
Expanded(child: Text(AppLocalizations.of(context)!.schlecht)),
|
|
||||||
Expanded(
|
Expanded(
|
||||||
child: TextField(
|
child: Padding(
|
||||||
|
padding: const EdgeInsets.all(8),
|
||||||
|
child: Column(
|
||||||
|
children: [
|
||||||
|
Align(alignment: Alignment.bottomLeft, child: Text(AppLocalizations.of(context)!.schlecht)),
|
||||||
|
TextField(
|
||||||
keyboardType: TextInputType.number,
|
keyboardType: TextInputType.number,
|
||||||
controller: widget.spSchlechtController,
|
controller: widget.spSchlechtController,
|
||||||
)),
|
),
|
||||||
Expanded(child: Center(child: Text("="))),
|
],
|
||||||
Expanded(child: Center(child: Text(badPercent))),
|
),
|
||||||
Expanded(child: Center(child: Text("%"))),
|
),
|
||||||
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
|||||||
Reference in New Issue
Block a user