Enhance Google and Apple sign-up methods to include name and firstname parameters

This commit is contained in:
Van Leemput Dayron
2025-11-06 11:28:18 +01:00
parent fa7daca50a
commit 75bdf591f3
6 changed files with 205 additions and 75 deletions

View File

@@ -6,11 +6,11 @@ class LoadingContent extends StatefulWidget {
final VoidCallback? onComplete;
const LoadingContent({
Key? key,
super.key,
this.onBackgroundTask,
this.loadingText = "Chargement en cours...",
this.onComplete,
}) : super(key: key);
});
@override
State<LoadingContent> createState() => _LoadingContentState();
@@ -57,7 +57,6 @@ class _LoadingContentState extends State<LoadingContent>
widget.onComplete!();
}
} catch (e) {
// Gérer les erreurs si nécessaire
print('Erreur lors de la tâche en arrière-plan: $e');
}
}
@@ -72,8 +71,11 @@ class _LoadingContentState extends State<LoadingContent>
@override
Widget build(BuildContext context) {
final theme = Theme.of(context);
final isDark = theme.brightness == Brightness.dark;
return Scaffold(
backgroundColor: Colors.white,
backgroundColor: theme.scaffoldBackgroundColor,
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
@@ -96,21 +98,21 @@ class _LoadingContentState extends State<LoadingContent>
shape: BoxShape.circle,
gradient: LinearGradient(
colors: [
Colors.blue.shade400,
Colors.purple.shade400,
theme.primaryColor.withValues(alpha: 0.8),
theme.primaryColor,
],
begin: Alignment.topLeft,
end: Alignment.bottomRight,
),
boxShadow: [
BoxShadow(
color: Colors.blue.withOpacity(0.3),
color: theme.primaryColor.withValues(alpha: 0.3),
blurRadius: 20,
spreadRadius: 5,
),
],
),
child: const Icon(
child: Icon(
Icons.travel_explore,
color: Colors.white,
size: 40,
@@ -130,10 +132,9 @@ class _LoadingContentState extends State<LoadingContent>
opacity: _pulseAnimation.value - 0.3,
child: Text(
widget.loadingText ?? "Chargement en cours...",
style: TextStyle(
fontSize: 18,
style: theme.textTheme.bodyLarge?.copyWith(
fontWeight: FontWeight.w500,
color: Colors.grey.shade700,
color: isDark ? Colors.white : Colors.black,
),
textAlign: TextAlign.center,
),
@@ -146,8 +147,10 @@ class _LoadingContentState extends State<LoadingContent>
SizedBox(
width: 200,
child: LinearProgressIndicator(
backgroundColor: Colors.grey.shade300,
valueColor: AlwaysStoppedAnimation<Color>(Colors.blue.shade400),
backgroundColor: isDark
? Colors.grey[800]
: Colors.grey.shade300,
valueColor: AlwaysStoppedAnimation<Color>(theme.primaryColor),
),
),
],

View File

@@ -1,4 +1,7 @@
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 {
final String platform; // 'google' ou 'apple'
@@ -8,13 +11,13 @@ class SignUpPlatformContent extends StatefulWidget {
final String? firstName;
const SignUpPlatformContent({
Key? key,
super.key,
required this.platform,
this.email,
this.phoneNumber,
this.name,
this.firstName,
}) : super(key: key);
});
@override
State<SignUpPlatformContent> createState() => _SignUpPlatformContentState();
@@ -53,15 +56,32 @@ class _SignUpPlatformContentState extends State<SignUpPlatformContent> {
}
void _submitForm() {
if (_formKey.currentState!.validate()) {
// Traitement de l'inscription
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(content: Text('Profil complété avec succès!')),
if (!_formKey.currentState!.validate()) {
return;
}
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'
? Colors.red
: Colors.black;
@@ -75,7 +95,9 @@ class _SignUpPlatformContentState extends State<SignUpPlatformContent> {
decoration: BoxDecoration(
color: widget.platform == 'google'
? Colors.red.shade50
: Colors.black.withValues(alpha: 0.05),
: (isDark
? Colors.grey[900]
: Colors.black.withValues(alpha: 0.05)),
borderRadius: BorderRadius.circular(8),
border: Border.all(color: platformColor, width: 1),
),
@@ -98,13 +120,16 @@ class _SignUpPlatformContentState extends State<SignUpPlatformContent> {
@override
Widget build(BuildContext context) {
final theme = Theme.of(context);
final isDark = theme.brightness == Brightness.dark;
return Scaffold(
backgroundColor: Colors.white,
backgroundColor: theme.scaffoldBackgroundColor,
appBar: AppBar(
backgroundColor: Colors.white,
backgroundColor: theme.appBarTheme.backgroundColor,
elevation: 0,
leading: IconButton(
icon: const Icon(Icons.arrow_back, color: Colors.black),
icon: Icon(Icons.arrow_back, color: theme.iconTheme.color),
onPressed: () => Navigator.pop(context),
),
),
@@ -117,20 +142,25 @@ class _SignUpPlatformContentState extends State<SignUpPlatformContent> {
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
// Indicateur de plateforme
_buildPlatformIndicator(),
_buildPlatformIndicator(theme),
const SizedBox(height: 32),
// Titre
const Text(
Text(
'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,
),
const SizedBox(height: 8),
Text(
'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,
),
const SizedBox(height: 32),
@@ -138,11 +168,15 @@ class _SignUpPlatformContentState extends State<SignUpPlatformContent> {
// Champ Nom
TextFormField(
controller: _nameController,
decoration: const InputDecoration(
decoration: InputDecoration(
labelText: 'Nom',
border: OutlineInputBorder(),
prefixIcon: Icon(Icons.person_outline),
border: const OutlineInputBorder(),
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'),
),
const SizedBox(height: 16),
@@ -150,11 +184,15 @@ class _SignUpPlatformContentState extends State<SignUpPlatformContent> {
// Champ Prénom
TextFormField(
controller: _firstNameController,
decoration: const InputDecoration(
decoration: InputDecoration(
labelText: 'Prénom',
border: OutlineInputBorder(),
prefixIcon: Icon(Icons.person_outline),
border: const OutlineInputBorder(),
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'),
),
const SizedBox(height: 16),
@@ -168,28 +206,43 @@ class _SignUpPlatformContentState extends State<SignUpPlatformContent> {
prefixIcon: const Icon(Icons.email_outlined),
suffixIcon: Icon(
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,
style: TextStyle(color: Colors.grey[600]),
style: TextStyle(
color: isDark ? Colors.grey[400] : Colors.grey[600],
),
),
const SizedBox(height: 8),
Text(
'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),
// Champ Téléphone
TextFormField(
controller: _phoneController,
decoration: const InputDecoration(
decoration: InputDecoration(
labelText: 'Numéro de téléphone',
border: OutlineInputBorder(),
prefixIcon: Icon(Icons.phone_outlined),
border: const OutlineInputBorder(),
prefixIcon: const Icon(Icons.phone_outlined),
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,
validator: (value) =>
_validateField(value, 'Numéro de téléphone'),
@@ -200,16 +253,20 @@ class _SignUpPlatformContentState extends State<SignUpPlatformContent> {
ElevatedButton(
onPressed: _submitForm,
style: ElevatedButton.styleFrom(
backgroundColor: Colors.blue,
foregroundColor: Colors.white,
backgroundColor: isDark ? Colors.white : Colors.black,
foregroundColor: isDark ? Colors.black : Colors.white,
padding: const EdgeInsets.symmetric(vertical: 16),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(8),
),
),
child: const Text(
child: Text(
'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),
@@ -217,9 +274,12 @@ class _SignUpPlatformContentState extends State<SignUpPlatformContent> {
// Bouton secondaire
TextButton(
onPressed: () => Navigator.pop(context),
child: const Text(
child: Text(
'Modifier la méthode de connexion',
style: TextStyle(color: Colors.grey, fontSize: 14),
style: TextStyle(
color: isDark ? Colors.grey[400] : Colors.grey,
fontSize: 14,
),
),
),
],