Files
fforte/lib/screens/excursion/widgets/letzter_niederschlag.dart

98 lines
2.9 KiB
Dart

// * 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<LetzterNiederschlag> {
/// 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<String>(
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<String>(
value: "aktuell",
child: Text(AppLocalizations.of(context)!.aktuell),
),
// Same morning option
DropdownMenuItem<String>(
value: "am selben Morgen",
child: Text(AppLocalizations.of(context)!.selberMorgen),
),
// Last night option
DropdownMenuItem<String>(
value: "in der Nacht",
child: Text(AppLocalizations.of(context)!.letzteNacht),
),
// Previous day/evening option
DropdownMenuItem<String>(
value: "am Tag oder Abend zuvor",
child: Text(AppLocalizations.of(context)!.vortag),
),
// 2-3 days ago option
DropdownMenuItem<String>(
value: "vor 2 bis 3 Tagen",
child: Text(AppLocalizations.of(context)!.vor23Tagen),
),
// 4-6 days ago option
DropdownMenuItem<String>(
value: "vor 4 bis 6 Tagen",
child: Text(AppLocalizations.of(context)!.vor46Tagen),
),
// 1 week or more option
DropdownMenuItem<String>(
value: ">=1 Woche",
child: Text(AppLocalizations.of(context)!.vor1Woche),
),
],
);
}
}