Ajout de la page de connexion
This commit is contained in:
parent
2a9918d755
commit
64a1d56e2f
31
em2rp/.vscode/launch.json
vendored
31
em2rp/.vscode/launch.json
vendored
@ -3,21 +3,22 @@
|
||||
// Hover to view descriptions of existing attributes.
|
||||
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
|
||||
"version": "0.2.0",
|
||||
"configurations": [
|
||||
{
|
||||
"name": "Launch Edge",
|
||||
"request": "launch",
|
||||
"type": "msedge",
|
||||
"url": "http://localhost:8080",
|
||||
"webRoot": "${workspaceFolder}"
|
||||
},
|
||||
{
|
||||
"name": "Attach to Edge",
|
||||
"port": 9222,
|
||||
"request": "attach",
|
||||
"type": "msedge",
|
||||
"webRoot": "${workspaceFolder}"
|
||||
},
|
||||
"configurations": [
|
||||
|
||||
{
|
||||
"name": "Launch Edge",
|
||||
"request": "launch",
|
||||
"type": "msedge",
|
||||
"url": "http://localhost:8080",
|
||||
"webRoot": "${workspaceFolder}"
|
||||
},
|
||||
{
|
||||
"name": "Attach to Edge",
|
||||
"port": 9222,
|
||||
"request": "attach",
|
||||
"type": "msedge",
|
||||
"webRoot": "${workspaceFolder}"
|
||||
},
|
||||
{
|
||||
"name": "em2rp",
|
||||
"request": "launch",
|
||||
|
BIN
em2rp/assets/EM2_NsurB.jpg
Normal file
BIN
em2rp/assets/EM2_NsurB.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 92 KiB |
1
em2rp/assets/Google__G__logo.svg
Normal file
1
em2rp/assets/Google__G__logo.svg
Normal file
@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" height="24" viewBox="0 0 24 24" width="24"><path d="M22.56 12.25c0-.78-.07-1.53-.2-2.25H12v4.26h5.92c-.26 1.37-1.04 2.53-2.21 3.31v2.77h3.57c2.08-1.92 3.28-4.74 3.28-8.09z" fill="#4285F4"/><path d="M12 23c2.97 0 5.46-.98 7.28-2.66l-3.57-2.77c-.98.66-2.23 1.06-3.71 1.06-2.86 0-5.29-1.93-6.16-4.53H2.18v2.84C3.99 20.53 7.7 23 12 23z" fill="#34A853"/><path d="M5.84 14.09c-.22-.66-.35-1.36-.35-2.09s.13-1.43.35-2.09V7.07H2.18C1.43 8.55 1 10.22 1 12s.43 3.45 1.18 4.93l2.85-2.22.81-.62z" fill="#FBBC05"/><path d="M12 5.38c1.62 0 3.06.56 4.21 1.64l3.15-3.15C17.45 2.09 14.97 1 12 1 7.7 1 3.99 3.47 2.18 7.07l3.66 2.84c.87-2.6 3.3-4.53 6.16-4.53z" fill="#EA4335"/><path d="M1 1h22v22H1z" fill="none"/></svg>
|
After Width: | Height: | Size: 742 B |
BIN
em2rp/assets/google.png
Normal file
BIN
em2rp/assets/google.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 16 KiB |
@ -42,11 +42,12 @@ class DefaultFirebaseOptions {
|
||||
|
||||
static const FirebaseOptions web = FirebaseOptions(
|
||||
apiKey: 'AIzaSyARQL4P-t5l-cNjQNP9cMokQrLJ8BorF0U',
|
||||
appId: '1:341201262902:web:bb70b5ff45df80935a3b97',
|
||||
appId: '1:341201262902:web:c9f26c7729df8e915a3b97',
|
||||
messagingSenderId: '341201262902',
|
||||
projectId: 'em2rp-951dc',
|
||||
authDomain: 'em2rp-951dc.firebaseapp.com',
|
||||
databaseURL: 'https://em2rp-951dc-default-rtdb.europe-west1.firebasedatabase.app',
|
||||
databaseURL:
|
||||
'https://em2rp-951dc-default-rtdb.europe-west1.firebasedatabase.app',
|
||||
storageBucket: 'em2rp-951dc.firebasestorage.app',
|
||||
);
|
||||
|
||||
@ -55,7 +56,8 @@ class DefaultFirebaseOptions {
|
||||
appId: '1:341201262902:android:8c9a9e340ecb58665a3b97',
|
||||
messagingSenderId: '341201262902',
|
||||
projectId: 'em2rp-951dc',
|
||||
databaseURL: 'https://em2rp-951dc-default-rtdb.europe-west1.firebasedatabase.app',
|
||||
databaseURL:
|
||||
'https://em2rp-951dc-default-rtdb.europe-west1.firebasedatabase.app',
|
||||
storageBucket: 'em2rp-951dc.firebasestorage.app',
|
||||
);
|
||||
|
||||
@ -64,10 +66,13 @@ class DefaultFirebaseOptions {
|
||||
appId: '1:341201262902:ios:767281c23dd9e76a5a3b97',
|
||||
messagingSenderId: '341201262902',
|
||||
projectId: 'em2rp-951dc',
|
||||
databaseURL: 'https://em2rp-951dc-default-rtdb.europe-west1.firebasedatabase.app',
|
||||
databaseURL:
|
||||
'https://em2rp-951dc-default-rtdb.europe-west1.firebasedatabase.app',
|
||||
storageBucket: 'em2rp-951dc.firebasestorage.app',
|
||||
androidClientId: '341201262902-opnuh9ri7ao77qlhebjhshsavplb7vsl.apps.googleusercontent.com',
|
||||
iosClientId: '341201262902-22rdtoljpgk65lj76bqbk52v861d9lt0.apps.googleusercontent.com',
|
||||
androidClientId:
|
||||
'341201262902-opnuh9ri7ao77qlhebjhshsavplb7vsl.apps.googleusercontent.com',
|
||||
iosClientId:
|
||||
'341201262902-22rdtoljpgk65lj76bqbk52v861d9lt0.apps.googleusercontent.com',
|
||||
iosBundleId: 'com.em2.erp',
|
||||
);
|
||||
|
||||
@ -76,10 +81,13 @@ class DefaultFirebaseOptions {
|
||||
appId: '1:341201262902:ios:767281c23dd9e76a5a3b97',
|
||||
messagingSenderId: '341201262902',
|
||||
projectId: 'em2rp-951dc',
|
||||
databaseURL: 'https://em2rp-951dc-default-rtdb.europe-west1.firebasedatabase.app',
|
||||
databaseURL:
|
||||
'https://em2rp-951dc-default-rtdb.europe-west1.firebasedatabase.app',
|
||||
storageBucket: 'em2rp-951dc.firebasestorage.app',
|
||||
androidClientId: '341201262902-opnuh9ri7ao77qlhebjhshsavplb7vsl.apps.googleusercontent.com',
|
||||
iosClientId: '341201262902-22rdtoljpgk65lj76bqbk52v861d9lt0.apps.googleusercontent.com',
|
||||
androidClientId:
|
||||
'341201262902-opnuh9ri7ao77qlhebjhshsavplb7vsl.apps.googleusercontent.com',
|
||||
iosClientId:
|
||||
'341201262902-22rdtoljpgk65lj76bqbk52v861d9lt0.apps.googleusercontent.com',
|
||||
iosBundleId: 'com.em2.erp',
|
||||
);
|
||||
|
||||
@ -89,7 +97,8 @@ class DefaultFirebaseOptions {
|
||||
messagingSenderId: '341201262902',
|
||||
projectId: 'em2rp-951dc',
|
||||
authDomain: 'em2rp-951dc.firebaseapp.com',
|
||||
databaseURL: 'https://em2rp-951dc-default-rtdb.europe-west1.firebasedatabase.app',
|
||||
databaseURL:
|
||||
'https://em2rp-951dc-default-rtdb.europe-west1.firebasedatabase.app',
|
||||
storageBucket: 'em2rp-951dc.firebasestorage.app',
|
||||
);
|
||||
}
|
||||
|
@ -1,28 +1,61 @@
|
||||
import 'package:em2rp/views/login_page.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:firebase_core/firebase_core.dart';
|
||||
import 'firebase_options.dart';
|
||||
import 'utils/colors.dart';
|
||||
|
||||
void main() async {
|
||||
WidgetsFlutterBinding
|
||||
.ensureInitialized(); // Assure que Flutter est initialisé
|
||||
WidgetsFlutterBinding.ensureInitialized();
|
||||
await Firebase.initializeApp(
|
||||
options:
|
||||
DefaultFirebaseOptions.currentPlatform, // Utilise firebase_options.dart
|
||||
options: DefaultFirebaseOptions.currentPlatform,
|
||||
);
|
||||
runApp(const MainApp());
|
||||
runApp(const MyApp());
|
||||
}
|
||||
|
||||
class MainApp extends StatelessWidget {
|
||||
const MainApp({super.key});
|
||||
class MyApp extends StatelessWidget {
|
||||
const MyApp({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return const MaterialApp(
|
||||
home: Scaffold(
|
||||
body: Center(
|
||||
child: Text('Hello World!'),
|
||||
return MaterialApp(
|
||||
title: 'EM2 ERP',
|
||||
theme: ThemeData(
|
||||
primarySwatch: Colors.red,
|
||||
primaryColor: AppColors.noir,
|
||||
colorScheme:
|
||||
ColorScheme.fromSwatch().copyWith(secondary: AppColors.rouge),
|
||||
textTheme: const TextTheme(
|
||||
bodyMedium: TextStyle(color: AppColors.noir),
|
||||
),
|
||||
// Personnalisation de l'InputDecorationTheme pour les text fields
|
||||
inputDecorationTheme: InputDecorationTheme(
|
||||
focusedBorder: OutlineInputBorder(
|
||||
// Bordure lorsqu'il est focus
|
||||
borderSide:
|
||||
BorderSide(color: AppColors.rouge), // Couleur rouge quand focus
|
||||
),
|
||||
enabledBorder: OutlineInputBorder(
|
||||
// Bordure par défaut (non focus)
|
||||
borderSide:
|
||||
BorderSide(color: AppColors.gris), // Couleur grise par défaut
|
||||
),
|
||||
labelStyle: TextStyle(color: AppColors.noir), // Couleur du label
|
||||
hintStyle: TextStyle(color: AppColors.gris), // Couleur du hint text
|
||||
// Tu peux personnaliser d'autres propriétés ici :
|
||||
// fillColor, filled, iconColor, prefixStyle, suffixStyle, etc.
|
||||
),
|
||||
elevatedButtonTheme: ElevatedButtonThemeData(
|
||||
style: ElevatedButton.styleFrom(
|
||||
foregroundColor:
|
||||
AppColors.blanc, // Couleur du texte du bouton (ici blanc)
|
||||
backgroundColor: AppColors
|
||||
.noir, // Couleur de fond du bouton (si tu veux aussi changer le fond)
|
||||
// Autres styles possibles pour les boutons :
|
||||
// textStyle, padding, shape, elevation, etc.
|
||||
),
|
||||
),
|
||||
),
|
||||
home: const LoginPage(),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
8
em2rp/lib/utils/colors.dart
Normal file
8
em2rp/lib/utils/colors.dart
Normal file
@ -0,0 +1,8 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class AppColors {
|
||||
static const Color noir = Color(0xFF000000); // Noir
|
||||
static const Color blanc = Color(0xFFFFFFFF); // Blanc
|
||||
static const Color rouge = Color(0xFFFF0000); // Rouge
|
||||
static const Color gris = Color(0xFF808080); // Gris (gris moyen)
|
||||
}
|
106
em2rp/lib/views/login_page.dart
Normal file
106
em2rp/lib/views/login_page.dart
Normal file
@ -0,0 +1,106 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:firebase_auth/firebase_auth.dart';
|
||||
|
||||
class LoginPage extends StatefulWidget {
|
||||
const LoginPage({super.key});
|
||||
|
||||
@override
|
||||
State<LoginPage> createState() => _LoginPageState();
|
||||
}
|
||||
|
||||
class _LoginPageState extends State<LoginPage> {
|
||||
final _emailController = TextEditingController();
|
||||
final _passwordController = TextEditingController();
|
||||
String _errorMessage = '';
|
||||
bool _isLoading = false;
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_emailController.dispose();
|
||||
_passwordController.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
Future<void> _signInWithEmailAndPassword() async {
|
||||
setState(() {
|
||||
_errorMessage = '';
|
||||
_isLoading = true;
|
||||
});
|
||||
try {
|
||||
await FirebaseAuth.instance.signInWithEmailAndPassword(
|
||||
email: _emailController.text.trim(),
|
||||
password: _passwordController.text,
|
||||
);
|
||||
// Navigation vers la page principale après connexion réussie (à implémenter)
|
||||
// Par exemple : Navigator.of(context).pushReplacementNamed('/home');
|
||||
} on FirebaseAuthException catch (e) {
|
||||
setState(() {
|
||||
_errorMessage = "Erreur de connexion: ${e.message}";
|
||||
_isLoading = false;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: const Text('Connexion'),
|
||||
),
|
||||
body: Center(
|
||||
child: SingleChildScrollView(
|
||||
// Pour éviter le débordement sur les petits écrans
|
||||
padding: const EdgeInsets.all(20.0),
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: <Widget>[
|
||||
Image.asset(
|
||||
'assets/EM2_NsurB.jpg',
|
||||
height: 150,
|
||||
),
|
||||
const SizedBox(height: 20),
|
||||
const Text(
|
||||
'Bienvenue !',
|
||||
style: TextStyle(fontSize: 24, fontWeight: FontWeight.bold),
|
||||
),
|
||||
const SizedBox(height: 20),
|
||||
TextField(
|
||||
controller: _emailController,
|
||||
keyboardType: TextInputType.emailAddress,
|
||||
decoration: const InputDecoration(
|
||||
labelText: 'Email',
|
||||
border: OutlineInputBorder(),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
TextField(
|
||||
controller: _passwordController,
|
||||
obscureText: true,
|
||||
decoration: const InputDecoration(
|
||||
labelText: 'Mot de passe',
|
||||
border: OutlineInputBorder(),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 20),
|
||||
ElevatedButton(
|
||||
onPressed: _isLoading
|
||||
? null
|
||||
: _signInWithEmailAndPassword, // Désactiver pendant le chargement
|
||||
child: _isLoading
|
||||
? const CircularProgressIndicator() // Indicateur de chargement
|
||||
: const Text('Se connecter'),
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
const SizedBox(height: 10),
|
||||
if (_errorMessage.isNotEmpty)
|
||||
Text(
|
||||
_errorMessage,
|
||||
style: const TextStyle(color: Colors.red),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
@ -12,11 +12,14 @@ dependencies:
|
||||
firebase_core: ^3.12.1
|
||||
firebase_auth: ^5.5.1
|
||||
cloud_firestore: ^5.6.5
|
||||
google_sign_in: ^6.2.2
|
||||
|
||||
dev_dependencies:
|
||||
flutter_test:
|
||||
sdk: flutter
|
||||
flutter_lints: ^4.0.0
|
||||
flutter_lints: ^5.0.0
|
||||
|
||||
flutter:
|
||||
uses-material-design: true
|
||||
assets:
|
||||
- assets/
|
||||
|
Loading…
x
Reference in New Issue
Block a user