Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

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