mirror of
https://github.com/Xevion/paperless-mobile.git
synced 2025-12-09 08:08:14 -06:00
Updated onboarding, reformatted files, improved referenced documents view, updated error handling
This commit is contained in:
@@ -4,6 +4,7 @@ import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:flutter_form_builder/flutter_form_builder.dart';
|
||||
import 'package:paperless_mobile/core/model/error_message.dart';
|
||||
import 'package:paperless_mobile/core/type/types.dart';
|
||||
import 'package:paperless_mobile/di_initializer.dart';
|
||||
import 'package:paperless_mobile/extensions/flutter_extensions.dart';
|
||||
import 'package:paperless_mobile/features/documents/model/document.model.dart';
|
||||
@@ -44,7 +45,7 @@ class _DocumentUploadPageState extends State<DocumentUploadPage> {
|
||||
static final fileNameDateFormat = DateFormat("yyyy_MM_ddTHH_mm_ss");
|
||||
final GlobalKey<FormBuilderState> _formKey = GlobalKey();
|
||||
|
||||
Map<String, String> _errors = {};
|
||||
PaperlessValidationErrors _errors = {};
|
||||
bool _isUploadLoading = false;
|
||||
|
||||
@override
|
||||
@@ -61,7 +62,8 @@ class _DocumentUploadPageState extends State<DocumentUploadPage> {
|
||||
title: Text(S.of(context).documentsUploadPageTitle),
|
||||
bottom: _isUploadLoading
|
||||
? const PreferredSize(
|
||||
child: LinearProgressIndicator(), preferredSize: Size.fromHeight(4.0))
|
||||
child: LinearProgressIndicator(),
|
||||
preferredSize: Size.fromHeight(4.0))
|
||||
: null,
|
||||
),
|
||||
floatingActionButton: Visibility(
|
||||
@@ -86,14 +88,17 @@ class _DocumentUploadPageState extends State<DocumentUploadPage> {
|
||||
suffixIcon: IconButton(
|
||||
icon: const Icon(Icons.close),
|
||||
onPressed: () {
|
||||
_formKey.currentState?.fields[DocumentModel.titleKey]?.didChange("");
|
||||
_formKey.currentState?.fields[fkFileName]?.didChange(".pdf");
|
||||
_formKey.currentState?.fields[DocumentModel.titleKey]
|
||||
?.didChange("");
|
||||
_formKey.currentState?.fields[fkFileName]
|
||||
?.didChange(".pdf");
|
||||
},
|
||||
),
|
||||
errorText: _errors[DocumentModel.titleKey],
|
||||
),
|
||||
onChanged: (value) {
|
||||
final String? transformedValue = value?.replaceAll(RegExp(r"[\W_]"), "_");
|
||||
final String? transformedValue =
|
||||
value?.replaceAll(RegExp(r"[\W_]"), "_");
|
||||
_formKey.currentState?.fields[fkFileName]
|
||||
?.didChange("${transformedValue ?? ''}.pdf");
|
||||
},
|
||||
@@ -106,7 +111,8 @@ class _DocumentUploadPageState extends State<DocumentUploadPage> {
|
||||
decoration: InputDecoration(
|
||||
labelText: S.of(context).documentUploadFileNameLabel,
|
||||
),
|
||||
initialValue: "scan_${fileNameDateFormat.format(DateTime.now())}.pdf",
|
||||
initialValue:
|
||||
"scan_${fileNameDateFormat.format(DateTime.now())}.pdf",
|
||||
),
|
||||
FormBuilderDateTimePicker(
|
||||
autovalidateMode: AutovalidateMode.always,
|
||||
@@ -125,7 +131,8 @@ class _DocumentUploadPageState extends State<DocumentUploadPage> {
|
||||
return LabelFormField<DocumentType, DocumentTypeQuery>(
|
||||
notAssignedSelectable: false,
|
||||
formBuilderState: _formKey.currentState,
|
||||
labelCreationWidgetBuilder: (initialValue) => BlocProvider.value(
|
||||
labelCreationWidgetBuilder: (initialValue) =>
|
||||
BlocProvider.value(
|
||||
value: BlocProvider.of<DocumentTypeCubit>(context),
|
||||
child: AddDocumentTypePage(initialName: initialValue),
|
||||
),
|
||||
@@ -133,7 +140,8 @@ class _DocumentUploadPageState extends State<DocumentUploadPage> {
|
||||
name: DocumentModel.documentTypeKey,
|
||||
state: state,
|
||||
queryParameterIdBuilder: DocumentTypeQuery.fromId,
|
||||
queryParameterNotAssignedBuilder: DocumentTypeQuery.notAssigned,
|
||||
queryParameterNotAssignedBuilder:
|
||||
DocumentTypeQuery.notAssigned,
|
||||
prefixIcon: const Icon(Icons.description_outlined),
|
||||
);
|
||||
},
|
||||
@@ -144,15 +152,18 @@ class _DocumentUploadPageState extends State<DocumentUploadPage> {
|
||||
return LabelFormField<Correspondent, CorrespondentQuery>(
|
||||
notAssignedSelectable: false,
|
||||
formBuilderState: _formKey.currentState,
|
||||
labelCreationWidgetBuilder: (initialValue) => BlocProvider.value(
|
||||
labelCreationWidgetBuilder: (initialValue) =>
|
||||
BlocProvider.value(
|
||||
value: BlocProvider.of<CorrespondentCubit>(context),
|
||||
child: AddCorrespondentPage(initalValue: initialValue),
|
||||
),
|
||||
label: S.of(context).documentCorrespondentPropertyLabel + " *",
|
||||
label:
|
||||
S.of(context).documentCorrespondentPropertyLabel + " *",
|
||||
name: DocumentModel.correspondentKey,
|
||||
state: state,
|
||||
queryParameterIdBuilder: CorrespondentQuery.fromId,
|
||||
queryParameterNotAssignedBuilder: CorrespondentQuery.notAssigned,
|
||||
queryParameterNotAssignedBuilder:
|
||||
CorrespondentQuery.notAssigned,
|
||||
prefixIcon: const Icon(Icons.person_outline),
|
||||
);
|
||||
},
|
||||
@@ -188,19 +199,27 @@ class _DocumentUploadPageState extends State<DocumentUploadPage> {
|
||||
onPressed: () {
|
||||
getIt<DocumentsCubit>().reloadDocuments();
|
||||
},
|
||||
label: S.of(context).documentUploadProcessingSuccessfulReloadActionText,
|
||||
label: S
|
||||
.of(context)
|
||||
.documentUploadProcessingSuccessfulReloadActionText,
|
||||
),
|
||||
content: Text(S.of(context).documentUploadProcessingSuccessfulText),
|
||||
content:
|
||||
Text(S.of(context).documentUploadProcessingSuccessfulText),
|
||||
),
|
||||
);
|
||||
},
|
||||
title: _formKey.currentState?.value[DocumentModel.titleKey],
|
||||
documentType:
|
||||
(_formKey.currentState?.value[DocumentModel.documentTypeKey] as IdQueryParameter).id,
|
||||
correspondent:
|
||||
(_formKey.currentState?.value[DocumentModel.correspondentKey] as IdQueryParameter).id,
|
||||
tags: (_formKey.currentState?.value[DocumentModel.tagsKey] as TagsQuery).ids,
|
||||
createdAt: (_formKey.currentState?.value[DocumentModel.createdKey] as DateTime?),
|
||||
documentType: (_formKey.currentState
|
||||
?.value[DocumentModel.documentTypeKey] as IdQueryParameter)
|
||||
.id,
|
||||
correspondent: (_formKey.currentState
|
||||
?.value[DocumentModel.correspondentKey] as IdQueryParameter)
|
||||
.id,
|
||||
tags:
|
||||
(_formKey.currentState?.value[DocumentModel.tagsKey] as TagsQuery)
|
||||
.ids,
|
||||
createdAt: (_formKey.currentState?.value[DocumentModel.createdKey]
|
||||
as DateTime?),
|
||||
);
|
||||
setState(() {
|
||||
_isUploadLoading = false;
|
||||
@@ -210,7 +229,7 @@ class _DocumentUploadPageState extends State<DocumentUploadPage> {
|
||||
showSnackBar(context, S.of(context).documentUploadSuccessText);
|
||||
} on ErrorMessage catch (error) {
|
||||
showError(context, error);
|
||||
} on Map<String, String> catch (errorMessages) {
|
||||
} on PaperlessValidationErrors catch (errorMessages) {
|
||||
setState(() => _errors = errorMessages);
|
||||
} catch (other) {
|
||||
showSnackBar(context, other.toString());
|
||||
|
||||
@@ -23,14 +23,16 @@ class ScannerPage extends StatefulWidget {
|
||||
State<ScannerPage> createState() => _ScannerPageState();
|
||||
}
|
||||
|
||||
class _ScannerPageState extends State<ScannerPage> with SingleTickerProviderStateMixin {
|
||||
class _ScannerPageState extends State<ScannerPage>
|
||||
with SingleTickerProviderStateMixin {
|
||||
late final AnimationController _fabPulsingController;
|
||||
late final Animation _animation;
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_fabPulsingController = AnimationController(vsync: this, duration: const Duration(seconds: 1))
|
||||
..repeat(reverse: true);
|
||||
_fabPulsingController =
|
||||
AnimationController(vsync: this, duration: const Duration(seconds: 1))
|
||||
..repeat(reverse: true);
|
||||
_animation = Tween(begin: 1.0, end: 1.2).animate(_fabPulsingController)
|
||||
..addListener(() {
|
||||
setState(() {});
|
||||
@@ -113,7 +115,8 @@ class _ScannerPageState extends State<ScannerPage> with SingleTickerProviderStat
|
||||
final img = pw.MemoryImage(element.readAsBytesSync());
|
||||
doc.addPage(
|
||||
pw.Page(
|
||||
pageFormat: PdfPageFormat(img.width!.toDouble(), img.height!.toDouble()),
|
||||
pageFormat:
|
||||
PdfPageFormat(img.width!.toDouble(), img.height!.toDouble()),
|
||||
build: (context) => pw.Image(img),
|
||||
),
|
||||
);
|
||||
@@ -164,7 +167,8 @@ class _ScannerPageState extends State<ScannerPage> with SingleTickerProviderStat
|
||||
itemBuilder: (context, index) {
|
||||
return GridImageItemWidget(
|
||||
file: scans[index],
|
||||
onDelete: () => BlocProvider.of<DocumentScannerCubit>(context).removeScan(index),
|
||||
onDelete: () => BlocProvider.of<DocumentScannerCubit>(context)
|
||||
.removeScan(index),
|
||||
index: index,
|
||||
totalNumberOfFiles: scans.length,
|
||||
);
|
||||
|
||||
@@ -25,7 +25,8 @@ class _ScannerWidgetState extends State<ScannerWidget> {
|
||||
appBar: AppBar(title: const Text("Scan document")),
|
||||
body: FutureBuilder<PermissionStatus>(
|
||||
future: Permission.camera.request(),
|
||||
builder: (BuildContext context, AsyncSnapshot<PermissionStatus> snapshot) {
|
||||
builder:
|
||||
(BuildContext context, AsyncSnapshot<PermissionStatus> snapshot) {
|
||||
if (!snapshot.hasData) {
|
||||
return const Center(child: CircularProgressIndicator());
|
||||
}
|
||||
|
||||
@@ -18,7 +18,8 @@ class _UploadDialogState extends State<UploadDialog> {
|
||||
void initState() {
|
||||
final DateFormat format = DateFormat("yyyy_MM_dd_hh_mm_ss");
|
||||
final today = format.format(DateTime.now());
|
||||
_controller = TextEditingController.fromValue(TextEditingValue(text: "Scan_$today.pdf"));
|
||||
_controller = TextEditingController.fromValue(
|
||||
TextEditingValue(text: "Scan_$today.pdf"));
|
||||
super.initState();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user