// * Widget for recording wildlife track findings during excursions // * Features: // * - Track presence recording // * - Track length measurement // * - Animal count estimation // * - Confidence level indication // * - Separate tracking for cubs/pups // * - Nested visibility based on selections import 'package:flutter/material.dart'; import 'package:fforte/l10n/app_localizations.dart'; /// Widget for managing wildlife track findings and measurements /// Includes options for both adult and cub/pup tracks class SpurGefunden extends StatefulWidget { /// Controller for track presence status final TextEditingController spurFund; /// Controller for total track length final TextEditingController spurLang; /// Controller for estimated number of animals final TextEditingController spurTiere; /// Controller for track identification confidence final TextEditingController spSicher; /// Controller for cub/pup track length final TextEditingController welpenSp; /// Controller for estimated number of cubs/pups final TextEditingController welpenAnz; /// Controller for cub/pup track identification confidence 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(); } /// State class for the track findings widget class _SpurGefundenState extends State { /// Whether any tracks were found late bool _spurFundChecked; /// Whether adult track identification is confident bool _spSicher = false; /// Whether cub/pup track identification is confident bool _wpSicher = false; /// Whether cub/pup tracks were found late bool _welpenSpFundChecked; @override void initState() { // Initialize track finding states 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: [ // Track presence checkbox Row( children: [ Text(AppLocalizations.of(context)!.spurGefunden), Checkbox( value: _spurFundChecked, onChanged: (val) { setState(() { _spurFundChecked = val ?? false; widget.spurFund.text = val ?? false ? "Spur" : ""; }); }, ), ], ), // Track details section (visible when tracks found) Visibility( visible: _spurFundChecked, child: Column( children: [ // Total track length input 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, ), ), ], ), // Estimated animal count input 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, ), ), ], ), // Track identification confidence Row( children: [ Text(AppLocalizations.of(context)!.sicher), Checkbox( value: _spSicher, onChanged: (val) { setState(() { _spSicher = val ?? false; widget.spSicher.text = _spSicher ? "sicher" : "unsicher"; }); }, ), ], ), // Cub/pup track presence checkbox Row( children: [ Text(AppLocalizations.of(context)!.welpenSpurGefunden), Checkbox( value: _welpenSpFundChecked, onChanged: (val) { setState(() { _welpenSpFundChecked = val ?? false; }); }, ), ], ), // Cub/pup track details section Visibility( visible: _welpenSpFundChecked, child: Column( children: [ // Cub/pup track length input 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, ), ), ], ), // Estimated cub/pup count input 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, ), ), ], ), // Cub/pup track identification confidence Row( children: [ Text(AppLocalizations.of(context)!.sicher), Checkbox( value: _wpSicher, onChanged: (val) { setState(() { _wpSicher = val ?? false; widget.spSicher.text = _spSicher ? "sicher" : "unsicher"; }); }, ), ], ), ], ), ), ], ), ), ], ); } }