173 lines
3.9 KiB
Dart
173 lines
3.9 KiB
Dart
/// États pour le BLoC des contributions
|
|
library contributions_state;
|
|
|
|
import 'package:equatable/equatable.dart';
|
|
import '../data/models/contribution_model.dart';
|
|
|
|
/// Classe de base pour tous les états de contributions
|
|
abstract class ContributionsState extends Equatable {
|
|
const ContributionsState();
|
|
|
|
@override
|
|
List<Object?> get props => [];
|
|
}
|
|
|
|
/// État initial
|
|
class ContributionsInitial extends ContributionsState {
|
|
const ContributionsInitial();
|
|
}
|
|
|
|
/// État de chargement
|
|
class ContributionsLoading extends ContributionsState {
|
|
final String? message;
|
|
|
|
const ContributionsLoading({this.message});
|
|
|
|
@override
|
|
List<Object?> get props => [message];
|
|
}
|
|
|
|
/// État de rafraîchissement
|
|
class ContributionsRefreshing extends ContributionsState {
|
|
const ContributionsRefreshing();
|
|
}
|
|
|
|
/// État chargé avec succès
|
|
class ContributionsLoaded extends ContributionsState {
|
|
final List<ContributionModel> contributions;
|
|
final int total;
|
|
final int page;
|
|
final int size;
|
|
final int totalPages;
|
|
|
|
const ContributionsLoaded({
|
|
required this.contributions,
|
|
required this.total,
|
|
required this.page,
|
|
required this.size,
|
|
required this.totalPages,
|
|
});
|
|
|
|
@override
|
|
List<Object?> get props => [contributions, total, page, size, totalPages];
|
|
}
|
|
|
|
/// État détail d'une contribution chargé
|
|
class ContributionDetailLoaded extends ContributionsState {
|
|
final ContributionModel contribution;
|
|
|
|
const ContributionDetailLoaded({required this.contribution});
|
|
|
|
@override
|
|
List<Object?> get props => [contribution];
|
|
}
|
|
|
|
/// État contribution créée
|
|
class ContributionCreated extends ContributionsState {
|
|
final ContributionModel contribution;
|
|
|
|
const ContributionCreated({required this.contribution});
|
|
|
|
@override
|
|
List<Object?> get props => [contribution];
|
|
}
|
|
|
|
/// État contribution mise à jour
|
|
class ContributionUpdated extends ContributionsState {
|
|
final ContributionModel contribution;
|
|
|
|
const ContributionUpdated({required this.contribution});
|
|
|
|
@override
|
|
List<Object?> get props => [contribution];
|
|
}
|
|
|
|
/// État contribution supprimée
|
|
class ContributionDeleted extends ContributionsState {
|
|
final String id;
|
|
|
|
const ContributionDeleted({required this.id});
|
|
|
|
@override
|
|
List<Object?> get props => [id];
|
|
}
|
|
|
|
/// État paiement enregistré
|
|
class PaymentRecorded extends ContributionsState {
|
|
final ContributionModel contribution;
|
|
|
|
const PaymentRecorded({required this.contribution});
|
|
|
|
@override
|
|
List<Object?> get props => [contribution];
|
|
}
|
|
|
|
/// État statistiques chargées
|
|
class ContributionsStatsLoaded extends ContributionsState {
|
|
final Map<String, dynamic> stats;
|
|
|
|
const ContributionsStatsLoaded({required this.stats});
|
|
|
|
@override
|
|
List<Object?> get props => [stats];
|
|
}
|
|
|
|
/// État contributions générées
|
|
class ContributionsGenerated extends ContributionsState {
|
|
final int nombreGenere;
|
|
|
|
const ContributionsGenerated({required this.nombreGenere});
|
|
|
|
@override
|
|
List<Object?> get props => [nombreGenere];
|
|
}
|
|
|
|
/// État rappel envoyé
|
|
class ReminderSent extends ContributionsState {
|
|
final String contributionId;
|
|
|
|
const ReminderSent({required this.contributionId});
|
|
|
|
@override
|
|
List<Object?> get props => [contributionId];
|
|
}
|
|
|
|
/// État d'erreur générique
|
|
class ContributionsError extends ContributionsState {
|
|
final String message;
|
|
final dynamic error;
|
|
|
|
const ContributionsError({
|
|
required this.message,
|
|
this.error,
|
|
});
|
|
|
|
@override
|
|
List<Object?> get props => [message, error];
|
|
}
|
|
|
|
/// État d'erreur réseau
|
|
class ContributionsNetworkError extends ContributionsState {
|
|
final String message;
|
|
|
|
const ContributionsNetworkError({required this.message});
|
|
|
|
@override
|
|
List<Object?> get props => [message];
|
|
}
|
|
|
|
/// État d'erreur de validation
|
|
class ContributionsValidationError extends ContributionsState {
|
|
final String message;
|
|
final Map<String, String>? fieldErrors;
|
|
|
|
const ContributionsValidationError({
|
|
required this.message,
|
|
this.fieldErrors,
|
|
});
|
|
|
|
@override
|
|
List<Object?> get props => [message, fieldErrors];
|
|
}
|
|
|