119 lines
3.4 KiB
Dart
119 lines
3.4 KiB
Dart
import 'package:flutter/material.dart';
|
|
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 TextEditingController mHund;
|
|
final TextEditingController mLeine;
|
|
|
|
const HundULeine({super.key, required this.mHund, required this.mLeine});
|
|
|
|
@override
|
|
HundULeineState createState() => HundULeineState();
|
|
}
|
|
|
|
class HundULeineState extends State<HundULeine> {
|
|
late String _selectedMHundValue;
|
|
late String _selectedMLeineValue;
|
|
bool visible = false;
|
|
|
|
@override
|
|
void initState() {
|
|
if (widget.mHund.text == "") {
|
|
_selectedMHundValue = "nein";
|
|
} else {
|
|
_selectedMHundValue = widget.mHund.text;
|
|
visible = true;
|
|
}
|
|
|
|
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;
|
|
});
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Column(
|
|
children: [
|
|
Align(
|
|
alignment: Alignment.bottomLeft,
|
|
child: Text(AppLocalizations.of(context)!.mHund),
|
|
),
|
|
ListTile(
|
|
visualDensity: const VisualDensity(vertical: -4),
|
|
title: Text(AppLocalizations.of(context)!.ja),
|
|
leading: Radio<String>(
|
|
value: "ja",
|
|
groupValue: _selectedMHundValue,
|
|
onChanged: (value) {
|
|
onValueChanged(value!, _selectedMLeineValue);
|
|
},
|
|
),
|
|
),
|
|
ListTile(
|
|
visualDensity: const VisualDensity(vertical: -4),
|
|
title: Text(AppLocalizations.of(context)!.nein),
|
|
leading: Radio<String>(
|
|
value: "nein",
|
|
groupValue: _selectedMHundValue,
|
|
onChanged: (value) {
|
|
onValueChanged(value!, "nein");
|
|
},
|
|
),
|
|
),
|
|
if (visible) ...[
|
|
// 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),
|
|
),
|
|
ListTile(
|
|
visualDensity: const VisualDensity(vertical: -4),
|
|
title: Text(AppLocalizations.of(context)!.ja),
|
|
leading: Radio<String>(
|
|
value: "ja",
|
|
groupValue: _selectedMLeineValue,
|
|
onChanged: (value) {
|
|
onValueChanged("ja", value!);
|
|
},
|
|
),
|
|
),
|
|
ListTile(
|
|
visualDensity: const VisualDensity(vertical: -4),
|
|
title: Text(AppLocalizations.of(context)!.nein),
|
|
leading: Radio<String>(
|
|
value: "nein",
|
|
groupValue: _selectedMLeineValue,
|
|
onChanged: (value) {
|
|
onValueChanged("ja", value!);
|
|
},
|
|
),
|
|
),
|
|
],
|
|
],
|
|
);
|
|
}
|
|
}
|