J'ajoute tout ce que cursor a oublié...
This commit is contained in:
@@ -1,22 +0,0 @@
|
||||
import 'package:firebase_core/firebase_core.dart' show FirebaseOptions;
|
||||
import 'package:flutter/foundation.dart'
|
||||
show defaultTargetPlatform, kIsWeb, TargetPlatform;
|
||||
|
||||
class DefaultFirebaseOptions {
|
||||
static FirebaseOptions get currentPlatform {
|
||||
if (kIsWeb) {
|
||||
return web;
|
||||
}
|
||||
// Handle other platforms if needed
|
||||
return web;
|
||||
}
|
||||
|
||||
static const FirebaseOptions web = FirebaseOptions(
|
||||
apiKey: 'AIzaSyDXVQr3rlBPXhk-dYB6DyQF_JYrHKxXwrk',
|
||||
appId: '1:654650461516:web:7a9e7c84c26c5a3a7c0e2c',
|
||||
messagingSenderId: '654650461516',
|
||||
projectId: 'petitspas-dev',
|
||||
authDomain: 'petitspas-dev.firebaseapp.com',
|
||||
storageBucket: 'petitspas-dev.appspot.com',
|
||||
);
|
||||
}
|
||||
+10
-49
@@ -1,61 +1,22 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:google_fonts/google_fonts.dart';
|
||||
import 'theme/app_theme.dart';
|
||||
import 'theme/theme_provider.dart';
|
||||
import 'screens/auth/login_screen.dart';
|
||||
import 'screens/auth/parent_register_screen.dart';
|
||||
import 'screens/home/home_screen.dart';
|
||||
import 'navigation/app_router.dart';
|
||||
|
||||
void main() {
|
||||
runApp(
|
||||
MultiProvider(
|
||||
providers: [
|
||||
ChangeNotifierProvider(create: (_) => ThemeProvider()),
|
||||
],
|
||||
child: const MyApp(),
|
||||
),
|
||||
);
|
||||
}
|
||||
void main() => runApp(const PtiPasApp());
|
||||
|
||||
final _router = GoRouter(
|
||||
initialLocation: '/login',
|
||||
routes: [
|
||||
GoRoute(
|
||||
path: '/login',
|
||||
builder: (context, state) => const LoginScreen(),
|
||||
),
|
||||
GoRoute(
|
||||
path: '/parent-register',
|
||||
builder: (context, state) => const ParentRegisterScreen(),
|
||||
),
|
||||
GoRoute(
|
||||
path: '/home',
|
||||
builder: (context, state) => const HomeScreen(),
|
||||
),
|
||||
],
|
||||
);
|
||||
final _router = GoRouter(routes: [
|
||||
GoRoute(path: '/', builder: (_, __) => const LoginPage()),
|
||||
]);
|
||||
|
||||
class MyApp extends StatelessWidget {
|
||||
const MyApp({super.key});
|
||||
class PtiPasApp extends StatelessWidget {
|
||||
const PtiPasApp({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Consumer<ThemeProvider>(
|
||||
builder: (context, themeProvider, _) {
|
||||
final appTheme = AppTheme();
|
||||
return MaterialApp.router(
|
||||
title: 'P\'titsPas',
|
||||
theme: themeProvider.currentTheme == ThemeType.darkTheme
|
||||
? appTheme.darkTheme
|
||||
: (themeProvider.currentTheme == ThemeType.pastelTheme
|
||||
? appTheme.pastelTheme
|
||||
: appTheme.lightTheme),
|
||||
routerConfig: _router,
|
||||
);
|
||||
},
|
||||
return MaterialApp.router(
|
||||
title: 'P\'titsPas',
|
||||
routerConfig: _router,
|
||||
debugShowCheckedModeBanner: false,
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,12 +1,11 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import '../screens/auth/login_screen.dart';
|
||||
import '../screens/auth/register_screen.dart';
|
||||
import '../screens/auth/parent_register_screen.dart';
|
||||
import '../screens/home/home_screen.dart';
|
||||
|
||||
class AppRouter {
|
||||
static const String login = '/login';
|
||||
static const String register = '/register';
|
||||
static const String parentRegister = '/parent-register';
|
||||
static const String home = '/home';
|
||||
|
||||
@@ -14,8 +13,6 @@ class AppRouter {
|
||||
switch (settings.name) {
|
||||
case login:
|
||||
return MaterialPageRoute(builder: (_) => const LoginScreen());
|
||||
case register:
|
||||
return MaterialPageRoute(builder: (_) => const RegisterScreen());
|
||||
case parentRegister:
|
||||
return MaterialPageRoute(builder: (_) => const ParentRegisterScreen());
|
||||
case home:
|
||||
|
||||
@@ -3,6 +3,7 @@ import 'package:image_picker/image_picker.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import '../../services/auth_service.dart';
|
||||
import '../../theme/app_theme.dart';
|
||||
import 'dart:convert';
|
||||
|
||||
class ChildData {
|
||||
final TextEditingController firstNameController = TextEditingController();
|
||||
@@ -107,17 +108,12 @@ class _ParentRegisterScreenState extends State<ParentRegisterScreen> {
|
||||
final List<Map<String, dynamic>> childrenData = [];
|
||||
|
||||
for (var child in _children) {
|
||||
String? childPhotoUrl;
|
||||
if (child.photo != null) {
|
||||
childPhotoUrl = await _uploadImage(child.photo!, _emailController.text);
|
||||
}
|
||||
|
||||
childrenData.add({
|
||||
'firstName': child.firstNameController.text,
|
||||
'lastName': child.lastNameController.text,
|
||||
'birthDate': child.isUnborn ? null : child.birthDate,
|
||||
'expectedBirthDate': child.isUnborn ? child.expectedBirthDate : null,
|
||||
'photoUrl': childPhotoUrl,
|
||||
'photo': child.photo != null ? base64Encode(child.photo!.readAsBytesSync()) : null,
|
||||
'hasPhotoConsent': child.hasPhotoConsent,
|
||||
'isMultipleBirth': child.isMultipleBirth,
|
||||
});
|
||||
|
||||
@@ -1,157 +0,0 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import '../../services/auth_service.dart';
|
||||
|
||||
class RegisterScreen extends StatefulWidget {
|
||||
const RegisterScreen({super.key});
|
||||
|
||||
@override
|
||||
State<RegisterScreen> createState() => _RegisterScreenState();
|
||||
}
|
||||
|
||||
class _RegisterScreenState extends State<RegisterScreen> {
|
||||
final _formKey = GlobalKey<FormState>();
|
||||
final _emailController = TextEditingController();
|
||||
final _passwordController = TextEditingController();
|
||||
final _firstNameController = TextEditingController();
|
||||
final _lastNameController = TextEditingController();
|
||||
bool _isLoading = false;
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_emailController.dispose();
|
||||
_passwordController.dispose();
|
||||
_firstNameController.dispose();
|
||||
_lastNameController.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
Future<void> _register() async {
|
||||
if (_formKey.currentState!.validate()) {
|
||||
setState(() => _isLoading = true);
|
||||
try {
|
||||
await AuthService.register(
|
||||
email: _emailController.text,
|
||||
password: _passwordController.text,
|
||||
firstName: _firstNameController.text,
|
||||
lastName: _lastNameController.text,
|
||||
role: 'user',
|
||||
);
|
||||
|
||||
if (mounted) {
|
||||
context.go('/login');
|
||||
}
|
||||
} catch (e) {
|
||||
if (mounted) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(
|
||||
content: Text('Erreur lors de l\'inscription: $e'),
|
||||
backgroundColor: Colors.red,
|
||||
),
|
||||
);
|
||||
}
|
||||
} finally {
|
||||
if (mounted) {
|
||||
setState(() => _isLoading = false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: const Text('Inscription'),
|
||||
),
|
||||
body: Center(
|
||||
child: SingleChildScrollView(
|
||||
padding: const EdgeInsets.all(16.0),
|
||||
child: Form(
|
||||
key: _formKey,
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
TextFormField(
|
||||
controller: _firstNameController,
|
||||
decoration: const InputDecoration(
|
||||
labelText: 'Prénom',
|
||||
border: OutlineInputBorder(),
|
||||
),
|
||||
validator: (value) {
|
||||
if (value == null || value.isEmpty) {
|
||||
return 'Veuillez entrer votre prénom';
|
||||
}
|
||||
return null;
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
TextFormField(
|
||||
controller: _lastNameController,
|
||||
decoration: const InputDecoration(
|
||||
labelText: 'Nom',
|
||||
border: OutlineInputBorder(),
|
||||
),
|
||||
validator: (value) {
|
||||
if (value == null || value.isEmpty) {
|
||||
return 'Veuillez entrer votre nom';
|
||||
}
|
||||
return null;
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
TextFormField(
|
||||
controller: _emailController,
|
||||
decoration: const InputDecoration(
|
||||
labelText: 'Email',
|
||||
border: OutlineInputBorder(),
|
||||
),
|
||||
keyboardType: TextInputType.emailAddress,
|
||||
validator: (value) {
|
||||
if (value == null || value.isEmpty) {
|
||||
return 'Veuillez entrer votre email';
|
||||
}
|
||||
if (!value.contains('@')) {
|
||||
return 'Veuillez entrer un email valide';
|
||||
}
|
||||
return null;
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
TextFormField(
|
||||
controller: _passwordController,
|
||||
decoration: const InputDecoration(
|
||||
labelText: 'Mot de passe',
|
||||
border: OutlineInputBorder(),
|
||||
),
|
||||
obscureText: true,
|
||||
validator: (value) {
|
||||
if (value == null || value.isEmpty) {
|
||||
return 'Veuillez entrer un mot de passe';
|
||||
}
|
||||
if (value.length < 6) {
|
||||
return 'Le mot de passe doit contenir au moins 6 caractères';
|
||||
}
|
||||
return null;
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 24),
|
||||
ElevatedButton(
|
||||
onPressed: _isLoading ? null : _register,
|
||||
child: _isLoading
|
||||
? const CircularProgressIndicator()
|
||||
: const Text('S\'inscrire'),
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
TextButton(
|
||||
onPressed: () => context.go('/login'),
|
||||
child: const Text('Déjà un compte ? Se connecter'),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user