mirror of
https://github.com/Xevion/paperless-mobile.git
synced 2025-12-06 17:15:50 -06:00
feat: Add remote_version endpoint to mock server, resolve versions, update search
This commit is contained in:
@@ -4,7 +4,6 @@ import 'package:json_annotation/json_annotation.dart';
|
||||
import 'package:paperless_api/paperless_api.dart';
|
||||
import 'package:paperless_mobile/core/database/tables/local_user_app_state.dart';
|
||||
import 'package:paperless_mobile/core/notifier/document_changed_notifier.dart';
|
||||
import 'package:paperless_mobile/core/repository/label_repository.dart';
|
||||
import 'package:paperless_mobile/features/paged_document_view/cubit/document_paging_bloc_mixin.dart';
|
||||
import 'package:paperless_mobile/features/paged_document_view/cubit/paged_documents_state.dart';
|
||||
import 'package:paperless_mobile/features/settings/model/view_type.dart';
|
||||
@@ -16,7 +15,6 @@ class DocumentSearchCubit extends Cubit<DocumentSearchState> with DocumentPaging
|
||||
@override
|
||||
final PaperlessDocumentsApi api;
|
||||
|
||||
final LabelRepository _labelRepository;
|
||||
@override
|
||||
final DocumentChangedNotifier notifier;
|
||||
|
||||
@@ -24,22 +22,8 @@ class DocumentSearchCubit extends Cubit<DocumentSearchState> with DocumentPaging
|
||||
DocumentSearchCubit(
|
||||
this.api,
|
||||
this.notifier,
|
||||
this._labelRepository,
|
||||
this._userAppState,
|
||||
) : super(DocumentSearchState(searchHistory: _userAppState.documentSearchHistory)) {
|
||||
_labelRepository.addListener(
|
||||
this,
|
||||
onChanged: (labels) {
|
||||
emit(
|
||||
state.copyWith(
|
||||
correspondents: labels.correspondents,
|
||||
documentTypes: labels.documentTypes,
|
||||
tags: labels.tags,
|
||||
storagePaths: labels.storagePaths,
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
notifier.addListener(
|
||||
this,
|
||||
onDeleted: remove,
|
||||
@@ -95,8 +79,6 @@ class DocumentSearchCubit extends Cubit<DocumentSearchState> with DocumentPaging
|
||||
state.copyWith(
|
||||
isLoading: true,
|
||||
view: SearchView.suggestions,
|
||||
value: [],
|
||||
suggestions: [],
|
||||
),
|
||||
);
|
||||
final suggestions = await api.autocomplete(query);
|
||||
@@ -122,7 +104,6 @@ class DocumentSearchCubit extends Cubit<DocumentSearchState> with DocumentPaging
|
||||
@override
|
||||
Future<void> close() {
|
||||
notifier.removeListener(this);
|
||||
_labelRepository.removeListener(this);
|
||||
return super.close();
|
||||
}
|
||||
|
||||
|
||||
@@ -57,10 +57,6 @@ class DocumentSearchState extends DocumentPagingState {
|
||||
List<String>? suggestions,
|
||||
SearchView? view,
|
||||
ViewType? viewType,
|
||||
Map<int, Correspondent>? correspondents,
|
||||
Map<int, DocumentType>? documentTypes,
|
||||
Map<int, Tag>? tags,
|
||||
Map<int, StoragePath>? storagePaths,
|
||||
}) {
|
||||
return DocumentSearchState(
|
||||
value: value ?? this.value,
|
||||
@@ -79,3 +75,31 @@ class DocumentSearchState extends DocumentPagingState {
|
||||
|
||||
Map<String, dynamic> toJson() => _$DocumentSearchStateToJson(this);
|
||||
}
|
||||
|
||||
// sealed class DocumentSearchState1 {}
|
||||
|
||||
// class DocumentSearchStateInitial {}
|
||||
|
||||
// class SuggestionsLoadingState extends DocumentSearchState1 {
|
||||
// final List<String> history;
|
||||
|
||||
// SuggestionsLoadingState({required this.history});
|
||||
// }
|
||||
|
||||
// class SuggestionsLoadedState extends DocumentSearchState1 {
|
||||
// final List<String> history;
|
||||
// final List<String> suggestions;
|
||||
|
||||
// SuggestionsLoadedState({
|
||||
// required this.history,
|
||||
// required this.suggestions,
|
||||
// });
|
||||
// }
|
||||
|
||||
// class SuggestionsErrorState extends DocumentSearchState1 {}
|
||||
|
||||
// class ResultsLoadingState extends DocumentSearchState1 {}
|
||||
|
||||
// class ResultsLoadedState extends DocumentSearchState1 {}
|
||||
|
||||
// class ResultsErrorState extends DocumentSearchState1 {}
|
||||
|
||||
@@ -93,7 +93,6 @@ class _DocumentSearchBarState extends State<DocumentSearchBar> {
|
||||
],
|
||||
child: Provider(
|
||||
create: (_) => DocumentSearchCubit(
|
||||
context.read(),
|
||||
context.read(),
|
||||
context.read(),
|
||||
Hive.box<LocalUserAppState>(HiveBoxes.localUserAppState)
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import 'dart:async';
|
||||
import 'dart:math' as math;
|
||||
|
||||
import 'package:collection/collection.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:paperless_mobile/core/navigation/push_routes.dart';
|
||||
@@ -12,8 +12,6 @@ import 'package:paperless_mobile/features/documents/view/widgets/adaptive_docume
|
||||
import 'package:paperless_mobile/features/documents/view/widgets/selection/view_type_selection_widget.dart';
|
||||
import 'package:paperless_mobile/generated/l10n/app_localizations.dart';
|
||||
|
||||
import 'dart:math' as math;
|
||||
|
||||
class DocumentSearchPage extends StatefulWidget {
|
||||
const DocumentSearchPage({super.key});
|
||||
|
||||
@@ -28,13 +26,15 @@ class _DocumentSearchPageState extends State<DocumentSearchPage> {
|
||||
Timer? _debounceTimer;
|
||||
|
||||
String get query => _queryController.text;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
const double progressIndicatorHeight = 4;
|
||||
final theme = Theme.of(context);
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
backgroundColor: theme.colorScheme.surfaceVariant,
|
||||
toolbarHeight: 72,
|
||||
toolbarHeight: 72 - progressIndicatorHeight,
|
||||
leading: BackButton(
|
||||
color: theme.colorScheme.onSurfaceVariant,
|
||||
),
|
||||
@@ -77,13 +77,13 @@ class _DocumentSearchPageState extends State<DocumentSearchPage> {
|
||||
).padded(),
|
||||
],
|
||||
bottom: PreferredSize(
|
||||
preferredSize: Size.fromHeight(1),
|
||||
preferredSize: const Size.fromHeight(progressIndicatorHeight),
|
||||
child: BlocBuilder<DocumentSearchCubit, DocumentSearchState>(
|
||||
builder: (context, state) {
|
||||
if (state.isLoading) {
|
||||
return const LinearProgressIndicator();
|
||||
}
|
||||
return const SizedBox.shrink();
|
||||
return ColoredBox(color: Theme.of(context).colorScheme.surface);
|
||||
},
|
||||
),
|
||||
),
|
||||
@@ -140,6 +140,13 @@ class _DocumentSearchPageState extends State<DocumentSearchPage> {
|
||||
childCount: suggestions.length,
|
||||
),
|
||||
),
|
||||
if (suggestions.isEmpty && historyMatches.isEmpty)
|
||||
SliverPadding(
|
||||
padding: const EdgeInsets.all(16),
|
||||
sliver: SliverToBoxAdapter(
|
||||
child: Center(child: Text(S.of(context)!.noMatchesFound)),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,11 +1,8 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:hive_flutter/adapters.dart';
|
||||
import 'package:paperless_mobile/core/config/hive/hive_config.dart';
|
||||
import 'package:paperless_mobile/core/database/tables/global_settings.dart';
|
||||
import 'package:paperless_mobile/core/database/tables/local_user_app_state.dart';
|
||||
import 'package:paperless_mobile/core/delegate/customizable_sliver_persistent_header_delegate.dart';
|
||||
import 'package:paperless_mobile/features/document_search/cubit/document_search_cubit.dart';
|
||||
import 'package:paperless_mobile/features/document_search/view/document_search_bar.dart';
|
||||
|
||||
class SliverSearchBar extends StatelessWidget {
|
||||
@@ -30,15 +27,7 @@ class SliverSearchBar extends StatelessWidget {
|
||||
maxExtent: kToolbarHeight,
|
||||
child: Container(
|
||||
margin: const EdgeInsets.symmetric(horizontal: 16.0),
|
||||
child: BlocProvider(
|
||||
create: (context) => DocumentSearchCubit(
|
||||
context.read(),
|
||||
context.read(),
|
||||
context.read(),
|
||||
Hive.box<LocalUserAppState>(HiveBoxes.localUserAppState).get(currentUser)!,
|
||||
),
|
||||
child: const DocumentSearchBar(),
|
||||
),
|
||||
child: const DocumentSearchBar(),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user