small updates

This commit is contained in:
2026-10-27 14:03:31 +01:00
parent 3b50cb0fe9
commit 9d9e0c77f2
8 changed files with 391 additions and 356 deletions
+20 -71
View File
@@ -7,7 +7,9 @@ import 'yolo_detector.dart';
import 'preview_screen.dart';
import '../utils/translations.dart';
import '../utils/target_colors.dart';
import '../services/app_settings.dart';
import '../widgets/camera_sheet.dart';
import '../widgets/help_sheet.dart';
class CameraScreen extends StatefulWidget {
const CameraScreen({super.key});
@@ -113,8 +115,9 @@ class _CameraScreenState extends State<CameraScreen> {
Future<void> _loadBulletCount() async {
final prefs = await SharedPreferences.getInstance();
setState(() {
_numberOfBullets = prefs.getInt('bulletCount') ??
5; // Load stored bullet count, default to 5
// Older versions allowed up to 10
_numberOfBullets = (prefs.getInt('bulletCount') ?? AppSettings.maxBullets)
.clamp(AppSettings.minBullets, AppSettings.maxBullets);
});
}
@@ -203,11 +206,13 @@ class _CameraScreenState extends State<CameraScreen> {
mainAxisSize: MainAxisSize.min,
children: [
CameraSheetHeader(
title: _t('Select the number of bullets'), subtitle: '1 – 10'),
title: _t('Select the number of bullets'),
subtitle:
'${AppSettings.minBullets} – ${AppSettings.maxBullets}'),
SheetStepper(
value: _numberOfBullets,
min: 1,
max: 10,
min: AppSettings.minBullets,
max: AppSettings.maxBullets,
accent: _bulletColor,
onChanged: (n) {
_selectBulletCount(n);
@@ -222,71 +227,15 @@ class _CameraScreenState extends State<CameraScreen> {
}
void _showHelpDialog() {
showDialog(
context: context,
builder: (BuildContext context) {
return Dialog(
backgroundColor: Colors.grey[900],
shape:
RoundedRectangleBorder(borderRadius: BorderRadius.circular(16)),
child: Padding(
padding: const EdgeInsets.all(24.0),
child: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
_t('Help'),
style: const TextStyle(
color: Colors.white,
fontSize: 24,
fontWeight: FontWeight.bold),
),
const SizedBox(height: 20),
_buildHelpItem(Icons.camera_alt,
_t('Tap camera button to capture and detect bullets')),
const SizedBox(height: 12),
_buildHelpItem(Icons.filter_9_plus,
_t('Bottom left number: Set expected bullet count (1-5)')),
const SizedBox(height: 12),
_buildHelpItem(Icons.tune,
_t('Settings icon: exposure, zoom and flashlight')),
const SizedBox(height: 12),
_buildHelpItem(Icons.crop_square,
_t('Align target inside the square frame')),
const SizedBox(height: 20),
Center(
child: ElevatedButton(
onPressed: () => Navigator.of(context).pop(),
style: ElevatedButton.styleFrom(
backgroundColor: _bulletColor,
foregroundColor: Colors.white,
),
child: Text(_t('Got it!')),
),
),
],
),
),
);
},
);
}
Widget _buildHelpItem(IconData icon, String text) {
return Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Icon(icon, color: _bulletColor, size: 20),
const SizedBox(width: 12),
Expanded(
child: Text(
text,
style: const TextStyle(color: Colors.white, fontSize: 14),
),
),
],
);
showHelpSheet(context, accent: _bulletColor, t: _t, items: const [
(Icons.crop_square, 'Align the target inside the square frame.'),
(
Icons.camera_alt,
'Camera button: take a photo. Bullets are detected and you can check and save the result.'
),
(Icons.filter_5_rounded, 'Number bottom left: shots per target (1–5).'),
(Icons.tune, 'Settings icon: exposure, zoom and flashlight.'),
]);
}
void _showCameraControls() {
@@ -406,7 +355,7 @@ class _CameraScreenState extends State<CameraScreen> {
centerTitle: true,
actions: [
IconButton(
icon: const Icon(Icons.help_outline, color: Colors.white),
icon: const Icon(Icons.info_outline_rounded, color: Colors.white),
onPressed: _showHelpDialog,
),
const SizedBox(width: 16),