feat: Update translations, add pdf view to document edit page

This commit is contained in:
Anton Stubenbord
2023-10-24 15:37:43 +02:00
parent 652abb6945
commit cb4839f5a3
40 changed files with 804 additions and 609 deletions

View File

@@ -2,6 +2,7 @@ import 'package:flutter/material.dart';
import 'package:intl/intl.dart';
import 'package:paperless_api/paperless_api.dart';
import 'package:paperless_mobile/core/database/tables/local_user_account.dart';
import 'package:paperless_mobile/core/extensions/flutter_extensions.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/items/document_item.dart';
@@ -29,111 +30,133 @@ class DocumentGridItem extends DocumentItem {
@override
Widget build(BuildContext context) {
var currentUser = context.watch<LocalUserAccount>().paperlessUser;
return Padding(
padding: const EdgeInsets.all(8.0),
child: Card(
elevation: 1.0,
color: isSelected
? Theme.of(context).colorScheme.inversePrimary
: Theme.of(context).cardColor,
child: InkWell(
borderRadius: BorderRadius.circular(12),
onTap: _onTap,
onLongPress: onSelected != null ? () => onSelected!(document) : null,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
AspectRatio(
aspectRatio: 1,
child: Stack(
children: [
Positioned.fill(
child: DocumentPreview(
documentId: document.id,
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),
),
if (currentUser.canViewTags)
TagsWidget.sliver(
tags: document.tags
.map((e) => context
.watch<LabelRepository>()
.state
.tags[e]!)
.toList(),
onTagSelected: onTagSelected,
),
const SliverToBoxAdapter(
child: SizedBox(width: 8),
),
],
return Stack(
children: [
Card(
elevation: 1.0,
color: isSelected
? Theme.of(context).colorScheme.inversePrimary
: Theme.of(context).cardColor,
child: InkWell(
borderRadius: BorderRadius.circular(12),
onTap: _onTap,
onLongPress:
onSelected != null ? () => onSelected!(document) : null,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
ClipRRect(
borderRadius: BorderRadius.circular(12),
child: AspectRatio(
aspectRatio: 1,
child: Stack(
children: [
Positioned.fill(
child: DocumentPreview(
documentId: document.id,
borderRadius: 12.0,
enableHero: enableHeroAnimation,
),
),
),
Align(
alignment: Alignment.bottomLeft,
child: SizedBox(
height: kMinInteractiveDimension,
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),
),
if (currentUser.canViewTags)
TagsWidget.sliver(
tags: document.tags
.map((e) => context
.watch<LabelRepository>()
.state
.tags[e]!)
.toList(),
onTagSelected: onTagSelected,
),
const SliverToBoxAdapter(
child: SizedBox(width: 8),
),
],
),
),
),
),
],
),
],
),
),
Expanded(
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
if (currentUser.canViewCorrespondents)
CorrespondentWidget(
correspondent: context
.watch<LabelRepository>()
.state
.correspondents[document.correspondent],
onSelected: onCorrespondentSelected,
),
if (currentUser.canViewDocumentTypes)
DocumentTypeWidget(
documentType: context
.watch<LabelRepository>()
.state
.documentTypes[document.documentType],
onSelected: onDocumentTypeSelected,
),
Padding(
padding: const EdgeInsets.only(bottom: 8.0),
child: Text(
document.title.isEmpty ? '-' : document.title,
maxLines: 3,
overflow: TextOverflow.ellipsis,
style: Theme.of(context).textTheme.titleMedium,
),
),
const Spacer(),
Text(
DateFormat.yMMMMd(
Localizations.localeOf(context).toString())
.format(document.created),
style: Theme.of(context).textTheme.bodySmall,
),
],
),
),
),
],
Expanded(
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
if (currentUser.canViewCorrespondents)
CorrespondentWidget(
correspondent: context
.watch<LabelRepository>()
.state
.correspondents[document.correspondent],
onSelected: onCorrespondentSelected,
),
if (currentUser.canViewDocumentTypes)
DocumentTypeWidget(
documentType: context
.watch<LabelRepository>()
.state
.documentTypes[document.documentType],
onSelected: onDocumentTypeSelected,
),
Padding(
padding: const EdgeInsets.only(bottom: 8.0),
child: Text(
document.title.isEmpty ? '-' : document.title,
maxLines: 2,
overflow: TextOverflow.ellipsis,
style: Theme.of(context).textTheme.titleMedium,
),
),
const Spacer(),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
DateFormat.yMMMMd(
Localizations.localeOf(context).toString(),
).format(document.created),
style: Theme.of(context).textTheme.bodySmall,
),
if (document.archiveSerialNumber != null)
Text(
'#' + document.archiveSerialNumber!.toString(),
style: Theme.of(context)
.textTheme
.bodySmall
?.copyWith(
color: Theme.of(context)
.colorScheme
.onSurface,
),
)
],
),
],
),
),
),
],
),
),
),
),
],
);
}