mirror of
https://github.com/Xevion/paperless-mobile.git
synced 2025-12-07 16:07:53 -06:00
74 lines
2.4 KiB
Dart
74 lines
2.4 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
|
import 'package:intl/intl.dart';
|
|
import 'package:paperless_api/paperless_api.dart';
|
|
import 'package:paperless_mobile/core/repository/provider/label_repositories_provider.dart';
|
|
import 'package:paperless_mobile/features/document_details/bloc/document_details_cubit.dart';
|
|
import 'package:paperless_mobile/features/document_details/view/pages/document_details_page.dart';
|
|
import 'package:paperless_mobile/features/documents/view/widgets/document_preview.dart';
|
|
import 'package:paperless_mobile/features/inbox/bloc/inbox_cubit.dart';
|
|
import 'package:paperless_mobile/features/labels/tags/view/widgets/tags_widget.dart';
|
|
|
|
class InboxItem extends StatelessWidget {
|
|
static const _a4AspectRatio = 1 / 1.4142;
|
|
final void Function(DocumentModel model) onDocumentUpdated;
|
|
final DocumentModel document;
|
|
|
|
const InboxItem({
|
|
super.key,
|
|
required this.document,
|
|
required this.onDocumentUpdated,
|
|
});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return ListTile(
|
|
title: Text(document.title),
|
|
isThreeLine: true,
|
|
leading: AspectRatio(
|
|
aspectRatio: _a4AspectRatio,
|
|
child: DocumentPreview(
|
|
id: document.id,
|
|
fit: BoxFit.cover,
|
|
alignment: Alignment.topCenter,
|
|
enableHero: false,
|
|
),
|
|
),
|
|
subtitle: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
Text(DateFormat().format(document.added)),
|
|
TagsWidget(
|
|
tagIds: document.tags,
|
|
isMultiLine: false,
|
|
isClickable: false,
|
|
isSelectedPredicate: (_) => false,
|
|
onTagSelected: (_) {},
|
|
),
|
|
],
|
|
),
|
|
onTap: () async {
|
|
final returnedDocument = await Navigator.push<DocumentModel?>(
|
|
context,
|
|
MaterialPageRoute(
|
|
builder: (context) => BlocProvider(
|
|
create: (context) => DocumentDetailsCubit(
|
|
context.read<PaperlessDocumentsApi>(),
|
|
document,
|
|
),
|
|
child: const LabelRepositoriesProvider(
|
|
child: DocumentDetailsPage(
|
|
isLabelClickable: false,
|
|
),
|
|
),
|
|
),
|
|
),
|
|
);
|
|
if (returnedDocument != null) {
|
|
onDocumentUpdated(returnedDocument);
|
|
}
|
|
},
|
|
);
|
|
}
|
|
}
|