diff --git a/lib/l10n/app_de.arb b/lib/l10n/app_de.arb index b71f135..ef95b8d 100644 --- a/lib/l10n/app_de.arb +++ b/lib/l10n/app_de.arb @@ -115,5 +115,6 @@ "geschaeftsliegenschaftAGV": "Geschäftsliegenschaft/AGV", "kein": "Kein", "mHund": "Hund dabei", - "mLeine": "Mit Leine" + "mLeine": "Mit Leine", + "name": "Name" } \ No newline at end of file diff --git a/lib/l10n/app_en.arb b/lib/l10n/app_en.arb index 5833ec2..04c0c1c 100644 --- a/lib/l10n/app_en.arb +++ b/lib/l10n/app_en.arb @@ -567,9 +567,16 @@ "mLeine": "With Dog leash", "@mLeine": { "description": "mLeine radiobutten" +}, + +"name": "Name", +"@name": { +"description": "name text field" } + + } \ No newline at end of file diff --git a/lib/screens/Excursion/excursion_main.dart b/lib/screens/Excursion/excursion_main.dart index ca9b4b0..fefca7a 100644 --- a/lib/screens/Excursion/excursion_main.dart +++ b/lib/screens/Excursion/excursion_main.dart @@ -1,5 +1,6 @@ import 'package:animations/animations.dart'; import 'package:fforte/screens/Excursion/widgets/bima_nutzer.dart'; +import 'package:fforte/screens/Excursion/widgets/hund_u_leine.dart'; import 'package:fforte/screens/sharedWidgets/datum.dart'; import 'package:fforte/screens/sharedWidgets/var_text_field.dart'; import 'package:flutter/material.dart'; @@ -46,6 +47,7 @@ class _ExcursionMainState extends State { title: Text(AppLocalizations.of(context)!.dateandtime), content: Column( children: [ + // TODO onDateChanged Datum(initDatum: DateTime.now(), onDateChanged: (date) {}), const SizedBox( height: 10, @@ -62,21 +64,27 @@ class _ExcursionMainState extends State { textController: getTextFields()["Teilnehm"]!, localization: AppLocalizations.of(context)!.teilnehmer, dbName: "Teilnehm", - required: false, - ), - const SizedBox( - height: 10, - ), - VarTextField( - textController: getTextFields()["Dauer"]!, - localization: AppLocalizations.of(context)!.dauer, - dbName: "Dauer", - required: false), - const SizedBox( - height: 10, - ), + required: false, + ), + const SizedBox( + height: 10, + ), + VarTextField( + textController: getTextFields()["Dauer"]!, + localization: AppLocalizations.of(context)!.dauer, + dbName: "Dauer", + required: false), + const SizedBox( + height: 10, + ), - // Hund u Leine + HundULeine(onMHundChanged: (mHund, mLeine) { + getTextFields()["MHund"]!.text = mHund; + getTextFields()["MLeine"]!.text = mLeine; + + print(mHund); + print(mLeine); + }), const SizedBox( height: 10, diff --git a/lib/screens/Excursion/widgets/hund_u_leine.dart b/lib/screens/Excursion/widgets/hund_u_leine.dart index 92a08e2..ad193fe 100644 --- a/lib/screens/Excursion/widgets/hund_u_leine.dart +++ b/lib/screens/Excursion/widgets/hund_u_leine.dart @@ -2,7 +2,9 @@ import 'package:flutter/material.dart'; import 'package:flutter_gen/gen_l10n/app_localizations.dart'; class HundULeine extends StatefulWidget { - final Function(String) onMHundChanged; + // 1. with dog (ja, bzw name oder nein) 2. with leash + // if nothing selected null + final Function(String, String) onMHundChanged; const HundULeine({super.key, required this.onMHundChanged}); @@ -11,12 +13,26 @@ class HundULeine extends StatefulWidget { } class HundULeineState extends State { - String? _selectedValue; + String? _selectedMHundValue; + String _selectedMLeineValue = "nein"; TextEditingController controller = TextEditingController(); bool visible = false; - void onChanged(String mHund, String name, String mLeine) { - + void onValueChanged(String mHund, String mLeine) { + setState(() { + visible = mHund == "ja" ? true : false; + _selectedMHundValue = mHund; + _selectedMLeineValue = mLeine; + }); + + if (mHund != "nein" && controller.text != "") mHund = controller.text; + + if (mHund == "nein") { + _selectedMHundValue = "nein"; + widget.onMHundChanged(mHund, "nein"); + } else { + widget.onMHundChanged(mHund, mLeine); + } } @override @@ -29,12 +45,9 @@ class HundULeineState extends State { title: Text(AppLocalizations.of(context)!.ja), leading: Radio( value: "ja", - groupValue: _selectedValue, + groupValue: _selectedMHundValue, onChanged: (value) { - setState(() { - _selectedValue = value; - visible = value == "ja" ? true : false; - }); + onValueChanged(value!, _selectedMLeineValue); }, ), ), @@ -43,18 +56,20 @@ class HundULeineState extends State { title: Text(AppLocalizations.of(context)!.nein), leading: Radio( value: "nein", - groupValue: _selectedValue, + groupValue: _selectedMHundValue, onChanged: (value) { - setState(() { - _selectedValue = value; - visible = value == "ja" ? true : false; - }); + onValueChanged(value!, _selectedMLeineValue); }, ), ), if (visible) ...[ TextField( controller: controller, + onChanged: (value) { + onValueChanged("ja", _selectedMLeineValue); + }, + decoration: + InputDecoration(hintText: AppLocalizations.of(context)!.name), ), Text(AppLocalizations.of(context)!.mLeine), ListTile( @@ -62,12 +77,9 @@ class HundULeineState extends State { title: Text(AppLocalizations.of(context)!.ja), leading: Radio( value: "ja", - groupValue: _selectedValue, + groupValue: _selectedMLeineValue, onChanged: (value) { - setState(() { - _selectedValue = value; - widget.onMHundChanged(value!); - }); + onValueChanged("ja", value!); }, ), ), @@ -76,12 +88,9 @@ class HundULeineState extends State { title: Text(AppLocalizations.of(context)!.nein), leading: Radio( value: "nein", - groupValue: _selectedValue, + groupValue: _selectedMLeineValue, onChanged: (value) { - setState(() { - _selectedValue = value; - widget.onMHundChanged(value!); - }); + onValueChanged("ja", value!); }, ), ),