Fix: Passage à l'appareil photo classique et suppression de l'auto-capture
This commit is contained in:
@@ -2,7 +2,6 @@ import 'dart:io';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:image_picker/image_picker.dart';
|
||||
import 'package:permission_handler/permission_handler.dart';
|
||||
import 'package:google_mlkit_document_scanner/google_mlkit_document_scanner.dart';
|
||||
import 'package:device_info_plus/device_info_plus.dart';
|
||||
|
||||
import 'package:provider/provider.dart';
|
||||
@@ -26,7 +25,6 @@ class _CaptureScreenState extends State<CaptureScreen> {
|
||||
String? _selectedImagePath;
|
||||
bool _isLoading = false;
|
||||
|
||||
/// Gère la demande de permission et la sélection d'image depuis la galerie
|
||||
Future<void> _handleGallerySelection() async {
|
||||
PermissionStatus status;
|
||||
|
||||
@@ -83,8 +81,8 @@ class _CaptureScreenState extends State<CaptureScreen> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final sessionProvider = context.watch<SessionProvider>();
|
||||
final title = sessionProvider.isSessionActive
|
||||
? 'Cible ${sessionProvider.targetCount + 1}'
|
||||
final title = sessionProvider.isSessionActive
|
||||
? 'Cible ${sessionProvider.targetCount + 1}'
|
||||
: 'Source';
|
||||
|
||||
return Scaffold(
|
||||
@@ -104,7 +102,8 @@ class _CaptureScreenState extends State<CaptureScreen> {
|
||||
child: ImageSourceButton(
|
||||
icon: Icons.camera_alt,
|
||||
label: 'Scanner',
|
||||
onPressed: _isLoading ? null : _scanDocument,
|
||||
// Appelle maintenant l'appareil photo classique
|
||||
onPressed: _isLoading ? null : _openStandardCamera,
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 12),
|
||||
@@ -143,10 +142,6 @@ class _CaptureScreenState extends State<CaptureScreen> {
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Widget _buildGuide() {
|
||||
return Card(
|
||||
child: Padding(
|
||||
@@ -192,25 +187,17 @@ class _CaptureScreenState extends State<CaptureScreen> {
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> _scanDocument() async {
|
||||
setState(() => _isLoading = true);
|
||||
try {
|
||||
final options = DocumentScannerOptions(
|
||||
documentFormat: DocumentFormat.jpeg,
|
||||
mode: ScannerMode.base,
|
||||
pageLimit: 1,
|
||||
isGalleryImport: false,
|
||||
);
|
||||
final scanner = DocumentScanner(options: options);
|
||||
final documents = await scanner.scanDocument();
|
||||
if (documents.images.isNotEmpty) {
|
||||
_selectedImagePath = documents.images.first;
|
||||
_analyzeImage();
|
||||
// NOUVELLE FONCTION : Ouvre l'appareil photo classique 100% Manuel
|
||||
Future<void> _openStandardCamera() async {
|
||||
final status = await Permission.camera.request();
|
||||
if (status.isGranted) {
|
||||
_captureImage(ImageSource.camera);
|
||||
} else {
|
||||
if (mounted) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
const SnackBar(content: Text('Accès à l\'appareil photo requis')),
|
||||
);
|
||||
}
|
||||
} catch (e) {
|
||||
debugPrint('Erreur scan: $e');
|
||||
} finally {
|
||||
if (mounted) setState(() => _isLoading = false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -224,7 +211,10 @@ class _CaptureScreenState extends State<CaptureScreen> {
|
||||
imageQuality: 90,
|
||||
);
|
||||
if (image != null) {
|
||||
_selectedImagePath = image.path;
|
||||
setState(() {
|
||||
_selectedImagePath = image.path;
|
||||
});
|
||||
// On appelle directement l'analyse avec le bon chemin de fichier
|
||||
_analyzeImage();
|
||||
}
|
||||
} catch (e) {
|
||||
@@ -236,6 +226,8 @@ class _CaptureScreenState extends State<CaptureScreen> {
|
||||
|
||||
void _analyzeImage() {
|
||||
if (_selectedImagePath == null) return;
|
||||
|
||||
// Correction de la redirection pour ouvrir proprement le CropScreen
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
@@ -246,4 +238,4 @@ class _CaptureScreenState extends State<CaptureScreen> {
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -193,7 +193,7 @@ class _SessionSetupScreenState extends State<SessionSetupScreen> {
|
||||
|
||||
// Shots per target
|
||||
const Text(
|
||||
'Nombre de balles par cible',
|
||||
'Nombre de balles pour la cible actuelle',
|
||||
style: TextStyle(fontSize: 16, fontWeight: FontWeight.w500),
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
|
||||
Reference in New Issue
Block a user