diff --git a/lib/features/document_details/cubit/document_details_cubit.dart b/lib/features/document_details/cubit/document_details_cubit.dart index 66ab41c..30f0eba 100644 --- a/lib/features/document_details/cubit/document_details_cubit.dart +++ b/lib/features/document_details/cubit/document_details_cubit.dart @@ -214,7 +214,7 @@ class DocumentDetailsCubit extends Cubit { throw Exception("An error occurred while downloading the document."); } Printing.layoutPdf( - name: state.document.title ?? 'Document', + name: state.document.title, onLayout: (format) => file.readAsBytesSync(), ); } diff --git a/lib/features/document_details/view/pages/document_details_page.dart b/lib/features/document_details/view/pages/document_details_page.dart index 650fd6e..57460c1 100644 --- a/lib/features/document_details/view/pages/document_details_page.dart +++ b/lib/features/document_details/view/pages/document_details_page.dart @@ -26,6 +26,7 @@ import 'package:paperless_mobile/helpers/connectivity_aware_action_wrapper.dart' import 'package:paperless_mobile/helpers/message_helpers.dart'; import 'package:paperless_mobile/routes/typed/branches/documents_route.dart'; import 'package:paperless_mobile/routes/typed/shells/authenticated_route.dart'; +import 'package:paperless_mobile/theme.dart'; class DocumentDetailsPage extends StatefulWidget { final bool isLabelClickable; @@ -57,136 +58,100 @@ class _DocumentDetailsPageState extends State { context.watch().hasMultiUserSupport; final tabLength = 4 + (hasMultiUserSupport && false ? 1 : 0); final title = context.watch().state.document.title; - return WillPopScope( - onWillPop: () async { - Navigator.of(context) - .pop(context.read().state.document); - return false; - }, - child: DefaultTabController( - length: tabLength, - child: BlocListener( - listenWhen: (previous, current) => - !previous.isConnected && current.isConnected, - listener: (context, state) { - context.read().loadMetaData(); - }, - child: Scaffold( - extendBodyBehindAppBar: false, - floatingActionButtonLocation: - FloatingActionButtonLocation.endDocked, - floatingActionButton: _buildEditButton(), - bottomNavigationBar: _buildBottomAppBar(), - body: NestedScrollView( - headerSliverBuilder: (context, innerBoxIsScrolled) => [ - SliverOverlapAbsorber( - handle: - NestedScrollView.sliverOverlapAbsorberHandleFor(context), - sliver: SliverAppBar( - title: title != null ? Text(title) : null, - leading: const BackButton(), - pinned: true, - forceElevated: innerBoxIsScrolled, - collapsedHeight: kToolbarHeight, - expandedHeight: 250.0, - flexibleSpace: FlexibleSpaceBar( - background: BlocBuilder( - builder: (context, state) { - return Hero( - tag: "thumb_${state.document.id}", - child: GestureDetector( - onTap: () { - DocumentPreviewRoute($extra: state.document) - .push(context); - }, - child: Stack( - alignment: Alignment.topCenter, - children: [ - Positioned.fill( - child: DocumentPreview( - enableHero: false, - document: state.document, - fit: BoxFit.cover, - alignment: Alignment.topCenter, + return AnnotatedRegion( + value: buildOverlayStyle( + Theme.of(context), + systemNavigationBarColor: Theme.of(context).bottomAppBarTheme.color, + ), + child: WillPopScope( + onWillPop: () async { + Navigator.of(context) + .pop(context.read().state.document); + return false; + }, + child: DefaultTabController( + length: tabLength, + child: BlocListener( + listenWhen: (previous, current) => + !previous.isConnected && current.isConnected, + listener: (context, state) { + context.read().loadMetaData(); + }, + child: Scaffold( + extendBodyBehindAppBar: false, + floatingActionButtonLocation: + FloatingActionButtonLocation.endDocked, + floatingActionButton: _buildEditButton(), + bottomNavigationBar: _buildBottomAppBar(), + body: NestedScrollView( + headerSliverBuilder: (context, innerBoxIsScrolled) => [ + SliverOverlapAbsorber( + handle: NestedScrollView.sliverOverlapAbsorberHandleFor( + context), + sliver: SliverAppBar( + title: Text(title), + leading: const BackButton(), + pinned: true, + forceElevated: innerBoxIsScrolled, + collapsedHeight: kToolbarHeight, + expandedHeight: 250.0, + flexibleSpace: FlexibleSpaceBar( + background: BlocBuilder( + builder: (context, state) { + return Hero( + tag: "thumb_${state.document.id}", + child: GestureDetector( + onTap: () { + DocumentPreviewRoute($extra: state.document) + .push(context); + }, + child: Stack( + alignment: Alignment.topCenter, + children: [ + Positioned.fill( + child: DocumentPreview( + enableHero: false, + document: state.document, + fit: BoxFit.cover, + alignment: Alignment.topCenter, + ), ), - ), - Positioned.fill( - child: DecoratedBox( - decoration: BoxDecoration( - gradient: LinearGradient( - stops: [0.2, 0.4], - colors: [ - Theme.of(context) - .colorScheme - .background - .withOpacity(0.6), - Theme.of(context) - .colorScheme - .background - .withOpacity(0.3), - ], - begin: Alignment.topCenter, - end: Alignment.bottomCenter, + Positioned.fill( + child: DecoratedBox( + decoration: BoxDecoration( + gradient: LinearGradient( + stops: [0.2, 0.4], + colors: [ + Theme.of(context) + .colorScheme + .background + .withOpacity(0.6), + Theme.of(context) + .colorScheme + .background + .withOpacity(0.3), + ], + begin: Alignment.topCenter, + end: Alignment.bottomCenter, + ), ), ), ), - ), - ], + ], + ), ), - ), - ); - }, + ); + }, + ), ), - ), - bottom: ColoredTabBar( - tabBar: TabBar( - isScrollable: true, - tabs: [ - Tab( - child: Text( - S.of(context)!.overview, - style: TextStyle( - color: Theme.of(context) - .colorScheme - .onPrimaryContainer, - ), - ), - ), - Tab( - child: Text( - S.of(context)!.content, - style: TextStyle( - color: Theme.of(context) - .colorScheme - .onPrimaryContainer, - ), - ), - ), - Tab( - child: Text( - S.of(context)!.metaData, - style: TextStyle( - color: Theme.of(context) - .colorScheme - .onPrimaryContainer, - ), - ), - ), - Tab( - child: Text( - S.of(context)!.similarDocuments, - style: TextStyle( - color: Theme.of(context) - .colorScheme - .onPrimaryContainer, - ), - ), - ), - if (hasMultiUserSupport && false) + bottom: ColoredTabBar( + tabBar: TabBar( + isScrollable: true, + tabs: [ Tab( child: Text( - "Permissions", + S.of(context)!.overview, style: TextStyle( color: Theme.of(context) .colorScheme @@ -194,80 +159,111 @@ class _DocumentDetailsPageState extends State { ), ), ), - ], + Tab( + child: Text( + S.of(context)!.content, + style: TextStyle( + color: Theme.of(context) + .colorScheme + .onPrimaryContainer, + ), + ), + ), + Tab( + child: Text( + S.of(context)!.metaData, + style: TextStyle( + color: Theme.of(context) + .colorScheme + .onPrimaryContainer, + ), + ), + ), + Tab( + child: Text( + S.of(context)!.similarDocuments, + style: TextStyle( + color: Theme.of(context) + .colorScheme + .onPrimaryContainer, + ), + ), + ), + if (hasMultiUserSupport && false) + Tab( + child: Text( + "Permissions", + style: TextStyle( + color: Theme.of(context) + .colorScheme + .onPrimaryContainer, + ), + ), + ), + ], + ), ), ), ), - ), - ], - body: BlocBuilder( - builder: (context, state) { - return BlocProvider( - create: (context) => SimilarDocumentsCubit( - context.read(), - context.read(), - context.read(), - context.read(), - documentId: state.document.id, - ), - child: Padding( - padding: const EdgeInsets.symmetric( - vertical: 16, - horizontal: 16, + ], + body: BlocBuilder( + builder: (context, state) { + return BlocProvider( + create: (context) => SimilarDocumentsCubit( + context.read(), + context.read(), + context.read(), + context.read(), + documentId: state.document.id, ), - child: TabBarView( - children: [ - CustomScrollView( - slivers: [ - SliverOverlapInjector( - handle: NestedScrollView - .sliverOverlapAbsorberHandleFor(context), - ), - DocumentOverviewWidget( - document: state.document, - itemSpacing: _itemSpacing, - queryString: widget.titleAndContentQueryString, - ), - ], - ), - CustomScrollView( - slivers: [ - SliverOverlapInjector( - handle: NestedScrollView - .sliverOverlapAbsorberHandleFor(context), - ), - DocumentContentWidget( - isFullContentLoaded: state.isFullContentLoaded, - document: state.document, - queryString: widget.titleAndContentQueryString, - ), - ], - ), - CustomScrollView( - slivers: [ - SliverOverlapInjector( - handle: NestedScrollView - .sliverOverlapAbsorberHandleFor(context), - ), - DocumentMetaDataWidget( - document: state.document, - itemSpacing: _itemSpacing, - ), - ], - ), - CustomScrollView( - controller: _pagingScrollController, - slivers: [ - SliverOverlapInjector( - handle: NestedScrollView - .sliverOverlapAbsorberHandleFor(context), - ), - SimilarDocumentsView( - pagingScrollController: _pagingScrollController, - ), - ], - ), - if (hasMultiUserSupport && false) + child: Padding( + padding: const EdgeInsets.symmetric( + vertical: 16, + horizontal: 16, + ), + child: TabBarView( + children: [ + CustomScrollView( + slivers: [ + SliverOverlapInjector( + handle: NestedScrollView + .sliverOverlapAbsorberHandleFor(context), + ), + DocumentOverviewWidget( + document: state.document, + itemSpacing: _itemSpacing, + queryString: + widget.titleAndContentQueryString, + ), + ], + ), + CustomScrollView( + slivers: [ + SliverOverlapInjector( + handle: NestedScrollView + .sliverOverlapAbsorberHandleFor(context), + ), + DocumentContentWidget( + isFullContentLoaded: + state.isFullContentLoaded, + document: state.document, + queryString: + widget.titleAndContentQueryString, + ), + ], + ), + CustomScrollView( + slivers: [ + SliverOverlapInjector( + handle: NestedScrollView + .sliverOverlapAbsorberHandleFor(context), + ), + DocumentMetaDataWidget( + document: state.document, + itemSpacing: _itemSpacing, + ), + ], + ), CustomScrollView( controller: _pagingScrollController, slivers: [ @@ -275,16 +271,32 @@ class _DocumentDetailsPageState extends State { handle: NestedScrollView .sliverOverlapAbsorberHandleFor(context), ), - DocumentPermissionsWidget( - document: state.document, + SimilarDocumentsView( + pagingScrollController: + _pagingScrollController, ), ], ), - ], + if (hasMultiUserSupport && false) + CustomScrollView( + controller: _pagingScrollController, + slivers: [ + SliverOverlapInjector( + handle: NestedScrollView + .sliverOverlapAbsorberHandleFor( + context), + ), + DocumentPermissionsWidget( + document: state.document, + ), + ], + ), + ], + ), ), - ), - ); - }, + ); + }, + ), ), ), ), diff --git a/lib/features/document_details/view/widgets/document_overview_widget.dart b/lib/features/document_details/view/widgets/document_overview_widget.dart index 02bcf81..369cdf2 100644 --- a/lib/features/document_details/view/widgets/document_overview_widget.dart +++ b/lib/features/document_details/view/widgets/document_overview_widget.dart @@ -29,11 +29,11 @@ class DocumentOverviewWidget extends StatelessWidget { final availableLabels = context.watch().state; return SliverList.list( children: [ - if (document.title != null) + if (document.title.isNotEmpty) DetailsItem( label: S.of(context)!.title, content: HighlightedText( - text: document.title!, + text: document.title, highlights: queryString?.split(" ") ?? [], style: Theme.of(context).textTheme.bodyLarge, ), diff --git a/lib/features/document_edit/view/document_edit_page.dart b/lib/features/document_edit/view/document_edit_page.dart index 2b6d98e..2b51c97 100644 --- a/lib/features/document_edit/view/document_edit_page.dart +++ b/lib/features/document_edit/view/document_edit_page.dart @@ -2,6 +2,7 @@ import 'dart:async'; import 'package:collection/collection.dart'; import 'package:flutter/material.dart'; +import 'package:flutter/services.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:flutter_form_builder/flutter_form_builder.dart'; import 'package:flutter_typeahead/flutter_typeahead.dart'; @@ -9,7 +10,6 @@ import 'package:go_router/go_router.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/notifier/document_changed_notifier.dart'; import 'package:paperless_mobile/core/widgets/dialog_utils/dialog_cancel_button.dart'; import 'package:paperless_mobile/core/widgets/dialog_utils/pop_with_unsaved_changes.dart'; import 'package:paperless_mobile/core/workarounds/colored_chip.dart'; @@ -21,6 +21,7 @@ import 'package:paperless_mobile/generated/l10n/app_localizations.dart'; import 'package:paperless_mobile/helpers/message_helpers.dart'; import 'package:paperless_mobile/routes/typed/branches/labels_route.dart'; import 'package:paperless_mobile/routes/typed/shells/authenticated_route.dart'; +import 'package:paperless_mobile/theme.dart'; class DocumentEditPage extends StatefulWidget { const DocumentEditPage({ @@ -42,12 +43,6 @@ class _DocumentEditPageState extends State { final _formKey = GlobalKey(); - @override - void didUpdateWidget(covariant DocumentEditPage oldWidget) { - super.didUpdateWidget(oldWidget); - print("WIDGET CONFIGURATION CHANGED?!?!?"); - } - @override Widget build(BuildContext context) { final currentUser = context.watch().paperlessUser; @@ -404,12 +399,6 @@ class _DocumentEditPageState extends State { Widget _buildTitleFormField(String? initialTitle) { return FormBuilderTextField( name: fkTitle, - validator: (value) { - if (value?.trim().isEmpty ?? true) { - return S.of(context)!.thisFieldIsRequired; - } - return null; - }, decoration: InputDecoration( label: Text(S.of(context)!.title), ), @@ -478,55 +467,3 @@ class _DocumentEditPageState extends State { ).padded(); } } - -// class SampleWidget extends StatefulWidget { -// const SampleWidget({super.key}); - -// @override -// State createState() => _SampleWidgetState(); -// } - -// class _SampleWidgetState extends State { -// @override -// Widget build(BuildContext context) { -// return BlocBuilder( -// builder: (context, state) { -// return OptionsFormField( -// options: state.options, -// onAddOption: (option) { -// // This will call the repository and will cause a new state containing the new option to be emitted. -// context.read().addOption(option); -// }, -// ); -// }, -// ); -// } -// } - -// class OptionsFormField extends StatefulWidget { -// final List