mirror of
https://github.com/Xevion/paperless-mobile.git
synced 2025-12-11 04:07:56 -06:00
feat: Add reset button above filter button
This commit is contained in:
@@ -33,7 +33,6 @@ class DocumentFilterIntent {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO: Refactor this
|
|
||||||
class DocumentsPage extends StatefulWidget {
|
class DocumentsPage extends StatefulWidget {
|
||||||
const DocumentsPage({Key? key}) : super(key: key);
|
const DocumentsPage({Key? key}) : super(key: key);
|
||||||
|
|
||||||
|
|||||||
@@ -159,7 +159,7 @@ class SliverAdaptiveDocumentsView extends AdaptiveDocumentsView {
|
|||||||
crossAxisCount: 2,
|
crossAxisCount: 2,
|
||||||
mainAxisSpacing: 4,
|
mainAxisSpacing: 4,
|
||||||
crossAxisSpacing: 4,
|
crossAxisSpacing: 4,
|
||||||
childAspectRatio: 1 / 2,
|
mainAxisExtent: 350,
|
||||||
),
|
),
|
||||||
itemCount: documents.length,
|
itemCount: documents.length,
|
||||||
itemBuilder: (context, index) {
|
itemBuilder: (context, index) {
|
||||||
|
|||||||
@@ -141,10 +141,10 @@ class DocumentDetailedItem extends DocumentItem {
|
|||||||
],
|
],
|
||||||
).paddedLTRB(8, 0, 8, 4),
|
).paddedLTRB(8, 0, 8, 4),
|
||||||
TagsWidget(
|
TagsWidget(
|
||||||
isMultiLine: false,
|
|
||||||
tags: document.tags
|
tags: document.tags
|
||||||
.map((e) => context.watch<LabelRepository>().state.tags[e]!)
|
.map((e) => context.watch<LabelRepository>().state.tags[e]!)
|
||||||
.toList(),
|
.toList(),
|
||||||
|
onTagSelected: onTagSelected,
|
||||||
).padded(),
|
).padded(),
|
||||||
if (highlights != null)
|
if (highlights != null)
|
||||||
Html(
|
Html(
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:intl/intl.dart';
|
||||||
import 'package:paperless_mobile/core/repository/label_repository.dart';
|
import 'package:paperless_mobile/core/repository/label_repository.dart';
|
||||||
import 'package:paperless_mobile/features/documents/view/widgets/document_preview.dart';
|
import 'package:paperless_mobile/features/documents/view/widgets/document_preview.dart';
|
||||||
import 'package:paperless_mobile/features/documents/view/widgets/items/document_item.dart';
|
import 'package:paperless_mobile/features/documents/view/widgets/items/document_item.dart';
|
||||||
import 'package:paperless_mobile/features/labels/correspondent/view/widgets/correspondent_widget.dart';
|
import 'package:paperless_mobile/features/labels/correspondent/view/widgets/correspondent_widget.dart';
|
||||||
import 'package:paperless_mobile/features/labels/document_type/view/widgets/document_type_widget.dart';
|
import 'package:paperless_mobile/features/labels/document_type/view/widgets/document_type_widget.dart';
|
||||||
import 'package:paperless_mobile/features/labels/tags/view/widgets/tags_widget.dart';
|
import 'package:paperless_mobile/features/labels/tags/view/widgets/tags_widget.dart';
|
||||||
import 'package:intl/intl.dart';
|
|
||||||
import 'package:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
|
|
||||||
class DocumentGridItem extends DocumentItem {
|
class DocumentGridItem extends DocumentItem {
|
||||||
@@ -42,10 +42,46 @@ class DocumentGridItem extends DocumentItem {
|
|||||||
children: [
|
children: [
|
||||||
AspectRatio(
|
AspectRatio(
|
||||||
aspectRatio: 1,
|
aspectRatio: 1,
|
||||||
child: DocumentPreview(
|
child: Stack(
|
||||||
document: document,
|
children: [
|
||||||
borderRadius: 12.0,
|
Positioned.fill(
|
||||||
enableHero: enableHeroAnimation,
|
child: DocumentPreview(
|
||||||
|
document: document,
|
||||||
|
borderRadius: 12.0,
|
||||||
|
enableHero: enableHeroAnimation,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Align(
|
||||||
|
alignment: Alignment.bottomLeft,
|
||||||
|
child: SizedBox(
|
||||||
|
height: 48,
|
||||||
|
child: NotificationListener<ScrollNotification>(
|
||||||
|
// Prevents ancestor notification listeners to be notified when this widget scrolls
|
||||||
|
onNotification: (notification) => true,
|
||||||
|
child: CustomScrollView(
|
||||||
|
scrollDirection: Axis.horizontal,
|
||||||
|
slivers: [
|
||||||
|
const SliverToBoxAdapter(
|
||||||
|
child: SizedBox(width: 8),
|
||||||
|
),
|
||||||
|
TagsWidget.sliver(
|
||||||
|
tags: document.tags
|
||||||
|
.map((e) => context
|
||||||
|
.watch<LabelRepository>()
|
||||||
|
.state
|
||||||
|
.tags[e]!)
|
||||||
|
.toList(),
|
||||||
|
onTagSelected: onTagSelected,
|
||||||
|
),
|
||||||
|
const SliverToBoxAdapter(
|
||||||
|
child: SizedBox(width: 8),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
Expanded(
|
Expanded(
|
||||||
@@ -59,29 +95,25 @@ class DocumentGridItem extends DocumentItem {
|
|||||||
.watch<LabelRepository>()
|
.watch<LabelRepository>()
|
||||||
.state
|
.state
|
||||||
.correspondents[document.correspondent],
|
.correspondents[document.correspondent],
|
||||||
|
onSelected: onCorrespondentSelected,
|
||||||
),
|
),
|
||||||
DocumentTypeWidget(
|
DocumentTypeWidget(
|
||||||
documentType: context
|
documentType: context
|
||||||
.watch<LabelRepository>()
|
.watch<LabelRepository>()
|
||||||
.state
|
.state
|
||||||
.documentTypes[document.documentType],
|
.documentTypes[document.documentType],
|
||||||
|
onSelected: onDocumentTypeSelected,
|
||||||
),
|
),
|
||||||
Text(
|
Padding(
|
||||||
document.title,
|
padding: const EdgeInsets.only(bottom: 8.0),
|
||||||
maxLines: document.tags.isEmpty ? 3 : 2,
|
child: Text(
|
||||||
overflow: TextOverflow.ellipsis,
|
document.title,
|
||||||
style: Theme.of(context).textTheme.titleMedium,
|
maxLines: document.tags.isEmpty ? 3 : 2,
|
||||||
|
overflow: TextOverflow.ellipsis,
|
||||||
|
style: Theme.of(context).textTheme.titleMedium,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
const Spacer(),
|
Spacer(),
|
||||||
TagsWidget(
|
|
||||||
tags: document.tags
|
|
||||||
.map((e) =>
|
|
||||||
context.watch<LabelRepository>().state.tags[e]!)
|
|
||||||
.toList(),
|
|
||||||
isMultiLine: false,
|
|
||||||
onTagSelected: onTagSelected,
|
|
||||||
),
|
|
||||||
const Spacer(),
|
|
||||||
Text(
|
Text(
|
||||||
DateFormat.yMMMd().format(document.created),
|
DateFormat.yMMMd().format(document.created),
|
||||||
style: Theme.of(context).textTheme.bodySmall,
|
style: Theme.of(context).textTheme.bodySmall,
|
||||||
|
|||||||
@@ -68,7 +68,6 @@ class DocumentListItem extends DocumentItem {
|
|||||||
.where((e) => labels.tags.containsKey(e))
|
.where((e) => labels.tags.containsKey(e))
|
||||||
.map((e) => labels.tags[e]!)
|
.map((e) => labels.tags[e]!)
|
||||||
.toList(),
|
.toList(),
|
||||||
isMultiLine: false,
|
|
||||||
onTagSelected: (id) => onTagSelected?.call(id),
|
onTagSelected: (id) => onTagSelected?.call(id),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -213,13 +213,11 @@ class _InboxItemState extends State<InboxItem> {
|
|||||||
TagsWidget(
|
TagsWidget(
|
||||||
tags: widget.document.tags
|
tags: widget.document.tags
|
||||||
.map((e) => state.labels.tags[e])
|
.map((e) => state.labels.tags[e])
|
||||||
.whereNot((element) => element == null)
|
.whereNot((e) => e == null)
|
||||||
.toList()
|
.toList()
|
||||||
.cast<Tag>(),
|
.cast<Tag>(),
|
||||||
isMultiLine: false,
|
|
||||||
isClickable: false,
|
isClickable: false,
|
||||||
showShortNames: true,
|
showShortNames: true,
|
||||||
dense: true,
|
|
||||||
).paddedOnly(left: 8, bottom: 8),
|
).paddedOnly(left: 8, bottom: 8),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -4,51 +4,95 @@ import 'package:paperless_mobile/features/labels/tags/view/widgets/tag_widget.da
|
|||||||
|
|
||||||
class TagsWidget extends StatelessWidget {
|
class TagsWidget extends StatelessWidget {
|
||||||
final List<Tag> tags;
|
final List<Tag> tags;
|
||||||
final bool isMultiLine;
|
|
||||||
final void Function(int tagId)? onTagSelected;
|
final void Function(int tagId)? onTagSelected;
|
||||||
final bool isClickable;
|
final bool isClickable;
|
||||||
final bool showShortNames;
|
final bool showShortNames;
|
||||||
final bool dense;
|
final bool dense;
|
||||||
|
|
||||||
const TagsWidget({
|
const TagsWidget({
|
||||||
Key? key,
|
super.key,
|
||||||
required this.tags,
|
required this.tags,
|
||||||
this.isMultiLine = true,
|
|
||||||
this.isClickable = true,
|
|
||||||
this.onTagSelected,
|
this.onTagSelected,
|
||||||
|
this.isClickable = true,
|
||||||
this.showShortNames = false,
|
this.showShortNames = false,
|
||||||
this.dense = true,
|
this.dense = true,
|
||||||
}) : super(key: key);
|
});
|
||||||
|
|
||||||
|
List<Widget> get _children {
|
||||||
|
return [
|
||||||
|
for (var tag in tags)
|
||||||
|
TagWidget(
|
||||||
|
tag: tag,
|
||||||
|
isClickable: isClickable,
|
||||||
|
onSelected: () => onTagSelected?.call(tag.id!),
|
||||||
|
showShortName: showShortNames,
|
||||||
|
dense: dense,
|
||||||
|
)
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
const factory TagsWidget.multiLine({
|
||||||
|
Key? key,
|
||||||
|
required List<Tag> tags,
|
||||||
|
required void Function(int tagId)? onTagSelected,
|
||||||
|
required bool isClickable,
|
||||||
|
required bool showShortNames,
|
||||||
|
required bool dense,
|
||||||
|
}) = _MultiLineTagsWidget;
|
||||||
|
|
||||||
|
const factory TagsWidget.sliver({
|
||||||
|
Key? key,
|
||||||
|
required List<Tag> tags,
|
||||||
|
void Function(int tagId)? onTagSelected,
|
||||||
|
bool isClickable,
|
||||||
|
bool showShortNames,
|
||||||
|
bool dense,
|
||||||
|
}) = _SliverTagsWidget;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Builder(
|
return SingleChildScrollView(
|
||||||
builder: (context) {
|
scrollDirection: Axis.horizontal,
|
||||||
final children = tags
|
child: Row(children: _children),
|
||||||
.map(
|
);
|
||||||
(tag) => TagWidget(
|
}
|
||||||
tag: tag,
|
}
|
||||||
isClickable: isClickable,
|
|
||||||
onSelected: () => onTagSelected?.call(tag.id!),
|
class _MultiLineTagsWidget extends TagsWidget {
|
||||||
showShortName: showShortNames,
|
const _MultiLineTagsWidget({
|
||||||
dense: dense,
|
super.key,
|
||||||
),
|
required super.tags,
|
||||||
)
|
super.onTagSelected,
|
||||||
.toList();
|
super.isClickable,
|
||||||
if (isMultiLine) {
|
super.showShortNames,
|
||||||
return Wrap(
|
super.dense,
|
||||||
runAlignment: WrapAlignment.start,
|
});
|
||||||
children: children,
|
|
||||||
runSpacing: 4,
|
@override
|
||||||
spacing: 4,
|
Widget build(BuildContext context) {
|
||||||
);
|
return Wrap(
|
||||||
} else {
|
runAlignment: WrapAlignment.start,
|
||||||
return SingleChildScrollView(
|
children: _children,
|
||||||
scrollDirection: Axis.horizontal,
|
runSpacing: 4,
|
||||||
child: Row(children: children),
|
spacing: 4,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
|
|
||||||
|
class _SliverTagsWidget extends TagsWidget {
|
||||||
|
const _SliverTagsWidget({
|
||||||
|
super.key,
|
||||||
|
required super.tags,
|
||||||
|
super.isClickable,
|
||||||
|
super.showShortNames,
|
||||||
|
super.dense,
|
||||||
|
super.onTagSelected,
|
||||||
|
});
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return SliverList.list(
|
||||||
|
children: _children,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,7 +26,6 @@ import 'package:paperless_mobile/core/database/tables/local_user_app_state.dart'
|
|||||||
import 'package:paperless_mobile/core/exception/server_message_exception.dart';
|
import 'package:paperless_mobile/core/exception/server_message_exception.dart';
|
||||||
import 'package:paperless_mobile/core/factory/paperless_api_factory.dart';
|
import 'package:paperless_mobile/core/factory/paperless_api_factory.dart';
|
||||||
import 'package:paperless_mobile/core/factory/paperless_api_factory_impl.dart';
|
import 'package:paperless_mobile/core/factory/paperless_api_factory_impl.dart';
|
||||||
import 'package:paperless_mobile/core/interceptor/dio_http_error_interceptor.dart';
|
|
||||||
import 'package:paperless_mobile/core/interceptor/language_header.interceptor.dart';
|
import 'package:paperless_mobile/core/interceptor/language_header.interceptor.dart';
|
||||||
import 'package:paperless_mobile/core/notifier/document_changed_notifier.dart';
|
import 'package:paperless_mobile/core/notifier/document_changed_notifier.dart';
|
||||||
import 'package:paperless_mobile/core/security/session_manager.dart';
|
import 'package:paperless_mobile/core/security/session_manager.dart';
|
||||||
|
|||||||
@@ -164,7 +164,7 @@ class UnsetDateRangeQueryAdapter extends TypeAdapter<UnsetDateRangeQuery> {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
UnsetDateRangeQuery read(BinaryReader reader) {
|
UnsetDateRangeQuery read(BinaryReader reader) {
|
||||||
// reader.readByte();
|
reader.readByte();
|
||||||
return const UnsetDateRangeQuery();
|
return const UnsetDateRangeQuery();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user