Enhance Google and Apple sign-up methods to include name and firstname parameters
This commit is contained in:
@@ -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,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
|
||||
Reference in New Issue
Block a user