// * Widget for selecting the sampling type for camera trap monitoring // * Features: // * - Two sampling modes: opportunistic and systematic // * - Radio button selection interface // * - State management for selection // * - Callback for selection changes import 'package:flutter/material.dart'; import 'package:fforte/l10n/app_localizations.dart'; /// Widget for managing sampling type selection /// Provides choice between opportunistic and systematic sampling class STTyp extends StatefulWidget { /// Callback function when sampling type changes final Function(String) onSTTypChanged; /// Initial sampling type value final String initialSTTyp; const STTyp( {super.key, required this.onSTTypChanged, this.initialSTTyp = 'opportunistisch'}); @override State createState() => _STTypState(); } /// State class for the sampling type selection widget class _STTypState extends State { /// Currently selected sampling type String? _selectedSTTyp; @override void initState() { super.initState(); _selectedSTTyp = widget.initialSTTyp; } @override Widget build(BuildContext context) { return Column( children: [ // Opportunistic sampling option ListTile( visualDensity: const VisualDensity(vertical: -4), title: Text(AppLocalizations.of(context)!.opportunistisch), leading: Radio( value: 'opportunistisch', groupValue: _selectedSTTyp, onChanged: (value) { setState(() { _selectedSTTyp = value; widget.onSTTypChanged(value!); }); }, ), ), // Systematic sampling option ListTile( visualDensity: const VisualDensity(vertical: -4), title: Text(AppLocalizations.of(context)!.systematisch), leading: Radio( value: 'systematisch', groupValue: _selectedSTTyp, onChanged: (value) { setState(() { _selectedSTTyp = value; widget.onSTTypChanged(value!); }); }, ), ), ], ); } }