From 7fac53522af06730989222c53a1e300b62a4931e Mon Sep 17 00:00:00 2001 From: Anton Stubenbord Date: Tue, 15 Nov 2022 01:24:26 +0100 Subject: [PATCH] Bugfixes, some visual updates --- lib/core/util.dart | 4 +-- .../documents/view/pages/documents_page.dart | 12 ++++--- .../widgets/search/document_filter_panel.dart | 3 +- .../selection/documents_page_app_bar.dart | 35 +++++++++++++----- .../saved_view_selection_widget.dart | 14 ++++---- .../view/widget/bottom_navigation_bar.dart | 2 +- .../home/view/widget/info_drawer.dart | 32 +++++++++++++++-- lib/features/scan/view/scanner_page.dart | 36 ++----------------- lib/l10n/intl_de.arb | 12 ++++--- lib/l10n/intl_en.arb | 6 ++-- lib/util.dart | 10 +++++- pubspec.yaml | 2 +- 12 files changed, 99 insertions(+), 69 deletions(-) diff --git a/lib/core/util.dart b/lib/core/util.dart index 9e26b0b..b28c42d 100644 --- a/lib/core/util.dart +++ b/lib/core/util.dart @@ -24,7 +24,7 @@ Future getSingleResult( jsonDecode(utf8.decode(response.bodyBytes)) as JSON, ); } - return Future.error(errorCode); + throw ErrorMessage(errorCode); } Future> getCollection( @@ -52,7 +52,7 @@ Future> getCollection( } } } - return Future.error(errorCode); + throw ErrorMessage(errorCode); } List _collectionFromJson( diff --git a/lib/features/documents/view/pages/documents_page.dart b/lib/features/documents/view/pages/documents_page.dart index 47c27f0..46403b9 100644 --- a/lib/features/documents/view/pages/documents_page.dart +++ b/lib/features/documents/view/pages/documents_page.dart @@ -130,8 +130,7 @@ class _DocumentsPageState extends State { controller: _panelController, defaultPanelState: PanelState.CLOSED, minHeight: 48, - maxHeight: MediaQuery.of(context).size.height - - kBottomNavigationBarHeight, + maxHeight: (MediaQuery.of(context).size.height * 3) / 4, borderRadius: const BorderRadius.only( topLeft: Radius.circular(16), topRight: Radius.circular(16), @@ -193,7 +192,7 @@ class _DocumentsPageState extends State { onRefresh: _onRefresh, child: Container( padding: const EdgeInsets.only( - bottom: 142, + bottom: 48 + kBottomNavigationBarHeight + 48, ), // Prevents panel from hiding scrollable content child: CustomScrollView( slivers: [ @@ -211,7 +210,12 @@ class _DocumentsPageState extends State { ), ], ), - child + child, + // SliverToBoxAdapter( + // child: SizedBox( + // height: MediaQuery.of(context).size.height / 3, + // ), + // ) ], ), ), diff --git a/lib/features/documents/view/widgets/search/document_filter_panel.dart b/lib/features/documents/view/widgets/search/document_filter_panel.dart index 0bb0006..6257cd1 100644 --- a/lib/features/documents/view/widgets/search/document_filter_panel.dart +++ b/lib/features/documents/view/widgets/search/document_filter_panel.dart @@ -1,7 +1,6 @@ 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/logic/error_code_localization_mapper.dart'; import 'package:paperless_mobile/core/model/error_message.dart'; import 'package:paperless_mobile/extensions/flutter_extensions.dart'; import 'package:paperless_mobile/features/documents/bloc/documents_cubit.dart'; @@ -138,12 +137,12 @@ class _DocumentFilterPanelState extends State { const SizedBox( height: 16.0, ), + _buildSortByChipsList(context, state), Align( alignment: Alignment.centerLeft, child: Text(S.of(context).documentsFilterPageSearchLabel), ).padded(const EdgeInsets.only(left: 8.0)), _buildQueryFormField(state), - _buildSortByChipsList(context, state), Align( alignment: Alignment.centerLeft, child: Text(S.of(context).documentsFilterPageAdvancedLabel), diff --git a/lib/features/documents/view/widgets/selection/documents_page_app_bar.dart b/lib/features/documents/view/widgets/selection/documents_page_app_bar.dart index ce352aa..d3a3b66 100644 --- a/lib/features/documents/view/widgets/selection/documents_page_app_bar.dart +++ b/lib/features/documents/view/widgets/selection/documents_page_app_bar.dart @@ -6,6 +6,7 @@ import 'package:paperless_mobile/features/documents/bloc/documents_cubit.dart'; import 'package:paperless_mobile/features/documents/bloc/documents_state.dart'; import 'package:paperless_mobile/features/documents/view/widgets/selection/bulk_delete_confirmation_dialog.dart'; import 'package:paperless_mobile/features/documents/view/widgets/selection/saved_view_selection_widget.dart'; +import 'package:paperless_mobile/features/documents/view/widgets/sort_documents_button.dart'; import 'package:paperless_mobile/generated/l10n.dart'; import 'package:paperless_mobile/util.dart'; @@ -28,12 +29,14 @@ class _DocumentsPageAppBarState extends State { Widget build(BuildContext context) { return BlocBuilder( builder: (context, documentsState) { - if (documentsState.selection.isNotEmpty) { + final hasSelection = documentsState.selection.isNotEmpty; + if (hasSelection) { return SliverAppBar( + expandedHeight: kToolbarHeight + _flexibleAreaHeight, snap: true, floating: true, pinned: true, - expandedHeight: kToolbarHeight, + flexibleSpace: _buildFlexibleArea(false), leading: IconButton( icon: const Icon(Icons.close), onPressed: () => @@ -51,13 +54,10 @@ class _DocumentsPageAppBarState extends State { } else { return SliverAppBar( expandedHeight: kToolbarHeight + _flexibleAreaHeight, + snap: true, + floating: true, pinned: true, - flexibleSpace: const FlexibleSpaceBar( - background: Padding( - padding: EdgeInsets.all(8.0), - child: SavedViewSelectionWidget(height: _flexibleAreaHeight), - ), - ), + flexibleSpace: _buildFlexibleArea(true), title: BlocBuilder( builder: (context, state) { return Text( @@ -65,13 +65,30 @@ class _DocumentsPageAppBarState extends State { ); }, ), - actions: widget.actions, + actions: [ + ...widget.actions, + ], ); } }, ); } + Widget _buildFlexibleArea(bool enabled) { + return FlexibleSpaceBar( + background: Padding( + padding: EdgeInsets.all(8.0), + child: Column( + mainAxisAlignment: MainAxisAlignment.end, + children: [ +//TODO: replace with sorting stuff... + SavedViewSelectionWidget(height: 48, enabled: enabled), + ], + ), + ), + ); + } + void _onDelete(BuildContext context, DocumentsState documentsState) async { final shouldDelete = await showDialog( context: context, diff --git a/lib/features/documents/view/widgets/selection/saved_view_selection_widget.dart b/lib/features/documents/view/widgets/selection/saved_view_selection_widget.dart index 723373b..2522c44 100644 --- a/lib/features/documents/view/widgets/selection/saved_view_selection_widget.dart +++ b/lib/features/documents/view/widgets/selection/saved_view_selection_widget.dart @@ -1,5 +1,3 @@ -import 'dart:developer'; - import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:paperless_mobile/core/model/error_message.dart'; @@ -17,9 +15,11 @@ class SavedViewSelectionWidget extends StatelessWidget { const SavedViewSelectionWidget({ Key? key, required this.height, + required this.enabled, }) : super(key: key); final double height; + final bool enabled; @override Widget build(BuildContext context) { @@ -33,7 +33,7 @@ class SavedViewSelectionWidget extends StatelessWidget { return Text(S.of(context).savedViewsEmptyStateText); } return SizedBox( - height: 48.0, + height: height, child: ListView.separated( itemCount: state.value.length, scrollDirection: Axis.horizontal, @@ -44,8 +44,10 @@ class SavedViewSelectionWidget extends StatelessWidget { child: FilterChip( label: Text(state.value.values.toList()[index].name), selected: view.id == state.selectedSavedViewId, - onSelected: (isSelected) => - _onSelected(isSelected, context, view), + onSelected: enabled + ? (isSelected) => + _onSelected(isSelected, context, view) + : null, ), ); }, @@ -65,7 +67,7 @@ class SavedViewSelectionWidget extends StatelessWidget { ), TextButton.icon( icon: const Icon(Icons.add), - onPressed: () => _onCreatePressed(context), + onPressed: enabled ? () => _onCreatePressed(context) : null, label: Text(S.of(context).savedViewCreateNewLabel), ), ], diff --git a/lib/features/home/view/widget/bottom_navigation_bar.dart b/lib/features/home/view/widget/bottom_navigation_bar.dart index d97ff22..64699c0 100644 --- a/lib/features/home/view/widget/bottom_navigation_bar.dart +++ b/lib/features/home/view/widget/bottom_navigation_bar.dart @@ -19,7 +19,7 @@ class BottomNavBar extends StatelessWidget { selectedIndex: selectedIndex, destinations: [ NavigationDestination( - icon: const Icon(Icons.description_outlined), + icon: const Icon(Icons.description), selectedIcon: Icon( Icons.description, color: Theme.of(context).colorScheme.primary, diff --git a/lib/features/home/view/widget/info_drawer.dart b/lib/features/home/view/widget/info_drawer.dart index 40acd25..ac37583 100644 --- a/lib/features/home/view/widget/info_drawer.dart +++ b/lib/features/home/view/widget/info_drawer.dart @@ -26,6 +26,12 @@ class InfoDrawer extends StatelessWidget { child: ListView( children: [ DrawerHeader( + padding: EdgeInsets.only( + top: 8, + left: 8, + bottom: 0, + right: 8, + ), child: Column( mainAxisAlignment: MainAxisAlignment.spaceBetween, crossAxisAlignment: CrossAxisAlignment.start, @@ -60,25 +66,45 @@ class InfoDrawer extends StatelessWidget { contentPadding: EdgeInsets.zero, dense: true, title: Text( - state.host ?? '', + S.of(context).appDrawerHeaderLoggedInAsText + + (state.username ?? '?'), + style: Theme.of(context).textTheme.bodyText2, overflow: TextOverflow.ellipsis, textAlign: TextAlign.end, maxLines: 1, ), - isThreeLine: true, subtitle: Column( crossAxisAlignment: CrossAxisAlignment.end, children: [ Text( - state.username ?? '', + state.host ?? '', + style: Theme.of(context).textTheme.bodyText2, + overflow: TextOverflow.ellipsis, textAlign: TextAlign.end, + maxLines: 1, ), Text( '${S.of(context).serverInformationPaperlessVersionText} ${state.version} (API v${state.apiVersion})', style: Theme.of(context).textTheme.caption, + overflow: TextOverflow.ellipsis, + textAlign: TextAlign.end, + maxLines: 1, ), ], ), + // title: RichText( + + // text: TextSpan( + // children: [ + // TextSpan( + // text: + // style: + // Theme.of(context).textTheme.bodyText2, + // ), + // ], + // ), + // ), + isThreeLine: true, ), ], ); diff --git a/lib/features/scan/view/scanner_page.dart b/lib/features/scan/view/scanner_page.dart index bd9933c..4663afd 100644 --- a/lib/features/scan/view/scanner_page.dart +++ b/lib/features/scan/view/scanner_page.dart @@ -33,43 +33,13 @@ class ScannerPage extends StatefulWidget { class _ScannerPageState extends State 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); - _animation = Tween(begin: 1.0, end: 1.2).animate(_fabPulsingController) - ..addListener(() => setState((() {}))); - } - - @override - void dispose() { - _fabPulsingController.dispose(); - super.dispose(); - } - @override Widget build(BuildContext context) { return Scaffold( drawer: const InfoDrawer(), - floatingActionButton: BlocBuilder>( - builder: (context, state) { - final fab = FloatingActionButton( - onPressed: () => _openDocumentScanner(context), - child: const Icon(Icons.add_a_photo_outlined), - ); - if (state.isEmpty) { - return Transform.scale( - child: fab, - scale: _animation.value, - ); - } - return fab; - }, + floatingActionButton: FloatingActionButton( + onPressed: () => _openDocumentScanner(context), + child: const Icon(Icons.add_a_photo_outlined), ), appBar: _buildAppBar(context), body: Padding( diff --git a/lib/l10n/intl_de.arb b/lib/l10n/intl_de.arb index 949172c..d05919e 100644 --- a/lib/l10n/intl_de.arb +++ b/lib/l10n/intl_de.arb @@ -39,7 +39,7 @@ "genericActionUploadLabel": "Hochladen", "genericActionUpdateLabel": "Aktualisieren", "appDrawerSettingsLabel": "Einstellungen", - "appDrawerAboutLabel": "Über", + "appDrawerAboutLabel": "Über diese App", "appDrawerAboutInfoLoadingText": "Lade Anwendungsinformationen...", "appDrawerReportBugLabel": "Einen Fehler melden", "appDrawerLogoutLabel": "Verbindung trennen", @@ -186,9 +186,11 @@ "referencedDocumentsReadOnlyHintText": "Dies ist eine schreibgeschützte Ansicht! Dokumente können nicht bearbeitet oder entfernt werden.", "editLabelPageConfirmDeletionDialogTitle": "Löschen bestätigen", "editLabelPageDeletionDialogText": "Dieser Kennzeichner wird von Dokumenten referenziert. Durch das Löschen dieses Kennzeichners werden alle Referenzen entfernt. Fortfahren?", - "settingsPageStorageSettingsLabel": "Storage", - "settingsPageStorageSettingsDescriptionText": "Manage files and storage space", - "documentUpdateErrorMessage": "Document successfully updated.", + "settingsPageStorageSettingsLabel": "Speicher", + "settingsPageStorageSettingsDescriptionText": "Dateien und Speicherplatz verwalten", + "documentUpdateErrorMessage": "Dokument erfolgreich aktualisiert.", "errorMessageMissingClientCertificate": "Ein Client Zerfitikat wurde erwartet, aber nicht gesendet. Bitte konfiguriere ein gültiges Zertifikat.", - "serverInformationPaperlessVersionText": "Paperless Server-Version" + "serverInformationPaperlessVersionText": "Paperless Server-Version", + "errorReportLabel": "MELDEN", + "appDrawerHeaderLoggedInAsText": "Eingeloggt als " } \ No newline at end of file diff --git a/lib/l10n/intl_en.arb b/lib/l10n/intl_en.arb index d58d53f..0014a65 100644 --- a/lib/l10n/intl_en.arb +++ b/lib/l10n/intl_en.arb @@ -39,7 +39,7 @@ "genericActionUploadLabel": "Upload", "genericActionUpdateLabel": "Update", "appDrawerSettingsLabel": "Settings", - "appDrawerAboutLabel": "About", + "appDrawerAboutLabel": "About this app", "appDrawerAboutInfoLoadingText": "Retrieving application information...", "appDrawerReportBugLabel": "Report a Bug", "appDrawerLogoutLabel": "Disconnect", @@ -191,5 +191,7 @@ "settingsPageStorageSettingsDescriptionText": "Manage files and storage space", "documentUpdateErrorMessage": "Document successfully updated.", "errorMessageMissingClientCertificate": "A client certificate was expected but not sent. Please provide a valid client certificate.", - "serverInformationPaperlessVersionText": "Paperless server version" + "serverInformationPaperlessVersionText": "Paperless server version", + "errorReportLabel": "REPORT", + "appDrawerHeaderLoggedInAsText": "Logged in as " } \ No newline at end of file diff --git a/lib/util.dart b/lib/util.dart index 1542902..cb1115c 100644 --- a/lib/util.dart +++ b/lib/util.dart @@ -1,4 +1,5 @@ import 'dart:convert'; +import 'dart:developer'; import 'dart:io'; import 'dart:typed_data'; @@ -9,6 +10,7 @@ import 'package:intl/intl.dart'; import 'package:package_info_plus/package_info_plus.dart'; import 'package:paperless_mobile/core/service/github_issue_service.dart'; import 'package:paperless_mobile/generated/intl/messages_de.dart'; +import 'package:paperless_mobile/generated/l10n.dart'; import 'package:path_provider/path_provider.dart'; final dateFormat = DateFormat("yyyy-MM-dd"); @@ -42,7 +44,7 @@ void showError( translateError(context, error.code), details: error.details, action: SnackBarAction( - label: "REPORT", + label: S.of(context).errorReportLabel, textColor: Colors.amber, onPressed: () => GithubIssueService.createIssueFromError( context, @@ -50,6 +52,12 @@ void showError( ), ), ); + log( + "An error has occurred.", + error: error, + stackTrace: stackTrace, + time: DateTime.now(), + ); } bool isNotNull(dynamic value) { diff --git a/pubspec.yaml b/pubspec.yaml index 8689da9..bde34e3 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -17,7 +17,7 @@ publish_to: "none" # Remove this line if you wish to publish to pub.dev # In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion. # Read more about iOS versioning at # https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html -version: 1.0.4+2 +version: 1.0.5+3 environment: sdk: ">=2.17.0 <3.0.0"