Files
flux/lib/features/operations/blocs/operation_form_state.dart

49 lines
1.2 KiB
Dart
Raw Permalink Normal View History

2026-05-08 12:28:14 +02:00
part of 'operation_form_cubit.dart';
2026-05-07 19:29:39 +02:00
enum OperationFormStatus {
initial,
loading,
2026-05-08 12:28:14 +02:00
ready,
2026-05-07 19:29:39 +02:00
saving,
success,
2026-05-08 12:28:14 +02:00
successAndAddAnother, // Nuovo stato in stile Ticket!
2026-05-07 19:29:39 +02:00
failure,
}
class OperationFormState extends Equatable {
final OperationFormStatus status;
2026-05-08 12:28:14 +02:00
final OperationModel operation;
2026-05-07 19:29:39 +02:00
final String? errorMessage;
2026-05-08 12:28:14 +02:00
// Teniamo traccia delle operazioni salvate in questa sessione (per UI riepilogo)
final List<OperationModel> savedBatchOperations;
2026-05-07 19:29:39 +02:00
const OperationFormState({
this.status = OperationFormStatus.initial,
2026-05-08 12:28:14 +02:00
required this.operation,
2026-05-07 19:29:39 +02:00
this.errorMessage,
2026-05-08 12:28:14 +02:00
this.savedBatchOperations = const [],
2026-05-07 19:29:39 +02:00
});
OperationFormState copyWith({
OperationFormStatus? status,
2026-05-08 12:28:14 +02:00
OperationModel? operation,
2026-05-07 19:29:39 +02:00
String? errorMessage,
2026-05-08 12:28:14 +02:00
List<OperationModel>? savedBatchOperations,
2026-05-07 19:29:39 +02:00
}) {
return OperationFormState(
status: status ?? this.status,
2026-05-08 12:28:14 +02:00
operation: operation ?? this.operation,
2026-05-07 19:29:39 +02:00
errorMessage: errorMessage,
2026-05-08 12:28:14 +02:00
savedBatchOperations: savedBatchOperations ?? this.savedBatchOperations,
2026-05-07 19:29:39 +02:00
);
}
2026-05-08 12:28:14 +02:00
@override
List<Object?> get props => [
status,
operation,
errorMessage,
savedBatchOperations,
];
2026-05-07 19:29:39 +02:00
}