You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

132 line
4.7KB

  1. // lib/presentation/screens/post_preview/post_preview_screen.dart
  2. import 'dart:convert';
  3. import 'package:flutter/material.dart';
  4. import '../../../repositories/ai_repository.dart';
  5. import '../../widgets/creation_flow_layout.dart';
  6. // --- ACTION 1 : CRÉER LA CLASSE D'ARGUMENTS MANQUANTE ---
  7. // Cette classe encapsule toutes les données nécessaires pour cet écran.
  8. class PostPreviewArguments {
  9. final String imageBase64;
  10. final String text;
  11. final AiRepository aiRepository;
  12. PostPreviewArguments({
  13. required this.imageBase64,
  14. required this.text,
  15. required this.aiRepository,
  16. });
  17. }
  18. // --- ACTION 2 : ADAPTER L'ÉCRAN POUR UTILISER LA CLASSE D'ARGUMENTS ---
  19. final class PostPreviewScreen extends StatelessWidget {
  20. // L'écran attend maintenant un seul objet 'arguments'
  21. final PostPreviewArguments arguments;
  22. const PostPreviewScreen({
  23. super.key,
  24. required this.arguments, // Le constructeur est simplifié
  25. });
  26. @override
  27. Widget build(BuildContext context) {
  28. return CreationFlowLayout(
  29. // Adaptez ce chiffre au nombre total d'étapes de votre flux.
  30. currentStep: 6,
  31. title: "Aperçu & Publication",
  32. child: SingleChildScrollView(
  33. padding: const EdgeInsets.all(16.0),
  34. child: Column(
  35. children: [
  36. // Widget de carte simulant un post de réseau social
  37. Card(
  38. clipBehavior: Clip.antiAlias,
  39. elevation: 4,
  40. shape: RoundedRectangleBorder(
  41. borderRadius: BorderRadius.circular(12),
  42. ),
  43. child: Column(
  44. crossAxisAlignment: CrossAxisAlignment.start,
  45. children: [
  46. // L'image du post
  47. Image.memory(
  48. // On accède aux données via l'objet 'arguments'
  49. base64Decode(arguments.imageBase64),
  50. width: double.infinity,
  51. height: 350,
  52. fit: BoxFit.cover,
  53. ),
  54. // Le texte final du post
  55. Padding(
  56. padding: const EdgeInsets.all(16.0),
  57. child: Text(
  58. // On accède aux données via l'objet 'arguments'
  59. arguments.text,
  60. style: const TextStyle(fontSize: 16),
  61. ),
  62. ),
  63. // Barre d'actions (inchangée)
  64. Padding(
  65. padding: const EdgeInsets.symmetric(
  66. horizontal: 16.0, vertical: 8.0),
  67. child: Row(
  68. mainAxisAlignment: MainAxisAlignment.spaceAround,
  69. children: [
  70. Icon(Icons.favorite_border,
  71. color: Theme.of(context)
  72. .colorScheme
  73. .onSurface
  74. .withOpacity(0.6)),
  75. Icon(Icons.mode_comment_outlined,
  76. color: Theme.of(context)
  77. .colorScheme
  78. .onSurface
  79. .withOpacity(0.6)),
  80. Icon(Icons.send_outlined,
  81. color: Theme.of(context)
  82. .colorScheme
  83. .onSurface
  84. .withOpacity(0.6)),
  85. ],
  86. ),
  87. ),
  88. ],
  89. ),
  90. ),
  91. const SizedBox(height: 24),
  92. // Bouton final de publication
  93. SizedBox(
  94. width: double.infinity,
  95. child: FilledButton.icon(
  96. onPressed: () {
  97. // La logique de publication utilise maintenant les arguments
  98. // arguments.aiRepository.publishPost(
  99. // image: arguments.imageBase64,
  100. // text: arguments.text,
  101. // );
  102. ScaffoldMessenger.of(context).showSnackBar(
  103. const SnackBar(
  104. content: Text('Publication simulée avec succès !'),
  105. backgroundColor: Colors.green,
  106. ),
  107. );
  108. // Potentiellement, naviguer vers l'accueil après publication
  109. // Navigator.of(context).popUntil((route) => route.isFirst);
  110. },
  111. icon: const Icon(Icons.check_circle_outline),
  112. label: const Text('Publier maintenant'),
  113. style: FilledButton.styleFrom(
  114. padding: const EdgeInsets.symmetric(vertical: 16),
  115. ),
  116. ),
  117. ),
  118. ],
  119. ),
  120. ),
  121. );
  122. }
  123. }