fantascenza attachment bloc agnostico, ora continuo refactor rimuovendo customer file bloc ecc.
This commit is contained in:
65
lib/features/attachments/blocs/attachments_state.dart
Normal file
65
lib/features/attachments/blocs/attachments_state.dart
Normal file
@@ -0,0 +1,65 @@
|
||||
part of 'attachments_bloc.dart';
|
||||
|
||||
enum AttachmentsStatus { initial, loading, uploading, success, failure }
|
||||
|
||||
enum AttachmentParentType {
|
||||
operation('operation_id'),
|
||||
ticket('ticket_id'),
|
||||
customer('customer_id');
|
||||
|
||||
final String dbColumn;
|
||||
const AttachmentParentType(this.dbColumn);
|
||||
}
|
||||
|
||||
class AttachmentsState extends Equatable {
|
||||
final String? parentId;
|
||||
final AttachmentParentType parentType;
|
||||
final AttachmentsStatus status;
|
||||
final String? error;
|
||||
final List<AttachmentModel> localFiles;
|
||||
final List<AttachmentModel> remoteFiles;
|
||||
final List<AttachmentModel> selectedFiles;
|
||||
|
||||
const AttachmentsState({
|
||||
this.parentId,
|
||||
required this.parentType,
|
||||
required this.status,
|
||||
this.error,
|
||||
this.localFiles = const [],
|
||||
this.remoteFiles = const [],
|
||||
this.selectedFiles = const [],
|
||||
});
|
||||
|
||||
@override
|
||||
List<Object?> get props => [
|
||||
parentId,
|
||||
parentType,
|
||||
status,
|
||||
error,
|
||||
localFiles,
|
||||
remoteFiles,
|
||||
selectedFiles,
|
||||
];
|
||||
|
||||
List<AttachmentModel> get allFiles => [...remoteFiles, ...localFiles];
|
||||
|
||||
AttachmentsState copyWith({
|
||||
String? parentId,
|
||||
AttachmentParentType? parentType,
|
||||
AttachmentsStatus? status,
|
||||
String? error,
|
||||
List<AttachmentModel>? localFiles,
|
||||
List<AttachmentModel>? remoteFiles,
|
||||
List<AttachmentModel>? selectedFiles,
|
||||
}) {
|
||||
return AttachmentsState(
|
||||
parentId: parentId ?? this.parentId,
|
||||
parentType: parentType ?? this.parentType,
|
||||
status: status ?? this.status,
|
||||
error: error,
|
||||
localFiles: localFiles ?? this.localFiles,
|
||||
remoteFiles: remoteFiles ?? this.remoteFiles,
|
||||
selectedFiles: selectedFiles ?? this.selectedFiles,
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user