diff --git a/lib/features/document_edit/view/document_edit_page.dart b/lib/features/document_edit/view/document_edit_page.dart index 9ec064f..7d8c338 100644 --- a/lib/features/document_edit/view/document_edit_page.dart +++ b/lib/features/document_edit/view/document_edit_page.dart @@ -8,9 +8,6 @@ import 'package:form_builder_validators/form_builder_validators.dart'; import 'package:intl/intl.dart'; import 'package:paperless_api/paperless_api.dart'; import 'package:paperless_mobile/core/repository/label_repository.dart'; -import 'package:paperless_mobile/core/repository/state/impl/correspondent_repository_state.dart'; -import 'package:paperless_mobile/core/repository/state/impl/document_type_repository_state.dart'; -import 'package:paperless_mobile/core/repository/state/impl/storage_path_repository_state.dart'; import 'package:paperless_mobile/core/workarounds/colored_chip.dart'; import 'package:paperless_mobile/extensions/flutter_extensions.dart'; import 'package:paperless_mobile/features/document_edit/cubit/document_edit_cubit.dart'; @@ -21,7 +18,6 @@ import 'package:paperless_mobile/features/labels/tags/view/widgets/tags_form_fie import 'package:paperless_mobile/features/labels/view/widgets/label_form_field.dart'; import 'package:paperless_mobile/generated/l10n.dart'; import 'package:paperless_mobile/helpers/message_helpers.dart'; -import 'package:paperless_mobile/constants.dart'; class DocumentEditPage extends StatefulWidget { final FieldSuggestions suggestions; @@ -88,14 +84,14 @@ class _DocumentEditPageState extends State { children: [ _buildTitleFormField(state.document.title).padded(), _buildCreatedAtFormField(state.document.created).padded(), - _buildDocumentTypeFormField( - state.document.documentType, - state.documentTypes, - ).padded(), _buildCorrespondentFormField( state.document.correspondent, state.correspondents, ).padded(), + _buildDocumentTypeFormField( + state.document.documentType, + state.documentTypes, + ).padded(), _buildStoragePathFormField( state.document.storagePath, state.storagePaths, diff --git a/lib/features/document_upload/view/document_upload_preparation_page.dart b/lib/features/document_upload/view/document_upload_preparation_page.dart index 8b46b75..3acce30 100644 --- a/lib/features/document_upload/view/document_upload_preparation_page.dart +++ b/lib/features/document_upload/view/document_upload_preparation_page.dart @@ -47,6 +47,7 @@ class _DocumentUploadPreparationPageState PaperlessValidationErrors _errors = {}; bool _isUploadLoading = false; late bool _syncTitleAndFilename; + bool _showDatePickerDeleteIcon = false; final _now = DateTime.now(); @override @@ -82,6 +83,7 @@ class _DocumentUploadPreparationPageState key: _formKey, child: ListView( children: [ + // Title FormBuilderTextField( autovalidateMode: AutovalidateMode.always, name: DocumentModel.titleKey, @@ -112,6 +114,7 @@ class _DocumentUploadPreparationPageState } }, ), + // Filename FormBuilderTextField( autovalidateMode: AutovalidateMode.always, readOnly: _syncTitleAndFilename, @@ -129,6 +132,7 @@ class _DocumentUploadPreparationPageState initialValue: widget.filename ?? "scan_${fileNameDateFormat.format(_now)}", ), + // Synchronize title and filename SwitchListTile( value: _syncTitleAndFilename, onChanged: (value) { @@ -152,40 +156,33 @@ class _DocumentUploadPreparationPageState .documentUploadPageSynchronizeTitleAndFilenameLabel, ), ), + // Created at FormBuilderDateTimePicker( autovalidateMode: AutovalidateMode.always, format: DateFormat.yMMMMd(), inputType: InputType.date, name: DocumentModel.createdKey, initialValue: null, + onChanged: (value) { + setState(() => _showDatePickerDeleteIcon = value != null); + }, decoration: InputDecoration( prefixIcon: const Icon(Icons.calendar_month_outlined), labelText: S.of(context).documentCreatedPropertyLabel + " *", - suffixIcon: IconButton( - icon: const Icon(Icons.close), - onPressed: () { - _formKey - .currentState!.fields[DocumentModel.createdKey] - ?.didChange(null); - }, - )), - ), - LabelFormField( - notAssignedSelectable: false, - formBuilderState: _formKey.currentState, - labelCreationWidgetBuilder: (initialName) => - RepositoryProvider( - create: (context) => - context.read>(), - child: AddDocumentTypePage(initialName: initialName), + suffixIcon: _showDatePickerDeleteIcon + ? IconButton( + icon: const Icon(Icons.close), + onPressed: () { + _formKey.currentState! + .fields[DocumentModel.createdKey] + ?.didChange(null); + }, + ) + : null, ), - textFieldLabel: - S.of(context).documentDocumentTypePropertyLabel + " *", - name: DocumentModel.documentTypeKey, - labelOptions: state.documentTypes, - prefixIcon: const Icon(Icons.description_outlined), ), + // Correspondent LabelFormField( notAssignedSelectable: false, formBuilderState: _formKey.currentState, @@ -201,6 +198,22 @@ class _DocumentUploadPreparationPageState labelOptions: state.correspondents, prefixIcon: const Icon(Icons.person_outline), ), + // Document type + LabelFormField( + notAssignedSelectable: false, + formBuilderState: _formKey.currentState, + labelCreationWidgetBuilder: (initialName) => + RepositoryProvider( + create: (context) => + context.read>(), + child: AddDocumentTypePage(initialName: initialName), + ), + textFieldLabel: + S.of(context).documentDocumentTypePropertyLabel + " *", + name: DocumentModel.documentTypeKey, + labelOptions: state.documentTypes, + prefixIcon: const Icon(Icons.description_outlined), + ), TagFormField( name: DocumentModel.tagsKey, notAssignedSelectable: false,