import 'package:equatable/equatable.dart'; /// Abstract base class for all balance-related events. /// /// This class extends [Equatable] to enable value equality for event comparison. /// All balance events in the application should inherit from this class. abstract class BalanceEvent extends Equatable { /// Creates a new [BalanceEvent]. const BalanceEvent(); @override List get props => []; } /// Event to load balance information for a specific group. /// /// This event triggers the loading of user balances and settlements /// for all members of the specified group. It calculates who owes /// money to whom based on shared expenses. class LoadGroupBalances extends BalanceEvent { /// The ID of the group to load balances for. final String groupId; /// Creates a [LoadGroupBalances] event for the specified [groupId]. const LoadGroupBalances(this.groupId); @override List get props => [groupId]; } /// Event to refresh balance calculations for a group. /// /// This event recalculates all balances and settlements for a group, /// typically called after expenses are added, modified, or deleted. class RefreshBalance extends BalanceEvent { /// The ID of the group to refresh balances for. final String groupId; /// Creates a [RefreshBalance] event for the specified [groupId]. const RefreshBalance(this.groupId); @override List get props => [groupId]; } /// Event to mark a settlement as completed between two users. /// /// This event is dispatched when one user pays back money they owe /// to another user, updating the balance calculations accordingly. class MarkSettlementAsCompleted extends BalanceEvent { /// The ID of the group where the settlement occurred. final String groupId; /// The ID of the user who is paying the debt. final String fromUserId; /// The ID of the user who is receiving the payment. final String toUserId; /// The amount being settled. final double amount; /// Creates a [MarkSettlementAsCompleted] event with the settlement details. /// /// All parameters are required to properly record the settlement. const MarkSettlementAsCompleted({ required this.groupId, required this.fromUserId, required this.toUserId, required this.amount, }); @override List get props => [groupId, fromUserId, toUserId, amount]; }