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:
dahoud
2026-01-10 10:43:17 +00:00
parent 06031b01f2
commit 92612abbd7
321 changed files with 43137 additions and 4285 deletions

View File

@@ -1,47 +1,215 @@
import 'package:flutter/material.dart';
import '../../../core/constants/colors.dart';
import '../../../data/models/social_post_model.dart';
class SocialInteractionRow extends StatelessWidget {
import '../../core/constants/design_system.dart';
import '../../domain/entities/social_post.dart';
import 'animated_widgets.dart';
/// Widget de barre d'interactions pour les posts sociaux.
///
/// Affiche les boutons Like, Comment, Share et Bookmark avec animations.
class SocialInteractionRow extends StatefulWidget {
const SocialInteractionRow({
required this.post,
required this.onLike,
required this.onComment,
required this.onShare,
super.key,
});
final SocialPost post;
final VoidCallback onLike;
final VoidCallback onComment;
final VoidCallback onShare;
const SocialInteractionRow({
Key? key,
required this.post,
required this.onLike,
required this.onComment,
required this.onShare,
}) : super(key: key);
@override
State<SocialInteractionRow> createState() => _SocialInteractionRowState();
}
class _SocialInteractionRowState extends State<SocialInteractionRow>
with SingleTickerProviderStateMixin {
late AnimationController _likeController;
bool _isBookmarked = false;
@override
void initState() {
super.initState();
_likeController = AnimationController(
duration: const Duration(milliseconds: 400),
vsync: this,
);
if (widget.post.isLikedByCurrentUser) {
_likeController.value = 1.0;
}
}
@override
void didUpdateWidget(SocialInteractionRow oldWidget) {
super.didUpdateWidget(oldWidget);
if (widget.post.isLikedByCurrentUser != oldWidget.post.isLikedByCurrentUser) {
if (widget.post.isLikedByCurrentUser) {
_likeController.forward();
} else {
_likeController.reverse();
}
}
}
@override
void dispose() {
_likeController.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
final theme = Theme.of(context);
return Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: [
Expanded(
child: _buildIconButton(Icons.thumb_up_alt_outlined, 'Jaime', post.likes, onLike),
),
Expanded(
child: _buildIconButton(Icons.comment_outlined, 'Commentaires', post.comments, onComment),
),
Expanded(
child: _buildIconButton(Icons.share_outlined, 'Partages', post.shares, onShare),
),
_buildLikeButton(theme),
const SizedBox(width: DesignSystem.spacingLg),
_buildCommentButton(theme),
const SizedBox(width: DesignSystem.spacingLg),
_buildShareButton(theme),
const Spacer(),
_buildBookmarkButton(theme),
],
);
}
Widget _buildIconButton(IconData icon, String label, int count, VoidCallback onPressed) {
return TextButton.icon(
onPressed: onPressed,
icon: Icon(icon, color: AppColors.accentColor, size: 18),
label: Text(
'$label ($count)',
style: const TextStyle(color: Colors.white70, fontSize: 12),
overflow: TextOverflow.ellipsis,
/// Construit le bouton Like avec animation
Widget _buildLikeButton(ThemeData theme) {
final isLiked = widget.post.isLikedByCurrentUser;
return AnimatedScaleButton(
onTap: () {
if (isLiked) {
_likeController.reverse();
} else {
_likeController.forward();
}
widget.onLike();
},
scaleFactor: 0.8,
child: Padding(
padding: const EdgeInsets.symmetric(
horizontal: DesignSystem.spacingSm,
vertical: DesignSystem.spacingSm,
),
child: Row(
mainAxisSize: MainAxisSize.min,
children: [
AnimatedBuilder(
animation: _likeController,
builder: (context, child) {
return Stack(
alignment: Alignment.center,
children: [
// Cercle d'effet de like
if (_likeController.value > 0)
Container(
width: 26 + (8 * _likeController.value),
height: 26 + (8 * _likeController.value),
decoration: BoxDecoration(
shape: BoxShape.circle,
color: Colors.red.withOpacity(
0.2 * (1 - _likeController.value),
),
),
),
// Icône de coeur avec animation
Transform.scale(
scale: 1 + (_likeController.value * 0.2),
child: Icon(
isLiked ? Icons.favorite_rounded : Icons.favorite_border_rounded,
size: 26,
color: isLiked
? Colors.red
: theme.colorScheme.onSurface.withOpacity(0.7),
),
),
],
);
},
),
],
),
),
);
}
/// Construit le bouton Commentaire
Widget _buildCommentButton(ThemeData theme) {
return AnimatedScaleButton(
onTap: widget.onComment,
scaleFactor: 0.85,
child: Padding(
padding: const EdgeInsets.symmetric(
horizontal: DesignSystem.spacingSm,
vertical: DesignSystem.spacingSm,
),
child: Icon(
Icons.chat_bubble_outline_rounded,
size: 26,
color: theme.colorScheme.onSurface.withOpacity(0.7),
),
),
);
}
/// Construit le bouton Partage
Widget _buildShareButton(ThemeData theme) {
return AnimatedScaleButton(
onTap: widget.onShare,
scaleFactor: 0.85,
child: Padding(
padding: const EdgeInsets.symmetric(
horizontal: DesignSystem.spacingSm,
vertical: DesignSystem.spacingSm,
),
child: Icon(
Icons.send_outlined,
size: 26,
color: theme.colorScheme.onSurface.withOpacity(0.7),
),
),
);
}
/// Construit le bouton Bookmark
Widget _buildBookmarkButton(ThemeData theme) {
return AnimatedScaleButton(
onTap: () {
setState(() {
_isBookmarked = !_isBookmarked;
});
},
scaleFactor: 0.85,
child: Padding(
padding: const EdgeInsets.symmetric(
horizontal: DesignSystem.spacingSm,
vertical: DesignSystem.spacingSm,
),
child: AnimatedSwitcher(
duration: DesignSystem.durationFast,
transitionBuilder: (child, animation) {
return ScaleTransition(
scale: animation,
child: child,
);
},
child: Icon(
_isBookmarked
? Icons.bookmark_rounded
: Icons.bookmark_border_rounded,
key: ValueKey<bool>(_isBookmarked),
size: 26,
color: _isBookmarked
? theme.colorScheme.primary
: theme.colorScheme.onSurface.withOpacity(0.7),
),
),
),
);
}