From c4ac9c81914e7a9154db0dd6e977ca41b64d147b Mon Sep 17 00:00:00 2001 From: Hillel Coren Date: Mon, 18 Apr 2022 22:25:36 +0300 Subject: [PATCH] Update PDF lib --- lib/redux/credit/credit_actions.dart | 13 ++ lib/redux/invoice/invoice_actions.dart | 2 + lib/redux/quote/quote_actions.dart | 13 ++ lib/ui/client/client_pdf.dart | 5 +- lib/ui/invoice/edit/invoice_edit_desktop.dart | 4 +- lib/ui/invoice/invoice_pdf.dart | 4 +- pubspec.lock | 193 +++++++++++------- pubspec.yaml | 2 +- windows/CMakeLists.txt | 2 +- 9 files changed, 152 insertions(+), 86 deletions(-) diff --git a/lib/redux/credit/credit_actions.dart b/lib/redux/credit/credit_actions.dart index 9bc212217..b8db8990f 100644 --- a/lib/redux/credit/credit_actions.dart +++ b/lib/redux/credit/credit_actions.dart @@ -22,6 +22,10 @@ import 'package:invoiceninja_flutter/utils/completers.dart'; import 'package:invoiceninja_flutter/utils/dialogs.dart'; import 'package:invoiceninja_flutter/utils/localization.dart'; +import 'package:http/http.dart' as http; +import 'package:invoiceninja_flutter/data/web_client.dart'; +import 'package:printing/printing.dart'; + class ViewCreditList implements PersistUI { ViewCreditList({this.force = false}); @@ -627,6 +631,15 @@ Future handleCreditAction( } } break; + case EntityAction.printPdf: + final invitation = credit.invitations.first; + final url = invitation.downloadLink; + store.dispatch(StartLoading()); + final http.Response response = + await WebClient().get(url, '', rawResponse: true); + store.dispatch(StopLoading()); + await Printing.layoutPdf(onLayout: (_) => response.bodyBytes); + break; case EntityAction.more: showEntityActionsDialog( entities: [credit], diff --git a/lib/redux/invoice/invoice_actions.dart b/lib/redux/invoice/invoice_actions.dart index 2ac143acc..c8d85fe14 100644 --- a/lib/redux/invoice/invoice_actions.dart +++ b/lib/redux/invoice/invoice_actions.dart @@ -700,8 +700,10 @@ void handleInvoiceAction(BuildContext context, List invoices, case EntityAction.printPdf: final invitation = invoice.invitations.first; final url = invitation.downloadLink; + store.dispatch(StartLoading()); final http.Response response = await WebClient().get(url, '', rawResponse: true); + store.dispatch(StopLoading()); await Printing.layoutPdf(onLayout: (_) => response.bodyBytes); break; case EntityAction.more: diff --git a/lib/redux/quote/quote_actions.dart b/lib/redux/quote/quote_actions.dart index d7f64f874..7402f1c43 100644 --- a/lib/redux/quote/quote_actions.dart +++ b/lib/redux/quote/quote_actions.dart @@ -21,6 +21,10 @@ import 'package:invoiceninja_flutter/utils/completers.dart'; import 'package:invoiceninja_flutter/utils/dialogs.dart'; import 'package:invoiceninja_flutter/utils/localization.dart'; +import 'package:http/http.dart' as http; +import 'package:invoiceninja_flutter/data/web_client.dart'; +import 'package:printing/printing.dart'; + class ViewQuoteList implements PersistUI { ViewQuoteList({this.force = false}); @@ -644,6 +648,15 @@ Future handleQuoteAction( } } break; + case EntityAction.printPdf: + final invitation = quote.invitations.first; + final url = invitation.downloadLink; + store.dispatch(StartLoading()); + final http.Response response = + await WebClient().get(url, '', rawResponse: true); + store.dispatch(StopLoading()); + await Printing.layoutPdf(onLayout: (_) => response.bodyBytes); + break; case EntityAction.more: showEntityActionsDialog( entities: [quote], diff --git a/lib/ui/client/client_pdf.dart b/lib/ui/client/client_pdf.dart index 2d18e2a3d..c06ce9ecd 100644 --- a/lib/ui/client/client_pdf.dart +++ b/lib/ui/client/client_pdf.dart @@ -55,7 +55,6 @@ class ClientPdfView extends StatefulWidget { class _ClientPdfViewState extends State { bool _isLoading = false; http.Response _response; - int _pageNumber = 1, _pageCount = 1; static const STATUS_ALL = 'all'; static const STATUS_PAID = 'paid'; @@ -177,6 +176,7 @@ class _ClientPdfViewState extends State { final localization = AppLocalization.of(context); final client = widget.viewModel.client; + /* final pageSelector = _pageCount == 1 ? [] : [ @@ -195,6 +195,7 @@ class _ClientPdfViewState extends State { onPressed: _pageNumber < _pageCount ? () => null : null, ), ]; + */ bool showEmail = false; //isDesktop(context); @@ -335,7 +336,7 @@ class _ClientPdfViewState extends State { if (isDesktop(context)) ...[ showPayments, showAging, - ...pageSelector, + //...pageSelector, ] ], ), diff --git a/lib/ui/invoice/edit/invoice_edit_desktop.dart b/lib/ui/invoice/edit/invoice_edit_desktop.dart index 8429a5030..2a874a18d 100644 --- a/lib/ui/invoice/edit/invoice_edit_desktop.dart +++ b/lib/ui/invoice/edit/invoice_edit_desktop.dart @@ -931,8 +931,6 @@ class __PdfPreviewState extends State<_PdfPreview> { final _pdfDebouncer = Debouncer(milliseconds: kMillisecondsToDebounceSave); http.Response _response; - int _pageCount = 1; - int _currentPage = 1; bool _isLoading = false; @override @@ -1012,6 +1010,7 @@ class __PdfPreviewState extends State<_PdfPreview> { Column( crossAxisAlignment: CrossAxisAlignment.stretch, children: [ + /* if (_pageCount > 1) Padding( padding: const EdgeInsets.only(bottom: 16), @@ -1032,6 +1031,7 @@ class __PdfPreviewState extends State<_PdfPreview> { ], ), ), + */ Expanded( child: _response == null ? SizedBox() diff --git a/lib/ui/invoice/invoice_pdf.dart b/lib/ui/invoice/invoice_pdf.dart index e30b936ec..1a8c91bd5 100644 --- a/lib/ui/invoice/invoice_pdf.dart +++ b/lib/ui/invoice/invoice_pdf.dart @@ -97,6 +97,7 @@ class _InvoicePdfViewState extends State { final invoice = widget.viewModel.invoice; final client = state.clientState.get(invoice.clientId); + /* final pageSelector = _pageCount == 1 ? [] : [ @@ -115,6 +116,7 @@ class _InvoicePdfViewState extends State { onPressed: _pageNumber < _pageCount ? () => null : null, ), ]; + */ final activitySelector = _activityId == null || kIsWeb ? [] @@ -203,7 +205,7 @@ class _InvoicePdfViewState extends State { .title()), ), if (isDesktop(context)) ...activitySelector, - if (isDesktop(context)) ...pageSelector, + //if (isDesktop(context)) ...pageSelector, if (isDesktop(context) && invoice.isInvoice && _activityId == null) diff --git a/pubspec.lock b/pubspec.lock index 1e6b92519..a6e6d4523 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -7,14 +7,14 @@ packages: name: _fe_analyzer_shared url: "https://pub.dartlang.org" source: hosted - version: "30.0.0" + version: "31.0.0" analyzer: dependency: transitive description: name: analyzer url: "https://pub.dartlang.org" source: hosted - version: "2.7.0" + version: "2.8.0" ansicolor: dependency: transitive description: @@ -70,7 +70,7 @@ packages: name: build url: "https://pub.dartlang.org" source: hosted - version: "2.1.1" + version: "2.3.0" build_config: dependency: transitive description: @@ -84,28 +84,28 @@ packages: name: build_daemon url: "https://pub.dartlang.org" source: hosted - version: "3.0.1" + version: "3.1.0" build_resolvers: dependency: transitive description: name: build_resolvers url: "https://pub.dartlang.org" source: hosted - version: "2.0.4" + version: "2.0.6" build_runner: dependency: "direct dev" description: name: build_runner url: "https://pub.dartlang.org" source: hosted - version: "2.1.5" + version: "2.1.10" build_runner_core: dependency: transitive description: name: build_runner_core url: "https://pub.dartlang.org" source: hosted - version: "7.2.2" + version: "7.2.3" built_collection: dependency: "direct main" description: @@ -119,14 +119,14 @@ packages: name: built_value url: "https://pub.dartlang.org" source: hosted - version: "8.1.3" + version: "8.1.4" built_value_generator: dependency: "direct dev" description: name: built_value_generator url: "https://pub.dartlang.org" source: hosted - version: "8.1.3" + version: "8.2.0" cached_network_image: dependency: "direct main" description: @@ -245,7 +245,7 @@ packages: name: dart_style url: "https://pub.dartlang.org" source: hosted - version: "2.2.0" + version: "2.2.1" diacritic: dependency: "direct main" description: @@ -287,7 +287,7 @@ packages: name: file_picker url: "https://pub.dartlang.org" source: hosted - version: "4.2.3" + version: "4.5.1" fixnum: dependency: transitive description: @@ -306,14 +306,14 @@ packages: name: flutter_blurhash url: "https://pub.dartlang.org" source: hosted - version: "0.6.0" + version: "0.6.6" flutter_cache_manager: dependency: transitive description: name: flutter_cache_manager url: "https://pub.dartlang.org" source: hosted - version: "3.1.3" + version: "3.3.0" flutter_colorpicker: dependency: "direct main" description: @@ -358,7 +358,7 @@ packages: name: flutter_plugin_android_lifecycle url: "https://pub.dartlang.org" source: hosted - version: "2.0.4" + version: "2.0.5" flutter_redux: dependency: "direct main" description: @@ -372,7 +372,7 @@ packages: name: flutter_slidable url: "https://pub.dartlang.org" source: hosted - version: "1.1.0" + version: "1.2.0" flutter_styled_toast: dependency: "direct main" description: @@ -415,21 +415,35 @@ packages: name: google_sign_in url: "https://pub.dartlang.org" source: hosted - version: "5.2.1" + version: "5.3.0" + google_sign_in_android: + dependency: transitive + description: + name: google_sign_in_android + url: "https://pub.dartlang.org" + source: hosted + version: "5.2.5" + google_sign_in_ios: + dependency: transitive + description: + name: google_sign_in_ios + url: "https://pub.dartlang.org" + source: hosted + version: "5.2.5" google_sign_in_platform_interface: dependency: transitive description: name: google_sign_in_platform_interface url: "https://pub.dartlang.org" source: hosted - version: "2.1.0" + version: "2.1.2" google_sign_in_web: dependency: transitive description: name: google_sign_in_web url: "https://pub.dartlang.org" source: hosted - version: "0.10.0+3" + version: "0.10.1" graphs: dependency: transitive description: @@ -464,7 +478,7 @@ packages: name: http_multi_server url: "https://pub.dartlang.org" source: hosted - version: "3.0.1" + version: "3.2.0" http_parser: dependency: transitive description: @@ -478,28 +492,42 @@ packages: name: image url: "https://pub.dartlang.org" source: hosted - version: "3.0.8" + version: "3.1.3" image_picker: dependency: "direct main" description: name: image_picker url: "https://pub.dartlang.org" source: hosted - version: "0.8.4+4" + version: "0.8.5" + image_picker_android: + dependency: transitive + description: + name: image_picker_android + url: "https://pub.dartlang.org" + source: hosted + version: "0.8.4+11" image_picker_for_web: dependency: transitive description: name: image_picker_for_web url: "https://pub.dartlang.org" source: hosted - version: "2.1.4" + version: "2.1.6" + image_picker_ios: + dependency: transitive + description: + name: image_picker_ios + url: "https://pub.dartlang.org" + source: hosted + version: "0.8.4+11" image_picker_platform_interface: dependency: transitive description: name: image_picker_platform_interface url: "https://pub.dartlang.org" source: hosted - version: "2.4.1" + version: "2.4.4" import_sorter: dependency: "direct dev" description: @@ -507,13 +535,6 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "4.6.0" - injector: - dependency: transitive - description: - name: injector - url: "https://pub.dartlang.org" - source: hosted - version: "2.0.0" intl: dependency: "direct main" description: @@ -541,7 +562,7 @@ packages: name: json_annotation url: "https://pub.dartlang.org" source: hosted - version: "4.3.0" + version: "4.4.0" linkify: dependency: transitive description: @@ -562,7 +583,7 @@ packages: name: local_auth url: "https://pub.dartlang.org" source: hosted - version: "1.1.8" + version: "1.1.11" logging: dependency: transitive description: @@ -576,7 +597,7 @@ packages: name: markdown url: "https://pub.dartlang.org" source: hosted - version: "4.0.0" + version: "4.0.1" matcher: dependency: transitive description: @@ -597,7 +618,7 @@ packages: name: material_design_icons_flutter url: "https://pub.dartlang.org" source: hosted - version: "5.0.6295" + version: "5.0.6595" memoize: dependency: "direct main" description: @@ -625,7 +646,7 @@ packages: name: msix url: "https://pub.dartlang.org" source: hosted - version: "2.6.2" + version: "2.8.18" node_preamble: dependency: transitive description: @@ -639,7 +660,7 @@ packages: name: octo_image url: "https://pub.dartlang.org" source: hosted - version: "1.0.0+1" + version: "1.0.1" overflow_view: dependency: "direct main" description: @@ -667,14 +688,14 @@ packages: name: package_info_plus url: "https://pub.dartlang.org" source: hosted - version: "1.3.0" + version: "1.4.2" package_info_plus_linux: dependency: transitive description: name: package_info_plus_linux url: "https://pub.dartlang.org" source: hosted - version: "1.0.3" + version: "1.0.5" package_info_plus_macos: dependency: transitive description: @@ -695,14 +716,14 @@ packages: name: package_info_plus_web url: "https://pub.dartlang.org" source: hosted - version: "1.0.4" + version: "1.0.5" package_info_plus_windows: dependency: transitive description: name: package_info_plus_windows url: "https://pub.dartlang.org" source: hosted - version: "1.0.4" + version: "1.0.5" path: dependency: transitive description: @@ -723,49 +744,49 @@ packages: name: path_provider url: "https://pub.dartlang.org" source: hosted - version: "2.0.7" + version: "2.0.9" path_provider_android: dependency: transitive description: name: path_provider_android url: "https://pub.dartlang.org" source: hosted - version: "2.0.7" + version: "2.0.12" path_provider_ios: dependency: transitive description: name: path_provider_ios url: "https://pub.dartlang.org" source: hosted - version: "2.0.7" + version: "2.0.8" path_provider_linux: dependency: transitive description: name: path_provider_linux url: "https://pub.dartlang.org" source: hosted - version: "2.1.2" + version: "2.1.5" path_provider_macos: dependency: transitive description: name: path_provider_macos url: "https://pub.dartlang.org" source: hosted - version: "2.0.3" + version: "2.0.5" path_provider_platform_interface: dependency: transitive description: name: path_provider_platform_interface url: "https://pub.dartlang.org" source: hosted - version: "2.0.1" + version: "2.0.3" path_provider_windows: dependency: transitive description: name: path_provider_windows url: "https://pub.dartlang.org" source: hosted - version: "2.0.4" + version: "2.0.5" pdf: dependency: transitive description: @@ -823,14 +844,14 @@ packages: name: plugin_platform_interface url: "https://pub.dartlang.org" source: hosted - version: "2.0.2" + version: "2.1.2" pointer_interceptor: dependency: "direct main" description: name: pointer_interceptor url: "https://pub.dartlang.org" source: hosted - version: "0.9.0+1" + version: "0.9.3" pool: dependency: transitive description: @@ -858,14 +879,14 @@ packages: name: pub_semver url: "https://pub.dartlang.org" source: hosted - version: "2.1.0" + version: "2.1.1" pubspec_parse: dependency: transitive description: name: pubspec_parse url: "https://pub.dartlang.org" source: hosted - version: "1.1.0" + version: "1.2.0" qr: dependency: transitive description: @@ -900,28 +921,28 @@ packages: name: rounded_loading_button url: "https://pub.dartlang.org" source: hosted - version: "2.0.9" + version: "2.1.0" rxdart: dependency: transitive description: name: rxdart url: "https://pub.dartlang.org" source: hosted - version: "0.27.2" + version: "0.27.3" sentry: dependency: transitive description: name: sentry url: "https://pub.dartlang.org" source: hosted - version: "6.1.2" + version: "6.4.0" sentry_flutter: dependency: "direct main" description: name: sentry_flutter url: "https://pub.dartlang.org" source: hosted - version: "6.1.2" + version: "6.4.0" share: dependency: "direct main" description: @@ -935,21 +956,35 @@ packages: name: shared_preferences url: "https://pub.dartlang.org" source: hosted - version: "2.0.8" + version: "2.0.13" + shared_preferences_android: + dependency: transitive + description: + name: shared_preferences_android + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.11" + shared_preferences_ios: + dependency: transitive + description: + name: shared_preferences_ios + url: "https://pub.dartlang.org" + source: hosted + version: "2.1.0" shared_preferences_linux: dependency: transitive description: name: shared_preferences_linux url: "https://pub.dartlang.org" source: hosted - version: "2.0.3" + version: "2.1.0" shared_preferences_macos: dependency: transitive description: name: shared_preferences_macos url: "https://pub.dartlang.org" source: hosted - version: "2.0.2" + version: "2.0.3" shared_preferences_platform_interface: dependency: transitive description: @@ -963,21 +998,21 @@ packages: name: shared_preferences_web url: "https://pub.dartlang.org" source: hosted - version: "2.0.2" + version: "2.0.3" shared_preferences_windows: dependency: transitive description: name: shared_preferences_windows url: "https://pub.dartlang.org" source: hosted - version: "2.0.3" + version: "2.1.0" shelf: dependency: transitive description: name: shelf url: "https://pub.dartlang.org" source: hosted - version: "1.2.0" + version: "1.3.0" shelf_packages_handler: dependency: transitive description: @@ -1010,7 +1045,7 @@ packages: name: source_gen url: "https://pub.dartlang.org" source: hosted - version: "1.1.1" + version: "1.2.2" source_map_stack_trace: dependency: transitive description: @@ -1038,14 +1073,14 @@ packages: name: sqflite url: "https://pub.dartlang.org" source: hosted - version: "2.0.0+4" + version: "2.0.2+1" sqflite_common: dependency: transitive description: name: sqflite_common url: "https://pub.dartlang.org" source: hosted - version: "2.0.1+1" + version: "2.2.1+1" stack_trace: dependency: transitive description: @@ -1101,7 +1136,7 @@ packages: name: synchronized url: "https://pub.dartlang.org" source: hosted - version: "3.0.0" + version: "3.0.0+2" term_glyph: dependency: transitive description: @@ -1136,7 +1171,7 @@ packages: name: timeago url: "https://pub.dartlang.org" source: hosted - version: "3.1.0" + version: "3.2.2" timing: dependency: transitive description: @@ -1185,42 +1220,42 @@ packages: name: url_launcher_linux url: "https://pub.dartlang.org" source: hosted - version: "2.0.2" + version: "3.0.0" url_launcher_macos: dependency: transitive description: name: url_launcher_macos url: "https://pub.dartlang.org" source: hosted - version: "2.0.2" + version: "3.0.0" url_launcher_platform_interface: dependency: transitive description: name: url_launcher_platform_interface url: "https://pub.dartlang.org" source: hosted - version: "2.0.4" + version: "2.0.5" url_launcher_web: dependency: transitive description: name: url_launcher_web url: "https://pub.dartlang.org" source: hosted - version: "2.0.4" + version: "2.0.9" url_launcher_windows: dependency: transitive description: name: url_launcher_windows url: "https://pub.dartlang.org" source: hosted - version: "2.0.2" + version: "3.0.0" uuid: dependency: transitive description: name: uuid url: "https://pub.dartlang.org" source: hosted - version: "3.0.5" + version: "3.0.6" value_layout_builder: dependency: transitive description: @@ -1283,42 +1318,42 @@ packages: name: webview_flutter url: "https://pub.dartlang.org" source: hosted - version: "2.3.1" + version: "2.8.0" webview_flutter_android: dependency: transitive description: name: webview_flutter_android url: "https://pub.dartlang.org" source: hosted - version: "2.2.1" + version: "2.8.5" webview_flutter_platform_interface: dependency: transitive description: name: webview_flutter_platform_interface url: "https://pub.dartlang.org" source: hosted - version: "1.4.0" + version: "1.8.1" webview_flutter_wkwebview: dependency: transitive description: name: webview_flutter_wkwebview url: "https://pub.dartlang.org" source: hosted - version: "2.4.0" + version: "2.7.2" win32: dependency: transitive description: name: win32 url: "https://pub.dartlang.org" source: hosted - version: "2.3.0" + version: "2.5.1" xdg_directories: dependency: transitive description: name: xdg_directories url: "https://pub.dartlang.org" source: hosted - version: "0.2.0" + version: "0.2.0+1" xml: dependency: transitive description: @@ -1335,4 +1370,4 @@ packages: version: "3.1.0" sdks: dart: ">=2.16.0 <3.0.0" - flutter: ">=2.8.0" + flutter: ">=2.10.0" diff --git a/pubspec.yaml b/pubspec.yaml index 5308fa3c2..81e3c9ed5 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -59,8 +59,8 @@ dependencies: states_rebuilder: ^5.2.0 super_editor: ^0.2.0 html2md: ^1.2.5 - # bitsdojo_window: ^0.1.1+1 printing: ^5.8.0 + # bitsdojo_window: ^0.1.1+1 # quick_actions: ^0.2.1 # idb_shim: ^1.11.1+1 diff --git a/windows/CMakeLists.txt b/windows/CMakeLists.txt index c1fbc08d3..cfc358cb1 100644 --- a/windows/CMakeLists.txt +++ b/windows/CMakeLists.txt @@ -7,7 +7,7 @@ cmake_policy(SET CMP0063 NEW) set(CMAKE_INSTALL_RPATH "$ORIGIN/lib") -set(PDFIUM_VERSION "4929" CACHE STRING "" FORCE) +set(PDFIUM_VERSION "latest" CACHE STRING "" FORCE) set(PDFIUM_ARCH "x64" CACHE STRING "" FORCE) # Configure build options.