redone hund u leine
removed name field, fixed a bug and fixed value reset error
This commit is contained in:
@@ -224,13 +224,11 @@ class _ExcursionMainState extends State<ExcursionMain> {
|
||||
required: false,
|
||||
dbDesignation: DatabasesEnum.excursion,
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
const SizedBox(height: 20),
|
||||
// ---------- Dog(leash)
|
||||
HundULeine(
|
||||
onMHundChanged: (mHund, mLeine) {
|
||||
rmap["MHund"]!["controller"]!.text = mHund;
|
||||
rmap["MLeine"]!["controller"]!.text = mLeine;
|
||||
},
|
||||
mHund: rmap["MHund"]!["controller"]!,
|
||||
mLeine: rmap["MLeine"]!["controller"]!,
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
// ---------- State
|
||||
@@ -391,6 +389,7 @@ class _ExcursionMainState extends State<ExcursionMain> {
|
||||
// welpenAnz: rmap["WelpenAnz"]!["controller"]!,
|
||||
// wpSicher: rmap["WpSicher"]!["controller"]!,
|
||||
),
|
||||
const Divider(),
|
||||
const SizedBox(height: 20),
|
||||
// ---------- Counts
|
||||
Anzahlen(
|
||||
|
||||
@@ -4,35 +4,45 @@ import 'package:fforte/l10n/app_localizations.dart';
|
||||
class HundULeine extends StatefulWidget {
|
||||
// 1. with dog (ja, bzw name oder nein) 2. with leash
|
||||
// if nothing selected null
|
||||
final Function(String, String) onMHundChanged;
|
||||
final TextEditingController mHund;
|
||||
final TextEditingController mLeine;
|
||||
|
||||
const HundULeine({super.key, required this.onMHundChanged});
|
||||
const HundULeine({super.key, required this.mHund, required this.mLeine});
|
||||
|
||||
@override
|
||||
HundULeineState createState() => HundULeineState();
|
||||
}
|
||||
|
||||
class HundULeineState extends State<HundULeine> {
|
||||
String? _selectedMHundValue;
|
||||
String _selectedMLeineValue = "nein";
|
||||
TextEditingController controller = TextEditingController();
|
||||
late String _selectedMHundValue;
|
||||
late String _selectedMLeineValue;
|
||||
bool visible = false;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
if (widget.mHund.text == "") {
|
||||
_selectedMHundValue = "nein";
|
||||
} else {
|
||||
_selectedMHundValue = widget.mHund.text;
|
||||
}
|
||||
|
||||
if (widget.mLeine.text == "") {
|
||||
_selectedMLeineValue = "nein";
|
||||
} else {
|
||||
_selectedMLeineValue = widget.mLeine.text;
|
||||
}
|
||||
|
||||
super.initState();
|
||||
}
|
||||
|
||||
void onValueChanged(String mHund, String mLeine) {
|
||||
setState(() {
|
||||
visible = mHund == "ja" ? true : false;
|
||||
_selectedMHundValue = mHund;
|
||||
_selectedMLeineValue = mLeine;
|
||||
widget.mHund.text = mHund;
|
||||
widget.mLeine.text = mLeine;
|
||||
});
|
||||
|
||||
if (mHund != "nein" && controller.text != "") mHund = controller.text;
|
||||
|
||||
if (mHund == "nein") {
|
||||
_selectedMHundValue = "nein";
|
||||
widget.onMHundChanged(mHund, "nein");
|
||||
} else {
|
||||
widget.onMHundChanged(mHund, mLeine);
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -41,7 +51,8 @@ class HundULeineState extends State<HundULeine> {
|
||||
children: [
|
||||
Align(
|
||||
alignment: Alignment.bottomLeft,
|
||||
child: Text(AppLocalizations.of(context)!.mHund)),
|
||||
child: Text(AppLocalizations.of(context)!.mHund),
|
||||
),
|
||||
ListTile(
|
||||
visualDensity: const VisualDensity(vertical: -4),
|
||||
title: Text(AppLocalizations.of(context)!.ja),
|
||||
@@ -60,20 +71,23 @@ class HundULeineState extends State<HundULeine> {
|
||||
value: "nein",
|
||||
groupValue: _selectedMHundValue,
|
||||
onChanged: (value) {
|
||||
onValueChanged(value!, _selectedMLeineValue);
|
||||
onValueChanged(value!, "nein");
|
||||
},
|
||||
),
|
||||
),
|
||||
if (visible) ...[
|
||||
TextField(
|
||||
controller: controller,
|
||||
onChanged: (value) {
|
||||
onValueChanged("ja", _selectedMLeineValue);
|
||||
},
|
||||
decoration:
|
||||
InputDecoration(hintText: AppLocalizations.of(context)!.name),
|
||||
// TextField(
|
||||
// controller: controller,
|
||||
// onChanged: (value) {
|
||||
// onValueChanged("ja", _selectedMLeineValue);
|
||||
// },
|
||||
// decoration:
|
||||
// InputDecoration(hintText: AppLocalizations.of(context)!.name),
|
||||
// ),
|
||||
Align(
|
||||
alignment: Alignment.bottomLeft,
|
||||
child: Text(AppLocalizations.of(context)!.mLeine),
|
||||
),
|
||||
Text(AppLocalizations.of(context)!.mLeine),
|
||||
ListTile(
|
||||
visualDensity: const VisualDensity(vertical: -4),
|
||||
title: Text(AppLocalizations.of(context)!.ja),
|
||||
@@ -96,7 +110,7 @@ class HundULeineState extends State<HundULeine> {
|
||||
},
|
||||
),
|
||||
),
|
||||
]
|
||||
],
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user