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,394 +1,545 @@
import 'dart:async';
import 'package:afterwork/data/datasources/user_remote_data_source.dart';
import 'package:afterwork/data/models/user_model.dart';
import 'package:afterwork/data/services/preferences_helper.dart';
import 'package:afterwork/data/services/secure_storage.dart';
import 'package:flutter/material.dart';
import 'package:http/http.dart' as http;
import 'package:loading_icon_button/loading_icon_button.dart';
import 'package:provider/provider.dart';
import '../../../core/theme/theme_provider.dart';
/// Écran d'inscription pour l'application AfterWork.
/// Permet à l'utilisateur de créer un nouveau compte avec des champs comme nom, prénom, email, mot de passe.
import '../../../core/constants/env_config.dart';
import '../../../core/theme/theme_provider.dart';
import '../../../core/utils/validators.dart';
import '../../../data/datasources/user_remote_data_source.dart';
import '../../../data/models/user_model.dart';
import '../../../data/services/preferences_helper.dart';
import '../../../data/services/secure_storage.dart';
import '../../widgets/custom_button.dart';
import '../login/login_screen.dart';
/// Écran d'inscription avec design moderne et compact.
///
/// Cet écran permet aux utilisateurs de créer un nouveau compte avec
/// validation des champs, gestion d'erreurs, et interface optimisée.
///
/// **Fonctionnalités:**
/// - Validation des champs en temps réel
/// - Vérification de correspondance des mots de passe
/// - Affichage/masquage du mot de passe
/// - Gestion d'erreurs robuste
/// - Support du thème clair/sombre
class SignUpScreen extends StatefulWidget {
const SignUpScreen({super.key});
@override
_SignUpScreenState createState() => _SignUpScreenState();
State<SignUpScreen> createState() => _SignUpScreenState();
}
class _SignUpScreenState extends State<SignUpScreen> {
final _formKey = GlobalKey<FormState>(); // Clé pour valider le formulaire
class _SignUpScreenState extends State<SignUpScreen>
with SingleTickerProviderStateMixin {
// ============================================================================
// FORMULAIRE
// ============================================================================
// Champs utilisateur
String _nom = ''; // Nom de l'utilisateur
String _prenoms = ''; // Prénom de l'utilisateur
String _email = ''; // Email de l'utilisateur
String _password = ''; // Mot de passe de l'utilisateur
String _confirmPassword = ''; // Confirmation du mot de passe
final _formKey = GlobalKey<FormState>();
final _lastNameController = TextEditingController();
final _firstNameController = TextEditingController();
final _emailController = TextEditingController();
final _passwordController = TextEditingController();
final _confirmPasswordController = TextEditingController();
// États de gestion
bool _isPasswordVisible = false; // Pour afficher/masquer le mot de passe
bool _isSubmitting = false; // Indicateur pour l'état de soumission du formulaire
bool _showErrorMessage = false; // Affichage des erreurs
// ============================================================================
// ÉTATS
// ============================================================================
// Services pour les opérations
final UserRemoteDataSource _userRemoteDataSource = UserRemoteDataSource(http.Client());
final SecureStorage _secureStorage = SecureStorage();
final PreferencesHelper _preferencesHelper = PreferencesHelper();
bool _isPasswordVisible = false;
bool _isSubmitting = false;
String? _errorMessage;
// Contrôleur pour le bouton de chargement
final _btnController = LoadingButtonController();
// ============================================================================
// SERVICES
// ============================================================================
late final UserRemoteDataSource _userRemoteDataSource;
late final SecureStorage _secureStorage;
late final PreferencesHelper _preferencesHelper;
// ============================================================================
// ANIMATIONS
// ============================================================================
late AnimationController _animationController;
late Animation<double> _fadeAnimation;
@override
void initState() {
super.initState();
_initializeServices();
_initializeAnimations();
}
void _initializeServices() {
_userRemoteDataSource = UserRemoteDataSource(http.Client());
_secureStorage = SecureStorage();
_preferencesHelper = PreferencesHelper();
}
void _initializeAnimations() {
_animationController = AnimationController(
vsync: this,
duration: const Duration(milliseconds: 800),
);
_fadeAnimation = CurvedAnimation(
parent: _animationController,
curve: Curves.easeIn,
);
_animationController.forward();
}
@override
void dispose() {
_btnController.reset();
_lastNameController.dispose();
_firstNameController.dispose();
_emailController.dispose();
_passwordController.dispose();
_confirmPasswordController.dispose();
_animationController.dispose();
super.dispose();
}
/// Fonction pour basculer la visibilité du mot de passe
// ============================================================================
// ACTIONS
// ============================================================================
/// Bascule la visibilité du mot de passe.
void _togglePasswordVisibility() {
setState(() {
_isPasswordVisible = !_isPasswordVisible;
});
print("Visibilité du mot de passe basculée: $_isPasswordVisible");
}
Future<void> _submit() async {
print("Tentative de soumission du formulaire d'inscription.");
/// Soumet le formulaire d'inscription.
Future<void> _handleSubmit() async {
if (!_formKey.currentState!.validate()) {
return;
}
if (_formKey.currentState!.validate()) {
// Vérifier la correspondance des mots de passe
if (_passwordController.text != _confirmPasswordController.text) {
setState(() {
_isSubmitting = true;
_showErrorMessage = false;
_errorMessage = 'Les mots de passe ne correspondent pas';
});
_formKey.currentState!.save();
return;
}
// Vérifier si le mot de passe et la confirmation correspondent
if (_password != _confirmPassword) {
setState(() {
_showErrorMessage = true;
});
print("Les mots de passe ne correspondent pas.");
_btnController.reset();
return;
}
setState(() {
_isSubmitting = true;
_errorMessage = null;
});
try {
_btnController.start();
try {
final user = UserModel(
userId: '',
userLastName: _lastNameController.text.trim(),
userFirstName: _firstNameController.text.trim(),
email: _emailController.text.trim(),
motDePasse: _passwordController.text,
profileImageUrl: '',
);
// Créer l'utilisateur avec les informations fournies
final UserModel user = UserModel(
userId: '', // L'ID sera généré côté serveur
userLastName: _nom,
userFirstName: _prenoms,
email: _email,
motDePasse: _password, // Le mot de passe sera envoyé en clair pour l'instant
profileImageUrl: '',
);
final createdUser = await _userRemoteDataSource.createUser(user);
// Envoi des informations pour créer un nouvel utilisateur
final createdUser = await _userRemoteDataSource.createUser(user);
print("Utilisateur créé : ${createdUser.userId}");
// Sauvegarder les informations de l'utilisateur
await _secureStorage.saveUserId(createdUser.userId);
await _preferencesHelper.saveUserName(createdUser.userLastName);
await _preferencesHelper.saveUserLastName(createdUser.userFirstName);
// Rediriger vers la page d'accueil ou une page de confirmation
Navigator.pushReplacementNamed(context, '/home');
} catch (e) {
print("Erreur lors de la création du compte : $e");
_btnController.error();
setState(() {
_showErrorMessage = true;
});
} finally {
_btnController.reset();
await _saveUserData(createdUser);
await _navigateToLogin();
} catch (e) {
_handleError(e);
} finally {
if (mounted) {
setState(() {
_isSubmitting = false;
});
}
} else {
print("Échec de validation du formulaire.");
_btnController.reset();
}
}
/// Sauvegarde les données utilisateur.
Future<void> _saveUserData(UserModel user) async {
await _secureStorage.saveUserId(user.userId);
await _preferencesHelper.saveUserName(user.userLastName);
await _preferencesHelper.saveUserLastName(user.userFirstName);
}
/// Navigue vers l'écran de connexion.
Future<void> _navigateToLogin() async {
if (!mounted) return;
Navigator.pushReplacement(
context,
MaterialPageRoute(
builder: (context) => const LoginScreen(),
),
);
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(
content: Text('Compte créé avec succès ! Connectez-vous maintenant'),
behavior: SnackBarBehavior.floating,
),
);
}
/// Gère les erreurs d'inscription.
void _handleError(Object error) {
String message = 'Erreur lors de la création du compte';
if (error.toString().contains('Conflict') ||
error.toString().contains('existe déjà')) {
message = 'Un compte avec cet email existe déjà';
} else if (error.toString().contains('network') ||
error.toString().contains('timeout')) {
message = 'Problème de connexion. Vérifiez votre réseau';
} else {
message = error.toString().replaceAll('Exception: ', '');
}
setState(() {
_errorMessage = message;
});
if (EnvConfig.enableDetailedLogs) {
debugPrint('[SignUpScreen] Erreur: $error');
}
}
// ============================================================================
// BUILD
// ============================================================================
@override
Widget build(BuildContext context) {
final theme = Theme.of(context); // Utilisation du thème global
final size = MediaQuery.of(context).size;
final themeProvider = Provider.of<ThemeProvider>(context);
// Vérification si le clavier est visible
bool isKeyboardVisible = MediaQuery.of(context).viewInsets.bottom != 0;
final theme = Theme.of(context);
final isKeyboardVisible = MediaQuery.of(context).viewInsets.bottom > 0;
return Scaffold(
body: Stack(
children: [
// Arrière-plan animé avec un dégradé basé sur le thème
AnimatedContainer(
duration: const Duration(seconds: 3),
decoration: BoxDecoration(
gradient: LinearGradient(
colors: [
theme.colorScheme.primary,
theme.colorScheme.secondary
],
begin: Alignment.topLeft,
end: Alignment.bottomRight,
),
),
),
if (_isSubmitting)
const Center(
child: CircularProgressIndicator(),
),
// Bouton pour basculer entre les modes jour et nuit
Positioned(
top: 40,
right: 20,
child: IconButton(
icon: Icon(
themeProvider.isDarkMode ? Icons.dark_mode : Icons.light_mode,
color: theme.iconTheme.color,
),
onPressed: () {
themeProvider.toggleTheme();
print("Thème basculé : ${themeProvider.isDarkMode ? 'Sombre' : 'Clair'}");
},
),
),
// Formulaire d'inscription
Center(
child: SingleChildScrollView(
padding: const EdgeInsets.all(16.0),
child: Form(
key: _formKey,
child: Column(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
// Logo de l'application
Image.asset(
'lib/assets/images/logo.png',
height: size.height * 0.25,
),
const SizedBox(height: 20),
// Titre de la page
Text(
'Créer un compte AfterWork',
style: theme.textTheme.titleLarge,
),
const SizedBox(height: 40),
// Champ nom
_buildTextFormField(
label: 'Nom',
icon: Icons.person,
validator: (value) {
if (value == null || value.isEmpty) {
return 'Veuillez entrer votre nom';
}
return null;
},
onSaved: (value) {
_nom = value!;
},
),
const SizedBox(height: 20),
// Champ prénom
_buildTextFormField(
label: 'Prénoms',
icon: Icons.person_outline,
validator: (value) {
if (value == null || value.isEmpty) {
return 'Veuillez entrer votre prénom';
}
return null;
},
onSaved: (value) {
_prenoms = value!;
},
),
const SizedBox(height: 20),
// Champ email
_buildTextFormField(
label: 'Email',
icon: Icons.email,
validator: (value) {
if (value == null || value.isEmpty) {
return 'Veuillez entrer votre email';
}
if (!RegExp(r'^[^@]+@[^@]+\.[^@]+').hasMatch(value)) {
return 'Veuillez entrer un email valide';
}
return null;
},
onSaved: (value) {
_email = value!;
},
),
const SizedBox(height: 20),
// Champ mot de passe
_buildTextFormField(
label: 'Mot de passe',
icon: Icons.lock,
obscureText: !_isPasswordVisible,
suffixIcon: IconButton(
icon: Icon(
_isPasswordVisible
? Icons.visibility
: Icons.visibility_off,
color: theme.iconTheme.color,
),
onPressed: _togglePasswordVisibility,
),
validator: (value) {
if (value == null || value.isEmpty) {
return 'Veuillez entrer votre mot de passe';
}
if (value.length < 6) {
return 'Le mot de passe doit comporter au moins 6 caractères';
}
return null;
},
onSaved: (value) {
_password = value!;
},
),
const SizedBox(height: 20),
// Champ de confirmation du mot de passe
_buildTextFormField(
label: 'Confirmer le mot de passe',
icon: Icons.lock_outline,
obscureText: !_isPasswordVisible,
suffixIcon: IconButton(
icon: Icon(
_isPasswordVisible
? Icons.visibility
: Icons.visibility_off,
color: theme.iconTheme.color,
),
onPressed: _togglePasswordVisibility,
),
validator: (value) {
if (value == null || value.isEmpty) {
return 'Veuillez confirmer votre mot de passe';
}
if (value != _password) {
return 'Les mots de passe ne correspondent pas';
}
return null;
},
onSaved: (value) {
_confirmPassword = value!;
},
),
const SizedBox(height: 30),
// Bouton de création de compte
SizedBox(
width: size.width * 0.85,
child: LoadingButton(
controller: _btnController,
onPressed: _isSubmitting ? null : _submit,
iconData: Icons.person_add,
iconColor: theme.colorScheme.onPrimary,
child: Text(
'Créer un compte',
style: theme.textTheme.bodyLarge!.copyWith(
color: theme.colorScheme.onPrimary,
),
),
),
),
const SizedBox(height: 20),
// Lien pour revenir à la connexion
TextButton(
onPressed: () {
Navigator.pop(context);
},
child: Text(
'Déjà un compte ? Connectez-vous',
style: theme.textTheme.bodyMedium!
.copyWith(color: Colors.white70),
),
),
// Affichage du message d'erreur si nécessaire
if (_showErrorMessage)
const Padding(
padding: EdgeInsets.only(top: 20),
child: Text(
'Erreur lors de la création du compte. Veuillez vérifier vos informations.',
style: TextStyle(color: Colors.red, fontSize: 16),
textAlign: TextAlign.center,
),
),
],
),
),
),
),
// Pied de page avec logo et mention copyright
AnimatedPositioned(
duration: const Duration(milliseconds: 300),
bottom: isKeyboardVisible ? 0 : 20,
left: isKeyboardVisible ? 20 : 0,
right: isKeyboardVisible ? 20 : 0,
child: Row(
mainAxisAlignment: isKeyboardVisible
? MainAxisAlignment.spaceBetween
: MainAxisAlignment.center,
children: [
Image.asset(
'lib/assets/images/logolionsdev.png',
height: 30,
),
if (isKeyboardVisible)
Text(
'© 2024 LionsDev',
style: theme.textTheme.bodyMedium!
.copyWith(color: Colors.white70),
textAlign: TextAlign.center,
),
],
),
),
_buildBackground(theme),
_buildContent(theme, isKeyboardVisible),
_buildThemeToggle(theme),
if (_isSubmitting) _buildLoadingOverlay(theme),
],
),
);
}
/// Widget réutilisable pour les champs de texte avec validation et design amélioré
Widget _buildTextFormField({
required String label,
required IconData icon,
bool obscureText = false,
Widget? suffixIcon,
required FormFieldValidator<String> validator,
required FormFieldSetter<String> onSaved,
}) {
final theme = Theme.of(context); // Utilisation du thème global
return TextFormField(
decoration: InputDecoration(
labelText: label,
filled: true,
fillColor: theme.inputDecorationTheme.fillColor,
labelStyle: theme.textTheme.bodyMedium,
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(12.0),
borderSide: BorderSide.none,
/// Construit l'arrière-plan avec dégradé.
Widget _buildBackground(ThemeData theme) {
return AnimatedContainer(
duration: const Duration(seconds: 3),
decoration: BoxDecoration(
gradient: LinearGradient(
colors: [
theme.colorScheme.primary,
theme.colorScheme.secondary,
],
begin: Alignment.topLeft,
end: Alignment.bottomRight,
),
prefixIcon: Icon(icon, color: theme.iconTheme.color),
suffixIcon: suffixIcon,
),
obscureText: obscureText,
style: theme.textTheme.bodyLarge,
validator: validator,
onSaved: onSaved,
);
}
/// Construit le contenu principal.
Widget _buildContent(ThemeData theme, bool isKeyboardVisible) {
return FadeTransition(
opacity: _fadeAnimation,
child: Center(
child: SingleChildScrollView(
padding: const EdgeInsets.all(24),
child: Form(
key: _formKey,
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
if (!isKeyboardVisible) _buildLogo(theme),
if (!isKeyboardVisible) const SizedBox(height: 32),
_buildTitle(theme),
const SizedBox(height: 32),
_buildLastNameField(theme),
const SizedBox(height: 16),
_buildFirstNameField(theme),
const SizedBox(height: 16),
_buildEmailField(theme),
const SizedBox(height: 16),
_buildPasswordField(theme),
const SizedBox(height: 16),
_buildConfirmPasswordField(theme),
const SizedBox(height: 24),
_buildSubmitButton(theme),
const SizedBox(height: 16),
_buildLoginLink(theme),
if (_errorMessage != null) _buildErrorMessage(theme),
],
),
),
),
),
);
}
/// Construit le logo.
Widget _buildLogo(ThemeData theme) {
return Image.asset(
'lib/assets/images/logo.png',
height: 100,
errorBuilder: (context, error, stackTrace) {
return Icon(
Icons.person_add,
size: 64,
color: theme.colorScheme.onPrimary,
);
},
);
}
/// Construit le titre.
Widget _buildTitle(ThemeData theme) {
return Text(
'Créer un compte',
style: theme.textTheme.headlineSmall?.copyWith(
color: theme.colorScheme.onPrimary,
fontWeight: FontWeight.bold,
),
textAlign: TextAlign.center,
);
}
/// Construit le champ nom.
Widget _buildLastNameField(ThemeData theme) {
return TextFormField(
controller: _lastNameController,
textInputAction: TextInputAction.next,
decoration: _buildInputDecoration(
theme,
'Nom',
Icons.person,
),
style: TextStyle(color: theme.colorScheme.onPrimary),
validator: (value) => Validators.validateName(value, fieldName: 'le nom'),
);
}
/// Construit le champ prénom.
Widget _buildFirstNameField(ThemeData theme) {
return TextFormField(
controller: _firstNameController,
textInputAction: TextInputAction.next,
decoration: _buildInputDecoration(
theme,
'Prénoms',
Icons.person_outline,
),
style: TextStyle(color: theme.colorScheme.onPrimary),
validator: (value) =>
Validators.validateName(value, fieldName: 'le prénom'),
);
}
/// Construit le champ email.
Widget _buildEmailField(ThemeData theme) {
return TextFormField(
controller: _emailController,
keyboardType: TextInputType.emailAddress,
textInputAction: TextInputAction.next,
decoration: _buildInputDecoration(
theme,
'Email',
Icons.email,
),
style: TextStyle(color: theme.colorScheme.onPrimary),
validator: Validators.validateEmail,
);
}
/// Construit le champ mot de passe.
Widget _buildPasswordField(ThemeData theme) {
return TextFormField(
controller: _passwordController,
obscureText: !_isPasswordVisible,
textInputAction: TextInputAction.next,
decoration: _buildInputDecoration(
theme,
'Mot de passe',
Icons.lock,
suffixIcon: IconButton(
icon: Icon(
_isPasswordVisible ? Icons.visibility : Icons.visibility_off,
color: theme.colorScheme.onPrimary.withOpacity(0.7),
),
onPressed: _togglePasswordVisibility,
),
),
style: TextStyle(color: theme.colorScheme.onPrimary),
validator: (value) => Validators.validatePassword(value, minLength: 6),
);
}
/// Construit le champ confirmation mot de passe.
Widget _buildConfirmPasswordField(ThemeData theme) {
return TextFormField(
controller: _confirmPasswordController,
obscureText: !_isPasswordVisible,
textInputAction: TextInputAction.done,
onFieldSubmitted: (_) => _handleSubmit(),
decoration: _buildInputDecoration(
theme,
'Confirmer le mot de passe',
Icons.lock_outline,
suffixIcon: IconButton(
icon: Icon(
_isPasswordVisible ? Icons.visibility : Icons.visibility_off,
color: theme.colorScheme.onPrimary.withOpacity(0.7),
),
onPressed: _togglePasswordVisibility,
),
),
style: TextStyle(color: theme.colorScheme.onPrimary),
validator: (value) => Validators.validatePasswordMatch(
_passwordController.text,
value,
),
);
}
/// Construit le bouton de soumission (compact).
Widget _buildSubmitButton(ThemeData theme) {
return SizedBox(
width: double.infinity,
child: CustomButton(
text: 'Créer un compte',
icon: Icons.person_add,
onPressed: () => _handleSubmit(),
isLoading: _isSubmitting,
isEnabled: !_isSubmitting,
variant: ButtonVariant.primary,
size: ButtonSize.medium,
),
);
}
/// Construit le lien vers la connexion.
Widget _buildLoginLink(ThemeData theme) {
return TextButton(
onPressed: () => Navigator.pop(context),
child: Text(
'Déjà un compte ? Connectez-vous',
style: theme.textTheme.bodyMedium?.copyWith(
color: theme.colorScheme.onPrimary.withOpacity(0.9),
decoration: TextDecoration.underline,
),
),
);
}
/// Construit le message d'erreur.
Widget _buildErrorMessage(ThemeData theme) {
return Padding(
padding: const EdgeInsets.only(top: 16),
child: Container(
padding: const EdgeInsets.all(12),
decoration: BoxDecoration(
color: theme.colorScheme.error.withOpacity(0.1),
borderRadius: BorderRadius.circular(8),
border: Border.all(
color: theme.colorScheme.error.withOpacity(0.3),
),
),
child: Row(
children: [
Icon(
Icons.error_outline,
color: theme.colorScheme.error,
size: 20,
),
const SizedBox(width: 8),
Expanded(
child: Text(
_errorMessage!,
style: theme.textTheme.bodySmall?.copyWith(
color: theme.colorScheme.error,
),
),
),
],
),
),
);
}
/// Construit le bouton de basculement de thème.
Widget _buildThemeToggle(ThemeData theme) {
return Positioned(
top: MediaQuery.of(context).padding.top + 8,
right: 16,
child: IconButton(
icon: Icon(
Provider.of<ThemeProvider>(context).isDarkMode
? Icons.light_mode
: Icons.dark_mode,
color: theme.colorScheme.onPrimary,
),
onPressed: () {
Provider.of<ThemeProvider>(context, listen: false).toggleTheme();
},
tooltip: 'Changer le thème',
),
);
}
/// Construit l'overlay de chargement.
Widget _buildLoadingOverlay(ThemeData theme) {
return Container(
color: Colors.black.withOpacity(0.3),
child: Center(
child: CircularProgressIndicator(
valueColor: AlwaysStoppedAnimation<Color>(
theme.colorScheme.onPrimary,
),
),
),
);
}
// ============================================================================
// UTILITAIRES
// ============================================================================
/// Construit la décoration d'un champ de texte.
InputDecoration _buildInputDecoration(
ThemeData theme,
String label,
IconData icon, {
Widget? suffixIcon,
}) {
return InputDecoration(
labelText: label,
prefixIcon: Icon(icon, color: theme.colorScheme.onPrimary),
suffixIcon: suffixIcon,
filled: true,
fillColor: theme.colorScheme.onPrimary.withOpacity(0.1),
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(12),
borderSide: BorderSide.none,
),
enabledBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(12),
borderSide: BorderSide(
color: theme.colorScheme.onPrimary.withOpacity(0.3),
),
),
focusedBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(12),
borderSide: BorderSide(
color: theme.colorScheme.onPrimary,
width: 2,
),
),
labelStyle: TextStyle(color: theme.colorScheme.onPrimary),
);
}
}