58 lines
1.4 KiB
Dart
58 lines
1.4 KiB
Dart
|
|
part of 'services_cubit.dart';
|
||
|
|
|
||
|
|
class ServicesState extends Equatable {
|
||
|
|
final List<ServiceModel> allServices;
|
||
|
|
final ServiceModel? currentService; // La bozza che stiamo editando
|
||
|
|
final bool isLoading;
|
||
|
|
final bool isSaving; // Per mostrare il caricamento solo sul tasto salva
|
||
|
|
final String? errorMessage;
|
||
|
|
final String query;
|
||
|
|
final DateTimeRange? dateRange;
|
||
|
|
final bool hasReachedMax;
|
||
|
|
|
||
|
|
const ServicesState({
|
||
|
|
this.allServices = const [],
|
||
|
|
this.currentService,
|
||
|
|
this.isLoading = false,
|
||
|
|
this.isSaving = false,
|
||
|
|
this.errorMessage,
|
||
|
|
this.query = '',
|
||
|
|
this.dateRange,
|
||
|
|
this.hasReachedMax = false,
|
||
|
|
});
|
||
|
|
|
||
|
|
ServicesState copyWith({
|
||
|
|
List<ServiceModel>? allServices,
|
||
|
|
ServiceModel? currentService,
|
||
|
|
bool? isLoading,
|
||
|
|
bool? isSaving,
|
||
|
|
String? errorMessage,
|
||
|
|
String? query,
|
||
|
|
DateTimeRange? dateRange,
|
||
|
|
bool? hasReachedMax,
|
||
|
|
}) {
|
||
|
|
return ServicesState(
|
||
|
|
allServices: allServices ?? this.allServices,
|
||
|
|
currentService: currentService ?? this.currentService,
|
||
|
|
isLoading: isLoading ?? this.isLoading,
|
||
|
|
isSaving: isSaving ?? this.isSaving,
|
||
|
|
errorMessage: errorMessage,
|
||
|
|
query: query ?? this.query,
|
||
|
|
dateRange: dateRange ?? this.dateRange,
|
||
|
|
hasReachedMax: hasReachedMax ?? this.hasReachedMax,
|
||
|
|
);
|
||
|
|
}
|
||
|
|
|
||
|
|
@override
|
||
|
|
List<Object?> get props => [
|
||
|
|
allServices,
|
||
|
|
currentService,
|
||
|
|
isLoading,
|
||
|
|
isSaving,
|
||
|
|
errorMessage,
|
||
|
|
query,
|
||
|
|
dateRange,
|
||
|
|
hasReachedMax,
|
||
|
|
];
|
||
|
|
}
|