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:
@@ -1,6 +1,27 @@
|
||||
/// States for trip-related operations in the TripBloc.
|
||||
///
|
||||
/// This file defines all possible states that the TripBloc can emit in response
|
||||
/// to trip-related events. The states represent different phases of trip
|
||||
/// operations including loading, success, error, and data states for trip management.
|
||||
///
|
||||
/// State Categories:
|
||||
/// - **Initial State**: TripInitial
|
||||
/// - **Loading States**: TripLoading
|
||||
/// - **Success States**: TripLoaded, TripCreated, TripOperationSuccess
|
||||
/// - **Error States**: TripError
|
||||
///
|
||||
/// The states support complete trip lifecycle management with proper feedback
|
||||
/// for create, read, update, and delete operations.
|
||||
///
|
||||
/// All states extend [TripState] and implement [Equatable] for proper
|
||||
/// equality comparison and state change detection in the BLoC pattern.
|
||||
import 'package:equatable/equatable.dart';
|
||||
import '../../models/trip.dart';
|
||||
|
||||
/// Base class for all trip-related states.
|
||||
///
|
||||
/// All trip states must extend this class and implement the [props] getter
|
||||
/// for proper equality comparison in the BLoC pattern.
|
||||
abstract class TripState extends Equatable {
|
||||
const TripState();
|
||||
|
||||
@@ -8,44 +29,111 @@ abstract class TripState extends Equatable {
|
||||
List<Object?> get props => [];
|
||||
}
|
||||
|
||||
/// The initial state of the TripBloc before any operations are performed.
|
||||
///
|
||||
/// This is the default state when the bloc is first created and represents
|
||||
/// a clean slate with no trip data loaded or operations in progress.
|
||||
class TripInitial extends TripState {}
|
||||
|
||||
/// State indicating that a trip operation is currently in progress.
|
||||
///
|
||||
/// This state is emitted when the bloc is performing operations like
|
||||
/// loading trips, creating trips, updating trip information, or deleting trips.
|
||||
/// UI components can use this state to show loading indicators.
|
||||
class TripLoading extends TripState {}
|
||||
|
||||
/// State containing a list of successfully loaded trips.
|
||||
///
|
||||
/// This state is emitted when trips have been successfully retrieved
|
||||
/// from the repository, either through initial loading or real-time updates.
|
||||
/// The UI can use this data to display the list of available trips for the user.
|
||||
///
|
||||
/// Properties:
|
||||
/// [trips]: List of Trip objects that were loaded
|
||||
class TripLoaded extends TripState {
|
||||
/// The list of loaded trips
|
||||
final List<Trip> trips;
|
||||
|
||||
/// Creates a TripLoaded state.
|
||||
///
|
||||
/// Args:
|
||||
/// [trips]: The list of trips to include in this state
|
||||
const TripLoaded(this.trips);
|
||||
|
||||
@override
|
||||
List<Object?> get props => [trips];
|
||||
}
|
||||
|
||||
/// State indicating successful trip creation.
|
||||
///
|
||||
/// This state is emitted when a new trip has been successfully created.
|
||||
/// It contains the ID of the newly created trip and a success message
|
||||
/// that can be displayed to the user. This state is typically followed
|
||||
/// by automatic reloading of the user's trip list.
|
||||
///
|
||||
/// Properties:
|
||||
/// [tripId]: The unique identifier of the newly created trip
|
||||
/// [message]: A success message to display to the user
|
||||
class TripCreated extends TripState {
|
||||
/// The unique identifier of the newly created trip
|
||||
final String tripId;
|
||||
|
||||
/// Success message for the user
|
||||
final String message;
|
||||
|
||||
/// Creates a TripCreated state.
|
||||
///
|
||||
/// Args:
|
||||
/// [tripId]: The ID of the newly created trip
|
||||
/// [message]: Optional success message (defaults to "Trip created successfully")
|
||||
const TripCreated({
|
||||
required this.tripId,
|
||||
this.message = 'Voyage créé avec succès',
|
||||
this.message = 'Trip created successfully',
|
||||
});
|
||||
|
||||
@override
|
||||
List<Object?> get props => [tripId, message];
|
||||
}
|
||||
|
||||
/// State indicating successful completion of a trip operation.
|
||||
///
|
||||
/// This state is emitted when operations like updating or deleting trips
|
||||
/// have completed successfully. It contains a message that can be displayed
|
||||
/// to inform the user of the successful operation. This state is typically
|
||||
/// followed by automatic reloading of the user's trip list.
|
||||
///
|
||||
/// Properties:
|
||||
/// [message]: A success message describing the completed operation
|
||||
class TripOperationSuccess extends TripState {
|
||||
/// The success message to display to the user
|
||||
final String message;
|
||||
|
||||
/// Creates a TripOperationSuccess state.
|
||||
///
|
||||
/// Args:
|
||||
/// [message]: The success message to display
|
||||
const TripOperationSuccess(this.message);
|
||||
|
||||
@override
|
||||
List<Object?> get props => [message];
|
||||
}
|
||||
|
||||
/// State indicating that a trip operation has failed.
|
||||
///
|
||||
/// This state is emitted when any trip operation encounters an error.
|
||||
/// It contains an error message that can be displayed to the user to
|
||||
/// explain what went wrong during the operation.
|
||||
///
|
||||
/// Properties:
|
||||
/// [message]: An error message describing what went wrong
|
||||
class TripError extends TripState {
|
||||
/// The error message to display to the user
|
||||
final String message;
|
||||
|
||||
/// Creates a TripError state.
|
||||
///
|
||||
/// Args:
|
||||
/// [message]: The error message to display
|
||||
const TripError(this.message);
|
||||
|
||||
@override
|
||||
|
||||
Reference in New Issue
Block a user