Enhance model and service documentation with detailed comments and descriptions
- Updated Group, Trip, User, and other model classes to include comprehensive documentation for better understanding and maintainability. - Improved error handling and logging in services, including AuthService, ErrorService, and StorageService. - Added validation and business logic explanations in ExpenseService and TripService. - Refactored method comments to follow a consistent format across the codebase. - Translated error messages and comments from French to English for consistency.
This commit is contained in:
@@ -4,7 +4,13 @@ import '../blocs/auth/auth_bloc.dart';
|
||||
import '../blocs/auth/auth_event.dart';
|
||||
import '../blocs/auth/auth_state.dart';
|
||||
|
||||
/// Login page widget for user authentication.
|
||||
///
|
||||
/// This page provides a user interface for signing in with email and password,
|
||||
/// as well as options for social sign-in (Google, Apple) and password reset.
|
||||
/// It integrates with the AuthBloc to handle authentication state management.
|
||||
class LoginPage extends StatefulWidget {
|
||||
/// Creates a new [LoginPage].
|
||||
const LoginPage({super.key});
|
||||
|
||||
@override
|
||||
@@ -12,9 +18,16 @@ class LoginPage extends StatefulWidget {
|
||||
}
|
||||
|
||||
class _LoginPageState extends State<LoginPage> {
|
||||
/// Form key for validation
|
||||
final _formKey = GlobalKey<FormState>();
|
||||
|
||||
/// Controller for email input field
|
||||
final _emailController = TextEditingController();
|
||||
|
||||
/// Controller for password input field
|
||||
final _passwordController = TextEditingController();
|
||||
|
||||
/// Whether the password field should hide its content
|
||||
bool _obscurePassword = true;
|
||||
|
||||
@override
|
||||
@@ -24,24 +37,36 @@ class _LoginPageState extends State<LoginPage> {
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
/// Validates email input.
|
||||
///
|
||||
/// Returns an error message if the email is invalid or empty,
|
||||
/// null if the email is valid.
|
||||
String? _validateEmail(String? value) {
|
||||
if (value == null || value.trim().isEmpty) {
|
||||
return 'Email requis';
|
||||
return 'Email required';
|
||||
}
|
||||
final emailRegex = RegExp(r'^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$');
|
||||
if (!emailRegex.hasMatch(value.trim())) {
|
||||
return 'Email invalide';
|
||||
return 'Invalid email';
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/// Validates password input.
|
||||
///
|
||||
/// Returns an error message if the password is empty,
|
||||
/// null if the password is valid.
|
||||
String? _validatePassword(String? value) {
|
||||
if (value == null || value.isEmpty) {
|
||||
return 'Mot de passe requis';
|
||||
return 'Password required';
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/// Handles the login process.
|
||||
///
|
||||
/// Validates the form and dispatches a sign-in event to the AuthBloc
|
||||
/// if all fields are valid.
|
||||
void _login(BuildContext context) {
|
||||
if (!_formKey.currentState!.validate()) {
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user