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:
Dayron
2025-10-30 15:56:17 +01:00
parent 1eeea6997e
commit 2faf37f145
46 changed files with 2656 additions and 220 deletions

View File

@@ -4,23 +4,39 @@ import 'package:shared_preferences/shared_preferences.dart';
import 'theme_event.dart';
import 'theme_state.dart';
/// BLoC for managing application theme preferences.
///
/// This BLoC handles theme-related events and manages the application's
/// theme mode (light, dark, or system). It persists theme preferences
/// using SharedPreferences for consistency across app sessions.
class ThemeBloc extends Bloc<ThemeEvent, ThemeState> {
/// Creates a new [ThemeBloc] with default theme state.
///
/// Registers event handlers for theme changes and loading saved preferences.
ThemeBloc() : super(const ThemeState()) {
on<ThemeChanged>(_onThemeChanged);
on<ThemeLoadRequested>(_onThemeLoadRequested);
}
/// Handles [ThemeChanged] events.
///
/// Updates the theme mode and persists the preference to local storage.
/// This ensures the theme choice is remembered across app restarts.
Future<void> _onThemeChanged(
ThemeChanged event,
Emitter<ThemeState> emit,
) async {
emit(state.copyWith(themeMode: event.themeMode));
// Sauvegarder la préférence
// Save the theme preference to persistent storage
final prefs = await SharedPreferences.getInstance();
await prefs.setString('themeMode', event.themeMode.toString());
}
/// Handles [ThemeLoadRequested] events.
///
/// Loads the saved theme preference from SharedPreferences and applies it.
/// If no preference is saved, the theme remains as system default.
Future<void> _onThemeLoadRequested(
ThemeLoadRequested event,
Emitter<ThemeState> emit,

View File

@@ -1,20 +1,35 @@
import 'package:equatable/equatable.dart';
import 'package:flutter/material.dart';
/// Abstract base class for all theme-related events.
///
/// This class extends [Equatable] to enable value equality for event comparison.
/// All theme events in the application should inherit from this class.
abstract class ThemeEvent extends Equatable {
/// Creates a new [ThemeEvent].
const ThemeEvent();
@override
List<Object?> get props => [];
}
/// Event to request a theme change.
///
/// This event is dispatched when the user wants to change the application theme
/// mode (light, dark, or system). The new theme mode is persisted and applied immediately.
class ThemeChanged extends ThemeEvent {
/// The new theme mode to apply.
final ThemeMode themeMode;
/// Creates a new [ThemeChanged] event with the specified [themeMode].
const ThemeChanged({required this.themeMode});
@override
List<Object?> get props => [themeMode];
}
/// Event to request loading of saved theme preferences.
///
/// This event is typically dispatched when the app starts to restore
/// the user's previously selected theme preference.
class ThemeLoadRequested extends ThemeEvent {}

View File

@@ -1,15 +1,32 @@
import 'package:equatable/equatable.dart';
import 'package:flutter/material.dart';
/// State class for theme management.
///
/// This class represents the current theme state of the application,
/// including the selected theme mode and provides utility methods
/// for theme-related operations.
class ThemeState extends Equatable {
/// The current theme mode of the application.
final ThemeMode themeMode;
/// Creates a new [ThemeState] with the specified [themeMode].
///
/// Defaults to [ThemeMode.system] if no theme mode is provided.
const ThemeState({this.themeMode = ThemeMode.system});
/// Whether the current theme mode is explicitly set to dark.
///
/// Returns true only if the theme mode is [ThemeMode.dark].
/// Returns false for [ThemeMode.light] and [ThemeMode.system].
bool get isDarkMode {
return themeMode == ThemeMode.dark;
}
/// Creates a copy of this state with optionally modified properties.
///
/// Allows updating the theme mode while preserving other state properties.
/// Useful for state transitions in the theme BLoC.
ThemeState copyWith({ThemeMode? themeMode}) {
return ThemeState(
themeMode: themeMode ?? this.themeMode,