import 'package:flutter/material.dart'; import 'package:fforte/l10n/app_localizations.dart'; class SpurGefunden extends StatefulWidget { final TextEditingController spurFund; final TextEditingController spurLang; final TextEditingController spurTiere; final TextEditingController spSicher; final TextEditingController welpenSp; final TextEditingController welpenAnz; final TextEditingController wpSicher; const SpurGefunden({ super.key, required this.spurFund, required this.spurLang, required this.spurTiere, required this.spSicher, required this.welpenSp, required this.welpenAnz, required this.wpSicher, }); @override State createState() => _SpurGefundenState(); } class _SpurGefundenState extends State { late bool _spurFundChecked; bool _spSicher = false; bool _wpSicher = false; late bool _welpenSpFundChecked; @override void initState() { if (widget.spurFund.text == "") { _spurFundChecked = false; _welpenSpFundChecked = false; } else { _spurFundChecked = true; _welpenSpFundChecked = true; if (widget.wpSicher.text != "") { _wpSicher = true; } if (widget.spSicher.text != "") { _spSicher = true; } } super.initState(); } @override Widget build(BuildContext context) { return Column( children: [ Row( children: [ Text(AppLocalizations.of(context)!.spurGefunden), Checkbox( value: _spurFundChecked, onChanged: (val) { setState(() { _spurFundChecked = val ?? false; widget.spurFund.text = val ?? false ? "Spur" : ""; }); }, ), // Text(AppLocalizations.of(context)!.welpenSpurGefunden), // Checkbox( // value: _welpenSpFundChecked, // onChanged: (val) { // setState(() { // _welpenSpFundChecked = val ?? false; // widget.welpenSp.text = val ?? false ? "WelpenSp" : ""; // }); // }, // ), ], ), Visibility( visible: _spurFundChecked, child: Column( children: [ Row( children: [ Expanded( flex: 7, child: Align( alignment: Alignment.bottomLeft, child: Text( AppLocalizations.of(context)!.gesLaengeAllerDokSpuren, ), ), ), Expanded( flex: 2, child: TextField( keyboardType: TextInputType.number, controller: widget.spurLang, ), ), ], ), // const SizedBox(height: 10), Row( children: [ Expanded( flex: 7, child: Align( alignment: Alignment.bottomLeft, child: Text( AppLocalizations.of( context, )!.maxAnzahlZusGefaehrdeterTiere, ), ), ), Expanded( flex: 2, child: TextField( keyboardType: TextInputType.number, controller: widget.spurTiere, ), ), ], ), Row( children: [ Text(AppLocalizations.of(context)!.sicher), Checkbox( value: _spSicher, onChanged: (val) { setState(() { _spSicher = val ?? false; widget.spSicher.text = _spSicher ? "sicher" : "unsicher"; }); }, ), ], ), // const SizedBox(height: 10), Row( children: [ Text(AppLocalizations.of(context)!.welpenSpurGefunden), Checkbox( value: _welpenSpFundChecked, onChanged: (val) { setState(() { _welpenSpFundChecked = val ?? false; }); }, ), ], ), Visibility( visible: _welpenSpFundChecked, child: Column( children: [ Row( children: [ Expanded( flex: 7, child: Align( alignment: Alignment.bottomLeft, child: Text( AppLocalizations.of( context, )!.gesLaengeAllerDokWelpenSpuren, ), ), ), Expanded( flex: 2, child: TextField( keyboardType: TextInputType.number, controller: widget.welpenSp, ), ), ], ), // const SizedBox(height: 10), Row( children: [ Expanded( flex: 7, child: Align( alignment: Alignment.bottomLeft, child: Text( AppLocalizations.of( context, )!.maxAnzahlZusGefaehrdeterTiere, ), ), ), Expanded( flex: 2, child: TextField( keyboardType: TextInputType.number, controller: widget.welpenAnz, ), ), ], ), Row( children: [ Text(AppLocalizations.of(context)!.sicher), Checkbox( value: _wpSicher, onChanged: (val) { setState(() { _wpSicher = val ?? false; widget.spSicher.text = _spSicher ? "sicher" : "unsicher"; }); }, ), ], ), ], ), ), ], ), ), ], ); } }