feat: Add query highlight fragments to detailed view, fix build

This commit is contained in:
Anton Stubenbord
2023-02-24 14:29:19 +01:00
parent 6cf88b6fdc
commit ce39190723
9 changed files with 153 additions and 93 deletions

View File

@@ -5,6 +5,7 @@ import 'package:paperless_mobile/core/notifier/document_changed_notifier.dart';
import 'package:paperless_mobile/features/paged_document_view/cubit/document_paging_bloc_mixin.dart';
import 'package:json_annotation/json_annotation.dart';
import 'package:paperless_mobile/features/paged_document_view/cubit/paged_documents_state.dart';
import 'package:paperless_mobile/features/settings/model/view_type.dart';
part 'document_search_state.dart';
@@ -33,7 +34,7 @@ class DocumentSearchCubit extends HydratedCubit<DocumentSearchState>
view: SearchView.results,
));
final searchFilter = DocumentFilter(
query: TextQuery.titleAndContent(query),
query: TextQuery.extended(query),
);
await updateFilter(filter: searchFilter);
@@ -48,6 +49,10 @@ class DocumentSearchCubit extends HydratedCubit<DocumentSearchState>
);
}
void updateViewType(ViewType viewType) {
emit(state.copyWith(viewType: viewType));
}
void removeHistoryEntry(String entry) {
emit(
state.copyWith(

View File

@@ -11,10 +11,13 @@ class DocumentSearchState extends DocumentPagingState {
final List<String> searchHistory;
final SearchView view;
final List<String> suggestions;
@JsonKey()
final ViewType viewType;
const DocumentSearchState({
this.view = SearchView.suggestions,
this.searchHistory = const [],
this.suggestions = const [],
this.viewType = ViewType.detailed,
super.filter,
super.hasLoaded,
super.isLoading,
@@ -27,6 +30,7 @@ class DocumentSearchState extends DocumentPagingState {
searchHistory,
suggestions,
view,
viewType,
];
@override
@@ -52,6 +56,7 @@ class DocumentSearchState extends DocumentPagingState {
DocumentFilter? filter,
List<String>? suggestions,
SearchView? view,
ViewType? viewType,
}) {
return DocumentSearchState(
value: value ?? this.value,
@@ -61,6 +66,7 @@ class DocumentSearchState extends DocumentPagingState {
searchHistory: searchHistory ?? this.searchHistory,
view: view ?? this.view,
suggestions: suggestions ?? this.suggestions,
viewType: viewType ?? this.viewType,
);
}