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:
112
lib/presentation/widgets/requests_tab.dart
Normal file
112
lib/presentation/widgets/requests_tab.dart
Normal file
@@ -0,0 +1,112 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
import '../../../data/providers/friends_provider.dart';
|
||||
import 'friend_request_card.dart';
|
||||
import 'requests_empty_state.dart';
|
||||
import 'requests_loading_state.dart';
|
||||
import 'requests_section_header.dart';
|
||||
|
||||
/// Onglet affichant les demandes d'amitié reçues et envoyées.
|
||||
class RequestsTab extends StatelessWidget {
|
||||
const RequestsTab({
|
||||
required this.onAccept,
|
||||
required this.onReject,
|
||||
required this.onCancel,
|
||||
required this.onRefresh,
|
||||
super.key,
|
||||
});
|
||||
|
||||
final Future<void> Function(FriendsProvider, String) onAccept;
|
||||
final Future<void> Function(FriendsProvider, String) onReject;
|
||||
final Future<void> Function(FriendsProvider, String) onCancel;
|
||||
final VoidCallback onRefresh;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final theme = Theme.of(context);
|
||||
|
||||
return Consumer<FriendsProvider>(
|
||||
builder: (context, provider, child) {
|
||||
final isLoading =
|
||||
provider.isLoadingReceivedRequests || provider.isLoadingSentRequests;
|
||||
final hasReceived = provider.receivedRequests.isNotEmpty;
|
||||
final hasSent = provider.sentRequests.isNotEmpty;
|
||||
|
||||
if (isLoading && !hasReceived && !hasSent) {
|
||||
return RequestsLoadingState(theme: theme);
|
||||
}
|
||||
|
||||
if (!hasReceived && !hasSent) {
|
||||
return RefreshIndicator(
|
||||
onRefresh: () async {
|
||||
await Future.wait([
|
||||
provider.fetchReceivedRequests(),
|
||||
provider.fetchSentRequests(),
|
||||
]);
|
||||
},
|
||||
child: SingleChildScrollView(
|
||||
physics: const AlwaysScrollableScrollPhysics(),
|
||||
child: SizedBox(
|
||||
height: MediaQuery.of(context).size.height - 300,
|
||||
child: RequestsEmptyState(theme: theme),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
return _buildRequestsList(theme, provider);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
/// Construit la liste des demandes.
|
||||
Widget _buildRequestsList(ThemeData theme, FriendsProvider provider) {
|
||||
return RefreshIndicator(
|
||||
onRefresh: () async {
|
||||
await Future.wait([
|
||||
provider.fetchReceivedRequests(),
|
||||
provider.fetchSentRequests(),
|
||||
]);
|
||||
},
|
||||
child: ListView(
|
||||
physics: const AlwaysScrollableScrollPhysics(),
|
||||
padding: const EdgeInsets.symmetric(vertical: 8),
|
||||
children: [
|
||||
if (provider.receivedRequests.isNotEmpty) ...[
|
||||
RequestsSectionHeader(
|
||||
title: 'Demandes reçues',
|
||||
theme: theme,
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
...provider.receivedRequests.map(
|
||||
(request) => FriendRequestCard(
|
||||
request: request,
|
||||
onAccept: () => onAccept(provider, request.friendshipId),
|
||||
onReject: () => onReject(provider, request.friendshipId),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 24),
|
||||
],
|
||||
if (provider.sentRequests.isNotEmpty) ...[
|
||||
RequestsSectionHeader(
|
||||
title: 'Demandes envoyées',
|
||||
theme: theme,
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
...provider.sentRequests.map(
|
||||
(request) => FriendRequestCard(
|
||||
request: request,
|
||||
onAccept: null,
|
||||
onReject: () => onCancel(provider, request.friendshipId),
|
||||
isSentRequest: true,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
],
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user