let AI comment everything because well... yeah...

This commit is contained in:
Nico
2025-06-06 21:00:32 +02:00
parent 9c84d0c375
commit cc110ac104
44 changed files with 1230 additions and 646 deletions

View File

@@ -1,9 +1,24 @@
// * Widget for managing wildlife observation hints and indicators
// * Features:
// * - Checkbox selection for common observation types
// * - Custom text input for additional observations
// * - Automatic text aggregation of selected items
// * Available observation types:
// * - Resting places (Liegestelle)
// * - Animal carcasses (Wildtierkadaver)
// * - Direct sightings (Sichtung)
// * - Howling (Heulen)
// * - Other observations (Sonstiges)
import 'package:fforte/enums/databases.dart';
import 'package:fforte/screens/sharedWidgets/var_text_field.dart';
import 'package:flutter/material.dart';
import 'package:fforte/l10n/app_localizations.dart';
/// Widget for recording various types of wildlife observations
/// Combines predefined categories with custom input options
class Hinweise extends StatefulWidget {
/// Controller for the combined observation text
final TextEditingController hinweise;
const Hinweise({super.key, required this.hinweise});
@@ -11,21 +26,29 @@ class Hinweise extends StatefulWidget {
@override
State<Hinweise> createState() => _HinweiseState();
}
class _HinweiseState extends State<Hinweise> {
// Vars for Checkboxes
late bool liegestelleChecked;
late bool kadaverChecked;
late bool sichtungChecked;
late bool heulenChecked;
bool sonstigesChecked = false;
// for sonstiges textfield
/// State class for the observations widget
class _HinweiseState extends State<Hinweise> {
// Checkbox state variables
/// Whether resting place was observed
late bool liegestelleChecked;
/// Whether animal carcass was found
late bool kadaverChecked;
/// Whether direct sighting occurred
late bool sichtungChecked;
/// Whether howling was heard
late bool heulenChecked;
/// Whether other observations exist
bool sonstigesChecked = false;
/// Controller for additional observations text
TextEditingController sonstigesController = TextEditingController();
@override
void initState() {
sonstigesController.addListener(updateController);
// Initialize checkboxes based on existing text
liegestelleChecked = widget.hinweise.text.contains("Liegestelle") ? true : false;
kadaverChecked = widget.hinweise.text.contains("Wildtierkadaver") ? true : false;
sichtungChecked = widget.hinweise.text.contains("Sichtung") ? true : false;
@@ -33,6 +56,7 @@ class _HinweiseState extends State<Hinweise> {
bool firstRun = true;
// Parse existing other observations
for (String val in widget.hinweise.text.split(",")) {
if (val != "Liegestelle" && val != "Wildtierkadaver" && val != "Sichtung" && val != "Heulen" && val != "") {
sonstigesChecked = true;
@@ -51,6 +75,8 @@ class _HinweiseState extends State<Hinweise> {
super.dispose();
}
/// Update the main controller text based on selected options
/// Combines all checked items and additional text into a comma-separated string
void updateController() {
Map<String, bool> props = {
"Liegestelle": liegestelleChecked,
@@ -63,6 +89,7 @@ class _HinweiseState extends State<Hinweise> {
widget.hinweise.text = "";
// Build combined text from selected options
for (String key in props.keys) {
if (!firstRun && props[key]!) {
widget.hinweise.text += ",";
@@ -74,7 +101,6 @@ class _HinweiseState extends State<Hinweise> {
} else if (props[key]!){
widget.hinweise.text += key;
}
}
debugPrint(widget.hinweise.text);
}
@@ -83,6 +109,7 @@ class _HinweiseState extends State<Hinweise> {
Widget build(BuildContext context) {
return Column(
children: [
// Resting place checkbox
CheckboxListTile(
title: Text(AppLocalizations.of(context)!.liegestelle),
value: liegestelleChecked,
@@ -90,6 +117,7 @@ class _HinweiseState extends State<Hinweise> {
setState(() => liegestelleChecked = value ?? false);
updateController();
}),
// Animal carcass checkbox
CheckboxListTile(
title: Text(AppLocalizations.of(context)!.wildtierKadaver),
value: kadaverChecked,
@@ -97,6 +125,7 @@ class _HinweiseState extends State<Hinweise> {
setState(() => kadaverChecked = value ?? false);
updateController();
}),
// Direct sighting checkbox
CheckboxListTile(
title: Text(AppLocalizations.of(context)!.sichtung),
value: sichtungChecked,
@@ -104,6 +133,7 @@ class _HinweiseState extends State<Hinweise> {
setState(() => sichtungChecked = value ?? false);
updateController();
}),
// Howling checkbox
CheckboxListTile(
title: Text(AppLocalizations.of(context)!.heulen),
value: heulenChecked,
@@ -111,6 +141,7 @@ class _HinweiseState extends State<Hinweise> {
setState(() => heulenChecked = value ?? false);
updateController();
}),
// Other observations checkbox and input field
CheckboxListTile(
title: Text(AppLocalizations.of(context)!.sonstiges),
value: sonstigesChecked,