Restructuration majeure du projet: migration de flutt vers app, ajout de l'API et mise à jour du site web
This commit is contained in:
75
app/lib/core/models/loading_state.dart
Normal file
75
app/lib/core/models/loading_state.dart
Normal file
@@ -0,0 +1,75 @@
|
||||
/// Modèle pour suivre l'état du chargement des données
|
||||
class LoadingState {
|
||||
/// Progression globale (0.0 à 1.0)
|
||||
final double progress;
|
||||
|
||||
/// Description de l'étape en cours
|
||||
final String? stepDescription;
|
||||
|
||||
/// Message principal
|
||||
final String? message;
|
||||
|
||||
/// Indique si le chargement est terminé
|
||||
final bool isCompleted;
|
||||
|
||||
/// Indique si une erreur s'est produite
|
||||
final bool hasError;
|
||||
|
||||
/// Message d'erreur éventuel
|
||||
final String? errorMessage;
|
||||
|
||||
const LoadingState({
|
||||
this.progress = 0.0,
|
||||
this.stepDescription,
|
||||
this.message,
|
||||
this.isCompleted = false,
|
||||
this.hasError = false,
|
||||
this.errorMessage,
|
||||
});
|
||||
|
||||
/// Crée un nouvel état de chargement avec les valeurs mises à jour
|
||||
LoadingState copyWith({
|
||||
double? progress,
|
||||
String? stepDescription,
|
||||
String? message,
|
||||
bool? isCompleted,
|
||||
bool? hasError,
|
||||
String? errorMessage,
|
||||
}) {
|
||||
return LoadingState(
|
||||
progress: progress ?? this.progress,
|
||||
stepDescription: stepDescription ?? this.stepDescription,
|
||||
message: message ?? this.message,
|
||||
isCompleted: isCompleted ?? this.isCompleted,
|
||||
hasError: hasError ?? this.hasError,
|
||||
errorMessage: errorMessage ?? this.errorMessage,
|
||||
);
|
||||
}
|
||||
|
||||
/// État initial du chargement
|
||||
static const initial = LoadingState(
|
||||
progress: 0.0,
|
||||
message: 'Chargement en cours...',
|
||||
isCompleted: false,
|
||||
hasError: false,
|
||||
);
|
||||
|
||||
/// État de chargement terminé avec succès
|
||||
static const completed = LoadingState(
|
||||
progress: 1.0,
|
||||
message: 'Chargement terminé',
|
||||
isCompleted: true,
|
||||
hasError: false,
|
||||
);
|
||||
|
||||
/// Crée un état d'erreur
|
||||
static LoadingState error(String message) {
|
||||
return LoadingState(
|
||||
progress: 0.0,
|
||||
message: 'Erreur de chargement',
|
||||
errorMessage: message,
|
||||
isCompleted: true,
|
||||
hasError: true,
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user