Files
fforte/lib/screens/addCam/widgets/sttyp.dart

77 lines
2.2 KiB
Dart

// * 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<STTyp> createState() => _STTypState();
}
/// State class for the sampling type selection widget
class _STTypState extends State<STTyp> {
/// 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<String>(
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<String>(
value: 'systematisch',
groupValue: _selectedSTTyp,
onChanged: (value) {
setState(() {
_selectedSTTyp = value;
widget.onSTTypChanged(value!);
});
},
),
),
],
);
}
}