finished mHund u mLeine fields

This commit is contained in:
Nico
2024-12-27 20:16:28 +01:00
parent e14cc401ad
commit 1ed257de27
4 changed files with 64 additions and 39 deletions

View File

@@ -115,5 +115,6 @@
"geschaeftsliegenschaftAGV": "Geschäftsliegenschaft/AGV", "geschaeftsliegenschaftAGV": "Geschäftsliegenschaft/AGV",
"kein": "Kein", "kein": "Kein",
"mHund": "Hund dabei", "mHund": "Hund dabei",
"mLeine": "Mit Leine" "mLeine": "Mit Leine",
"name": "Name"
} }

View File

@@ -567,9 +567,16 @@
"mLeine": "With Dog leash", "mLeine": "With Dog leash",
"@mLeine": { "@mLeine": {
"description": "mLeine radiobutten" "description": "mLeine radiobutten"
},
"name": "Name",
"@name": {
"description": "name text field"
} }
} }

View File

@@ -1,5 +1,6 @@
import 'package:animations/animations.dart'; import 'package:animations/animations.dart';
import 'package:fforte/screens/Excursion/widgets/bima_nutzer.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/datum.dart';
import 'package:fforte/screens/sharedWidgets/var_text_field.dart'; import 'package:fforte/screens/sharedWidgets/var_text_field.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
@@ -46,6 +47,7 @@ class _ExcursionMainState extends State<ExcursionMain> {
title: Text(AppLocalizations.of(context)!.dateandtime), title: Text(AppLocalizations.of(context)!.dateandtime),
content: Column( content: Column(
children: [ children: [
// TODO onDateChanged
Datum(initDatum: DateTime.now(), onDateChanged: (date) {}), Datum(initDatum: DateTime.now(), onDateChanged: (date) {}),
const SizedBox( const SizedBox(
height: 10, height: 10,
@@ -62,21 +64,27 @@ class _ExcursionMainState extends State<ExcursionMain> {
textController: getTextFields()["Teilnehm"]!, textController: getTextFields()["Teilnehm"]!,
localization: AppLocalizations.of(context)!.teilnehmer, localization: AppLocalizations.of(context)!.teilnehmer,
dbName: "Teilnehm", dbName: "Teilnehm",
required: false, required: false,
), ),
const SizedBox( const SizedBox(
height: 10, height: 10,
), ),
VarTextField( VarTextField(
textController: getTextFields()["Dauer"]!, textController: getTextFields()["Dauer"]!,
localization: AppLocalizations.of(context)!.dauer, localization: AppLocalizations.of(context)!.dauer,
dbName: "Dauer", dbName: "Dauer",
required: false), required: false),
const SizedBox( const SizedBox(
height: 10, height: 10,
), ),
// Hund u Leine HundULeine(onMHundChanged: (mHund, mLeine) {
getTextFields()["MHund"]!.text = mHund;
getTextFields()["MLeine"]!.text = mLeine;
print(mHund);
print(mLeine);
}),
const SizedBox( const SizedBox(
height: 10, height: 10,

View File

@@ -2,7 +2,9 @@ import 'package:flutter/material.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart'; import 'package:flutter_gen/gen_l10n/app_localizations.dart';
class HundULeine extends StatefulWidget { 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}); const HundULeine({super.key, required this.onMHundChanged});
@@ -11,12 +13,26 @@ class HundULeine extends StatefulWidget {
} }
class HundULeineState extends State<HundULeine> { class HundULeineState extends State<HundULeine> {
String? _selectedValue; String? _selectedMHundValue;
String _selectedMLeineValue = "nein";
TextEditingController controller = TextEditingController(); TextEditingController controller = TextEditingController();
bool visible = false; 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 @override
@@ -29,12 +45,9 @@ class HundULeineState extends State<HundULeine> {
title: Text(AppLocalizations.of(context)!.ja), title: Text(AppLocalizations.of(context)!.ja),
leading: Radio<String>( leading: Radio<String>(
value: "ja", value: "ja",
groupValue: _selectedValue, groupValue: _selectedMHundValue,
onChanged: (value) { onChanged: (value) {
setState(() { onValueChanged(value!, _selectedMLeineValue);
_selectedValue = value;
visible = value == "ja" ? true : false;
});
}, },
), ),
), ),
@@ -43,18 +56,20 @@ class HundULeineState extends State<HundULeine> {
title: Text(AppLocalizations.of(context)!.nein), title: Text(AppLocalizations.of(context)!.nein),
leading: Radio<String>( leading: Radio<String>(
value: "nein", value: "nein",
groupValue: _selectedValue, groupValue: _selectedMHundValue,
onChanged: (value) { onChanged: (value) {
setState(() { onValueChanged(value!, _selectedMLeineValue);
_selectedValue = value;
visible = value == "ja" ? true : false;
});
}, },
), ),
), ),
if (visible) ...[ if (visible) ...[
TextField( TextField(
controller: controller, controller: controller,
onChanged: (value) {
onValueChanged("ja", _selectedMLeineValue);
},
decoration:
InputDecoration(hintText: AppLocalizations.of(context)!.name),
), ),
Text(AppLocalizations.of(context)!.mLeine), Text(AppLocalizations.of(context)!.mLeine),
ListTile( ListTile(
@@ -62,12 +77,9 @@ class HundULeineState extends State<HundULeine> {
title: Text(AppLocalizations.of(context)!.ja), title: Text(AppLocalizations.of(context)!.ja),
leading: Radio<String>( leading: Radio<String>(
value: "ja", value: "ja",
groupValue: _selectedValue, groupValue: _selectedMLeineValue,
onChanged: (value) { onChanged: (value) {
setState(() { onValueChanged("ja", value!);
_selectedValue = value;
widget.onMHundChanged(value!);
});
}, },
), ),
), ),
@@ -76,12 +88,9 @@ class HundULeineState extends State<HundULeine> {
title: Text(AppLocalizations.of(context)!.nein), title: Text(AppLocalizations.of(context)!.nein),
leading: Radio<String>( leading: Radio<String>(
value: "nein", value: "nein",
groupValue: _selectedValue, groupValue: _selectedMLeineValue,
onChanged: (value) { onChanged: (value) {
setState(() { onValueChanged("ja", value!);
_selectedValue = value;
widget.onMHundChanged(value!);
});
}, },
), ),
), ),