mirror of
https://github.com/Xevion/paperless-mobile.git
synced 2025-12-15 00:12:22 -06:00
Added new query options for tags, added pdf preview on documents scanner page
This commit is contained in:
@@ -420,7 +420,9 @@ class _DocumentDetailsPageState extends State<DocumentDetailsPage> {
|
||||
Future<void> _onOpen(DocumentModel document) async {
|
||||
Navigator.of(context).push(
|
||||
MaterialPageRoute(
|
||||
builder: (context) => DocumentView(document: document),
|
||||
builder: (context) => DocumentView(
|
||||
documentBytes: getIt<DocumentRepository>().getPreview(document.id),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -53,9 +53,8 @@ class _DocumentEditPageState extends State<DocumentEditPage> {
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
documentBytes = getIt<DocumentRepository>().getPreview(widget.document.id);
|
||||
|
||||
super.initState();
|
||||
documentBytes = getIt<DocumentRepository>().getPreview(widget.document.id);
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -69,10 +68,14 @@ class _DocumentEditPageState extends State<DocumentEditPage> {
|
||||
final updatedDocument = widget.document.copyWith(
|
||||
title: values[fkTitle],
|
||||
created: values[fkCreatedDate],
|
||||
documentType: values[fkDocumentType] as IdQueryParameter,
|
||||
correspondent: values[fkCorrespondent] as IdQueryParameter,
|
||||
storagePath: values[fkStoragePath] as IdQueryParameter,
|
||||
tags: values[fkTags] as TagsQuery,
|
||||
overwriteDocumentType: true,
|
||||
documentType: (values[fkDocumentType] as IdQueryParameter).id,
|
||||
overwriteCorrespondent: true,
|
||||
correspondent: (values[fkCorrespondent] as IdQueryParameter).id,
|
||||
overwriteStoragePath: true,
|
||||
storagePath: (values[fkStoragePath] as IdQueryParameter).id,
|
||||
overwriteTags: true,
|
||||
tags: (values[fkTags] as IdsTagsQuery).includedIds,
|
||||
);
|
||||
setState(() {
|
||||
_isSubmitLoading = true;
|
||||
@@ -181,7 +184,10 @@ class _DocumentEditPageState extends State<DocumentEditPage> {
|
||||
},
|
||||
).padded(),
|
||||
TagFormField(
|
||||
initialValue: TagsQuery.fromIds(widget.document.tags),
|
||||
initialValue: IdsTagsQuery.included(widget.document.tags),
|
||||
notAssignedSelectable: false,
|
||||
anyAssignedSelectable: false,
|
||||
excludeAllowed: false,
|
||||
name: fkTags,
|
||||
).padded(),
|
||||
]),
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:paperless_mobile/di_initializer.dart';
|
||||
import 'package:paperless_mobile/features/documents/model/document.model.dart';
|
||||
@@ -6,11 +7,11 @@ import 'package:paperless_mobile/generated/l10n.dart';
|
||||
import 'package:pdfx/pdfx.dart';
|
||||
|
||||
class DocumentView extends StatefulWidget {
|
||||
final DocumentModel document;
|
||||
final Future<Uint8List> documentBytes;
|
||||
|
||||
const DocumentView({
|
||||
Key? key,
|
||||
required this.document,
|
||||
required this.documentBytes,
|
||||
}) : super(key: key);
|
||||
|
||||
@override
|
||||
@@ -25,7 +26,7 @@ class _DocumentViewState extends State<DocumentView> {
|
||||
super.initState();
|
||||
_pdfController = PdfController(
|
||||
document: PdfDocument.openData(
|
||||
getIt<DocumentRepository>().getPreview(widget.document.id),
|
||||
widget.documentBytes,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -66,8 +66,12 @@ class DocumentGridItem extends StatelessWidget {
|
||||
tagIds: document.tags,
|
||||
isMultiLine: false,
|
||||
),
|
||||
Text(DateFormat.yMMMd(Intl.getCurrentLocale())
|
||||
.format(document.created)),
|
||||
const Spacer(),
|
||||
Text(
|
||||
DateFormat.yMMMd(Intl.getCurrentLocale())
|
||||
.format(document.created),
|
||||
style: Theme.of(context).textTheme.caption,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
@@ -11,7 +11,6 @@ import 'package:paperless_mobile/features/documents/model/document_filter.dart';
|
||||
import 'package:paperless_mobile/features/documents/model/query_parameters/correspondent_query.dart';
|
||||
import 'package:paperless_mobile/features/documents/model/query_parameters/document_type_query.dart';
|
||||
import 'package:paperless_mobile/features/documents/model/query_parameters/query_type.dart';
|
||||
import 'package:paperless_mobile/features/documents/model/query_parameters/sort_field.dart';
|
||||
import 'package:paperless_mobile/features/documents/model/query_parameters/storage_path_query.dart';
|
||||
import 'package:paperless_mobile/features/documents/model/query_parameters/tags_query.dart';
|
||||
import 'package:paperless_mobile/features/documents/view/widgets/search/query_type_form_field.dart';
|
||||
@@ -89,8 +88,7 @@ class _DocumentFilterPanelState extends State<DocumentFilterPanel> {
|
||||
builder: (context, state) {
|
||||
return FormBuilder(
|
||||
key: _formKey,
|
||||
child: ListView(
|
||||
controller: widget.scrollController,
|
||||
child: Column(
|
||||
children: [
|
||||
Stack(
|
||||
alignment: Alignment.center,
|
||||
@@ -127,28 +125,43 @@ class _DocumentFilterPanelState extends State<DocumentFilterPanel> {
|
||||
const SizedBox(
|
||||
height: 16.0,
|
||||
),
|
||||
Align(
|
||||
alignment: Alignment.centerLeft,
|
||||
child: Text(S.of(context).documentsFilterPageSearchLabel),
|
||||
).padded(const EdgeInsets.only(left: 8.0)),
|
||||
_buildQueryFormField(state),
|
||||
Align(
|
||||
alignment: Alignment.centerLeft,
|
||||
child: Text(S.of(context).documentsFilterPageAdvancedLabel),
|
||||
).padded(const EdgeInsets.only(left: 8.0, top: 8.0)),
|
||||
_buildCreatedDateRangePickerFormField(state).padded(),
|
||||
_buildAddedDateRangePickerFormField(state).padded(),
|
||||
_buildCorrespondentFormField(state).padded(),
|
||||
_buildDocumentTypeFormField(state).padded(),
|
||||
_buildStoragePathFormField(state).padded(),
|
||||
TagFormField(
|
||||
name: DocumentModel.tagsKey,
|
||||
initialValue: state.filter.tags,
|
||||
allowCreation: false,
|
||||
).padded(),
|
||||
// Required in order for the storage path field to be visible when typing
|
||||
const SizedBox(
|
||||
height: 200,
|
||||
Expanded(
|
||||
child: ClipRRect(
|
||||
borderRadius: const BorderRadius.only(
|
||||
topLeft: Radius.circular(16.0),
|
||||
topRight: Radius.circular(16.0),
|
||||
),
|
||||
child: ListView(
|
||||
controller: widget.scrollController,
|
||||
children: [
|
||||
Align(
|
||||
alignment: Alignment.centerLeft,
|
||||
child: Text(
|
||||
S.of(context).documentsFilterPageSearchLabel),
|
||||
).padded(const EdgeInsets.only(left: 8.0)),
|
||||
_buildQueryFormField(state),
|
||||
Align(
|
||||
alignment: Alignment.centerLeft,
|
||||
child: Text(
|
||||
S.of(context).documentsFilterPageAdvancedLabel),
|
||||
).padded(const EdgeInsets.only(left: 8.0, top: 8.0)),
|
||||
_buildCreatedDateRangePickerFormField(state).padded(),
|
||||
_buildAddedDateRangePickerFormField(state).padded(),
|
||||
_buildCorrespondentFormField(state).padded(),
|
||||
_buildDocumentTypeFormField(state).padded(),
|
||||
_buildStoragePathFormField(state).padded(),
|
||||
TagFormField(
|
||||
name: DocumentModel.tagsKey,
|
||||
initialValue: state.filter.tags,
|
||||
allowCreation: false,
|
||||
).padded(),
|
||||
// Required in order for the storage path field to be visible when typing
|
||||
const SizedBox(
|
||||
height: 150,
|
||||
),
|
||||
],
|
||||
).padded(),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
@@ -374,6 +387,7 @@ class _DocumentFilterPanelState extends State<DocumentFilterPanel> {
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 4.0),
|
||||
_buildDateRangePickerHelper(state, fkCreatedAt),
|
||||
],
|
||||
);
|
||||
@@ -421,6 +435,7 @@ class _DocumentFilterPanelState extends State<DocumentFilterPanel> {
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 4.0),
|
||||
_buildDateRangePickerHelper(state, fkAddedAt),
|
||||
],
|
||||
);
|
||||
|
||||
@@ -44,9 +44,10 @@ class _SortFieldSelectionBottomSheetState
|
||||
children: [
|
||||
Text(
|
||||
S.of(context).documentsPageOrderByLabel,
|
||||
style: Theme.of(context).textTheme.titleSmall,
|
||||
style: Theme.of(context).textTheme.caption,
|
||||
textAlign: TextAlign.start,
|
||||
).padded(EdgeInsets.symmetric(horizontal: 16, vertical: 16)),
|
||||
).padded(
|
||||
const EdgeInsets.symmetric(horizontal: 16, vertical: 16)),
|
||||
Column(
|
||||
children: _sortFields
|
||||
.map(
|
||||
@@ -110,9 +111,9 @@ class _SortFieldSelectionBottomSheetState
|
||||
|
||||
Widget _buildOrderIcon(SortOrder order) {
|
||||
if (order == SortOrder.ascending) {
|
||||
return Icon(Icons.arrow_upward);
|
||||
return const Icon(Icons.arrow_upward);
|
||||
}
|
||||
return Icon(Icons.arrow_downward);
|
||||
return const Icon(Icons.arrow_downward);
|
||||
}
|
||||
|
||||
String _localizedSortField(SortField sortField) {
|
||||
|
||||
@@ -18,10 +18,10 @@ class ConfirmDeleteSavedViewDialog extends StatelessWidget {
|
||||
Widget build(BuildContext context) {
|
||||
return AlertDialog(
|
||||
title: Text(
|
||||
"Delete view " + view.name + "?",
|
||||
S.of(context).deleteViewDialogTitleText + view.name + "?",
|
||||
softWrap: true,
|
||||
),
|
||||
content: Text("Do you really want to delete this view?"),
|
||||
content: Text(S.of(context).deleteViewDialogContentText),
|
||||
actions: [
|
||||
TextButton(
|
||||
child: Text(S.of(context).genericActionCancelLabel),
|
||||
|
||||
@@ -77,7 +77,7 @@ class _DocumentsPageAppBarState extends State<DocumentsPageAppBar> {
|
||||
Widget _buildFlexibleArea(bool enabled) {
|
||||
return FlexibleSpaceBar(
|
||||
background: Padding(
|
||||
padding: EdgeInsets.all(8.0),
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.end,
|
||||
children: [
|
||||
|
||||
@@ -27,7 +27,7 @@ class _SortDocumentsButtonState extends State<SortDocumentsButton> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return IconButton(
|
||||
icon: Icon(Icons.sort),
|
||||
icon: const Icon(Icons.sort),
|
||||
onPressed: _onOpenSortBottomSheet,
|
||||
);
|
||||
}
|
||||
@@ -45,9 +45,9 @@ class _SortDocumentsButtonState extends State<SortDocumentsButton> {
|
||||
),
|
||||
builder: (context) => BlocProvider.value(
|
||||
value: getIt<DocumentsCubit>(),
|
||||
child: FractionallySizedBox(
|
||||
child: const FractionallySizedBox(
|
||||
heightFactor: .6,
|
||||
child: const SortFieldSelectionBottomSheet(),
|
||||
child: SortFieldSelectionBottomSheet(),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user