mirror of
https://github.com/Xevion/paperless-mobile.git
synced 2025-12-08 16:07:52 -06:00
71 lines
1.9 KiB
Dart
71 lines
1.9 KiB
Dart
import 'package:json_annotation/json_annotation.dart';
|
|
import 'package:paperless_api/paperless_api.dart';
|
|
import 'package:paperless_mobile/features/paged_document_view/model/paged_documents_state.dart';
|
|
import 'package:paperless_mobile/features/settings/model/view_type.dart';
|
|
|
|
part 'documents_state.g.dart';
|
|
|
|
@JsonSerializable()
|
|
class DocumentsState extends PagedDocumentsState {
|
|
@JsonKey(includeFromJson: false, includeToJson: false)
|
|
final List<DocumentModel> selection;
|
|
|
|
final ViewType viewType;
|
|
|
|
const DocumentsState({
|
|
this.selection = const [],
|
|
this.viewType = ViewType.list,
|
|
super.value = const [],
|
|
super.filter = const DocumentFilter(),
|
|
super.hasLoaded = false,
|
|
super.isLoading = false,
|
|
});
|
|
|
|
List<int> get selectedIds => selection.map((e) => e.id).toList();
|
|
|
|
DocumentsState copyWith({
|
|
bool? hasLoaded,
|
|
bool? isLoading,
|
|
List<PagedSearchResult<DocumentModel>>? value,
|
|
DocumentFilter? filter,
|
|
List<DocumentModel>? selection,
|
|
ViewType? viewType,
|
|
}) {
|
|
return DocumentsState(
|
|
hasLoaded: hasLoaded ?? this.hasLoaded,
|
|
isLoading: isLoading ?? this.isLoading,
|
|
value: value ?? this.value,
|
|
filter: filter ?? this.filter,
|
|
selection: selection ?? this.selection,
|
|
viewType: viewType ?? this.viewType,
|
|
);
|
|
}
|
|
|
|
factory DocumentsState.fromJson(Map<String, dynamic> json) =>
|
|
_$DocumentsStateFromJson(json);
|
|
|
|
Map<String, dynamic> toJson() => _$DocumentsStateToJson(this);
|
|
|
|
@override
|
|
List<Object?> get props => [
|
|
selection,
|
|
viewType,
|
|
...super.props,
|
|
];
|
|
|
|
@override
|
|
DocumentsState copyWithPaged({
|
|
bool? hasLoaded,
|
|
bool? isLoading,
|
|
List<PagedSearchResult<DocumentModel>>? value,
|
|
DocumentFilter? filter,
|
|
}) {
|
|
return copyWith(
|
|
filter: filter,
|
|
hasLoaded: hasLoaded,
|
|
isLoading: isLoading,
|
|
value: value,
|
|
);
|
|
}
|
|
}
|