116 lines
3.3 KiB
Dart
116 lines
3.3 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];
|
|
}
|
|
|
|
/// Event to add a member to an existing account.
|
|
///
|
|
/// This event is dispatched when a new member needs to be added to
|
|
/// an account, typically when editing a trip and adding new participants.
|
|
class AddMemberToAccount extends AccountEvent {
|
|
final String accountId;
|
|
final GroupMember member;
|
|
|
|
const AddMemberToAccount(this.accountId, this.member);
|
|
|
|
@override
|
|
List<Object?> get props => [accountId, member];
|
|
}
|
|
|
|
/// Event to remove a member from an existing account.
|
|
///
|
|
/// This event is dispatched when a member needs to be removed from
|
|
/// an account, typically when editing a trip and removing participants.
|
|
class RemoveMemberFromAccount extends AccountEvent {
|
|
final String accountId;
|
|
final String memberId;
|
|
|
|
const RemoveMemberFromAccount(this.accountId, this.memberId);
|
|
|
|
@override
|
|
List<Object?> get props => [accountId, memberId];
|
|
} |