@amafil/react-native-pdf-toolkit 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/DoubleTapView.js +125 -0
- package/LICENSE +21 -0
- package/PdfManager.js +26 -0
- package/PdfPageView.js +53 -0
- package/PdfView.js +421 -0
- package/PdfViewFlatList.js +30 -0
- package/PinchZoomView.js +125 -0
- package/README.md +450 -0
- package/android/.gradle/8.5/checksums/checksums.lock +0 -0
- package/android/.gradle/8.5/checksums/md5-checksums.bin +0 -0
- package/android/.gradle/8.5/checksums/sha1-checksums.bin +0 -0
- package/android/.gradle/8.5/dependencies-accessors/dependencies-accessors.lock +0 -0
- package/android/.gradle/8.5/dependencies-accessors/gc.properties +0 -0
- package/android/.gradle/8.5/executionHistory/executionHistory.bin +0 -0
- package/android/.gradle/8.5/executionHistory/executionHistory.lock +0 -0
- package/android/.gradle/8.5/fileChanges/last-build.bin +0 -0
- package/android/.gradle/8.5/fileHashes/fileHashes.bin +0 -0
- package/android/.gradle/8.5/fileHashes/fileHashes.lock +0 -0
- package/android/.gradle/8.5/fileHashes/resourceHashesCache.bin +0 -0
- package/android/.gradle/8.5/gc.properties +0 -0
- package/android/.gradle/buildOutputCleanup/buildOutputCleanup.lock +0 -0
- package/android/.gradle/buildOutputCleanup/cache.properties +2 -0
- package/android/.gradle/buildOutputCleanup/outputFiles.bin +0 -0
- package/android/.gradle/config.properties +2 -0
- package/android/.gradle/file-system.probe +0 -0
- package/android/.gradle/vcs-1/gc.properties +0 -0
- package/android/.idea/AndroidProjectSystem.xml +6 -0
- package/android/.idea/caches/deviceStreaming.xml +1414 -0
- package/android/.idea/compiler.xml +6 -0
- package/android/.idea/deviceManager.xml +13 -0
- package/android/.idea/gradle.xml +17 -0
- package/android/.idea/migrations.xml +10 -0
- package/android/.idea/misc.xml +10 -0
- package/android/.idea/runConfigurations.xml +17 -0
- package/android/.idea/vcs.xml +6 -0
- package/android/build/.transforms/3337b950908a4f6985ba400cb8386b0b/results.bin +1 -0
- package/android/build/.transforms/3337b950908a4f6985ba400cb8386b0b/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/com/facebook/react/viewmanagers/RNPDFPdfViewManagerDelegate.dex +0 -0
- package/android/build/.transforms/3337b950908a4f6985ba400cb8386b0b/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/com/facebook/react/viewmanagers/RNPDFPdfViewManagerInterface.dex +0 -0
- package/android/build/.transforms/3337b950908a4f6985ba400cb8386b0b/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/org/wonday/pdf/BuildConfig.dex +0 -0
- package/android/build/.transforms/3337b950908a4f6985ba400cb8386b0b/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/org/wonday/pdf/PdfManager.dex +0 -0
- package/android/build/.transforms/3337b950908a4f6985ba400cb8386b0b/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/org/wonday/pdf/PdfView$1.dex +0 -0
- package/android/build/.transforms/3337b950908a4f6985ba400cb8386b0b/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/org/wonday/pdf/PdfView$2.dex +0 -0
- package/android/build/.transforms/3337b950908a4f6985ba400cb8386b0b/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/org/wonday/pdf/PdfView$3.dex +0 -0
- package/android/build/.transforms/3337b950908a4f6985ba400cb8386b0b/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/org/wonday/pdf/PdfView.dex +0 -0
- package/android/build/.transforms/3337b950908a4f6985ba400cb8386b0b/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/org/wonday/pdf/RNPDFPackage.dex +0 -0
- package/android/build/.transforms/3337b950908a4f6985ba400cb8386b0b/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/org/wonday/pdf/events/TopChangeEvent.dex +0 -0
- package/android/build/.transforms/3337b950908a4f6985ba400cb8386b0b/transformed/bundleLibRuntimeToDirDebug/desugar_graph.bin +0 -0
- package/android/build/.transforms/787b9137f14dcc9eebbb21ac62a7be22/results.bin +1 -0
- package/android/build/.transforms/787b9137f14dcc9eebbb21ac62a7be22/transformed/classes/classes_dex/classes.dex +0 -0
- package/android/build/.transforms/79ca1220a602ed0c9c23366e0e92a6d1/results.bin +1 -0
- package/android/build/.transforms/79ca1220a602ed0c9c23366e0e92a6d1/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/com/facebook/react/viewmanagers/RNPDFPdfViewManagerDelegate.dex +0 -0
- package/android/build/.transforms/79ca1220a602ed0c9c23366e0e92a6d1/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/com/facebook/react/viewmanagers/RNPDFPdfViewManagerInterface.dex +0 -0
- package/android/build/.transforms/79ca1220a602ed0c9c23366e0e92a6d1/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/org/wonday/pdf/BuildConfig.dex +0 -0
- package/android/build/.transforms/79ca1220a602ed0c9c23366e0e92a6d1/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/org/wonday/pdf/PdfManager.dex +0 -0
- package/android/build/.transforms/79ca1220a602ed0c9c23366e0e92a6d1/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/org/wonday/pdf/PdfView$1.dex +0 -0
- package/android/build/.transforms/79ca1220a602ed0c9c23366e0e92a6d1/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/org/wonday/pdf/PdfView$2.dex +0 -0
- package/android/build/.transforms/79ca1220a602ed0c9c23366e0e92a6d1/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/org/wonday/pdf/PdfView$3.dex +0 -0
- package/android/build/.transforms/79ca1220a602ed0c9c23366e0e92a6d1/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/org/wonday/pdf/PdfView.dex +0 -0
- package/android/build/.transforms/79ca1220a602ed0c9c23366e0e92a6d1/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/org/wonday/pdf/RNPDFPackage.dex +0 -0
- package/android/build/.transforms/79ca1220a602ed0c9c23366e0e92a6d1/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/org/wonday/pdf/events/TopChangeEvent.dex +0 -0
- package/android/build/.transforms/79ca1220a602ed0c9c23366e0e92a6d1/transformed/bundleLibRuntimeToDirDebug/desugar_graph.bin +0 -0
- package/android/build/.transforms/c29f40a753b0ae1d85db8c8c5812fc85/results.bin +1 -0
- package/android/build/.transforms/c29f40a753b0ae1d85db8c8c5812fc85/transformed/classes/classes_dex/classes.dex +0 -0
- package/android/build/generated/source/buildConfig/debug/org/wonday/pdf/BuildConfig.java +12 -0
- package/android/build/generated/source/codegen/java/com/facebook/react/viewmanagers/RNPDFPdfViewManagerDelegate.java +99 -0
- package/android/build/generated/source/codegen/java/com/facebook/react/viewmanagers/RNPDFPdfViewManagerInterface.java +38 -0
- package/android/build/generated/source/codegen/jni/CMakeLists.txt +28 -0
- package/android/build/generated/source/codegen/jni/react/renderer/components/rnpdf/ComponentDescriptors.cpp +22 -0
- package/android/build/generated/source/codegen/jni/react/renderer/components/rnpdf/ComponentDescriptors.h +24 -0
- package/android/build/generated/source/codegen/jni/react/renderer/components/rnpdf/EventEmitters.cpp +24 -0
- package/android/build/generated/source/codegen/jni/react/renderer/components/rnpdf/EventEmitters.h +25 -0
- package/android/build/generated/source/codegen/jni/react/renderer/components/rnpdf/Props.cpp +132 -0
- package/android/build/generated/source/codegen/jni/react/renderer/components/rnpdf/Props.h +50 -0
- package/android/build/generated/source/codegen/jni/react/renderer/components/rnpdf/ShadowNodes.cpp +17 -0
- package/android/build/generated/source/codegen/jni/react/renderer/components/rnpdf/ShadowNodes.h +32 -0
- package/android/build/generated/source/codegen/jni/react/renderer/components/rnpdf/States.cpp +16 -0
- package/android/build/generated/source/codegen/jni/react/renderer/components/rnpdf/States.h +20 -0
- package/android/build/generated/source/codegen/jni/react/renderer/components/rnpdf/rnpdfJSI-generated.cpp +17 -0
- package/android/build/generated/source/codegen/jni/react/renderer/components/rnpdf/rnpdfJSI.h +19 -0
- package/android/build/generated/source/codegen/jni/rnpdf-generated.cpp +22 -0
- package/android/build/generated/source/codegen/jni/rnpdf.h +24 -0
- package/android/build/generated/source/codegen/schema.json +1 -0
- package/android/build/intermediates/aapt_friendly_merged_manifests/debug/aapt/AndroidManifest.xml +7 -0
- package/android/build/intermediates/aapt_friendly_merged_manifests/debug/aapt/output-metadata.json +18 -0
- package/android/build/intermediates/aapt_friendly_merged_manifests/debug/processDebugManifest/aapt/AndroidManifest.xml +7 -0
- package/android/build/intermediates/aapt_friendly_merged_manifests/debug/processDebugManifest/aapt/output-metadata.json +18 -0
- package/android/build/intermediates/aar_main_jar/debug/syncDebugLibJars/classes.jar +0 -0
- package/android/build/intermediates/aar_metadata/debug/aar-metadata.properties +5 -0
- package/android/build/intermediates/aar_metadata/debug/writeDebugAarMetadata/aar-metadata.properties +6 -0
- package/android/build/intermediates/annotation_processor_list/debug/annotationProcessors.json +1 -0
- package/android/build/intermediates/annotation_processor_list/debug/javaPreCompileDebug/annotationProcessors.json +1 -0
- package/android/build/intermediates/annotation_processor_list/debugAndroidTest/annotationProcessors.json +1 -0
- package/android/build/intermediates/annotation_processor_list/debugUnitTest/annotationProcessors.json +1 -0
- package/android/build/intermediates/annotations_typedef_file/debug/extractDebugAnnotations/typedefs.txt +0 -0
- package/android/build/intermediates/compile_library_classes_jar/debug/bundleLibCompileToJarDebug/classes.jar +0 -0
- package/android/build/intermediates/compile_r_class_jar/debug/generateDebugRFile/R.jar +0 -0
- package/android/build/intermediates/compile_symbol_list/debug/generateDebugRFile/R.txt +0 -0
- package/android/build/intermediates/incremental/debug/packageDebugResources/compile-file-map.properties +1 -0
- package/android/build/intermediates/incremental/debug/packageDebugResources/merger.xml +2 -0
- package/android/build/intermediates/incremental/debug-mergeJavaRes/merge-state +0 -0
- package/android/build/intermediates/incremental/mergeDebugAssets/merger.xml +2 -0
- package/android/build/intermediates/incremental/mergeDebugJniLibFolders/merger.xml +2 -0
- package/android/build/intermediates/incremental/mergeDebugShaders/merger.xml +2 -0
- package/android/build/intermediates/javac/debug/compileDebugJavaWithJavac/classes/com/facebook/react/viewmanagers/RNPDFPdfViewManagerDelegate.class +0 -0
- package/android/build/intermediates/javac/debug/compileDebugJavaWithJavac/classes/com/facebook/react/viewmanagers/RNPDFPdfViewManagerInterface.class +0 -0
- package/android/build/intermediates/javac/debug/compileDebugJavaWithJavac/classes/org/wonday/pdf/BuildConfig.class +0 -0
- package/android/build/intermediates/javac/debug/compileDebugJavaWithJavac/classes/org/wonday/pdf/PdfManager.class +0 -0
- package/android/build/intermediates/javac/debug/compileDebugJavaWithJavac/classes/org/wonday/pdf/PdfView$1.class +0 -0
- package/android/build/intermediates/javac/debug/compileDebugJavaWithJavac/classes/org/wonday/pdf/PdfView$2.class +0 -0
- package/android/build/intermediates/javac/debug/compileDebugJavaWithJavac/classes/org/wonday/pdf/PdfView$3.class +0 -0
- package/android/build/intermediates/javac/debug/compileDebugJavaWithJavac/classes/org/wonday/pdf/PdfView.class +0 -0
- package/android/build/intermediates/javac/debug/compileDebugJavaWithJavac/classes/org/wonday/pdf/RNPDFPackage.class +0 -0
- package/android/build/intermediates/javac/debug/compileDebugJavaWithJavac/classes/org/wonday/pdf/events/TopChangeEvent.class +0 -0
- package/android/build/intermediates/local_only_symbol_list/debug/R-def.txt +2 -0
- package/android/build/intermediates/local_only_symbol_list/debug/parseDebugLocalResources/R-def.txt +2 -0
- package/android/build/intermediates/manifest_merge_blame_file/debug/manifest-merger-blame-debug-report.txt +8 -0
- package/android/build/intermediates/manifest_merge_blame_file/debug/processDebugManifest/manifest-merger-blame-debug-report.txt +7 -0
- package/android/build/intermediates/merged_java_res/debug/mergeDebugJavaResource/feature-react-native-pdf.jar +0 -0
- package/android/build/intermediates/merged_manifest/debug/AndroidManifest.xml +7 -0
- package/android/build/intermediates/merged_manifest/debug/processDebugManifest/AndroidManifest.xml +7 -0
- package/android/build/intermediates/navigation_json/debug/extractDeepLinksDebug/navigation.json +1 -0
- package/android/build/intermediates/navigation_json/debug/navigation.json +1 -0
- package/android/build/intermediates/nested_resources_validation_report/debug/generateDebugResources/nestedResourcesValidationReport.txt +1 -0
- package/android/build/intermediates/packaged_manifests/debug/output-metadata.json +18 -0
- package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/com/facebook/react/viewmanagers/RNPDFPdfViewManagerDelegate.class +0 -0
- package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/com/facebook/react/viewmanagers/RNPDFPdfViewManagerInterface.class +0 -0
- package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/org/wonday/pdf/BuildConfig.class +0 -0
- package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/org/wonday/pdf/PdfManager.class +0 -0
- package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/org/wonday/pdf/PdfView$1.class +0 -0
- package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/org/wonday/pdf/PdfView$2.class +0 -0
- package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/org/wonday/pdf/PdfView$3.class +0 -0
- package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/org/wonday/pdf/PdfView.class +0 -0
- package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/org/wonday/pdf/RNPDFPackage.class +0 -0
- package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/org/wonday/pdf/events/TopChangeEvent.class +0 -0
- package/android/build/intermediates/runtime_library_classes_jar/debug/bundleLibRuntimeToJarDebug/classes.jar +0 -0
- package/android/build/intermediates/symbol_list_with_package_name/debug/generateDebugRFile/package-aware-r.txt +1 -0
- package/android/build/outputs/aar/react-native-pdf-debug.aar +0 -0
- package/android/build/outputs/logs/manifest-merger-debug-report.txt +16 -0
- package/android/build/tmp/compileDebugJavaWithJavac/compileTransaction/stash-dir/PdfManager.class.uniqueId3 +0 -0
- package/android/build/tmp/compileDebugJavaWithJavac/compileTransaction/stash-dir/PdfManager.class.uniqueId4 +0 -0
- package/android/build/tmp/compileDebugJavaWithJavac/compileTransaction/stash-dir/PdfView$1.class.uniqueId0 +0 -0
- package/android/build/tmp/compileDebugJavaWithJavac/compileTransaction/stash-dir/PdfView$2.class.uniqueId5 +0 -0
- package/android/build/tmp/compileDebugJavaWithJavac/compileTransaction/stash-dir/PdfView$2.class.uniqueId6 +0 -0
- package/android/build/tmp/compileDebugJavaWithJavac/compileTransaction/stash-dir/PdfView$3.class.uniqueId4 +0 -0
- package/android/build/tmp/compileDebugJavaWithJavac/compileTransaction/stash-dir/PdfView$3.class.uniqueId5 +0 -0
- package/android/build/tmp/compileDebugJavaWithJavac/compileTransaction/stash-dir/PdfView.class.uniqueId2 +0 -0
- package/android/build/tmp/compileDebugJavaWithJavac/compileTransaction/stash-dir/PdfView.class.uniqueId3 +0 -0
- package/android/build/tmp/compileDebugJavaWithJavac/compileTransaction/stash-dir/RNPDFPackage.class.uniqueId1 +0 -0
- package/android/build/tmp/compileDebugJavaWithJavac/compileTransaction/stash-dir/RNPDFPackage.class.uniqueId2 +0 -0
- package/android/build/tmp/compileDebugJavaWithJavac/compileTransaction/stash-dir/RNPDFPdfViewManagerDelegate.class.uniqueId7 +0 -0
- package/android/build/tmp/compileDebugJavaWithJavac/compileTransaction/stash-dir/RNPDFPdfViewManagerInterface.class.uniqueId1 +0 -0
- package/android/build/tmp/compileDebugJavaWithJavac/previous-compilation-data.bin +0 -0
- package/android/build.gradle +148 -0
- package/android/gradle/wrapper/gradle-wrapper.jar +0 -0
- package/android/gradle/wrapper/gradle-wrapper.properties +7 -0
- package/android/gradle.properties +2 -0
- package/android/gradlew +249 -0
- package/android/gradlew.bat +92 -0
- package/android/local.properties +8 -0
- package/android/project.properties +12 -0
- package/android/src/main/AndroidManifest.xml +4 -0
- package/android/src/main/AndroidManifestNew.xml +4 -0
- package/android/src/main/java/org/wonday/pdf/PdfManager.java +196 -0
- package/android/src/main/java/org/wonday/pdf/PdfView.java +680 -0
- package/android/src/main/java/org/wonday/pdf/RNPDFPackage.java +39 -0
- package/android/src/main/java/org/wonday/pdf/events/TopChangeEvent.java +26 -0
- package/android/src/paper/java/com/facebook/react/viewmanagers/RNPDFPdfViewManagerDelegate.java +92 -0
- package/android/src/paper/java/com/facebook/react/viewmanagers/RNPDFPdfViewManagerInterface.java +35 -0
- package/fabric/RNPDFPdfNativeComponent.js +56 -0
- package/index.d.ts +83 -0
- package/index.js +524 -0
- package/index.js.flow +67 -0
- package/ios/RNPDFPdf/PdfManager.h +23 -0
- package/ios/RNPDFPdf/PdfManager.mm +152 -0
- package/ios/RNPDFPdf/RNPDFPdfPageView.h +21 -0
- package/ios/RNPDFPdf/RNPDFPdfPageView.mm +185 -0
- package/ios/RNPDFPdf/RNPDFPdfPageViewManager.h +18 -0
- package/ios/RNPDFPdf/RNPDFPdfPageViewManager.mm +30 -0
- package/ios/RNPDFPdf/RNPDFPdfView.h +60 -0
- package/ios/RNPDFPdf/RNPDFPdfView.mm +1101 -0
- package/ios/RNPDFPdf/RNPDFPdfViewManager.h +18 -0
- package/ios/RNPDFPdf/RNPDFPdfViewManager.mm +96 -0
- package/ios/RNPDFPdf.xcodeproj/project.pbxproj +321 -0
- package/package.json +73 -0
- package/react-native-pdf.podspec +30 -0
- package/windows/RCTPdf/PropertySheet.props +16 -0
- package/windows/RCTPdf/RCTPdf.def +3 -0
- package/windows/RCTPdf/RCTPdf.vcxproj +180 -0
- package/windows/RCTPdf/RCTPdf.vcxproj.filters +38 -0
- package/windows/RCTPdf/RCTPdfControl.cpp +667 -0
- package/windows/RCTPdf/RCTPdfControl.h +119 -0
- package/windows/RCTPdf/RCTPdfControl.idl +10 -0
- package/windows/RCTPdf/RCTPdfControl.xaml +33 -0
- package/windows/RCTPdf/RCTPdfViewManager.cpp +69 -0
- package/windows/RCTPdf/RCTPdfViewManager.h +51 -0
- package/windows/RCTPdf/ReactPackageProvider.cpp +15 -0
- package/windows/RCTPdf/ReactPackageProvider.h +16 -0
- package/windows/RCTPdf/ReactPackageProvider.idl +9 -0
- package/windows/RCTPdf/packages.config +4 -0
- package/windows/RCTPdf/pch.cpp +1 -0
- package/windows/RCTPdf/pch.h +31 -0
- package/windows/README.md +21 -0
package/DoubleTapView.js
ADDED
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2017-present, Wonday (@wonday.org)
|
|
3
|
+
* All rights reserved.
|
|
4
|
+
*
|
|
5
|
+
* This source code is licensed under the MIT-style license found in the
|
|
6
|
+
* LICENSE file in the root directory of this source tree.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
'use strict';
|
|
10
|
+
import React, {Component} from 'react';
|
|
11
|
+
import {
|
|
12
|
+
View,
|
|
13
|
+
PanResponder
|
|
14
|
+
} from 'react-native';
|
|
15
|
+
import PropTypes from 'prop-types';
|
|
16
|
+
import {ViewPropTypes} from 'deprecated-react-native-prop-types';
|
|
17
|
+
export default class DoubleTapView extends Component {
|
|
18
|
+
|
|
19
|
+
static propTypes = {
|
|
20
|
+
...ViewPropTypes,
|
|
21
|
+
delay: PropTypes.number,
|
|
22
|
+
radius: PropTypes.number,
|
|
23
|
+
onSingleTap: PropTypes.func,
|
|
24
|
+
onDoubleTap: PropTypes.func,
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
static defaultProps = {
|
|
28
|
+
delay: 300,
|
|
29
|
+
radius: 50,
|
|
30
|
+
onSingleTap: () => {
|
|
31
|
+
},
|
|
32
|
+
onDoubleTap: () => {
|
|
33
|
+
},
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
constructor() {
|
|
37
|
+
super();
|
|
38
|
+
|
|
39
|
+
this.gestureHandlers = PanResponder.create({
|
|
40
|
+
onStartShouldSetPanResponder: (evt, gestureState) => (gestureState.numberActiveTouches === 1),
|
|
41
|
+
onStartShouldSetResponderCapture: (evt, gestureState) => (gestureState.numberActiveTouches === 1),
|
|
42
|
+
onMoveShouldSetPanResponder: (evt, gestureState) => (false),
|
|
43
|
+
onMoveShouldSetResponderCapture: (evt, gestureState) => (false),
|
|
44
|
+
onPanResponderTerminationRequest: (evt, gestureState) => false,
|
|
45
|
+
onPanResponderRelease: this.handlePanResponderRelease,
|
|
46
|
+
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
this.prevTouchInfo = {
|
|
50
|
+
prevTouchX: 0,
|
|
51
|
+
prevTouchY: 0,
|
|
52
|
+
prevTouchTimeStamp: 0,
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
this.timer = null;
|
|
56
|
+
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
distance = (x0, y0, x1, y1) => {
|
|
61
|
+
return Math.sqrt(Math.pow((x1 - x0), 2) + Math.pow((y1 - y0), 2)).toFixed(1);
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
isDoubleTap = (currentTouchTimeStamp, {x0, y0}) => {
|
|
65
|
+
const {prevTouchX, prevTouchY, prevTouchTimeStamp} = this.prevTouchInfo;
|
|
66
|
+
const dt = currentTouchTimeStamp - prevTouchTimeStamp;
|
|
67
|
+
const {delay, radius} = this.props;
|
|
68
|
+
|
|
69
|
+
return (prevTouchTimeStamp > 0 && dt < delay && this.distance(prevTouchX, prevTouchY, x0, y0) < radius);
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
handlePanResponderRelease = (evt, gestureState) => {
|
|
73
|
+
|
|
74
|
+
const currentTouchTimeStamp = Date.now();
|
|
75
|
+
const x = evt.nativeEvent.locationX;
|
|
76
|
+
const y = evt.nativeEvent.locationY;
|
|
77
|
+
|
|
78
|
+
if (this.timer) {
|
|
79
|
+
|
|
80
|
+
if (this.isDoubleTap(currentTouchTimeStamp, gestureState)) {
|
|
81
|
+
|
|
82
|
+
clearTimeout(this.timer);
|
|
83
|
+
this.timer = null;
|
|
84
|
+
this.props.onDoubleTap();
|
|
85
|
+
|
|
86
|
+
} else {
|
|
87
|
+
|
|
88
|
+
const {prevTouchX, prevTouchY, prevTouchTimeStamp} = this.prevTouchInfo;
|
|
89
|
+
const {radius} = this.props;
|
|
90
|
+
|
|
91
|
+
// if not in radius, it's a move
|
|
92
|
+
if (this.distance(prevTouchX, prevTouchY, gestureState.x0, gestureState.y0) < radius) {
|
|
93
|
+
this.timer = null;
|
|
94
|
+
this.props.onSingleTap(x, y);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
}
|
|
98
|
+
} else {
|
|
99
|
+
// do not count scroll gestures as taps
|
|
100
|
+
if (this.distance(0, gestureState.dx, 0, gestureState.dy) < 10) {
|
|
101
|
+
|
|
102
|
+
this.timer = setTimeout(() => {
|
|
103
|
+
this.props.onSingleTap(x, y);
|
|
104
|
+
this.timer = null;
|
|
105
|
+
}, this.props.delay);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
|
|
110
|
+
this.prevTouchInfo = {
|
|
111
|
+
prevTouchX: gestureState.x0,
|
|
112
|
+
prevTouchY: gestureState.y0,
|
|
113
|
+
prevTouchTimeStamp: currentTouchTimeStamp,
|
|
114
|
+
};
|
|
115
|
+
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
render() {
|
|
119
|
+
return (
|
|
120
|
+
<View {...this.props} {...this.gestureHandlers.panHandlers}>
|
|
121
|
+
{this.props.children}
|
|
122
|
+
</View>
|
|
123
|
+
);
|
|
124
|
+
}
|
|
125
|
+
}
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2017 Wonday (@wonday.org)
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/PdfManager.js
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2017-present, Wonday (@wonday.org)
|
|
3
|
+
* All rights reserved.
|
|
4
|
+
*
|
|
5
|
+
* This source code is licensed under the MIT-style license found in the
|
|
6
|
+
* LICENSE file in the root directory of this source tree.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
'use strict';
|
|
10
|
+
|
|
11
|
+
const PdfManagerNative = require('react-native').NativeModules.PdfManager;
|
|
12
|
+
|
|
13
|
+
export default class PdfManager {
|
|
14
|
+
|
|
15
|
+
static loadFile(path, password) {
|
|
16
|
+
if (typeof path !== 'string') {
|
|
17
|
+
throw new TypeError('path must be a valid string.');
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
if (password === undefined) {
|
|
21
|
+
password = "";
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
return PdfManagerNative.loadFile(path, password);
|
|
25
|
+
}
|
|
26
|
+
}
|
package/PdfPageView.js
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2017-present, Wonday (@wonday.org)
|
|
3
|
+
* All rights reserved.
|
|
4
|
+
*
|
|
5
|
+
* This source code is licensed under the MIT-style license found in the
|
|
6
|
+
* LICENSE file in the root directory of this source tree.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
'use strict';
|
|
11
|
+
import React, {PureComponent} from 'react';
|
|
12
|
+
import PropTypes from 'prop-types';
|
|
13
|
+
import {
|
|
14
|
+
requireNativeComponent,
|
|
15
|
+
} from 'react-native';
|
|
16
|
+
import {ViewPropTypes} from 'deprecated-react-native-prop-types';
|
|
17
|
+
export default class PdfPageView extends PureComponent {
|
|
18
|
+
_getStylePropsProps = () => {
|
|
19
|
+
const {width, height} = this.props;
|
|
20
|
+
if (width || height) {
|
|
21
|
+
return {width, height};
|
|
22
|
+
}
|
|
23
|
+
return {};
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
render() {
|
|
27
|
+
const {
|
|
28
|
+
style,
|
|
29
|
+
...restProps
|
|
30
|
+
} = this.props;
|
|
31
|
+
return (
|
|
32
|
+
<PdfPageViewCustom
|
|
33
|
+
{...restProps}
|
|
34
|
+
style={[style, this._getStylePropsProps()]}
|
|
35
|
+
/>
|
|
36
|
+
);
|
|
37
|
+
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
PdfPageView.propTypes = {
|
|
42
|
+
...ViewPropTypes,
|
|
43
|
+
fileNo: PropTypes.number,
|
|
44
|
+
page: PropTypes.number,
|
|
45
|
+
width: PropTypes.number,
|
|
46
|
+
height: PropTypes.number
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
PdfPageView.defaultProps = {
|
|
50
|
+
style: {}
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
let PdfPageViewCustom = requireNativeComponent('RCTPdfPageView', PdfPageView, {nativeOnly: {}});
|
package/PdfView.js
ADDED
|
@@ -0,0 +1,421 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2017-present, Wonday (@wonday.org)
|
|
3
|
+
* All rights reserved.
|
|
4
|
+
*
|
|
5
|
+
* This source code is licensed under the MIT-style license found in the
|
|
6
|
+
* LICENSE file in the root directory of this source tree.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
'use strict';
|
|
10
|
+
import React, {Component} from 'react';
|
|
11
|
+
import {ScrollView, View, StyleSheet} from 'react-native';
|
|
12
|
+
import {ViewPropTypes} from 'deprecated-react-native-prop-types';
|
|
13
|
+
import PropTypes from 'prop-types';
|
|
14
|
+
|
|
15
|
+
import PdfManager from './PdfManager';
|
|
16
|
+
import PdfPageView from './PdfPageView';
|
|
17
|
+
import DoubleTapView from './DoubleTapView';
|
|
18
|
+
import PinchZoomView from './PinchZoomView';
|
|
19
|
+
import PdfViewFlatList from './PdfViewFlatList';
|
|
20
|
+
|
|
21
|
+
const MIN_SCALE = 1;
|
|
22
|
+
const MAX_SCALE = 3;
|
|
23
|
+
|
|
24
|
+
const VIEWABILITYCONFIG = {minimumViewTime: 500, itemVisiblePercentThreshold: 10, waitForInteraction: false};
|
|
25
|
+
|
|
26
|
+
export default class PdfView extends Component {
|
|
27
|
+
|
|
28
|
+
static propTypes = {
|
|
29
|
+
...ViewPropTypes,
|
|
30
|
+
path: PropTypes.string,
|
|
31
|
+
password: PropTypes.string,
|
|
32
|
+
scale: PropTypes.number,
|
|
33
|
+
minScale: PropTypes.number,
|
|
34
|
+
maxScale: PropTypes.number,
|
|
35
|
+
spacing: PropTypes.number,
|
|
36
|
+
fitPolicy: PropTypes.number,
|
|
37
|
+
horizontal: PropTypes.bool,
|
|
38
|
+
page: PropTypes.number,
|
|
39
|
+
currentPage: PropTypes.number,
|
|
40
|
+
singlePage: PropTypes.bool,
|
|
41
|
+
onPageSingleTap: PropTypes.func,
|
|
42
|
+
onScaleChanged: PropTypes.func,
|
|
43
|
+
showsHorizontalScrollIndicator: PropTypes.bool,
|
|
44
|
+
showsVerticalScrollIndicator: PropTypes.bool,
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
static defaultProps = {
|
|
48
|
+
path: "",
|
|
49
|
+
password: "",
|
|
50
|
+
scale: 1,
|
|
51
|
+
minScale: MIN_SCALE,
|
|
52
|
+
maxScale: MAX_SCALE,
|
|
53
|
+
spacing: 10,
|
|
54
|
+
style: {},
|
|
55
|
+
progressContainerStyle: {},
|
|
56
|
+
fitPolicy: 2,
|
|
57
|
+
horizontal: false,
|
|
58
|
+
centerContent: false,
|
|
59
|
+
page: 1,
|
|
60
|
+
currentPage: -1,
|
|
61
|
+
enablePaging: false,
|
|
62
|
+
singlePage: false,
|
|
63
|
+
onPageSingleTap: (page, x, y) => {
|
|
64
|
+
},
|
|
65
|
+
onScaleChanged: (scale) => {
|
|
66
|
+
},
|
|
67
|
+
showsHorizontalScrollIndicator: true,
|
|
68
|
+
showsVerticalScrollIndicator: true,
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
constructor(props) {
|
|
72
|
+
|
|
73
|
+
super(props);
|
|
74
|
+
this.state = {
|
|
75
|
+
pdfLoaded: false,
|
|
76
|
+
fileNo: -1,
|
|
77
|
+
numberOfPages: 0,
|
|
78
|
+
page: -1,
|
|
79
|
+
currentPage: -1,
|
|
80
|
+
pageAspectRate: 0.5,
|
|
81
|
+
pdfPageSize: {width: 0, height: 0},
|
|
82
|
+
contentContainerSize: {width: 0, height: 0},
|
|
83
|
+
scale: this.props.scale,
|
|
84
|
+
contentOffset: {x: 0, y: 0},
|
|
85
|
+
newContentOffset: {x: 0, y: 0},
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
this._flatList = null;
|
|
89
|
+
this._scaleTimer = null;
|
|
90
|
+
this._scrollTimer = null;
|
|
91
|
+
this._mounted = false;
|
|
92
|
+
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
componentDidMount() {
|
|
96
|
+
this._mounted = true;
|
|
97
|
+
PdfManager.loadFile(this.props.path, this.props.password)
|
|
98
|
+
.then((pdfInfo) => {
|
|
99
|
+
if (this._mounted) {
|
|
100
|
+
const fileNo = pdfInfo[0];
|
|
101
|
+
const numberOfPages = pdfInfo[1];
|
|
102
|
+
const width = pdfInfo[2];
|
|
103
|
+
const height = pdfInfo[3];
|
|
104
|
+
const pageAspectRatio = height === 0 ? 1 : width / height;
|
|
105
|
+
|
|
106
|
+
this.setState({
|
|
107
|
+
pdfLoaded: true,
|
|
108
|
+
fileNo,
|
|
109
|
+
numberOfPages,
|
|
110
|
+
pageAspectRate: pageAspectRatio,
|
|
111
|
+
pdfPageSize: {width, height},
|
|
112
|
+
centerContent: numberOfPages > 1 ? false : true
|
|
113
|
+
});
|
|
114
|
+
if (this.props.onLoadComplete) {
|
|
115
|
+
this.props.onLoadComplete(numberOfPages, this.props.path, {width, height});
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
})
|
|
120
|
+
.catch((error) => {
|
|
121
|
+
this.props.onError(error);
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
clearTimeout(this._scrollTimer);
|
|
125
|
+
this._scrollTimer = setTimeout(() => {
|
|
126
|
+
if (this._flatList) {
|
|
127
|
+
this._flatList.scrollToIndex({animated: false, index: this.props.page < 1 ? 0 : this.props.page - 1});
|
|
128
|
+
}
|
|
129
|
+
}, 200);
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
componentDidUpdate(prevProps) {
|
|
133
|
+
|
|
134
|
+
if (this.props.scale !== this.state.scale) {
|
|
135
|
+
this._onScaleChanged({
|
|
136
|
+
scale: this.props.scale / this.state.scale,
|
|
137
|
+
pageX: this.state.contentContainerSize.width / 2,
|
|
138
|
+
pageY: this.state.contentContainerSize.height / 2
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
if (this.props.horizontal !== prevProps.horizontal || this.props.page !== prevProps.page) {
|
|
143
|
+
let page = (this.props.page) < 1 ? 1 : this.props.page;
|
|
144
|
+
page = page > this.state.numberOfPages ? this.state.numberOfPages : page;
|
|
145
|
+
|
|
146
|
+
if (this._flatList) {
|
|
147
|
+
clearTimeout(this._scrollTimer);
|
|
148
|
+
this._scrollTimer = setTimeout(() => {
|
|
149
|
+
this._flatList.scrollToIndex({animated: false, index: page - 1});
|
|
150
|
+
}, 200);
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
componentWillUnmount() {
|
|
157
|
+
this._mounted = false;
|
|
158
|
+
clearTimeout(this._scaleTimer);
|
|
159
|
+
clearTimeout(this._scrollTimer);
|
|
160
|
+
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
_keyExtractor = (item, index) => "pdf-page-" + index;
|
|
164
|
+
|
|
165
|
+
_getPageWidth = () => {
|
|
166
|
+
|
|
167
|
+
let fitPolicy = this.props.fitPolicy;
|
|
168
|
+
|
|
169
|
+
// if only one page, show whole page in center
|
|
170
|
+
if (this.state.numberOfPages === 1 || this.props.singlePage) {
|
|
171
|
+
fitPolicy = 2;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
|
|
175
|
+
switch (fitPolicy) {
|
|
176
|
+
case 0: //fit width
|
|
177
|
+
return this.state.contentContainerSize.width * this.state.scale;
|
|
178
|
+
case 1: //fit height
|
|
179
|
+
return this.state.contentContainerSize.height * this.state.pageAspectRate * this.state.scale;
|
|
180
|
+
case 2: //fit both
|
|
181
|
+
default: {
|
|
182
|
+
if (this.state.contentContainerSize.width/this.state.contentContainerSize.height<this.state.pageAspectRate) {
|
|
183
|
+
return this.state.contentContainerSize.width * this.state.scale;
|
|
184
|
+
} else {
|
|
185
|
+
return this.state.contentContainerSize.height * this.state.pageAspectRate * this.state.scale;
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
};
|
|
191
|
+
|
|
192
|
+
_getPageHeight = () => {
|
|
193
|
+
|
|
194
|
+
let fitPolicy = this.props.fitPolicy;
|
|
195
|
+
|
|
196
|
+
// if only one page, show whole page in center
|
|
197
|
+
if (this.state.numberOfPages === 1 || this.props.singlePage) {
|
|
198
|
+
fitPolicy = 2;
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
switch (fitPolicy) {
|
|
202
|
+
case 0: //fit width
|
|
203
|
+
return this.state.contentContainerSize.width * (1 / this.state.pageAspectRate) * this.state.scale;
|
|
204
|
+
case 1: //fit height
|
|
205
|
+
return this.state.contentContainerSize.height * this.state.scale;
|
|
206
|
+
case 2: //fit both
|
|
207
|
+
default: {
|
|
208
|
+
if (this.state.contentContainerSize.width/this.state.contentContainerSize.height<this.state.pageAspectRate) {
|
|
209
|
+
return this.state.contentContainerSize.width * (1 / this.state.pageAspectRate) * this.state.scale;
|
|
210
|
+
} else {
|
|
211
|
+
return this.state.contentContainerSize.height * this.state.scale;
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
};
|
|
217
|
+
|
|
218
|
+
_renderSeparator = () => (
|
|
219
|
+
<View style={this.props.horizontal ? {
|
|
220
|
+
width: this.props.spacing * this.state.scale,
|
|
221
|
+
backgroundColor: 'transparent'
|
|
222
|
+
} : {
|
|
223
|
+
height: this.props.spacing * this.state.scale,
|
|
224
|
+
backgroundColor: 'transparent'
|
|
225
|
+
}}/>
|
|
226
|
+
);
|
|
227
|
+
|
|
228
|
+
_onItemSingleTap = (index, x, y) => {
|
|
229
|
+
|
|
230
|
+
this.props.onPageSingleTap(index + 1, x, y);
|
|
231
|
+
|
|
232
|
+
};
|
|
233
|
+
|
|
234
|
+
_onItemDoubleTap = (index) => {
|
|
235
|
+
|
|
236
|
+
if (this.state.scale >= this.props.maxScale) {
|
|
237
|
+
this._onScaleChanged({
|
|
238
|
+
scale: 1 / this.state.scale,
|
|
239
|
+
pageX: this.state.contentContainerSize.width / 2,
|
|
240
|
+
pageY: this.state.contentContainerSize.height / 2
|
|
241
|
+
});
|
|
242
|
+
} else {
|
|
243
|
+
this._onScaleChanged({
|
|
244
|
+
scale: 1.2,
|
|
245
|
+
pageX: this.state.contentContainerSize.width / 2,
|
|
246
|
+
pageY: this.state.contentContainerSize.height / 2
|
|
247
|
+
});
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
};
|
|
251
|
+
|
|
252
|
+
_onScaleChanged = (pinchInfo) => {
|
|
253
|
+
|
|
254
|
+
let newScale = pinchInfo.scale * this.state.scale;
|
|
255
|
+
newScale = newScale > this.props.maxScale ? this.props.maxScale : newScale;
|
|
256
|
+
newScale = newScale < this.props.minScale ? this.props.minScale : newScale;
|
|
257
|
+
let newContentOffset = {
|
|
258
|
+
x: (this.state.contentOffset.x + pinchInfo.pageX) * (newScale / this.state.scale) - pinchInfo.pageX,
|
|
259
|
+
y: (this.state.contentOffset.y + pinchInfo.pageY) * (newScale / this.state.scale) - pinchInfo.pageY
|
|
260
|
+
}
|
|
261
|
+
this.setState({scale: newScale, newContentOffset: newContentOffset});
|
|
262
|
+
this.props.onScaleChanged(newScale);
|
|
263
|
+
|
|
264
|
+
};
|
|
265
|
+
|
|
266
|
+
_renderItem = ({item, index}) => {
|
|
267
|
+
const pageView = (
|
|
268
|
+
<PdfPageView
|
|
269
|
+
accessible={true}
|
|
270
|
+
key={item.id}
|
|
271
|
+
fileNo={this.state.fileNo}
|
|
272
|
+
page={item.key + 1}
|
|
273
|
+
width={this._getPageWidth()}
|
|
274
|
+
height={this._getPageHeight()}
|
|
275
|
+
/>
|
|
276
|
+
)
|
|
277
|
+
|
|
278
|
+
if (this.props.singlePage) {
|
|
279
|
+
return (
|
|
280
|
+
<View style={{flexDirection: this.props.horizontal ? 'row' : 'column'}} >
|
|
281
|
+
{pageView}
|
|
282
|
+
</View>
|
|
283
|
+
)
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
return (
|
|
287
|
+
<DoubleTapView style={{flexDirection: this.props.horizontal ? 'row' : 'column'}}
|
|
288
|
+
onSingleTap={(x, y) => {
|
|
289
|
+
this._onItemSingleTap(index, x, y);
|
|
290
|
+
}}
|
|
291
|
+
onDoubleTap={() => {
|
|
292
|
+
this._onItemDoubleTap(index);
|
|
293
|
+
}}
|
|
294
|
+
>
|
|
295
|
+
{pageView}
|
|
296
|
+
{(index !== this.state.numberOfPages - 1) && this._renderSeparator()}
|
|
297
|
+
</DoubleTapView>
|
|
298
|
+
);
|
|
299
|
+
|
|
300
|
+
};
|
|
301
|
+
|
|
302
|
+
_onViewableItemsChanged = (viewableInfo) => {
|
|
303
|
+
|
|
304
|
+
for (let i = 0; i < viewableInfo.viewableItems.length; i++) {
|
|
305
|
+
this._onPageChanged(viewableInfo.viewableItems[i].index + 1, this.state.numberOfPages);
|
|
306
|
+
if (viewableInfo.viewableItems.length + viewableInfo.viewableItems[0].index < this.state.numberOfPages) break;
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
};
|
|
310
|
+
|
|
311
|
+
_onPageChanged = (page, numberOfPages) => {
|
|
312
|
+
if (this.props.onPageChanged && this.state.currentPage !== page) {
|
|
313
|
+
this.props.onPageChanged(page, numberOfPages);
|
|
314
|
+
this.setState({currentPage: page});
|
|
315
|
+
}
|
|
316
|
+
};
|
|
317
|
+
|
|
318
|
+
|
|
319
|
+
_getRef = (ref) => this._flatList = ref;
|
|
320
|
+
|
|
321
|
+
_getItemLayout = (data, index) => ({
|
|
322
|
+
length: this.props.horizontal ? this._getPageWidth() : this._getPageHeight(),
|
|
323
|
+
offset: ((this.props.horizontal ? this._getPageWidth() : this._getPageHeight()) + this.props.spacing * this.state.scale) * index,
|
|
324
|
+
index
|
|
325
|
+
});
|
|
326
|
+
|
|
327
|
+
_onScroll = (e) => {
|
|
328
|
+
this.setState({contentOffset: e.nativeEvent.contentOffset, newContentOffset: e.nativeEvent.contentOffset});
|
|
329
|
+
};
|
|
330
|
+
|
|
331
|
+
_onListContentSizeChange = (contentWidth, contentHeight) => {
|
|
332
|
+
if (this.state.contentOffset.x != this.state.newContentOffset.x
|
|
333
|
+
|| this.state.contentOffset.y != this.state.newContentOffset.y) {
|
|
334
|
+
this._flatList.scrollToXY(this.state.newContentOffset.x, this.state.newContentOffset.y);
|
|
335
|
+
}
|
|
336
|
+
};
|
|
337
|
+
|
|
338
|
+
_renderList = () => {
|
|
339
|
+
let data = [];
|
|
340
|
+
|
|
341
|
+
if (this.props.singlePage) {
|
|
342
|
+
data[0] = {key: this.props.currentPage >= 0 ? this.props.currentPage : 0}
|
|
343
|
+
} else {
|
|
344
|
+
for (let i = 0; i < this.state.numberOfPages; i++) {
|
|
345
|
+
data[i] = {key: i};
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
return (
|
|
350
|
+
<PdfViewFlatList
|
|
351
|
+
ref={this._getRef}
|
|
352
|
+
style={[styles.container, this.props.style]}
|
|
353
|
+
pagingEnabled={this.props.enablePaging}
|
|
354
|
+
contentContainerStyle={[{
|
|
355
|
+
justifyContent: 'center',
|
|
356
|
+
alignItems: 'center'
|
|
357
|
+
}, this.props.horizontal ? {height: this.state.contentContainerSize.height * this.state.scale} : {width: this.state.contentContainerSize.width * this.state.scale}]}
|
|
358
|
+
horizontal={this.props.horizontal}
|
|
359
|
+
data={data}
|
|
360
|
+
renderItem={this._renderItem}
|
|
361
|
+
keyExtractor={this._keyExtractor}
|
|
362
|
+
windowSize={11}
|
|
363
|
+
getItemLayout={this._getItemLayout}
|
|
364
|
+
maxToRenderPerBatch={1}
|
|
365
|
+
renderScrollComponent={(props) => <ScrollView
|
|
366
|
+
{...props}
|
|
367
|
+
centerContent={this.state.centerContent}
|
|
368
|
+
pinchGestureEnabled={false}
|
|
369
|
+
/>}
|
|
370
|
+
initialScrollIndex={this.props.page < 1 ? 0 : this.props.page - 1}
|
|
371
|
+
onViewableItemsChanged={this._onViewableItemsChanged}
|
|
372
|
+
viewabilityConfig={VIEWABILITYCONFIG}
|
|
373
|
+
onScroll={this._onScroll}
|
|
374
|
+
onContentSizeChange={this._onListContentSizeChange}
|
|
375
|
+
scrollEnabled={!this.props.singlePage}
|
|
376
|
+
/>
|
|
377
|
+
);
|
|
378
|
+
|
|
379
|
+
};
|
|
380
|
+
|
|
381
|
+
_onLayout = (event) => {
|
|
382
|
+
this.setState({
|
|
383
|
+
contentContainerSize: {
|
|
384
|
+
width: event.nativeEvent.layout.width,
|
|
385
|
+
height: event.nativeEvent.layout.height
|
|
386
|
+
}
|
|
387
|
+
});
|
|
388
|
+
};
|
|
389
|
+
|
|
390
|
+
|
|
391
|
+
render() {
|
|
392
|
+
if (this.props.singlePage) {
|
|
393
|
+
return (
|
|
394
|
+
<View
|
|
395
|
+
style={styles.container}
|
|
396
|
+
onLayout={this._onLayout}
|
|
397
|
+
>
|
|
398
|
+
{this.state.pdfLoaded && this._renderList()}
|
|
399
|
+
</View>
|
|
400
|
+
)
|
|
401
|
+
}
|
|
402
|
+
|
|
403
|
+
return (
|
|
404
|
+
<PinchZoomView
|
|
405
|
+
style={styles.container}
|
|
406
|
+
onLayout={this._onLayout}
|
|
407
|
+
onScaleChanged={this._onScaleChanged}
|
|
408
|
+
>
|
|
409
|
+
{this.state.pdfLoaded && this._renderList()}
|
|
410
|
+
</PinchZoomView>
|
|
411
|
+
);
|
|
412
|
+
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
}
|
|
416
|
+
|
|
417
|
+
const styles = StyleSheet.create({
|
|
418
|
+
container: {
|
|
419
|
+
flex: 1
|
|
420
|
+
}
|
|
421
|
+
});
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2017-present, Wonday (@wonday.org)
|
|
3
|
+
* All rights reserved.
|
|
4
|
+
*
|
|
5
|
+
* This source code is licensed under the MIT-style license found in the
|
|
6
|
+
* LICENSE file in the root directory of this source tree.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
'use strict';
|
|
10
|
+
import {
|
|
11
|
+
FlatList,
|
|
12
|
+
} from 'react-native';
|
|
13
|
+
|
|
14
|
+
export default class PdfViewFlatList extends FlatList {
|
|
15
|
+
/**
|
|
16
|
+
* Scrolls to a given x, y offset, either immediately or with a smooth animation.
|
|
17
|
+
*
|
|
18
|
+
* Example:
|
|
19
|
+
*
|
|
20
|
+
* `scrollTo({x: 0, y: 0, animated: true})`
|
|
21
|
+
*
|
|
22
|
+
* Note: The weird function signature is due to the fact that, for historical reasons,
|
|
23
|
+
* the function also accepts separate arguments as an alternative to the options object.
|
|
24
|
+
* This is deprecated due to ambiguity (y before x), and SHOULD NOT BE USED.
|
|
25
|
+
*/
|
|
26
|
+
scrollToXY = (x, y) => {
|
|
27
|
+
this._listRef._scrollRef.scrollTo({x: x, y: y, animated: false});
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
}
|