feat: bouton nuage d'export vers le backend IA dans l'écran d'analyse
This commit is contained in:
@@ -17,6 +17,7 @@ import '../../data/repositories/session_repository.dart';
|
|||||||
import '../../services/target_detection_service.dart';
|
import '../../services/target_detection_service.dart';
|
||||||
import '../../services/score_calculator_service.dart';
|
import '../../services/score_calculator_service.dart';
|
||||||
import '../../services/grouping_analyzer_service.dart';
|
import '../../services/grouping_analyzer_service.dart';
|
||||||
|
import '../../services/wallet_identity_service.dart';
|
||||||
import '../session/session_provider.dart';
|
import '../session/session_provider.dart';
|
||||||
import 'analysis_provider.dart';
|
import 'analysis_provider.dart';
|
||||||
import 'impact_editor_screen.dart';
|
import 'impact_editor_screen.dart';
|
||||||
@@ -257,6 +258,52 @@ class _AnalysisScreenContentState extends State<_AnalysisScreenContent> {
|
|||||||
context.read<AnalysisProvider>().targetType!,
|
context.read<AnalysisProvider>().targetType!,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
// Nuage d'export vers le backend IA : visible uniquement si l'analyse
|
||||||
|
// a réussi ET que l'utilisateur a activé l'option dans les Paramètres.
|
||||||
|
if (!_isCalibrating && !_isSelectingReferences)
|
||||||
|
FutureBuilder<bool>(
|
||||||
|
future: WalletIdentityService().isUploadEnabled(),
|
||||||
|
builder: (context, snapshot) {
|
||||||
|
final isEnabled = snapshot.data ?? false;
|
||||||
|
if (!isEnabled ||
|
||||||
|
provider.state != AnalysisState.success) {
|
||||||
|
return const SizedBox.shrink();
|
||||||
|
}
|
||||||
|
return IconButton(
|
||||||
|
icon: const Icon(Icons.cloud_upload),
|
||||||
|
tooltip: 'Exporter pour IA',
|
||||||
|
onPressed: () async {
|
||||||
|
final p = context.read<AnalysisProvider>();
|
||||||
|
if (p.state != AnalysisState.success) return;
|
||||||
|
|
||||||
|
ScaffoldMessenger.of(context).showSnackBar(
|
||||||
|
const SnackBar(content: Text('Exportation en cours...')),
|
||||||
|
);
|
||||||
|
|
||||||
|
final success = await p.exportToAiBackend();
|
||||||
|
|
||||||
|
if (!context.mounted) return;
|
||||||
|
ScaffoldMessenger.of(context).hideCurrentSnackBar();
|
||||||
|
if (success) {
|
||||||
|
ScaffoldMessenger.of(context).showSnackBar(
|
||||||
|
const SnackBar(
|
||||||
|
content: Text('Export réussi vers le backend IA !'),
|
||||||
|
backgroundColor: AppTheme.successColor,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
ScaffoldMessenger.of(context).showSnackBar(
|
||||||
|
SnackBar(
|
||||||
|
content:
|
||||||
|
Text(p.errorMessage ?? 'Erreur d\'export'),
|
||||||
|
backgroundColor: AppTheme.errorColor,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
if (_isCalibrating)
|
if (_isCalibrating)
|
||||||
TextButton(
|
TextButton(
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
|
|||||||
Reference in New Issue
Block a user