Refactor service management: streamline service form, enhance state management, and improve loading logic

This commit is contained in:
2026-04-17 19:19:01 +02:00
parent 667bbf6404
commit a06be4bf7a
13 changed files with 715 additions and 261 deletions

View File

@@ -0,0 +1,57 @@
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,
];
}