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:
214
lib/presentation/widgets/social/social_badge.dart
Normal file
214
lib/presentation/widgets/social/social_badge.dart
Normal file
@@ -0,0 +1,214 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../../core/constants/design_system.dart';
|
||||
|
||||
/// Badge réutilisable pour les posts sociaux.
|
||||
///
|
||||
/// Design compact et uniforme pour différents types de badges.
|
||||
class SocialBadge extends StatelessWidget {
|
||||
const SocialBadge({
|
||||
required this.label,
|
||||
this.icon,
|
||||
this.color,
|
||||
this.backgroundColor,
|
||||
this.fontSize = 11,
|
||||
this.padding,
|
||||
super.key,
|
||||
});
|
||||
|
||||
final String label;
|
||||
final IconData? icon;
|
||||
final Color? color;
|
||||
final Color? backgroundColor;
|
||||
final double fontSize;
|
||||
final EdgeInsets? padding;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final theme = Theme.of(context);
|
||||
final effectiveColor = color ?? theme.colorScheme.onPrimaryContainer;
|
||||
final effectiveBackgroundColor =
|
||||
backgroundColor ?? theme.colorScheme.primaryContainer;
|
||||
|
||||
return Container(
|
||||
padding: padding ??
|
||||
const EdgeInsets.symmetric(
|
||||
horizontal: DesignSystem.spacingSm,
|
||||
vertical: DesignSystem.spacingXs,
|
||||
),
|
||||
decoration: BoxDecoration(
|
||||
color: effectiveBackgroundColor,
|
||||
borderRadius: BorderRadius.circular(DesignSystem.radiusSm),
|
||||
),
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
if (icon != null) ...[
|
||||
Icon(
|
||||
icon,
|
||||
size: fontSize + 2,
|
||||
color: effectiveColor,
|
||||
),
|
||||
const SizedBox(width: 4),
|
||||
],
|
||||
Text(
|
||||
label,
|
||||
style: TextStyle(
|
||||
fontSize: fontSize,
|
||||
fontWeight: FontWeight.w600,
|
||||
color: effectiveColor,
|
||||
letterSpacing: -0.1,
|
||||
height: 1.2,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// Badge vérifié pour les utilisateurs vérifiés.
|
||||
class VerifiedBadge extends StatelessWidget {
|
||||
const VerifiedBadge({
|
||||
this.size = 16,
|
||||
super.key,
|
||||
});
|
||||
|
||||
final double size;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final theme = Theme.of(context);
|
||||
|
||||
return Tooltip(
|
||||
message: 'Compte vérifié',
|
||||
child: Icon(
|
||||
Icons.verified,
|
||||
size: size,
|
||||
color: theme.colorScheme.primary,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// Badge de catégorie pour les posts.
|
||||
class CategoryBadge extends StatelessWidget {
|
||||
const CategoryBadge({
|
||||
required this.category,
|
||||
this.icon,
|
||||
super.key,
|
||||
});
|
||||
|
||||
final String category;
|
||||
final IconData? icon;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final theme = Theme.of(context);
|
||||
|
||||
return SocialBadge(
|
||||
label: category,
|
||||
icon: icon,
|
||||
backgroundColor: theme.colorScheme.secondaryContainer,
|
||||
color: theme.colorScheme.onSecondaryContainer,
|
||||
fontSize: 10,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// Badge de statut pour les posts (nouveau, tendance, etc.).
|
||||
class StatusBadge extends StatelessWidget {
|
||||
const StatusBadge({
|
||||
required this.status,
|
||||
this.icon,
|
||||
super.key,
|
||||
});
|
||||
|
||||
final String status;
|
||||
final IconData? icon;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final theme = Theme.of(context);
|
||||
|
||||
Color backgroundColor;
|
||||
Color color;
|
||||
|
||||
switch (status.toLowerCase()) {
|
||||
case 'nouveau':
|
||||
case 'new':
|
||||
backgroundColor = theme.colorScheme.primaryContainer;
|
||||
color = theme.colorScheme.onPrimaryContainer;
|
||||
break;
|
||||
case 'tendance':
|
||||
case 'trending':
|
||||
backgroundColor = theme.colorScheme.errorContainer;
|
||||
color = theme.colorScheme.onErrorContainer;
|
||||
break;
|
||||
case 'populaire':
|
||||
case 'popular':
|
||||
backgroundColor = theme.colorScheme.tertiaryContainer;
|
||||
color = theme.colorScheme.onTertiaryContainer;
|
||||
break;
|
||||
default:
|
||||
backgroundColor = theme.colorScheme.surfaceVariant;
|
||||
color = theme.colorScheme.onSurfaceVariant;
|
||||
}
|
||||
|
||||
return SocialBadge(
|
||||
label: status,
|
||||
icon: icon,
|
||||
backgroundColor: backgroundColor,
|
||||
color: color,
|
||||
fontSize: 10,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// Badge de nombre de médias (images/vidéos).
|
||||
class MediaCountBadge extends StatelessWidget {
|
||||
const MediaCountBadge({
|
||||
required this.count,
|
||||
this.isVideo = false,
|
||||
super.key,
|
||||
});
|
||||
|
||||
final int count;
|
||||
final bool isVideo;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final theme = Theme.of(context);
|
||||
|
||||
return Container(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 6,
|
||||
vertical: 3,
|
||||
),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.black.withOpacity(0.7),
|
||||
borderRadius: BorderRadius.circular(DesignSystem.radiusSm),
|
||||
),
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Icon(
|
||||
isVideo ? Icons.play_circle_outline : Icons.image_outlined,
|
||||
size: 12,
|
||||
color: Colors.white,
|
||||
),
|
||||
const SizedBox(width: 3),
|
||||
Text(
|
||||
count.toString(),
|
||||
style: const TextStyle(
|
||||
fontSize: 10,
|
||||
fontWeight: FontWeight.w600,
|
||||
color: Colors.white,
|
||||
height: 1.2,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user