Enhance Google and Apple sign-up methods to include name and firstname parameters
This commit is contained in:
@@ -171,7 +171,11 @@ class AuthBloc extends Bloc<AuthEvent, AuthState> {
|
|||||||
// This method can be implemented if needed for Google sign-up specific logic.
|
// This method can be implemented if needed for Google sign-up specific logic.
|
||||||
emit(AuthLoading());
|
emit(AuthLoading());
|
||||||
try {
|
try {
|
||||||
final user = await _authRepository.signUpWithGoogle(event.phoneNumber);
|
final user = await _authRepository.signUpWithGoogle(
|
||||||
|
event.phoneNumber,
|
||||||
|
event.name,
|
||||||
|
event.firstname,
|
||||||
|
);
|
||||||
|
|
||||||
if (user != null) {
|
if (user != null) {
|
||||||
emit(AuthAuthenticated(user: user));
|
emit(AuthAuthenticated(user: user));
|
||||||
@@ -190,7 +194,11 @@ class AuthBloc extends Bloc<AuthEvent, AuthState> {
|
|||||||
// This method can be implemented if needed for Apple sign-up specific logic.
|
// This method can be implemented if needed for Apple sign-up specific logic.
|
||||||
emit(AuthLoading());
|
emit(AuthLoading());
|
||||||
try {
|
try {
|
||||||
final user = await _authRepository.signUpWithApple(event.phoneNumber);
|
final user = await _authRepository.signUpWithApple(
|
||||||
|
event.phoneNumber,
|
||||||
|
event.name,
|
||||||
|
event.firstname,
|
||||||
|
);
|
||||||
|
|
||||||
if (user != null) {
|
if (user != null) {
|
||||||
emit(AuthAuthenticated(user: user));
|
emit(AuthAuthenticated(user: user));
|
||||||
|
|||||||
@@ -81,11 +81,17 @@ class AuthGoogleSignInRequested extends AuthEvent {}
|
|||||||
class AuthGoogleSignUpRequested extends AuthEvent {
|
class AuthGoogleSignUpRequested extends AuthEvent {
|
||||||
/// The user's phone number.
|
/// The user's phone number.
|
||||||
final String phoneNumber;
|
final String phoneNumber;
|
||||||
|
final String name;
|
||||||
|
final String firstname;
|
||||||
|
|
||||||
/// Creates a new [AuthGoogleSignUpRequested] event.
|
/// Creates a new [AuthGoogleSignUpRequested] event.
|
||||||
///
|
///
|
||||||
/// The [phoneNumber] parameter is required.
|
/// The [phoneNumber] parameter is required.
|
||||||
const AuthGoogleSignUpRequested({required this.phoneNumber});
|
const AuthGoogleSignUpRequested({
|
||||||
|
required this.phoneNumber,
|
||||||
|
required this.name,
|
||||||
|
required this.firstname,
|
||||||
|
});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
List<Object?> get props => [phoneNumber];
|
List<Object?> get props => [phoneNumber];
|
||||||
@@ -99,11 +105,17 @@ class AuthAppleSignInRequested extends AuthEvent {}
|
|||||||
class AuthAppleSignUpRequested extends AuthEvent {
|
class AuthAppleSignUpRequested extends AuthEvent {
|
||||||
/// The user's phone number.
|
/// The user's phone number.
|
||||||
final String phoneNumber;
|
final String phoneNumber;
|
||||||
|
final String name;
|
||||||
|
final String firstname;
|
||||||
|
|
||||||
/// Creates a new [AuthAppleSignUpRequested] event.
|
/// Creates a new [AuthAppleSignUpRequested] event.
|
||||||
///
|
///
|
||||||
/// The [phoneNumber] parameter is required.
|
/// The [phoneNumber] parameter is required.
|
||||||
const AuthAppleSignUpRequested({required this.phoneNumber});
|
const AuthAppleSignUpRequested({
|
||||||
|
required this.phoneNumber,
|
||||||
|
required this.name,
|
||||||
|
required this.firstname,
|
||||||
|
});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
List<Object?> get props => [phoneNumber];
|
List<Object?> get props => [phoneNumber];
|
||||||
|
|||||||
@@ -6,11 +6,11 @@ class LoadingContent extends StatefulWidget {
|
|||||||
final VoidCallback? onComplete;
|
final VoidCallback? onComplete;
|
||||||
|
|
||||||
const LoadingContent({
|
const LoadingContent({
|
||||||
Key? key,
|
super.key,
|
||||||
this.onBackgroundTask,
|
this.onBackgroundTask,
|
||||||
this.loadingText = "Chargement en cours...",
|
this.loadingText = "Chargement en cours...",
|
||||||
this.onComplete,
|
this.onComplete,
|
||||||
}) : super(key: key);
|
});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
State<LoadingContent> createState() => _LoadingContentState();
|
State<LoadingContent> createState() => _LoadingContentState();
|
||||||
@@ -57,7 +57,6 @@ class _LoadingContentState extends State<LoadingContent>
|
|||||||
widget.onComplete!();
|
widget.onComplete!();
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
// Gérer les erreurs si nécessaire
|
|
||||||
print('Erreur lors de la tâche en arrière-plan: $e');
|
print('Erreur lors de la tâche en arrière-plan: $e');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -72,8 +71,11 @@ class _LoadingContentState extends State<LoadingContent>
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
final theme = Theme.of(context);
|
||||||
|
final isDark = theme.brightness == Brightness.dark;
|
||||||
|
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
backgroundColor: Colors.white,
|
backgroundColor: theme.scaffoldBackgroundColor,
|
||||||
body: Center(
|
body: Center(
|
||||||
child: Column(
|
child: Column(
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
@@ -96,21 +98,21 @@ class _LoadingContentState extends State<LoadingContent>
|
|||||||
shape: BoxShape.circle,
|
shape: BoxShape.circle,
|
||||||
gradient: LinearGradient(
|
gradient: LinearGradient(
|
||||||
colors: [
|
colors: [
|
||||||
Colors.blue.shade400,
|
theme.primaryColor.withValues(alpha: 0.8),
|
||||||
Colors.purple.shade400,
|
theme.primaryColor,
|
||||||
],
|
],
|
||||||
begin: Alignment.topLeft,
|
begin: Alignment.topLeft,
|
||||||
end: Alignment.bottomRight,
|
end: Alignment.bottomRight,
|
||||||
),
|
),
|
||||||
boxShadow: [
|
boxShadow: [
|
||||||
BoxShadow(
|
BoxShadow(
|
||||||
color: Colors.blue.withOpacity(0.3),
|
color: theme.primaryColor.withValues(alpha: 0.3),
|
||||||
blurRadius: 20,
|
blurRadius: 20,
|
||||||
spreadRadius: 5,
|
spreadRadius: 5,
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
child: const Icon(
|
child: Icon(
|
||||||
Icons.travel_explore,
|
Icons.travel_explore,
|
||||||
color: Colors.white,
|
color: Colors.white,
|
||||||
size: 40,
|
size: 40,
|
||||||
@@ -130,10 +132,9 @@ class _LoadingContentState extends State<LoadingContent>
|
|||||||
opacity: _pulseAnimation.value - 0.3,
|
opacity: _pulseAnimation.value - 0.3,
|
||||||
child: Text(
|
child: Text(
|
||||||
widget.loadingText ?? "Chargement en cours...",
|
widget.loadingText ?? "Chargement en cours...",
|
||||||
style: TextStyle(
|
style: theme.textTheme.bodyLarge?.copyWith(
|
||||||
fontSize: 18,
|
|
||||||
fontWeight: FontWeight.w500,
|
fontWeight: FontWeight.w500,
|
||||||
color: Colors.grey.shade700,
|
color: isDark ? Colors.white : Colors.black,
|
||||||
),
|
),
|
||||||
textAlign: TextAlign.center,
|
textAlign: TextAlign.center,
|
||||||
),
|
),
|
||||||
@@ -146,8 +147,10 @@ class _LoadingContentState extends State<LoadingContent>
|
|||||||
SizedBox(
|
SizedBox(
|
||||||
width: 200,
|
width: 200,
|
||||||
child: LinearProgressIndicator(
|
child: LinearProgressIndicator(
|
||||||
backgroundColor: Colors.grey.shade300,
|
backgroundColor: isDark
|
||||||
valueColor: AlwaysStoppedAnimation<Color>(Colors.blue.shade400),
|
? Colors.grey[800]
|
||||||
|
: Colors.grey.shade300,
|
||||||
|
valueColor: AlwaysStoppedAnimation<Color>(theme.primaryColor),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
|||||||
@@ -1,4 +1,7 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
|
import 'package:travel_mate/blocs/auth/auth_bloc.dart';
|
||||||
|
import 'package:travel_mate/blocs/auth/auth_event.dart';
|
||||||
|
|
||||||
class SignUpPlatformContent extends StatefulWidget {
|
class SignUpPlatformContent extends StatefulWidget {
|
||||||
final String platform; // 'google' ou 'apple'
|
final String platform; // 'google' ou 'apple'
|
||||||
@@ -8,13 +11,13 @@ class SignUpPlatformContent extends StatefulWidget {
|
|||||||
final String? firstName;
|
final String? firstName;
|
||||||
|
|
||||||
const SignUpPlatformContent({
|
const SignUpPlatformContent({
|
||||||
Key? key,
|
super.key,
|
||||||
required this.platform,
|
required this.platform,
|
||||||
this.email,
|
this.email,
|
||||||
this.phoneNumber,
|
this.phoneNumber,
|
||||||
this.name,
|
this.name,
|
||||||
this.firstName,
|
this.firstName,
|
||||||
}) : super(key: key);
|
});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
State<SignUpPlatformContent> createState() => _SignUpPlatformContentState();
|
State<SignUpPlatformContent> createState() => _SignUpPlatformContentState();
|
||||||
@@ -53,15 +56,32 @@ class _SignUpPlatformContentState extends State<SignUpPlatformContent> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void _submitForm() {
|
void _submitForm() {
|
||||||
if (_formKey.currentState!.validate()) {
|
if (!_formKey.currentState!.validate()) {
|
||||||
// Traitement de l'inscription
|
return;
|
||||||
ScaffoldMessenger.of(context).showSnackBar(
|
}
|
||||||
const SnackBar(content: Text('Profil complété avec succès!')),
|
|
||||||
|
if (widget.platform == 'google') {
|
||||||
|
context.read<AuthBloc>().add(
|
||||||
|
AuthGoogleSignUpRequested(
|
||||||
|
phoneNumber: _phoneController.text.trim(),
|
||||||
|
name: _nameController.text.trim(),
|
||||||
|
firstname: _firstNameController.text.trim(),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
} else if (widget.platform == 'apple') {
|
||||||
|
context.read<AuthBloc>().add(
|
||||||
|
AuthAppleSignUpRequested(
|
||||||
|
phoneNumber: _phoneController.text.trim(),
|
||||||
|
name: _nameController.text.trim(),
|
||||||
|
firstname: _firstNameController.text.trim(),
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget _buildPlatformIndicator() {
|
Widget _buildPlatformIndicator(ThemeData theme) {
|
||||||
|
final isDark = theme.brightness == Brightness.dark;
|
||||||
|
|
||||||
Color platformColor = widget.platform == 'google'
|
Color platformColor = widget.platform == 'google'
|
||||||
? Colors.red
|
? Colors.red
|
||||||
: Colors.black;
|
: Colors.black;
|
||||||
@@ -75,7 +95,9 @@ class _SignUpPlatformContentState extends State<SignUpPlatformContent> {
|
|||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
color: widget.platform == 'google'
|
color: widget.platform == 'google'
|
||||||
? Colors.red.shade50
|
? Colors.red.shade50
|
||||||
: Colors.black.withValues(alpha: 0.05),
|
: (isDark
|
||||||
|
? Colors.grey[900]
|
||||||
|
: Colors.black.withValues(alpha: 0.05)),
|
||||||
borderRadius: BorderRadius.circular(8),
|
borderRadius: BorderRadius.circular(8),
|
||||||
border: Border.all(color: platformColor, width: 1),
|
border: Border.all(color: platformColor, width: 1),
|
||||||
),
|
),
|
||||||
@@ -98,13 +120,16 @@ class _SignUpPlatformContentState extends State<SignUpPlatformContent> {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
final theme = Theme.of(context);
|
||||||
|
final isDark = theme.brightness == Brightness.dark;
|
||||||
|
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
backgroundColor: Colors.white,
|
backgroundColor: theme.scaffoldBackgroundColor,
|
||||||
appBar: AppBar(
|
appBar: AppBar(
|
||||||
backgroundColor: Colors.white,
|
backgroundColor: theme.appBarTheme.backgroundColor,
|
||||||
elevation: 0,
|
elevation: 0,
|
||||||
leading: IconButton(
|
leading: IconButton(
|
||||||
icon: const Icon(Icons.arrow_back, color: Colors.black),
|
icon: Icon(Icons.arrow_back, color: theme.iconTheme.color),
|
||||||
onPressed: () => Navigator.pop(context),
|
onPressed: () => Navigator.pop(context),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@@ -117,20 +142,25 @@ class _SignUpPlatformContentState extends State<SignUpPlatformContent> {
|
|||||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||||
children: [
|
children: [
|
||||||
// Indicateur de plateforme
|
// Indicateur de plateforme
|
||||||
_buildPlatformIndicator(),
|
_buildPlatformIndicator(theme),
|
||||||
const SizedBox(height: 32),
|
const SizedBox(height: 32),
|
||||||
|
|
||||||
// Titre
|
// Titre
|
||||||
const Text(
|
Text(
|
||||||
'Complétez votre profil',
|
'Complétez votre profil',
|
||||||
style: TextStyle(fontSize: 24, fontWeight: FontWeight.bold),
|
style: theme.textTheme.headlineSmall?.copyWith(
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
color: isDark ? Colors.white : Colors.black,
|
||||||
|
),
|
||||||
textAlign: TextAlign.center,
|
textAlign: TextAlign.center,
|
||||||
),
|
),
|
||||||
const SizedBox(height: 8),
|
const SizedBox(height: 8),
|
||||||
|
|
||||||
Text(
|
Text(
|
||||||
'Vérifiez et complétez vos informations',
|
'Vérifiez et complétez vos informations',
|
||||||
style: TextStyle(fontSize: 16, color: Colors.grey[600]),
|
style: theme.textTheme.bodyLarge?.copyWith(
|
||||||
|
color: isDark ? Colors.grey[400] : Colors.grey[600],
|
||||||
|
),
|
||||||
textAlign: TextAlign.center,
|
textAlign: TextAlign.center,
|
||||||
),
|
),
|
||||||
const SizedBox(height: 32),
|
const SizedBox(height: 32),
|
||||||
@@ -138,11 +168,15 @@ class _SignUpPlatformContentState extends State<SignUpPlatformContent> {
|
|||||||
// Champ Nom
|
// Champ Nom
|
||||||
TextFormField(
|
TextFormField(
|
||||||
controller: _nameController,
|
controller: _nameController,
|
||||||
decoration: const InputDecoration(
|
decoration: InputDecoration(
|
||||||
labelText: 'Nom',
|
labelText: 'Nom',
|
||||||
border: OutlineInputBorder(),
|
border: const OutlineInputBorder(),
|
||||||
prefixIcon: Icon(Icons.person_outline),
|
prefixIcon: const Icon(Icons.person_outline),
|
||||||
|
labelStyle: TextStyle(
|
||||||
|
color: isDark ? Colors.white70 : Colors.black87,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
|
style: TextStyle(color: isDark ? Colors.white : Colors.black),
|
||||||
validator: (value) => _validateField(value, 'Nom'),
|
validator: (value) => _validateField(value, 'Nom'),
|
||||||
),
|
),
|
||||||
const SizedBox(height: 16),
|
const SizedBox(height: 16),
|
||||||
@@ -150,11 +184,15 @@ class _SignUpPlatformContentState extends State<SignUpPlatformContent> {
|
|||||||
// Champ Prénom
|
// Champ Prénom
|
||||||
TextFormField(
|
TextFormField(
|
||||||
controller: _firstNameController,
|
controller: _firstNameController,
|
||||||
decoration: const InputDecoration(
|
decoration: InputDecoration(
|
||||||
labelText: 'Prénom',
|
labelText: 'Prénom',
|
||||||
border: OutlineInputBorder(),
|
border: const OutlineInputBorder(),
|
||||||
prefixIcon: Icon(Icons.person_outline),
|
prefixIcon: const Icon(Icons.person_outline),
|
||||||
|
labelStyle: TextStyle(
|
||||||
|
color: isDark ? Colors.white70 : Colors.black87,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
|
style: TextStyle(color: isDark ? Colors.white : Colors.black),
|
||||||
validator: (value) => _validateField(value, 'Prénom'),
|
validator: (value) => _validateField(value, 'Prénom'),
|
||||||
),
|
),
|
||||||
const SizedBox(height: 16),
|
const SizedBox(height: 16),
|
||||||
@@ -168,28 +206,43 @@ class _SignUpPlatformContentState extends State<SignUpPlatformContent> {
|
|||||||
prefixIcon: const Icon(Icons.email_outlined),
|
prefixIcon: const Icon(Icons.email_outlined),
|
||||||
suffixIcon: Icon(
|
suffixIcon: Icon(
|
||||||
Icons.lock_outline,
|
Icons.lock_outline,
|
||||||
color: Colors.grey[400],
|
color: isDark ? Colors.grey[600] : Colors.grey[400],
|
||||||
|
),
|
||||||
|
labelStyle: TextStyle(
|
||||||
|
color: isDark ? Colors.white70 : Colors.black87,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
enabled: false,
|
enabled: false,
|
||||||
style: TextStyle(color: Colors.grey[600]),
|
style: TextStyle(
|
||||||
|
color: isDark ? Colors.grey[400] : Colors.grey[600],
|
||||||
|
),
|
||||||
),
|
),
|
||||||
const SizedBox(height: 8),
|
const SizedBox(height: 8),
|
||||||
Text(
|
Text(
|
||||||
'Email fourni par ${widget.platform == 'google' ? 'Google' : 'Apple'}',
|
'Email fourni par ${widget.platform == 'google' ? 'Google' : 'Apple'}',
|
||||||
style: TextStyle(fontSize: 12, color: Colors.grey[500]),
|
style: TextStyle(
|
||||||
|
fontSize: 12,
|
||||||
|
color: isDark ? Colors.grey[500] : Colors.grey[600],
|
||||||
|
),
|
||||||
),
|
),
|
||||||
const SizedBox(height: 16),
|
const SizedBox(height: 16),
|
||||||
|
|
||||||
// Champ Téléphone
|
// Champ Téléphone
|
||||||
TextFormField(
|
TextFormField(
|
||||||
controller: _phoneController,
|
controller: _phoneController,
|
||||||
decoration: const InputDecoration(
|
decoration: InputDecoration(
|
||||||
labelText: 'Numéro de téléphone',
|
labelText: 'Numéro de téléphone',
|
||||||
border: OutlineInputBorder(),
|
border: const OutlineInputBorder(),
|
||||||
prefixIcon: Icon(Icons.phone_outlined),
|
prefixIcon: const Icon(Icons.phone_outlined),
|
||||||
hintText: '+33 6 12 34 56 78',
|
hintText: '+33 6 12 34 56 78',
|
||||||
|
labelStyle: TextStyle(
|
||||||
|
color: isDark ? Colors.white70 : Colors.black87,
|
||||||
|
),
|
||||||
|
hintStyle: TextStyle(
|
||||||
|
color: isDark ? Colors.grey[600] : Colors.grey[400],
|
||||||
|
),
|
||||||
),
|
),
|
||||||
|
style: TextStyle(color: isDark ? Colors.white : Colors.black),
|
||||||
keyboardType: TextInputType.phone,
|
keyboardType: TextInputType.phone,
|
||||||
validator: (value) =>
|
validator: (value) =>
|
||||||
_validateField(value, 'Numéro de téléphone'),
|
_validateField(value, 'Numéro de téléphone'),
|
||||||
@@ -200,16 +253,20 @@ class _SignUpPlatformContentState extends State<SignUpPlatformContent> {
|
|||||||
ElevatedButton(
|
ElevatedButton(
|
||||||
onPressed: _submitForm,
|
onPressed: _submitForm,
|
||||||
style: ElevatedButton.styleFrom(
|
style: ElevatedButton.styleFrom(
|
||||||
backgroundColor: Colors.blue,
|
backgroundColor: isDark ? Colors.white : Colors.black,
|
||||||
foregroundColor: Colors.white,
|
foregroundColor: isDark ? Colors.black : Colors.white,
|
||||||
padding: const EdgeInsets.symmetric(vertical: 16),
|
padding: const EdgeInsets.symmetric(vertical: 16),
|
||||||
shape: RoundedRectangleBorder(
|
shape: RoundedRectangleBorder(
|
||||||
borderRadius: BorderRadius.circular(8),
|
borderRadius: BorderRadius.circular(8),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
child: const Text(
|
child: Text(
|
||||||
'Confirmer mon inscription',
|
'Confirmer mon inscription',
|
||||||
style: TextStyle(fontSize: 16, fontWeight: FontWeight.w600),
|
style: TextStyle(
|
||||||
|
fontSize: 16,
|
||||||
|
fontWeight: FontWeight.w600,
|
||||||
|
color: isDark ? Colors.black : Colors.white,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
const SizedBox(height: 16),
|
const SizedBox(height: 16),
|
||||||
@@ -217,9 +274,12 @@ class _SignUpPlatformContentState extends State<SignUpPlatformContent> {
|
|||||||
// Bouton secondaire
|
// Bouton secondaire
|
||||||
TextButton(
|
TextButton(
|
||||||
onPressed: () => Navigator.pop(context),
|
onPressed: () => Navigator.pop(context),
|
||||||
child: const Text(
|
child: Text(
|
||||||
'Modifier la méthode de connexion',
|
'Modifier la méthode de connexion',
|
||||||
style: TextStyle(color: Colors.grey, fontSize: 14),
|
style: TextStyle(
|
||||||
|
color: isDark ? Colors.grey[400] : Colors.grey,
|
||||||
|
fontSize: 14,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ import 'package:flutter_bloc/flutter_bloc.dart';
|
|||||||
import 'package:sign_in_button/sign_in_button.dart';
|
import 'package:sign_in_button/sign_in_button.dart';
|
||||||
import 'package:travel_mate/components/loading/laoding_content.dart';
|
import 'package:travel_mate/components/loading/laoding_content.dart';
|
||||||
import 'package:travel_mate/components/signup/sign_up_platform_content.dart';
|
import 'package:travel_mate/components/signup/sign_up_platform_content.dart';
|
||||||
|
import 'package:travel_mate/services/auth_service.dart';
|
||||||
import '../blocs/auth/auth_bloc.dart';
|
import '../blocs/auth/auth_bloc.dart';
|
||||||
import '../blocs/auth/auth_event.dart';
|
import '../blocs/auth/auth_event.dart';
|
||||||
import '../blocs/auth/auth_state.dart';
|
import '../blocs/auth/auth_state.dart';
|
||||||
@@ -28,6 +29,7 @@ class _SignUpPageState extends State<SignUpPage> {
|
|||||||
bool _obscureConfirmPassword = true;
|
bool _obscureConfirmPassword = true;
|
||||||
|
|
||||||
final _errorService = ErrorService();
|
final _errorService = ErrorService();
|
||||||
|
final _authService = AuthService();
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void dispose() {
|
void dispose() {
|
||||||
@@ -327,20 +329,38 @@ class _SignUpPageState extends State<SignUpPage> {
|
|||||||
MaterialPageRoute(
|
MaterialPageRoute(
|
||||||
builder: (context) => LoadingContent(
|
builder: (context) => LoadingContent(
|
||||||
onBackgroundTask: () async {
|
onBackgroundTask: () async {
|
||||||
// Effectuer la requête vers Google
|
// Effectuer la requête vers Google et donner les informations de l'utilisateur pour le signup
|
||||||
final platformData = await _fetchGoogleSignInData();
|
await _authService.signInWithGoogle();
|
||||||
return platformData;
|
|
||||||
},
|
},
|
||||||
onComplete: () {
|
onComplete: () {
|
||||||
// Fermer le loading et naviguer vers SignUpPlatformContent
|
// Fermer le loading et naviguer vers SignUpPlatformContent
|
||||||
Navigator.pop(context); // Fermer LoadingContent
|
Navigator.pop(
|
||||||
Navigator.push(
|
|
||||||
context,
|
context,
|
||||||
MaterialPageRoute(
|
); // Fermer LoadingContent
|
||||||
builder: (context) =>
|
final user = _authService.currentUser;
|
||||||
SignUpPlatformContent(platform: 'google'),
|
if (user != null) {
|
||||||
),
|
Navigator.push(
|
||||||
);
|
context,
|
||||||
|
MaterialPageRoute(
|
||||||
|
builder: (context) =>
|
||||||
|
SignUpPlatformContent(
|
||||||
|
platform: 'google',
|
||||||
|
email: user.email ?? '',
|
||||||
|
firstName:
|
||||||
|
user.displayName
|
||||||
|
?.split(' ')
|
||||||
|
.first ??
|
||||||
|
'Prénom',
|
||||||
|
name:
|
||||||
|
user.displayName
|
||||||
|
?.split(' ')
|
||||||
|
.skip(1)
|
||||||
|
.join(' ') ??
|
||||||
|
'Nom',
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@@ -360,19 +380,38 @@ class _SignUpPageState extends State<SignUpPage> {
|
|||||||
builder: (context) => LoadingContent(
|
builder: (context) => LoadingContent(
|
||||||
onBackgroundTask: () async {
|
onBackgroundTask: () async {
|
||||||
// Effectuer la requête vers Google
|
// Effectuer la requête vers Google
|
||||||
final platformData = await
|
await _authService.signInWithApple();
|
||||||
return platformData;
|
|
||||||
},
|
},
|
||||||
onComplete: () {
|
onComplete: () {
|
||||||
// Fermer le loading et naviguer vers SignUpPlatformContent
|
// Fermer le loading et naviguer vers SignUpPlatformContent
|
||||||
Navigator.pop(context); // Fermer LoadingContent
|
Navigator.pop(
|
||||||
Navigator.push(
|
|
||||||
context,
|
context,
|
||||||
MaterialPageRoute(
|
); // Fermer LoadingContent
|
||||||
builder: (context) =>
|
|
||||||
SignUpPlatformContent(platform: 'apple'),
|
final user = _authService.currentUser;
|
||||||
),
|
if (user != null) {
|
||||||
);
|
Navigator.push(
|
||||||
|
context,
|
||||||
|
MaterialPageRoute(
|
||||||
|
builder: (context) =>
|
||||||
|
SignUpPlatformContent(
|
||||||
|
platform: 'apple',
|
||||||
|
email: user.email ?? '',
|
||||||
|
firstName:
|
||||||
|
user.displayName
|
||||||
|
?.split(' ')
|
||||||
|
.first ??
|
||||||
|
'Prénom',
|
||||||
|
name:
|
||||||
|
user.displayName
|
||||||
|
?.split(' ')
|
||||||
|
.skip(1)
|
||||||
|
.join(' ') ??
|
||||||
|
'Nom',
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -116,7 +116,11 @@ class AuthRepository {
|
|||||||
///
|
///
|
||||||
/// Returns the [User] model if successful, null if Google sign-in was cancelled.
|
/// Returns the [User] model if successful, null if Google sign-in was cancelled.
|
||||||
/// Throws an exception if authentication fails.
|
/// Throws an exception if authentication fails.
|
||||||
Future<User?> signUpWithGoogle(String phoneNumber) async {
|
Future<User?> signUpWithGoogle(
|
||||||
|
String phoneNumber,
|
||||||
|
String name,
|
||||||
|
String firstname,
|
||||||
|
) async {
|
||||||
try {
|
try {
|
||||||
final firebaseUser = await _authService.signInWithGoogle();
|
final firebaseUser = await _authService.signInWithGoogle();
|
||||||
|
|
||||||
@@ -132,8 +136,8 @@ class AuthRepository {
|
|||||||
final user = User(
|
final user = User(
|
||||||
id: firebaseUser.user!.uid,
|
id: firebaseUser.user!.uid,
|
||||||
email: firebaseUser.user!.email ?? '',
|
email: firebaseUser.user!.email ?? '',
|
||||||
nom: '',
|
nom: name,
|
||||||
prenom: firebaseUser.user!.displayName ?? 'User',
|
prenom: firstname,
|
||||||
phoneNumber: phoneNumber,
|
phoneNumber: phoneNumber,
|
||||||
profilePictureUrl: firebaseUser.user!.photoURL ?? 'Unknown',
|
profilePictureUrl: firebaseUser.user!.photoURL ?? 'Unknown',
|
||||||
platform: 'google',
|
platform: 'google',
|
||||||
@@ -171,7 +175,11 @@ class AuthRepository {
|
|||||||
///
|
///
|
||||||
/// Returns the [User] model if successful, null if Apple sign-in was cancelled.
|
/// Returns the [User] model if successful, null if Apple sign-in was cancelled.
|
||||||
/// Throws an exception if authentication fails.
|
/// Throws an exception if authentication fails.
|
||||||
Future<User?> signUpWithApple(String phoneNumber) async {
|
Future<User?> signUpWithApple(
|
||||||
|
String phoneNumber,
|
||||||
|
String name,
|
||||||
|
String firstname,
|
||||||
|
) async {
|
||||||
try {
|
try {
|
||||||
final firebaseUser = await _authService.signInWithApple();
|
final firebaseUser = await _authService.signInWithApple();
|
||||||
|
|
||||||
@@ -185,8 +193,8 @@ class AuthRepository {
|
|||||||
final user = User(
|
final user = User(
|
||||||
id: firebaseUser.user!.uid,
|
id: firebaseUser.user!.uid,
|
||||||
email: firebaseUser.user!.email ?? '',
|
email: firebaseUser.user!.email ?? '',
|
||||||
nom: '',
|
nom: name,
|
||||||
prenom: firebaseUser.user!.displayName ?? 'User',
|
prenom: firstname,
|
||||||
phoneNumber: phoneNumber,
|
phoneNumber: phoneNumber,
|
||||||
profilePictureUrl: firebaseUser.user!.photoURL ?? 'Unknown',
|
profilePictureUrl: firebaseUser.user!.photoURL ?? 'Unknown',
|
||||||
platform: 'apple',
|
platform: 'apple',
|
||||||
|
|||||||
Reference in New Issue
Block a user