## 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
384 lines
11 KiB
Dart
384 lines
11 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:provider/provider.dart';
|
|
|
|
import '../../../core/theme/theme_provider.dart';
|
|
import '../../../data/providers/user_provider.dart';
|
|
import '../../../data/services/secure_storage.dart';
|
|
import '../../widgets/custom_button.dart';
|
|
import '../../widgets/custom_list_tile.dart';
|
|
import '../login/login_screen.dart';
|
|
import '../profile/profile_screen.dart';
|
|
|
|
/// Écran des paramètres avec toutes les options et design moderne.
|
|
///
|
|
/// Cet écran permet de gérer les préférences utilisateur, les notifications,
|
|
/// la sécurité, et d'autres paramètres avec une interface organisée et compacte.
|
|
///
|
|
/// **Fonctionnalités:**
|
|
/// - Gestion du profil et sécurité
|
|
/// - Préférences (thème, langue)
|
|
/// - Notifications
|
|
/// - Aide et support
|
|
/// - Déconnexion
|
|
class SettingsScreen extends StatefulWidget {
|
|
const SettingsScreen({super.key});
|
|
|
|
@override
|
|
State<SettingsScreen> createState() => _SettingsScreenState();
|
|
}
|
|
|
|
class _SettingsScreenState extends State<SettingsScreen> {
|
|
// ============================================================================
|
|
// ÉTATS
|
|
// ============================================================================
|
|
|
|
bool _notificationsEnabled = true;
|
|
bool _locationEnabled = false;
|
|
String _selectedLanguage = 'Français';
|
|
final SecureStorage _secureStorage = SecureStorage();
|
|
|
|
// ============================================================================
|
|
// BUILD
|
|
// ============================================================================
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final theme = Theme.of(context);
|
|
|
|
return Scaffold(
|
|
appBar: AppBar(
|
|
title: const Text('Paramètres'),
|
|
),
|
|
body: ListView(
|
|
padding: const EdgeInsets.symmetric(vertical: 8),
|
|
children: [
|
|
_buildAccountSection(theme),
|
|
_buildPreferencesSection(theme),
|
|
_buildNotificationsSection(theme),
|
|
_buildHelpSection(theme),
|
|
_buildLogoutSection(theme),
|
|
const SizedBox(height: 16),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
|
|
// ============================================================================
|
|
// SECTIONS
|
|
// ============================================================================
|
|
|
|
/// Construit la section compte.
|
|
Widget _buildAccountSection(ThemeData theme) {
|
|
return Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
_buildSectionHeader(theme, 'Compte'),
|
|
CustomListTile(
|
|
icon: Icons.person,
|
|
label: 'Profil',
|
|
subtitle: 'Gérer vos informations personnelles',
|
|
onTap: _handleProfile,
|
|
),
|
|
CustomListTile(
|
|
icon: Icons.security,
|
|
label: 'Sécurité',
|
|
subtitle: 'Mot de passe et authentification',
|
|
onTap: _handleSecurity,
|
|
),
|
|
CustomListTile(
|
|
icon: Icons.privacy_tip,
|
|
label: 'Confidentialité',
|
|
subtitle: 'Contrôler votre vie privée',
|
|
onTap: _handlePrivacy,
|
|
),
|
|
const Divider(height: 32),
|
|
],
|
|
);
|
|
}
|
|
|
|
/// Construit la section préférences.
|
|
Widget _buildPreferencesSection(ThemeData theme) {
|
|
final themeProvider = Provider.of<ThemeProvider>(context);
|
|
|
|
return Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
_buildSectionHeader(theme, 'Préférences'),
|
|
SwitchListTile(
|
|
secondary: Icon(
|
|
Icons.dark_mode,
|
|
color: theme.colorScheme.primary,
|
|
),
|
|
title: const Text('Mode sombre'),
|
|
subtitle: const Text('Activer le thème sombre'),
|
|
value: themeProvider.isDarkMode,
|
|
onChanged: (value) {
|
|
themeProvider.toggleTheme();
|
|
},
|
|
),
|
|
ListTile(
|
|
leading: Icon(Icons.language, color: theme.colorScheme.primary),
|
|
title: const Text('Langue'),
|
|
subtitle: Text(_selectedLanguage),
|
|
trailing: DropdownButton<String>(
|
|
value: _selectedLanguage,
|
|
underline: const SizedBox(),
|
|
items: const [
|
|
DropdownMenuItem(value: 'Français', child: Text('Français')),
|
|
DropdownMenuItem(value: 'English', child: Text('English')),
|
|
],
|
|
onChanged: (value) {
|
|
if (value != null) {
|
|
setState(() {
|
|
_selectedLanguage = value;
|
|
});
|
|
}
|
|
},
|
|
),
|
|
),
|
|
const Divider(height: 32),
|
|
],
|
|
);
|
|
}
|
|
|
|
/// Construit la section notifications.
|
|
Widget _buildNotificationsSection(ThemeData theme) {
|
|
return Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
_buildSectionHeader(theme, 'Notifications'),
|
|
SwitchListTile(
|
|
secondary: Icon(
|
|
Icons.notifications,
|
|
color: theme.colorScheme.primary,
|
|
),
|
|
title: const Text('Notifications push'),
|
|
subtitle: const Text('Recevoir des notifications'),
|
|
value: _notificationsEnabled,
|
|
onChanged: (value) {
|
|
setState(() {
|
|
_notificationsEnabled = value;
|
|
});
|
|
},
|
|
),
|
|
SwitchListTile(
|
|
secondary: Icon(
|
|
Icons.location_on,
|
|
color: theme.colorScheme.primary,
|
|
),
|
|
title: const Text('Localisation'),
|
|
subtitle: const Text('Partager votre localisation'),
|
|
value: _locationEnabled,
|
|
onChanged: (value) {
|
|
setState(() {
|
|
_locationEnabled = value;
|
|
});
|
|
},
|
|
),
|
|
const Divider(height: 32),
|
|
],
|
|
);
|
|
}
|
|
|
|
/// Construit la section aide.
|
|
Widget _buildHelpSection(ThemeData theme) {
|
|
return Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
_buildSectionHeader(theme, 'Aide et Support'),
|
|
CustomListTile(
|
|
icon: Icons.help_outline,
|
|
label: 'Centre d\'aide',
|
|
subtitle: 'FAQ et support',
|
|
onTap: _handleHelp,
|
|
),
|
|
CustomListTile(
|
|
icon: Icons.feedback,
|
|
label: 'Envoyer un commentaire',
|
|
subtitle: 'Partagez vos suggestions',
|
|
onTap: _handleFeedback,
|
|
),
|
|
CustomListTile(
|
|
icon: Icons.info_outline,
|
|
label: 'À propos',
|
|
subtitle: 'Version 1.0.0',
|
|
onTap: _handleAbout,
|
|
),
|
|
const Divider(height: 32),
|
|
],
|
|
);
|
|
}
|
|
|
|
/// Construit la section déconnexion.
|
|
Widget _buildLogoutSection(ThemeData theme) {
|
|
return Padding(
|
|
padding: const EdgeInsets.symmetric(horizontal: 16),
|
|
child: CustomButton(
|
|
text: 'Déconnexion',
|
|
icon: Icons.logout,
|
|
onPressed: _handleLogout,
|
|
variant: ButtonVariant.outlined,
|
|
size: ButtonSize.medium,
|
|
),
|
|
);
|
|
}
|
|
|
|
// ============================================================================
|
|
// WIDGETS UTILITAIRES
|
|
// ============================================================================
|
|
|
|
/// Construit l'en-tête de section.
|
|
Widget _buildSectionHeader(ThemeData theme, String title) {
|
|
return Padding(
|
|
padding: const EdgeInsets.fromLTRB(16, 16, 16, 8),
|
|
child: Text(
|
|
title,
|
|
style: theme.textTheme.titleMedium?.copyWith(
|
|
color: theme.colorScheme.primary,
|
|
fontWeight: FontWeight.bold,
|
|
),
|
|
),
|
|
);
|
|
}
|
|
|
|
// ============================================================================
|
|
// ACTIONS
|
|
// ============================================================================
|
|
|
|
/// Gère la navigation vers le profil.
|
|
void _handleProfile() {
|
|
Navigator.push(
|
|
context,
|
|
MaterialPageRoute(
|
|
builder: (context) => const ProfileScreen(),
|
|
),
|
|
);
|
|
}
|
|
|
|
/// Gère la sécurité.
|
|
void _handleSecurity() {
|
|
_showDialog(
|
|
title: 'Sécurité',
|
|
content: 'Fonctionnalité de sécurité à venir',
|
|
);
|
|
}
|
|
|
|
/// Gère la confidentialité.
|
|
void _handlePrivacy() {
|
|
_showDialog(
|
|
title: 'Confidentialité',
|
|
content: 'Paramètres de confidentialité à venir',
|
|
);
|
|
}
|
|
|
|
/// Gère l'aide.
|
|
void _handleHelp() {
|
|
_showDialog(
|
|
title: 'Centre d\'aide',
|
|
content: 'FAQ et support à venir',
|
|
);
|
|
}
|
|
|
|
/// Gère le feedback.
|
|
void _handleFeedback() {
|
|
_showDialog(
|
|
title: 'Envoyer un commentaire',
|
|
content: 'Formulaire de feedback à venir',
|
|
);
|
|
}
|
|
|
|
/// Gère l'à propos.
|
|
void _handleAbout() {
|
|
showAboutDialog(
|
|
context: context,
|
|
applicationName: 'AfterWork',
|
|
applicationVersion: '1.0.0',
|
|
applicationIcon: const Icon(Icons.event, size: 48),
|
|
children: const [
|
|
Text('Application de gestion d\'événements sociaux'),
|
|
],
|
|
);
|
|
}
|
|
|
|
/// Gère la déconnexion.
|
|
void _handleLogout() {
|
|
showDialog(
|
|
context: context,
|
|
builder: (context) => AlertDialog(
|
|
title: const Text('Déconnexion'),
|
|
content: const Text('Êtes-vous sûr de vouloir vous déconnecter ?'),
|
|
actions: [
|
|
TextButton(
|
|
onPressed: () => Navigator.pop(context),
|
|
child: const Text('Annuler'),
|
|
),
|
|
TextButton(
|
|
onPressed: () async {
|
|
Navigator.pop(context);
|
|
await _performLogout();
|
|
},
|
|
style: TextButton.styleFrom(
|
|
foregroundColor: Theme.of(context).colorScheme.error,
|
|
),
|
|
child: const Text('Déconnexion'),
|
|
),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
|
|
/// Affiche une boîte de dialogue simple.
|
|
void _showDialog({required String title, required String content}) {
|
|
showDialog(
|
|
context: context,
|
|
builder: (context) => AlertDialog(
|
|
title: Text(title),
|
|
content: Text(content),
|
|
actions: [
|
|
TextButton(
|
|
onPressed: () => Navigator.pop(context),
|
|
child: const Text('Fermer'),
|
|
),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
|
|
/// Effectue la déconnexion complète de l'utilisateur.
|
|
Future<void> _performLogout() async {
|
|
try {
|
|
// Réinitialiser le UserProvider
|
|
Provider.of<UserProvider>(context, listen: false).resetUser();
|
|
|
|
// Supprimer toutes les données utilisateur du stockage sécurisé
|
|
await _secureStorage.deleteUserInfo();
|
|
|
|
if (mounted) {
|
|
// Naviguer vers l'écran de connexion
|
|
Navigator.of(context).pushAndRemoveUntil(
|
|
MaterialPageRoute(
|
|
builder: (context) => const LoginScreen(),
|
|
),
|
|
(route) => false,
|
|
);
|
|
|
|
ScaffoldMessenger.of(context).showSnackBar(
|
|
const SnackBar(
|
|
content: Text('Déconnexion réussie'),
|
|
behavior: SnackBarBehavior.floating,
|
|
),
|
|
);
|
|
}
|
|
} catch (e) {
|
|
if (mounted) {
|
|
ScaffoldMessenger.of(context).showSnackBar(
|
|
SnackBar(
|
|
content: Text('Erreur lors de la déconnexion: ${e.toString()}'),
|
|
behavior: SnackBarBehavior.floating,
|
|
),
|
|
);
|
|
}
|
|
}
|
|
}
|
|
}
|