- 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.
88 lines
2.5 KiB
Dart
88 lines
2.5 KiB
Dart
import 'package:equatable/equatable.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;
|
|
|
|
const LoadAccountsByUserId(this.userId);
|
|
|
|
@override
|
|
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;
|
|
|
|
const LoadAccountsByTrip(this.tripId);
|
|
|
|
@override
|
|
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;
|
|
|
|
const CreateAccount(this.account);
|
|
|
|
@override
|
|
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;
|
|
|
|
const UpdateAccount({
|
|
required this.accountId,
|
|
required this.account,
|
|
});
|
|
|
|
@override
|
|
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;
|
|
|
|
const CreateAccountWithMembers({
|
|
required this.account,
|
|
required this.members,
|
|
});
|
|
|
|
@override
|
|
List<Object?> get props => [account, members];
|
|
} |