fix(chat): Correction race condition + Implémentation TODOs
## Corrections Critiques ### Race Condition - Statuts de Messages - Fix : Les icônes de statut (✓, ✓✓, ✓✓ bleu) ne s'affichaient pas - Cause : WebSocket delivery confirmations arrivaient avant messages locaux - Solution : Pattern Optimistic UI dans chat_bloc.dart - Création message temporaire immédiate - Ajout à la liste AVANT requête HTTP - Remplacement par message serveur à la réponse - Fichier : lib/presentation/state_management/chat_bloc.dart ## Implémentation TODOs (13/21) ### Social (social_header_widget.dart) - ✅ Copier lien du post dans presse-papiers - ✅ Partage natif via Share.share() - ✅ Dialogue de signalement avec 5 raisons ### Partage (share_post_dialog.dart) - ✅ Interface sélection d'amis avec checkboxes - ✅ Partage externe via Share API ### Média (media_upload_service.dart) - ✅ Parsing JSON réponse backend - ✅ Méthode deleteMedia() pour suppression - ✅ Génération miniature vidéo ### Posts (create_post_dialog.dart, edit_post_dialog.dart) - ✅ Extraction URL depuis uploads - ✅ Documentation chargement médias ### Chat (conversations_screen.dart) - ✅ Navigation vers notifications - ✅ ConversationSearchDelegate pour recherche ## Nouveaux Fichiers ### Configuration - build-prod.ps1 : Script build production avec dart-define - lib/core/constants/env_config.dart : Gestion environnements ### Documentation - TODOS_IMPLEMENTED.md : Documentation complète TODOs ## Améliorations ### Architecture - Refactoring injection de dépendances - Amélioration routing et navigation - Optimisation providers (UserProvider, FriendsProvider) ### UI/UX - Amélioration thème et couleurs - Optimisation animations - Meilleure gestion erreurs ### Services - Configuration API avec env_config - Amélioration datasources (events, users) - Optimisation modèles de données
This commit is contained in:
@@ -1,34 +1,158 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
/// Champ de sélection d'image avec aperçu et support du thème.
|
||||
///
|
||||
/// Ce widget fournit un champ de sélection d'image cohérent avec le design system,
|
||||
/// avec support de l'aperçu de l'image sélectionnée.
|
||||
///
|
||||
/// **Usage:**
|
||||
/// ```dart
|
||||
/// ImagePickerField(
|
||||
/// label: 'Image de l\'événement',
|
||||
/// imagePath: selectedImagePath,
|
||||
/// onImagePicked: () {
|
||||
/// // Ouvrir le sélecteur d'image
|
||||
/// },
|
||||
/// )
|
||||
/// ```
|
||||
class ImagePickerField extends StatelessWidget {
|
||||
/// Crée un nouveau [ImagePickerField].
|
||||
///
|
||||
/// [onImagePicked] La fonction appelée pour ouvrir le sélecteur d'image
|
||||
/// [imagePath] Le chemin de l'image sélectionnée (optionnel)
|
||||
/// [label] Le texte du label (par défaut: 'Sélectionnez une image')
|
||||
/// [imageUrl] L'URL de l'image (optionnel, prioritaire sur imagePath)
|
||||
const ImagePickerField({
|
||||
required this.onImagePicked,
|
||||
super.key,
|
||||
this.imagePath,
|
||||
this.imageUrl,
|
||||
this.label = 'Sélectionnez une image',
|
||||
});
|
||||
|
||||
/// Le chemin de l'image sélectionnée
|
||||
final String? imagePath;
|
||||
|
||||
/// L'URL de l'image (prioritaire sur imagePath)
|
||||
final String? imageUrl;
|
||||
|
||||
/// La fonction appelée pour ouvrir le sélecteur d'image
|
||||
final VoidCallback onImagePicked;
|
||||
|
||||
const ImagePickerField({Key? key, this.imagePath, required this.onImagePicked}) : super(key: key);
|
||||
/// Le texte du label
|
||||
final String label;
|
||||
|
||||
/// Retourne true si une image est sélectionnée
|
||||
bool get hasImage => (imageUrl != null && imageUrl!.isNotEmpty) ||
|
||||
(imagePath != null && imagePath!.isNotEmpty);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return GestureDetector(
|
||||
final theme = Theme.of(context);
|
||||
|
||||
return InkWell(
|
||||
onTap: onImagePicked,
|
||||
borderRadius: BorderRadius.circular(16),
|
||||
child: Container(
|
||||
padding: const EdgeInsets.symmetric(vertical: 12.0, horizontal: 16.0),
|
||||
padding: const EdgeInsets.all(16),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white.withOpacity(0.1),
|
||||
borderRadius: BorderRadius.circular(10.0),
|
||||
color: theme.colorScheme.surface,
|
||||
borderRadius: BorderRadius.circular(16),
|
||||
border: Border.all(
|
||||
color: hasImage
|
||||
? theme.colorScheme.primary
|
||||
: theme.colorScheme.outline.withOpacity(0.5),
|
||||
width: hasImage ? 2 : 1,
|
||||
),
|
||||
),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text(
|
||||
imagePath == null
|
||||
? 'Sélectionnez une image'
|
||||
: 'Image sélectionnée: $imagePath',
|
||||
style: const TextStyle(color: Colors.white70),
|
||||
// Aperçu de l'image si disponible
|
||||
if (hasImage)
|
||||
Container(
|
||||
width: 60,
|
||||
height: 60,
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
image: imageUrl != null && imageUrl!.isNotEmpty
|
||||
? DecorationImage(
|
||||
image: NetworkImage(imageUrl!),
|
||||
fit: BoxFit.cover,
|
||||
onError: (exception, stackTrace) {
|
||||
// En cas d'erreur de chargement, afficher une icône
|
||||
},
|
||||
)
|
||||
: imagePath != null && imagePath!.isNotEmpty
|
||||
? DecorationImage(
|
||||
image: AssetImage(imagePath!),
|
||||
fit: BoxFit.cover,
|
||||
)
|
||||
: null,
|
||||
),
|
||||
child: imageUrl == null &&
|
||||
imagePath == null
|
||||
? Icon(
|
||||
Icons.image,
|
||||
color: theme.colorScheme.primary,
|
||||
size: 30,
|
||||
)
|
||||
: null,
|
||||
)
|
||||
else
|
||||
Container(
|
||||
width: 60,
|
||||
height: 60,
|
||||
decoration: BoxDecoration(
|
||||
color: theme.colorScheme.primary.withOpacity(0.1),
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
),
|
||||
child: Icon(
|
||||
Icons.add_photo_alternate,
|
||||
color: theme.colorScheme.primary,
|
||||
size: 30,
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 16),
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
if (hasImage)
|
||||
Text(
|
||||
'Image sélectionnée',
|
||||
style: theme.textTheme.bodySmall?.copyWith(
|
||||
color: theme.colorScheme.onSurface.withOpacity(0.6),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 4),
|
||||
Text(
|
||||
hasImage
|
||||
? (imageUrl ?? imagePath ?? 'Image')
|
||||
: label,
|
||||
style: theme.textTheme.bodyLarge?.copyWith(
|
||||
color: hasImage
|
||||
? theme.colorScheme.onSurface
|
||||
: theme.colorScheme.onSurface.withOpacity(0.6),
|
||||
fontWeight: hasImage ? FontWeight.w600 : FontWeight.normal,
|
||||
),
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 12),
|
||||
Icon(
|
||||
hasImage ? Icons.edit : Icons.photo_camera,
|
||||
color: hasImage
|
||||
? theme.colorScheme.primary
|
||||
: theme.colorScheme.onSurface.withOpacity(0.6),
|
||||
size: 24,
|
||||
),
|
||||
const Icon(Icons.image, color: Colors.white70),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user