From 17167d8e1bc61b686d5f4c56ea4822145e43c6fc Mon Sep 17 00:00:00 2001 From: Moaz El-sawaf Date: Thu, 20 Jul 2023 20:41:42 +0300 Subject: [PATCH 1/2] build: :wrench: upgrade `build.gradle` file upgrade `build.gradle` file to match the latest Flutter SDK version at the time of commit --- example/android/build.gradle | 4 +- example/pubspec.lock | 86 +++++++++++++++--------------------- 2 files changed, 37 insertions(+), 53 deletions(-) diff --git a/example/android/build.gradle b/example/android/build.gradle index 82083a81..3c18002c 100644 --- a/example/android/build.gradle +++ b/example/android/build.gradle @@ -24,11 +24,11 @@ subprojects { project.evaluationDependsOn(':app') } -task clean(type: Delete) { +tasks.register("clean", Delete) { delete rootProject.buildDir } configurations.all { resolutionStrategy { force 'androidx.core:core-ktx:1.6.0' } -} \ No newline at end of file +} diff --git a/example/pubspec.lock b/example/pubspec.lock index a1942a8f..a7b3462f 100644 --- a/example/pubspec.lock +++ b/example/pubspec.lock @@ -5,10 +5,10 @@ packages: dependency: transitive description: name: async - sha256: bfe67ef28df125b7dddcea62755991f807aa39a2492a23e1550161692950bbe0 + sha256: "947bfcf187f74dbc5e146c9eb9c0f10c9f8b30743e341481c1e2ed3ecc18c20c" url: "https://pub.dev" source: hosted - version: "2.10.0" + version: "2.11.0" boolean_selector: dependency: transitive description: @@ -21,10 +21,10 @@ packages: dependency: transitive description: name: characters - sha256: e6a326c8af69605aec75ed6c187d06b349707a27fbff8222ca9cc2cff167975c + sha256: "04a925763edad70e8443c99234dc3328f442e811f1d8fd1a72f1c8ad0f69a605" url: "https://pub.dev" source: hosted - version: "1.2.1" + version: "1.3.0" clock: dependency: transitive description: @@ -37,10 +37,10 @@ packages: dependency: transitive description: name: collection - sha256: cfc915e6923fe5ce6e153b0723c753045de46de1b4d63771530504004a45fae0 + sha256: "4a07be6cb69c84d677a6c3096fcf960cc3285a8330b4603e0d463d15d9bd934c" url: "https://pub.dev" source: hosted - version: "1.17.0" + version: "1.17.1" cupertino_icons: dependency: "direct main" description: @@ -61,18 +61,10 @@ packages: dependency: transitive description: name: ffi - sha256: a38574032c5f1dd06c4aee541789906c12ccaab8ba01446e800d9c5b79c4a978 + sha256: ed5337a5660c506388a9f012be0288fb38b49020ce2b45fe1f8b8323fe429f99 url: "https://pub.dev" source: hosted - version: "2.0.1" - file: - dependency: transitive - description: - name: file - sha256: "1b92bec4fc2a72f59a8e15af5f52cd441e4a7860b49499d69dfa817af20e925d" - url: "https://pub.dev" - source: hosted - version: "6.1.4" + version: "2.0.2" flutter: dependency: "direct main" description: flutter @@ -84,7 +76,7 @@ packages: path: ".." relative: true source: path - version: "1.3.0" + version: "1.3.1" flutter_test: dependency: "direct dev" description: flutter @@ -94,18 +86,18 @@ packages: dependency: transitive description: name: js - sha256: "5528c2f391ededb7775ec1daa69e65a2d61276f7552de2b5f7b8d34ee9fd4ab7" + sha256: f2c445dce49627136094980615a031419f7f3eb393237e4ecd97ac15dea343f3 url: "https://pub.dev" source: hosted - version: "0.6.5" + version: "0.6.7" matcher: dependency: transitive description: name: matcher - sha256: "16db949ceee371e9b99d22f88fa3a73c4e59fd0afed0bd25fc336eb76c198b72" + sha256: "6501fbd55da300384b768785b83e5ce66991266cec21af89ab9ae7f5ce1c4cbb" url: "https://pub.dev" source: hosted - version: "0.12.13" + version: "0.12.15" material_color_utilities: dependency: transitive description: @@ -118,50 +110,50 @@ packages: dependency: transitive description: name: meta - sha256: "6c268b42ed578a53088d834796959e4a1814b5e9e164f147f580a386e5decf42" + sha256: "3c74dbf8763d36539f114c799d8a2d87343b5067e9d796ca22b5eb8437090ee3" url: "https://pub.dev" source: hosted - version: "1.8.0" + version: "1.9.1" path: dependency: transitive description: name: path - sha256: db9d4f58c908a4ba5953fcee2ae317c94889433e5024c27ce74a37f94267945b + sha256: "8829d8a55c13fc0e37127c29fedf290c102f4e40ae94ada574091fe0ff96c917" url: "https://pub.dev" source: hosted - version: "1.8.2" + version: "1.8.3" path_provider: dependency: "direct main" description: name: path_provider - sha256: "04890b994ee89bfa80bf3080bfec40d5a92c5c7a785ebb02c13084a099d2b6f9" + sha256: "3087813781ab814e4157b172f1a11c46be20179fcc9bea043e0fba36bc0acaa2" url: "https://pub.dev" source: hosted - version: "2.0.13" + version: "2.0.15" path_provider_android: dependency: transitive description: name: path_provider_android - sha256: "019f18c9c10ae370b08dce1f3e3b73bc9f58e7f087bb5e921f06529438ac0ae7" + sha256: "2cec049d282c7f13c594b4a73976b0b4f2d7a1838a6dd5aaf7bd9719196bee86" url: "https://pub.dev" source: hosted - version: "2.0.24" + version: "2.0.27" path_provider_foundation: dependency: transitive description: name: path_provider_foundation - sha256: "026b97a6c29da75181a37aae2eba9227f5fe13cb2838c6b975ce209328b8ab4e" + sha256: "916731ccbdce44d545414dd9961f26ba5fbaa74bcbb55237d8e65a623a8c7297" url: "https://pub.dev" source: hosted - version: "2.1.3" + version: "2.2.4" path_provider_linux: dependency: transitive description: name: path_provider_linux - sha256: "2ae08f2216225427e64ad224a24354221c2c7907e448e6e0e8b57b1eb9f10ad1" + sha256: ffbb8cc9ed2c9ec0e4b7a541e56fd79b138e8f47d2fb86815f15358a349b3b57 url: "https://pub.dev" source: hosted - version: "2.1.10" + version: "2.1.11" path_provider_platform_interface: dependency: transitive description: @@ -174,10 +166,10 @@ packages: dependency: transitive description: name: path_provider_windows - sha256: f53720498d5a543f9607db4b0e997c4b5438884de25b0f73098cc2671a51b130 + sha256: "1cb68ba4cd3a795033de62ba1b7b4564dace301f952de6bfb3cd91b202b6ee96" url: "https://pub.dev" source: hosted - version: "2.1.5" + version: "2.1.7" platform: dependency: transitive description: @@ -194,14 +186,6 @@ packages: url: "https://pub.dev" source: hosted version: "2.1.4" - process: - dependency: transitive - description: - name: process - sha256: "53fd8db9cec1d37b0574e12f07520d582019cb6c44abf5479a01505099a34a09" - url: "https://pub.dev" - source: hosted - version: "4.2.4" sky_engine: dependency: transitive description: flutter @@ -251,10 +235,10 @@ packages: dependency: transitive description: name: test_api - sha256: ad540f65f92caa91bf21dfc8ffb8c589d6e4dc0c2267818b4cc2792857706206 + sha256: eb6ac1540b26de412b3403a163d919ba86f6a973fe6cc50ae3541b80092fdcfb url: "https://pub.dev" source: hosted - version: "0.4.16" + version: "0.5.1" vector_math: dependency: transitive description: @@ -267,18 +251,18 @@ packages: dependency: transitive description: name: win32 - sha256: c9ebe7ee4ab0c2194e65d3a07d8c54c5d00bb001b76081c4a04cdb8448b59e46 + sha256: dfdf0136e0aa7a1b474ea133e67cb0154a0acd2599c4f3ada3b49d38d38793ee url: "https://pub.dev" source: hosted - version: "3.1.3" + version: "5.0.5" xdg_directories: dependency: transitive description: name: xdg_directories - sha256: ee1505df1426458f7f60aac270645098d318a8b4766d85fde75f76f2e21807d1 + sha256: e0b1147eec179d3911f1f19b59206448f78195ca1d20514134e10641b7d7fbff url: "https://pub.dev" source: hosted - version: "1.0.0" + version: "1.0.1" sdks: - dart: ">=2.18.0 <4.0.0" - flutter: ">=3.0.0" + dart: ">=3.0.0 <4.0.0" + flutter: ">=3.3.0" From 4a6b8ad4103e0721cfd187e71ad030c75f291c9d Mon Sep 17 00:00:00 2001 From: Moaz El-sawaf Date: Thu, 20 Jul 2023 20:42:23 +0300 Subject: [PATCH 2/2] feat: :sparkles: add animation option to `setPage()` method for Android --- README.md | 2 +- .../endigo/plugins/pdfviewflutter/FlutterPDFView.java | 4 +++- example/lib/main.dart | 5 ++++- lib/flutter_pdfview.dart | 10 +++++++++- 4 files changed, 17 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index bb9e5905..810f6c3f 100644 --- a/README.md +++ b/README.md @@ -69,7 +69,7 @@ import 'package:flutter_pdfview/flutter_pdfview.dart'; | :------------- | :------------------: | :--------: | :------------: | | getPageCount | Get total page count | - | `Future` | | getCurrentPage | Get current page | - | `Future` | -| setPage | Go to/Set page | `int page` | `Future` | +| setPage | Go to/Set page | `int page`
`withAnimation` (**Optional**, only works for **Android**, defaults to `false`) | `Future` | ## Example diff --git a/android/src/main/java/io/endigo/plugins/pdfviewflutter/FlutterPDFView.java b/android/src/main/java/io/endigo/plugins/pdfviewflutter/FlutterPDFView.java index 7b91d027..f5158f52 100644 --- a/android/src/main/java/io/endigo/plugins/pdfviewflutter/FlutterPDFView.java +++ b/android/src/main/java/io/endigo/plugins/pdfviewflutter/FlutterPDFView.java @@ -133,7 +133,9 @@ void getCurrentPage(Result result) { void setPage(MethodCall call, Result result) { if (call.argument("page") != null) { int page = (int) call.argument("page"); - pdfView.jumpTo(page); + boolean withAnimation = call.argument("withAnimation"); + + pdfView.jumpTo(page, withAnimation); } result.success(true); diff --git a/example/lib/main.dart b/example/lib/main.dart index f593aa9a..6a8dfa64 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -253,7 +253,10 @@ class _PDFScreenState extends State with WidgetsBindingObserver { return FloatingActionButton.extended( label: Text("Go to ${pages! ~/ 2}"), onPressed: () async { - await snapshot.data!.setPage(pages! ~/ 2); + await snapshot.data!.setPage( + pages! ~/ 2, + withAnimation: true, + ); }, ); } diff --git a/lib/flutter_pdfview.dart b/lib/flutter_pdfview.dart index c18346c3..f1c200f5 100644 --- a/lib/flutter_pdfview.dart +++ b/lib/flutter_pdfview.dart @@ -350,10 +350,18 @@ class PDFViewController { return currentPage; } - Future setPage(int page) async { + /// Moves the PDF to the specified page number. + /// + /// [page] is the page number to move to. + /// + /// [withAnimation] is whether or not to animate the transition (only works on Android), defaults to `false`. + /// + /// Returns `true` if the page was set successfully, otherwise `false`. + Future setPage(int page, {bool withAnimation = false}) async { final bool? isSet = await _channel.invokeMethod('setPage', { 'page': page, + 'withAnimation': withAnimation, }); return isSet; }