fAdd phone number support to user authentication events and methods

This commit is contained in:
Van Leemput Dayron
2025-11-05 13:09:12 +01:00
parent 5977f4d0da
commit fa7daca50a
7 changed files with 685 additions and 188 deletions

View File

@@ -0,0 +1,232 @@
import 'package:flutter/material.dart';
class SignUpPlatformContent extends StatefulWidget {
final String platform; // 'google' ou 'apple'
final String? email;
final String? phoneNumber;
final String? name;
final String? firstName;
const SignUpPlatformContent({
Key? key,
required this.platform,
this.email,
this.phoneNumber,
this.name,
this.firstName,
}) : super(key: key);
@override
State<SignUpPlatformContent> createState() => _SignUpPlatformContentState();
}
class _SignUpPlatformContentState extends State<SignUpPlatformContent> {
final _formKey = GlobalKey<FormState>();
late TextEditingController _nameController;
late TextEditingController _firstNameController;
late TextEditingController _emailController;
late TextEditingController _phoneController;
@override
void initState() {
super.initState();
_nameController = TextEditingController(text: widget.name ?? '');
_firstNameController = TextEditingController(text: widget.firstName ?? '');
_emailController = TextEditingController(text: widget.email ?? '');
_phoneController = TextEditingController(text: widget.phoneNumber ?? '');
}
@override
void dispose() {
_nameController.dispose();
_firstNameController.dispose();
_emailController.dispose();
_phoneController.dispose();
super.dispose();
}
String? _validateField(String? value, String fieldName) {
if (value == null || value.isEmpty) {
return '$fieldName est requis';
}
return null;
}
void _submitForm() {
if (_formKey.currentState!.validate()) {
// Traitement de l'inscription
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(content: Text('Profil complété avec succès!')),
);
}
}
Widget _buildPlatformIndicator() {
Color platformColor = widget.platform == 'google'
? Colors.red
: Colors.black;
IconData platformIcon = widget.platform == 'google'
? Icons.g_mobiledata
: Icons.apple;
String platformName = widget.platform == 'google' ? 'Google' : 'Apple';
return Container(
padding: const EdgeInsets.all(16),
decoration: BoxDecoration(
color: widget.platform == 'google'
? Colors.red.shade50
: Colors.black.withValues(alpha: 0.05),
borderRadius: BorderRadius.circular(8),
border: Border.all(color: platformColor, width: 1),
),
child: Row(
children: [
Icon(platformIcon, color: platformColor, size: 24),
const SizedBox(width: 8),
Text(
'Connecté avec $platformName',
style: TextStyle(
color: platformColor,
fontWeight: FontWeight.w500,
fontSize: 16,
),
),
],
),
);
}
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Colors.white,
appBar: AppBar(
backgroundColor: Colors.white,
elevation: 0,
leading: IconButton(
icon: const Icon(Icons.arrow_back, color: Colors.black),
onPressed: () => Navigator.pop(context),
),
),
body: SafeArea(
child: SingleChildScrollView(
padding: const EdgeInsets.all(24.0),
child: Form(
key: _formKey,
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
// Indicateur de plateforme
_buildPlatformIndicator(),
const SizedBox(height: 32),
// Titre
const Text(
'Complétez votre profil',
style: TextStyle(fontSize: 24, fontWeight: FontWeight.bold),
textAlign: TextAlign.center,
),
const SizedBox(height: 8),
Text(
'Vérifiez et complétez vos informations',
style: TextStyle(fontSize: 16, color: Colors.grey[600]),
textAlign: TextAlign.center,
),
const SizedBox(height: 32),
// Champ Nom
TextFormField(
controller: _nameController,
decoration: const InputDecoration(
labelText: 'Nom',
border: OutlineInputBorder(),
prefixIcon: Icon(Icons.person_outline),
),
validator: (value) => _validateField(value, 'Nom'),
),
const SizedBox(height: 16),
// Champ Prénom
TextFormField(
controller: _firstNameController,
decoration: const InputDecoration(
labelText: 'Prénom',
border: OutlineInputBorder(),
prefixIcon: Icon(Icons.person_outline),
),
validator: (value) => _validateField(value, 'Prénom'),
),
const SizedBox(height: 16),
// Champ Email (non modifiable)
TextFormField(
controller: _emailController,
decoration: InputDecoration(
labelText: 'Email',
border: const OutlineInputBorder(),
prefixIcon: const Icon(Icons.email_outlined),
suffixIcon: Icon(
Icons.lock_outline,
color: Colors.grey[400],
),
),
enabled: false,
style: TextStyle(color: Colors.grey[600]),
),
const SizedBox(height: 8),
Text(
'Email fourni par ${widget.platform == 'google' ? 'Google' : 'Apple'}',
style: TextStyle(fontSize: 12, color: Colors.grey[500]),
),
const SizedBox(height: 16),
// Champ Téléphone
TextFormField(
controller: _phoneController,
decoration: const InputDecoration(
labelText: 'Numéro de téléphone',
border: OutlineInputBorder(),
prefixIcon: Icon(Icons.phone_outlined),
hintText: '+33 6 12 34 56 78',
),
keyboardType: TextInputType.phone,
validator: (value) =>
_validateField(value, 'Numéro de téléphone'),
),
const SizedBox(height: 32),
// Bouton de confirmation
ElevatedButton(
onPressed: _submitForm,
style: ElevatedButton.styleFrom(
backgroundColor: Colors.blue,
foregroundColor: Colors.white,
padding: const EdgeInsets.symmetric(vertical: 16),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(8),
),
),
child: const Text(
'Confirmer mon inscription',
style: TextStyle(fontSize: 16, fontWeight: FontWeight.w600),
),
),
const SizedBox(height: 16),
// Bouton secondaire
TextButton(
onPressed: () => Navigator.pop(context),
child: const Text(
'Modifier la méthode de connexion',
style: TextStyle(color: Colors.grey, fontSize: 14),
),
),
],
),
),
),
),
);
}
}