feat: Further migrations to go_router, add onclick to document previews

This commit is contained in:
Anton Stubenbord
2023-07-31 02:51:00 +02:00
parent f1398e6d4c
commit f3e660e91d
33 changed files with 868 additions and 845 deletions

View File

@@ -134,7 +134,7 @@ class _DocumentsPageState extends State<DocumentsPage>
Padding(
padding: const EdgeInsets.all(8.0),
child: FloatingActionButton.small(
key: UniqueKey(),
heroTag: "fab_documents_page_reset_filter",
backgroundColor: Theme.of(context)
.colorScheme
.onPrimaryContainer,
@@ -164,11 +164,13 @@ class _DocumentsPageState extends State<DocumentsPage>
duration: const Duration(milliseconds: 250),
child: (_currentTab == 0)
? FloatingActionButton(
heroTag: "fab_documents_page_filter",
child:
const Icon(Icons.filter_alt_outlined),
onPressed: _openDocumentFilter,
)
: FloatingActionButton(
heroTag: "fab_documents_page_filter",
child: const Icon(Icons.add),
onPressed: () =>
_onCreateSavedView(state.filter),

View File

@@ -2,6 +2,7 @@ import 'package:cached_network_image/cached_network_image.dart';
import 'package:flutter/material.dart';
import 'package:flutter_cache_manager/flutter_cache_manager.dart';
import 'package:paperless_api/paperless_api.dart';
import 'package:paperless_mobile/routes/typed/branches/documents_route.dart';
import 'package:provider/provider.dart';
import 'package:shimmer/shimmer.dart';
@@ -12,6 +13,7 @@ class DocumentPreview extends StatelessWidget {
final double borderRadius;
final bool enableHero;
final double scale;
final bool isClickable;
const DocumentPreview({
super.key,
@@ -21,15 +23,23 @@ class DocumentPreview extends StatelessWidget {
this.borderRadius = 12.0,
this.enableHero = true,
this.scale = 1.1,
this.isClickable = true,
});
@override
Widget build(BuildContext context) {
return HeroMode(
enabled: enableHero,
child: Hero(
tag: "thumb_${document.id}",
child: _buildPreview(context),
return GestureDetector(
onTap: isClickable
? () {
DocumentPreviewRoute($extra: document).push(context);
}
: null,
child: HeroMode(
enabled: enableHero,
child: Hero(
tag: "thumb_${document.id}",
child: _buildPreview(context),
),
),
);
}

View File

@@ -80,6 +80,7 @@ class _DocumentFilterPanelState extends State<DocumentFilterPanel> {
floatingActionButton: Visibility(
visible: MediaQuery.of(context).viewInsets.bottom == 0,
child: FloatingActionButton.extended(
heroTag: "fab_document_filter_panel",
icon: const Icon(Icons.done),
label: Text(S.of(context)!.apply),
onPressed: _onApplyFilter,

View File

@@ -7,6 +7,7 @@ import 'package:paperless_mobile/features/documents/cubit/documents_cubit.dart';
import 'package:paperless_mobile/features/documents/view/widgets/selection/bulk_delete_confirmation_dialog.dart';
import 'package:paperless_mobile/generated/l10n/app_localizations.dart';
import 'package:paperless_mobile/helpers/message_helpers.dart';
import 'package:paperless_mobile/routes/typed/branches/documents_route.dart';
class DocumentSelectionSliverAppBar extends StatelessWidget {
final DocumentsState state;
@@ -65,24 +66,30 @@ class DocumentSelectionSliverAppBar extends StatelessWidget {
label: Text(S.of(context)!.correspondent),
avatar: const Icon(Icons.edit),
onPressed: () {
pushBulkEditCorrespondentRoute(context,
selection: state.selection);
BulkEditDocumentsRoute(BulkEditExtraWrapper(
state.selection,
LabelType.correspondent,
)).push(context);
},
).paddedOnly(left: 8, right: 4),
ActionChip(
label: Text(S.of(context)!.documentType),
avatar: const Icon(Icons.edit),
onPressed: () async {
pushBulkEditDocumentTypeRoute(context,
selection: state.selection);
BulkEditDocumentsRoute(BulkEditExtraWrapper(
state.selection,
LabelType.documentType,
)).push(context);
},
).paddedOnly(left: 8, right: 4),
ActionChip(
label: Text(S.of(context)!.storagePath),
avatar: const Icon(Icons.edit),
onPressed: () async {
pushBulkEditStoragePathRoute(context,
selection: state.selection);
BulkEditDocumentsRoute(BulkEditExtraWrapper(
state.selection,
LabelType.storagePath,
)).push(context);
},
).paddedOnly(left: 8, right: 4),
_buildBulkEditTagsChip(context).paddedOnly(left: 4, right: 4),
@@ -98,7 +105,10 @@ class DocumentSelectionSliverAppBar extends StatelessWidget {
label: Text(S.of(context)!.tags),
avatar: const Icon(Icons.edit),
onPressed: () {
pushBulkEditTagsRoute(context, selection: state.selection);
BulkEditDocumentsRoute(BulkEditExtraWrapper(
state.selection,
LabelType.tag,
)).push(context);
},
);
}