// * Widget for selecting the timing of last precipitation // * Features: // * - Dropdown menu for time selection // * - Multiple predefined time ranges // * - Localized time descriptions // * Available time ranges: // * - Currently raining // * - Same morning // * - Last night // * - Previous day/evening // * - 2-3 days ago // * - 4-6 days ago // * - 1 week or more import 'package:flutter/material.dart'; import 'package:fforte/l10n/app_localizations.dart'; /// Widget for recording when the last precipitation occurred /// Used to track weather conditions during wildlife monitoring class LetzterNiederschlag extends StatefulWidget { /// Controller for storing the selected precipitation timing final TextEditingController controller; const LetzterNiederschlag({super.key, required this.controller}); @override LetzterNiederschlagState createState() => LetzterNiederschlagState(); } /// State class for the last precipitation selection widget class LetzterNiederschlagState extends State { /// Currently selected precipitation timing value late String? selectedValue; @override void initState() { // Initialize selection from controller if (widget.controller.text == "") { selectedValue = null; } else { selectedValue = widget.controller.text; } super.initState(); } @override Widget build(BuildContext context) { return DropdownButton( isExpanded: true, value: selectedValue, hint: Text(AppLocalizations.of(context)!.letzterNiederschlag), onChanged: (String? newValue) { setState(() { selectedValue = newValue; widget.controller.text = newValue ?? ""; }); }, items: [ // Currently raining option DropdownMenuItem( value: "aktuell", child: Text(AppLocalizations.of(context)!.aktuell), ), // Same morning option DropdownMenuItem( value: "am selben Morgen", child: Text(AppLocalizations.of(context)!.selberMorgen), ), // Last night option DropdownMenuItem( value: "in der Nacht", child: Text(AppLocalizations.of(context)!.letzteNacht), ), // Previous day/evening option DropdownMenuItem( value: "am Tag oder Abend zuvor", child: Text(AppLocalizations.of(context)!.vortag), ), // 2-3 days ago option DropdownMenuItem( value: "vor 2 bis 3 Tagen", child: Text(AppLocalizations.of(context)!.vor23Tagen), ), // 4-6 days ago option DropdownMenuItem( value: "vor 4 bis 6 Tagen", child: Text(AppLocalizations.of(context)!.vor46Tagen), ), // 1 week or more option DropdownMenuItem( value: ">=1 Woche", child: Text(AppLocalizations.of(context)!.vor1Woche), ), ], ); } }