Refactor signup page to use BLoC pattern and implement authentication repository

- Updated signup.dart to replace Provider with BLoC for state management.
- Created AuthRepository to handle authentication logic and Firestore user management.
- Added TripRepository and UserRepository for trip and user data management.
- Implemented methods for user sign-in, sign-up, and data retrieval in repositories.
- Enhanced trip management with create, update, delete, and participant management functionalities.
- Updated AuthService to include new methods for sign-in and sign-up.
- Removed unnecessary print statements from TripService for cleaner code.
- Added dependencies for flutter_bloc and equatable in pubspec.yaml.

Not tested yet
This commit is contained in:
Dayron
2025-10-14 10:53:28 +02:00
parent a467b92979
commit c4588a65c0
31 changed files with 1500 additions and 689 deletions

View File

@@ -1,7 +1,8 @@
import 'package:flutter/material.dart';
import '../services/auth_service.dart';
import 'package:provider/provider.dart';
import '../providers/user_provider.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import '../blocs/auth/auth_bloc.dart';
import '../blocs/auth/auth_event.dart';
import '../blocs/auth/auth_state.dart';
class LoginPage extends StatefulWidget {
const LoginPage({super.key});
@@ -14,9 +15,6 @@ class _LoginPageState extends State<LoginPage> {
final _formKey = GlobalKey<FormState>();
final _emailController = TextEditingController();
final _passwordController = TextEditingController();
final _authService = AuthService();
bool _isLoading = false;
bool _obscurePassword = true;
@override
@@ -26,339 +24,6 @@ class _LoginPageState extends State<LoginPage> {
super.dispose();
}
// Méthode de connexion
Future<void> _login() async {
if (!_formKey.currentState!.validate()) {
return;
}
setState(() {
_isLoading = true;
});
try {
final userCredential = await _authService.signIn(
email: _emailController.text.trim(),
password: _passwordController.text,
);
if (mounted && userCredential.user != null) {
// Récupérer les données utilisateur depuis Firestore
final userProvider = Provider.of<UserProvider>(context, listen: false);
final userData = await userProvider.getUserData(userCredential.user!.uid);
if (userData != null) {
userProvider.setCurrentUser(userData);
Navigator.pushReplacementNamed(context, '/home');
} else {
_showErrorMessage('Données utilisateur non trouvées');
}
}
} catch (e) {
if (mounted) {
_showErrorMessage('Email ou mot de passe incorrect');
}
} finally {
if (mounted) {
setState(() {
_isLoading = false;
});
}
}
}
Future<void> _signInWithGoogle() async {
setState(() {
_isLoading = true;
});
try {
final userCredential = await _authService.signInWithGoogle();
if (mounted && userCredential.user != null) {
final user = userCredential.user!;
final userProvider = Provider.of<UserProvider>(context, listen: false);
// Récupérer les données utilisateur depuis Firestore
final userData = await userProvider.getUserData(user.uid);
if (userData != null) {
// L'utilisateur existe déjà
userProvider.setCurrentUser(userData);
Navigator.pushReplacementNamed(context, '/home');
} else {
// L'utilisateur n'existe pas, créer son profil
final newUserData = {
'uid': user.uid,
'email': user.email ?? '',
'name': user.displayName ?? 'Utilisateur',
};
// Créer le profil utilisateur dans Firestore
final createdUser = await userProvider.createUser(newUserData);
if (createdUser != null) {
userProvider.setCurrentUser(createdUser);
Navigator.pushReplacementNamed(context, '/home');
} else {
_showErrorMessage('Erreur lors de la création du profil utilisateur');
}
}
}
} catch (e) {
if (mounted) {
_showErrorMessage('Erreur lors de la connexion avec Google: ${e.toString()}');
}
} finally {
if (mounted) {
setState(() {
_isLoading = false;
});
}
}
}
@override
Widget build(BuildContext context) {
return Scaffold(
body: SafeArea(
child: SingleChildScrollView(
child: Padding(
padding: const EdgeInsets.all(24.0),
child: Form(
key: _formKey,
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
const SizedBox(height: 40),
// Titre
Text(
'Travel Mate',
style: TextStyle(fontSize: 28, fontWeight: FontWeight.bold),
),
const SizedBox(height: 12),
// Sous-titre
Text(
'Connectez-vous pour continuer',
style: TextStyle(fontSize: 16, color: Colors.grey),
),
const SizedBox(height: 32),
// Champ email
TextFormField(
controller: _emailController,
validator: _validateEmail,
keyboardType: TextInputType.emailAddress,
decoration: InputDecoration(
labelText: 'Email',
border: OutlineInputBorder(
borderRadius: BorderRadius.all(Radius.circular(12)),
),
prefixIcon: Icon(Icons.email),
),
),
const SizedBox(height: 16),
// Champ mot de passe
TextFormField(
controller: _passwordController,
validator: _validatePassword,
obscureText: _obscurePassword,
decoration: InputDecoration(
labelText: 'Mot de passe',
border: OutlineInputBorder(
borderRadius: BorderRadius.all(Radius.circular(12)),
),
prefixIcon: Icon(Icons.lock),
suffixIcon: IconButton(
icon: Icon(
_obscurePassword
? Icons.visibility
: Icons.visibility_off,
),
onPressed: () {
setState(() {
_obscurePassword = !_obscurePassword;
});
},
),
),
),
const SizedBox(height: 8),
// Lien "Mot de passe oublié"
Align(
alignment: Alignment.centerRight,
child: TextButton(
onPressed: () {
Navigator.pushNamed(context, '/forgot');
},
child: Text('Mot de passe oublié?'),
),
),
const SizedBox(height: 24),
// Bouton de connexion
SizedBox(
width: double.infinity,
height: 50,
child: ElevatedButton(
onPressed: _isLoading ? null : _login,
style: ElevatedButton.styleFrom(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(12),
),
),
child: _isLoading
? CircularProgressIndicator(color: Colors.white)
: Text(
'Se connecter',
style: TextStyle(fontSize: 16),
),
),
),
const SizedBox(height: 24),
// Lien d'inscription
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text("Vous n'avez pas de compte?"),
TextButton(
onPressed: () {
Navigator.pushNamed(context, '/signup');
},
child: Text('S\'inscrire'),
),
],
),
const SizedBox(height: 40),
// Séparateur
Container(
width: double.infinity,
height: 1,
color: Colors.grey.shade300,
),
const SizedBox(height: 40),
Text(
'Ou connectez-vous avec',
style: TextStyle(color: Colors.grey.shade600),
),
const SizedBox(height: 20),
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Column(
children: [
// GOOGLE
GestureDetector(
onTap: _isLoading ? null : _signInWithGoogle,
child: Container(
width: 50,
height: 50,
decoration: BoxDecoration(
color: Colors.black,
shape: BoxShape.circle,
boxShadow: [
BoxShadow(
color: Colors.grey.withValues(alpha: 0.3),
spreadRadius: 1,
blurRadius: 3,
offset: Offset(0, 1),
),
],
border: Border.all(
color: Colors.grey.shade300,
width: 1,
),
),
child: Center(
child: Image.asset(
'assets/icons/google.png',
width: 24,
height: 24,
),
),
),
),
const SizedBox(height: 8),
const Text('Google'),
],
),
const SizedBox(width: 40),
Column(
children: [
// APPLE
GestureDetector(
onTap: () {
// TODO: Implémenter la connexion Apple
_showErrorMessage(
'Connexion Apple non implémentée',
);
},
child: Container(
width: 50,
height: 50,
decoration: BoxDecoration(
color: Colors.black,
shape: BoxShape.circle,
boxShadow: [
BoxShadow(
color: Colors.grey.withValues(alpha: 0.3),
spreadRadius: 1,
blurRadius: 3,
offset: Offset(0, 1),
),
],
border: Border.all(
color: Colors.grey.shade300,
width: 1,
),
),
child: Center(
child: Image.asset(
'assets/icons/apple_white.png',
width: 24,
height: 24,
color: Colors.white,
),
),
),
),
const SizedBox(height: 8),
const Text('Apple'),
],
),
],
),
const SizedBox(height: 40),
],
),
),
),
),
),
);
}
// Validation de l'email
String? _validateEmail(String? value) {
if (value == null || value.trim().isEmpty) {
return 'Email requis';
@@ -370,7 +35,6 @@ class _LoginPageState extends State<LoginPage> {
return null;
}
// Validation du mot de passe
String? _validatePassword(String? value) {
if (value == null || value.isEmpty) {
return 'Mot de passe requis';
@@ -378,15 +42,281 @@ class _LoginPageState extends State<LoginPage> {
return null;
}
void _showErrorMessage(String message) {
if (mounted) {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
content: Text(message),
backgroundColor: Colors.red,
duration: const Duration(seconds: 3),
),
);
void _login(BuildContext context) {
if (!_formKey.currentState!.validate()) {
return;
}
context.read<AuthBloc>().add(
AuthSignInRequested(
email: _emailController.text.trim(),
password: _passwordController.text,
),
);
}
}
@override
Widget build(BuildContext context) {
return Scaffold(
body: BlocConsumer<AuthBloc, AuthState>(
listener: (context, state) {
if (state is AuthAuthenticated) {
Navigator.pushReplacementNamed(context, '/home');
} else if (state is AuthError) {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
content: Text(state.message),
backgroundColor: Colors.red,
),
);
}
},
builder: (context, state) {
final isLoading = state is AuthLoading;
return SafeArea(
child: SingleChildScrollView(
child: Padding(
padding: const EdgeInsets.all(24.0),
child: Form(
key: _formKey,
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
const SizedBox(height: 40),
const Text(
'Travel Mate',
style: TextStyle(
fontSize: 28,
fontWeight: FontWeight.bold,
),
),
const SizedBox(height: 12),
const Text(
'Connectez-vous pour continuer',
style: TextStyle(fontSize: 16, color: Colors.grey),
),
const SizedBox(height: 32),
// Email
TextFormField(
controller: _emailController,
validator: _validateEmail,
keyboardType: TextInputType.emailAddress,
decoration: const InputDecoration(
labelText: 'Email',
border: OutlineInputBorder(
borderRadius: BorderRadius.all(Radius.circular(12)),
),
prefixIcon: Icon(Icons.email),
),
),
const SizedBox(height: 16),
// Password
TextFormField(
controller: _passwordController,
validator: _validatePassword,
obscureText: _obscurePassword,
decoration: InputDecoration(
labelText: 'Mot de passe',
border: const OutlineInputBorder(
borderRadius: BorderRadius.all(Radius.circular(12)),
),
prefixIcon: const Icon(Icons.lock),
suffixIcon: IconButton(
icon: Icon(
_obscurePassword
? Icons.visibility
: Icons.visibility_off,
),
onPressed: () {
setState(() {
_obscurePassword = !_obscurePassword;
});
},
),
),
),
const SizedBox(height: 8),
// Forgot password
Align(
alignment: Alignment.centerRight,
child: TextButton(
onPressed: () {
Navigator.pushNamed(context, '/forgot');
},
child: const Text('Mot de passe oublié?'),
),
),
const SizedBox(height: 24),
// Login button
SizedBox(
width: double.infinity,
height: 50,
child: ElevatedButton(
onPressed: isLoading ? null : () => _login(context),
style: ElevatedButton.styleFrom(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(12),
),
),
child: isLoading
? const CircularProgressIndicator(
color: Colors.white,
)
: const Text(
'Se connecter',
style: TextStyle(fontSize: 16),
),
),
),
const SizedBox(height: 24),
// Sign up link
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
const Text("Vous n'avez pas de compte?"),
TextButton(
onPressed: () {
Navigator.pushNamed(context, '/signup');
},
child: const Text('S\'inscrire'),
),
],
),
const SizedBox(height: 40),
// Divider
Container(
width: double.infinity,
height: 1,
color: Colors.grey.shade300,
),
const SizedBox(height: 40),
const Text(
'Ou connectez-vous avec',
style: TextStyle(color: Colors.grey),
),
const SizedBox(height: 20),
// Social login buttons
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
// Google
Column(
children: [
GestureDetector(
onTap: isLoading
? null
: () {
context
.read<AuthBloc>()
.add(AuthGoogleSignInRequested());
},
child: Container(
width: 50,
height: 50,
decoration: BoxDecoration(
color: Colors.black,
shape: BoxShape.circle,
boxShadow: [
BoxShadow(
color: Colors.grey.withValues(alpha: 0.3),
spreadRadius: 1,
blurRadius: 3,
offset: const Offset(0, 1),
),
],
border: Border.all(
color: Colors.grey.shade300,
width: 1,
),
),
child: Center(
child: Image.asset(
'assets/icons/google.png',
width: 24,
height: 24,
),
),
),
),
const SizedBox(height: 8),
const Text('Google'),
],
),
const SizedBox(width: 40),
// Apple
Column(
children: [
GestureDetector(
onTap: isLoading
? null
: () {
context
.read<AuthBloc>()
.add(AuthAppleSignInRequested());
},
child: Container(
width: 50,
height: 50,
decoration: BoxDecoration(
color: Colors.black,
shape: BoxShape.circle,
boxShadow: [
BoxShadow(
color: Colors.grey.withValues(alpha: 0.3),
spreadRadius: 1,
blurRadius: 3,
offset: const Offset(0, 1),
),
],
border: Border.all(
color: Colors.grey.shade300,
width: 1,
),
),
child: Center(
child: Image.asset(
'assets/icons/apple_white.png',
width: 24,
height: 24,
color: Colors.white,
),
),
),
),
const SizedBox(height: 8),
const Text('Apple'),
],
),
],
),
const SizedBox(height: 40),
],
),
),
),
),
);
},
),
);
}
}

View File

@@ -1,8 +1,8 @@
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import '../models/user.dart';
import '../services/auth_service.dart';
import '../providers/user_provider.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import '../blocs/auth/auth_bloc.dart';
import '../blocs/auth/auth_event.dart';
import '../blocs/auth/auth_state.dart';
class SignUpPage extends StatefulWidget {
const SignUpPage({super.key});
@@ -18,9 +18,7 @@ class _SignUpPageState extends State<SignUpPage> {
final _emailController = TextEditingController();
final _passwordController = TextEditingController();
final _confirmPasswordController = TextEditingController();
final _authService = AuthService();
bool _isLoading = false;
bool _obscurePassword = true;
bool _obscureConfirmPassword = true;
@@ -34,7 +32,6 @@ class _SignUpPageState extends State<SignUpPage> {
super.dispose();
}
// Méthode de validation
String? _validateField(String? value, String fieldName) {
if (value == null || value.trim().isEmpty) {
return '$fieldName est requis';
@@ -46,7 +43,6 @@ class _SignUpPageState extends State<SignUpPage> {
if (value == null || value.trim().isEmpty) {
return 'Email est requis';
}
final emailRegex = RegExp(r'^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$');
if (!emailRegex.hasMatch(value.trim())) {
return 'Email invalide';
@@ -74,86 +70,19 @@ class _SignUpPageState extends State<SignUpPage> {
return null;
}
// Méthode d'enregistrement
Future<void> _signUp() async {
void _signUp(BuildContext context) {
if (!_formKey.currentState!.validate()) {
return;
}
setState(() {
_isLoading = true;
});
try {
// Créer le compte avec Firebase Auth
final userCredential = await _authService.createAccount(
email: _emailController.text.trim(),
password: _passwordController.text,
);
// Créer l'objet User
User newUser = User(
id: userCredential.user!.uid,
nom: _nomController.text.trim(),
prenom: _prenomController.text.trim(),
email: _emailController.text.trim(),
);
// Sauvegarder les données utilisateur dans Firestore
await Provider.of<UserProvider>(context, listen: false).saveUserData(newUser);
// Mettre à jour le displayName
await _authService.updateDisplayName(displayName: newUser.fullName);
_showSuccessDialog();
} catch (e) {
_showErrorDialog('Erreur lors de la création du compte: ${e.toString()}');
} finally {
setState(() {
_isLoading = false;
});
}
}
void _showSuccessDialog() {
showDialog(
context: context,
builder: (BuildContext context) {
return AlertDialog(
title: Text('Succès'),
content: Text('Votre compte a été créé avec succès !'),
actions: [
TextButton(
onPressed: () {
Navigator.of(context).pop(); // Fermer la dialog
Navigator.of(context).pop(); // Retourner à la page de login
},
child: Text('OK'),
),
],
context.read<AuthBloc>().add(
AuthSignUpRequested(
email: _emailController.text.trim(),
password: _passwordController.text,
nom: _nomController.text.trim(),
prenom: _prenomController.text.trim(),
),
);
},
);
}
void _showErrorDialog(String message) {
showDialog(
context: context,
builder: (BuildContext context) {
return AlertDialog(
title: Text('Erreur'),
content: Text(message),
actions: [
TextButton(
onPressed: () {
Navigator.of(context).pop();
},
child: Text('OK'),
),
],
);
},
);
}
@override
@@ -161,185 +90,194 @@ class _SignUpPageState extends State<SignUpPage> {
return Scaffold(
appBar: AppBar(
leading: IconButton(
icon: Icon(Icons.arrow_back),
onPressed: () {
Navigator.pop(context);
},
icon: const Icon(Icons.arrow_back),
onPressed: () => Navigator.pop(context),
),
backgroundColor: Colors.transparent,
elevation: 0,
),
body: SafeArea(
child: SingleChildScrollView(
child: Padding(
padding: const EdgeInsets.all(16.0),
child: Form(
key: _formKey,
child: Column(
children: [
const SizedBox(height: 40),
body: BlocConsumer<AuthBloc, AuthState>(
listener: (context, state) {
if (state is AuthAuthenticated) {
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(
content: Text('Compte créé avec succès !'),
backgroundColor: Colors.green,
),
);
Navigator.pushReplacementNamed(context, '/home');
} else if (state is AuthError) {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
content: Text(state.message),
backgroundColor: Colors.red,
),
);
}
},
builder: (context, state) {
final isLoading = state is AuthLoading;
const Text(
'Créer un compte',
style: TextStyle(fontSize: 24, fontWeight: FontWeight.bold),
),
const SizedBox(height: 12),
const Text(
'Rejoignez Travel Mate',
style: TextStyle(fontSize: 16, color: Colors.grey),
),
const SizedBox(height: 40),
// Champ Prénom
TextFormField(
controller: _prenomController,
validator: (value) => _validateField(value, 'Prénom'),
decoration: InputDecoration(
labelText: 'Prénom',
border: OutlineInputBorder(
borderRadius: BorderRadius.all(Radius.circular(12)),
),
prefixIcon: Icon(Icons.person_outline),
),
),
const SizedBox(height: 20),
// Champ Nom
TextFormField(
controller: _nomController,
validator: (value) => _validateField(value, 'Nom'),
decoration: InputDecoration(
labelText: 'Nom',
border: OutlineInputBorder(
borderRadius: BorderRadius.all(Radius.circular(12)),
),
prefixIcon: Icon(Icons.person),
),
),
const SizedBox(height: 20),
// Champ Email
TextFormField(
controller: _emailController,
validator: _validateEmail,
keyboardType: TextInputType.emailAddress,
decoration: InputDecoration(
labelText: 'Email',
border: OutlineInputBorder(
borderRadius: BorderRadius.all(Radius.circular(12)),
),
prefixIcon: Icon(Icons.email),
),
),
const SizedBox(height: 20),
// Champ Mot de passe
TextFormField(
controller: _passwordController,
validator: _validatePassword,
obscureText: _obscurePassword,
decoration: InputDecoration(
labelText: 'Mot de passe',
border: OutlineInputBorder(
borderRadius: BorderRadius.all(Radius.circular(12)),
),
prefixIcon: Icon(Icons.lock),
suffixIcon: IconButton(
icon: Icon(
_obscurePassword
? Icons.visibility
: Icons.visibility_off,
),
onPressed: () {
setState(() {
_obscurePassword = !_obscurePassword;
});
},
),
),
),
const SizedBox(height: 20),
// Champ Confirmation mot de passe
TextFormField(
controller: _confirmPasswordController,
validator: _validateConfirmPassword,
obscureText: _obscureConfirmPassword,
decoration: InputDecoration(
labelText: 'Confirmez le mot de passe',
border: OutlineInputBorder(
borderRadius: BorderRadius.all(Radius.circular(12)),
),
prefixIcon: Icon(Icons.lock_outline),
suffixIcon: IconButton(
icon: Icon(
_obscureConfirmPassword
? Icons.visibility
: Icons.visibility_off,
),
onPressed: () {
setState(() {
_obscureConfirmPassword = !_obscureConfirmPassword;
});
},
),
),
),
const SizedBox(height: 30),
// Bouton d'inscription
SizedBox(
width: double.infinity,
height: 50,
child: ElevatedButton(
onPressed: _isLoading ? null : _signUp,
style: ElevatedButton.styleFrom(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(12),
),
),
child: _isLoading
? CircularProgressIndicator(color: Colors.white)
: Text('S\'inscrire', style: TextStyle(fontSize: 18)),
),
),
const SizedBox(height: 20),
// Lien vers login
Row(
mainAxisAlignment: MainAxisAlignment.center,
return SafeArea(
child: SingleChildScrollView(
child: Padding(
padding: const EdgeInsets.all(16.0),
child: Form(
key: _formKey,
child: Column(
children: [
const Text("Déjà un compte ? "),
GestureDetector(
onTap: () {
Navigator.pop(context);
},
child: const Text(
'Connectez-vous !',
style: TextStyle(
color: Colors.blue,
fontWeight: FontWeight.bold,
const SizedBox(height: 40),
const Text(
'Créer un compte',
style: TextStyle(fontSize: 24, fontWeight: FontWeight.bold),
),
const SizedBox(height: 12),
const Text(
'Rejoignez Travel Mate',
style: TextStyle(fontSize: 16, color: Colors.grey),
),
const SizedBox(height: 40),
// Champ Prénom
TextFormField(
controller: _prenomController,
validator: (value) => _validateField(value, 'Prénom'),
decoration: const InputDecoration(
labelText: 'Prénom',
border: OutlineInputBorder(
borderRadius: BorderRadius.all(Radius.circular(12)),
),
prefixIcon: Icon(Icons.person_outline),
),
),
const SizedBox(height: 20),
// Champ Nom
TextFormField(
controller: _nomController,
validator: (value) => _validateField(value, 'Nom'),
decoration: const InputDecoration(
labelText: 'Nom',
border: OutlineInputBorder(
borderRadius: BorderRadius.all(Radius.circular(12)),
),
prefixIcon: Icon(Icons.person),
),
),
const SizedBox(height: 20),
// Champ Email
TextFormField(
controller: _emailController,
validator: _validateEmail,
keyboardType: TextInputType.emailAddress,
decoration: const InputDecoration(
labelText: 'Email',
border: OutlineInputBorder(
borderRadius: BorderRadius.all(Radius.circular(12)),
),
prefixIcon: Icon(Icons.email),
),
),
const SizedBox(height: 20),
// Champ Mot de passe
TextFormField(
controller: _passwordController,
validator: _validatePassword,
obscureText: _obscurePassword,
decoration: InputDecoration(
labelText: 'Mot de passe',
border: const OutlineInputBorder(
borderRadius: BorderRadius.all(Radius.circular(12)),
),
prefixIcon: const Icon(Icons.lock),
suffixIcon: IconButton(
icon: Icon(
_obscurePassword
? Icons.visibility
: Icons.visibility_off,
),
onPressed: () {
setState(() {
_obscurePassword = !_obscurePassword;
});
},
),
),
),
const SizedBox(height: 20),
// Champ Confirmation mot de passe
TextFormField(
controller: _confirmPasswordController,
validator: _validateConfirmPassword,
obscureText: _obscureConfirmPassword,
decoration: InputDecoration(
labelText: 'Confirmez le mot de passe',
border: const OutlineInputBorder(
borderRadius: BorderRadius.all(Radius.circular(12)),
),
prefixIcon: const Icon(Icons.lock_outline),
suffixIcon: IconButton(
icon: Icon(
_obscureConfirmPassword
? Icons.visibility
: Icons.visibility_off,
),
onPressed: () {
setState(() {
_obscureConfirmPassword = !_obscureConfirmPassword;
});
},
),
),
),
const SizedBox(height: 30),
// Bouton d'inscription
SizedBox(
width: double.infinity,
height: 50,
child: ElevatedButton(
onPressed: isLoading ? null : () => _signUp(context),
style: ElevatedButton.styleFrom(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(12),
),
),
child: isLoading
? const CircularProgressIndicator(color: Colors.white)
: const Text('S\'inscrire', style: TextStyle(fontSize: 18)),
),
),
const SizedBox(height: 20),
// Lien vers login
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
const Text("Déjà un compte ? "),
GestureDetector(
onTap: () => Navigator.pop(context),
child: const Text(
'Connectez-vous !',
style: TextStyle(
color: Colors.blue,
fontWeight: FontWeight.bold,
),
),
),
],
),
],
),
],
),
),
),
),
),
);
},
),
);
}
}
}