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