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

@@ -1,3 +1,26 @@
/// A BLoC (Business Logic Component) that manages account-related state and operations.
///
/// This bloc handles account operations such as loading accounts by user ID,
/// creating new accounts, and managing real-time updates from the account repository.
/// It uses stream subscriptions to listen for account changes and emits corresponding states.
///
/// The bloc supports the following operations:
/// - Loading accounts by user ID with real-time updates
/// - Creating a single account without members
/// - Creating an account with associated members
///
/// All errors are logged using [ErrorService] and emitted as [AccountError] states.
///
/// Example usage:
/// ```dart
/// final accountBloc = AccountBloc(accountRepository);
/// accountBloc.add(LoadAccountsByUserId('user123'));
/// ```
///
/// Remember to close the bloc when done to cancel active subscriptions:
/// ```dart
/// accountBloc.close();
/// ```
import 'dart:async';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:travel_mate/services/error_service.dart';

View File

@@ -1,14 +1,23 @@
import 'package:equatable/equatable.dart';
import '../../models/account.dart';
import '../../models/group_member.dart';
import 'package:travel_mate/models/account.dart';
import 'package:travel_mate/models/group_member.dart';
/// Abstract base class for account-related events in the BLoC pattern.
///
/// This class extends [Equatable] to enable value comparison for events.
/// All account events should inherit from this class and implement the [props] getter.
abstract class AccountEvent extends Equatable {
const AccountEvent();
@override
List<Object?> get props => [];
}
}
/// Event to load accounts associated with a specific user ID.
///
/// This event is dispatched when the application needs to fetch accounts
/// for a given user, typically for displaying user-specific account data.
class LoadAccountsByUserId extends AccountEvent {
final String userId;
@@ -18,6 +27,10 @@ class LoadAccountsByUserId extends AccountEvent {
List<Object?> get props => [userId];
}
/// Event to load accounts associated with a specific trip.
///
/// This event is dispatched when the application needs to fetch accounts
/// related to a particular trip, such as for trip expense management.
class LoadAccountsByTrip extends AccountEvent {
final String tripId;
@@ -27,6 +40,10 @@ class LoadAccountsByTrip extends AccountEvent {
List<Object?> get props => [tripId];
}
/// Event to create a new account.
///
/// This event is dispatched when a new account needs to be created,
/// passing the [Account] object containing the account details.
class CreateAccount extends AccountEvent {
final Account account;
@@ -36,6 +53,10 @@ class CreateAccount extends AccountEvent {
List<Object?> get props => [account];
}
/// Event to update an existing account.
///
/// This event is dispatched when an account needs to be modified,
/// requiring the [accountId] to identify the account and the updated [Account] object.
class UpdateAccount extends AccountEvent {
final String accountId;
final Account account;
@@ -49,6 +70,10 @@ class UpdateAccount extends AccountEvent {
List<Object?> get props => [accountId, account];
}
/// Event to create a new account along with its group members.
///
/// This event is dispatched when creating an account that includes
/// a list of [GroupMember] objects, such as for shared trip accounts.
class CreateAccountWithMembers extends AccountEvent {
final Account account;
final List<GroupMember> members;

View File

@@ -1,3 +1,38 @@
/// The abstract base class for all account-related states used by the AccountBloc.
///
/// Extends Equatable to enable value-based comparisons between state
/// instances. Subclasses should provide the relevant properties by
/// overriding `props` so that the bloc can correctly determine whether
/// the state has changed.
/// Represents the initial state of the account feature.
///
/// Used before any account-related action has started or when the bloc
/// has been freshly created.
/// Indicates that an account-related operation is currently in progress.
///
/// This state is typically emitted while fetching account data, creating,
/// updating, or deleting an account so the UI can show a loading indicator.
/// Emitted when a collection of accounts has been successfully loaded.
///
/// Contains:
/// - `accounts`: the list of Account models retrieved from the repository.
///
/// Use this state to display fetched account data in the UI.
/// Represents a successful account operation that does not necessarily
/// carry account data (e.g., after creating, updating, or deleting an account).
///
/// Contains:
/// - `message`: a human-readable success message that can be shown to the user.
/// Represents an error that occurred during an account-related operation.
///
/// Contains:
/// - `message`: a human-readable error description suitable for logging
/// or displaying to the user.
import 'package:equatable/equatable.dart';
import '../../models/account.dart';