// lib/presentation/screens/post_preview/post_preview_screen.dart import 'dart:convert'; import 'package:flutter/material.dart'; import '../../../repositories/ai_repository.dart'; import '../../widgets/creation_flow_layout.dart'; // --- ACTION 1 : CRÉER LA CLASSE D'ARGUMENTS MANQUANTE --- // Cette classe encapsule toutes les données nécessaires pour cet écran. class PostPreviewArguments { PostPreviewArguments({ required this.imageBase64, required this.text, required this.aiRepository, }); final String imageBase64; final String text; final AiRepository aiRepository; } // --- ACTION 2 : ADAPTER L'ÉCRAN POUR UTILISER LA CLASSE D'ARGUMENTS --- final class PostPreviewScreen extends StatelessWidget { const PostPreviewScreen({required this.arguments, // Le constructeur est simplifié, super.key,, super.key, }); // L'écran attend maintenant un seul objet 'arguments' final PostPreviewArguments arguments; @override Widget build(BuildContext context) => CreationFlowLayout( // Adaptez ce chiffre au nombre total d'étapes de votre flux. currentStep: 6, title: 'Aperçu & Publication', child: SingleChildScrollView( padding: const EdgeInsets.all(16), child: Column( children: [ // Widget de carte simulant un post de réseau social Card( clipBehavior: Clip.antiAlias, elevation: 4, shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(12), ), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ // L'image du post Image.memory( // On accède aux données via l'objet 'arguments' base64Decode(arguments.imageBase64), width: double.infinity, height: 350, fit: BoxFit.cover, ), // Le texte final du post Padding( padding: const EdgeInsets.all(16), child: Text( // On accède aux données via l'objet 'arguments' arguments.text, style: const TextStyle(fontSize: 16), ), ), // Barre d'actions (inchangée) Padding( padding: const EdgeInsets.symmetric( horizontal: 16, vertical: 8), child: Row( mainAxisAlignment: MainAxisAlignment.spaceAround, children: [ Icon(Icons.favorite_border, color: Theme.of(context) .colorScheme .onSurface .withOpacity(0.6)), Icon(Icons.mode_comment_outlined, color: Theme.of(context) .colorScheme .onSurface .withOpacity(0.6)), Icon(Icons.send_outlined, color: Theme.of(context) .colorScheme .onSurface .withOpacity(0.6)), ], ), ), ], ), ), const SizedBox(height: 24), // Bouton final de publication SizedBox( width: double.infinity, child: FilledButton.icon( onPressed: () { // La logique de publication utilise maintenant les arguments // arguments.aiRepository.publishPost( // image: arguments.imageBase64, // text: arguments.text, // ); ScaffoldMessenger.of(context).showSnackBar( const SnackBar( content: Text('Publication simulée avec succès !'), backgroundColor: Colors.green, ), ); // Potentiellement, naviguer vers l'accueil après publication // Navigator.of(context).popUntil((route) => route.isFirst); }, icon: const Icon(Icons.check_circle_outline), label: const Text('Publier maintenant'), style: FilledButton.styleFrom( padding: const EdgeInsets.symmetric(vertical: 16), ), ), ), ], ), ), ); }