react-native-pdf 6.7.5 → 6.7.7
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/PdfView.js +4 -0
- package/README.md +16 -3
- package/android/build.gradle +1 -1
- package/android/src/main/java/org/wonday/pdf/PdfManager.java +5 -0
- package/android/src/main/java/org/wonday/pdf/PdfView.java +110 -45
- package/android/src/main/java/org/wonday/pdf/events/TopChangeEvent.java +26 -0
- package/android/src/paper/java/com/facebook/react/viewmanagers/RNPDFPdfViewManagerDelegate.java +6 -2
- package/android/src/paper/java/com/facebook/react/viewmanagers/RNPDFPdfViewManagerInterface.java +1 -0
- package/fabric/RNPDFPdfNativeComponent.js +3 -1
- package/index.d.ts +8 -1
- package/index.js +4 -2
- package/index.js.flow +1 -0
- package/ios/RNPDFPdf/RNPDFPdfView.h +1 -0
- package/ios/RNPDFPdf/RNPDFPdfView.mm +36 -21
- package/ios/RNPDFPdf/RNPDFPdfViewManager.mm +1 -0
- package/package.json +1 -1
package/PdfView.js
CHANGED
|
@@ -40,6 +40,8 @@ export default class PdfView extends Component {
|
|
|
40
40
|
singlePage: PropTypes.bool,
|
|
41
41
|
onPageSingleTap: PropTypes.func,
|
|
42
42
|
onScaleChanged: PropTypes.func,
|
|
43
|
+
showsHorizontalScrollIndicator: PropTypes.bool,
|
|
44
|
+
showsVerticalScrollIndicator: PropTypes.bool,
|
|
43
45
|
};
|
|
44
46
|
|
|
45
47
|
static defaultProps = {
|
|
@@ -62,6 +64,8 @@ export default class PdfView extends Component {
|
|
|
62
64
|
},
|
|
63
65
|
onScaleChanged: (scale) => {
|
|
64
66
|
},
|
|
67
|
+
showsHorizontalScrollIndicator: true,
|
|
68
|
+
showsVerticalScrollIndicator: true,
|
|
65
69
|
};
|
|
66
70
|
|
|
67
71
|
constructor(props) {
|
package/README.md
CHANGED
|
@@ -168,8 +168,21 @@ react-native run-ios
|
|
|
168
168
|
### ChangeLog
|
|
169
169
|
<details>
|
|
170
170
|
<summary>ChangeLog details</summary>
|
|
171
|
-
v6.7.
|
|
171
|
+
v6.7.7
|
|
172
|
+
1. Added: add support for customizable scroll indicators in PdfView component (#904)
|
|
173
|
+
2. Fixed: fix field values not being visible on android. issue #864 :bug: (#896)
|
|
174
|
+
|
|
175
|
+
v6.7.6
|
|
176
|
+
1. Fixed: Add missing 'enableDoubleTapZoom' to fabric codegen source (#832)
|
|
177
|
+
2. Fixed: added missing 'scrollEnabled' prop (#842)
|
|
178
|
+
3. Fixed: java.lang.IllegalStateException: Tried to access a JS module before the React instance was fully set up (#840)
|
|
179
|
+
4. Fixed: an issue that crashes when cancel is not present (#852)
|
|
180
|
+
5. Added: add load method (#861)
|
|
181
|
+
6. Fixed: encoded accented character is decoded incorrectly (#873)
|
|
182
|
+
7. Fixed: enableDoubleTapZoom bugfix
|
|
183
|
+
|
|
172
184
|
|
|
185
|
+
v6.7.5
|
|
173
186
|
1. Added progressContainerStyle prop
|
|
174
187
|
2. Improved: Added enableDoubleTapZoom option
|
|
175
188
|
3. Fixed: Fix app crash with this.lastRNBFTask.cancel is not a function (#827)
|
|
@@ -307,6 +320,7 @@ const styles = StyleSheet.create({
|
|
|
307
320
|
| horizontal | bool | false | draw page direction, if you want to listen the orientation change, you can use [[react-native-orientation-locker]](https://github.com/wonday/react-native-orientation-locker) | ✔ | ✔ | ✔ | <3.0 |
|
|
308
321
|
| showsHorizontalScrollIndicator | bool | true | shows or hides the horizontal scroll bar indicator on iOS | ✔ | | | 6.6 |
|
|
309
322
|
| showsVerticalScrollIndicator | bool | true | shows or hides the vertical scroll bar indicator on iOS | ✔ | | | 6.6 |
|
|
323
|
+
| scrollEnabled | bool | true | enable or disable scroll | ✔ | | | 6.6 |
|
|
310
324
|
| fitWidth | bool | false | if true fit the width of view, can not use fitWidth=true together with scale | ✔ | ✔ | ✔ | <3.0, abandoned from 3.0 |
|
|
311
325
|
| fitPolicy | number | 2 | 0:fit width, 1:fit height, 2:fit both(default) | ✔ | ✔ | ✔ | 3.0 |
|
|
312
326
|
| spacing | number | 10 | the breaker size between pages | ✔ | ✔ | ✔ | <3.0 |
|
|
@@ -377,5 +391,4 @@ Set the current page of the PDF component. pageNumber is a positive integer. If
|
|
|
377
391
|
Example:
|
|
378
392
|
```
|
|
379
393
|
this.pdf.setPage(42); // Display the answer to the Ultimate Question of Life, the Universe, and Everything
|
|
380
|
-
```
|
|
381
|
-
|
|
394
|
+
```
|
package/android/build.gradle
CHANGED
|
@@ -126,6 +126,6 @@ dependencies {
|
|
|
126
126
|
// The repo from zacharee is based on PdfiumAndroidKt, a much newer fork of PdfiumAndroid, with better maintenance and updated native libraries.
|
|
127
127
|
implementation 'com.github.zacharee:AndroidPdfViewer:4.0.1'
|
|
128
128
|
// Depend on PdfiumAndroidKt directly so this can be updated independently of AndroidPdfViewer as updates are provided.
|
|
129
|
-
implementation 'io.legere:pdfiumandroid:1.0.
|
|
129
|
+
implementation 'io.legere:pdfiumandroid:1.0.24'
|
|
130
130
|
implementation 'com.google.code.gson:gson:2.8.5'
|
|
131
131
|
}
|
|
@@ -104,6 +104,11 @@ public class PdfManager extends SimpleViewManager<PdfView> implements RNPDFPdfVi
|
|
|
104
104
|
// NOOP on Android
|
|
105
105
|
}
|
|
106
106
|
|
|
107
|
+
@ReactProp(name = "scrollEnabled")
|
|
108
|
+
public void setScrollEnabled(PdfView view, boolean scrollEnabled) {
|
|
109
|
+
pdfView.setScrollEnabled(scrollEnabled);
|
|
110
|
+
}
|
|
111
|
+
|
|
107
112
|
@ReactProp(name = "spacing")
|
|
108
113
|
public void setSpacing(PdfView pdfView, int spacing) {
|
|
109
114
|
pdfView.setSpacing(spacing);
|
|
@@ -22,6 +22,8 @@ import android.view.MotionEvent;
|
|
|
22
22
|
import android.graphics.Canvas;
|
|
23
23
|
|
|
24
24
|
|
|
25
|
+
import com.facebook.react.uimanager.ThemedReactContext;
|
|
26
|
+
import com.facebook.react.uimanager.UIManagerHelper;
|
|
25
27
|
import com.github.barteksc.pdfviewer.PDFView;
|
|
26
28
|
import com.github.barteksc.pdfviewer.listener.OnPageChangeListener;
|
|
27
29
|
import com.github.barteksc.pdfviewer.listener.OnLoadCompleteListener;
|
|
@@ -34,17 +36,15 @@ import com.github.barteksc.pdfviewer.util.Constants;
|
|
|
34
36
|
import com.github.barteksc.pdfviewer.link.LinkHandler;
|
|
35
37
|
import com.github.barteksc.pdfviewer.model.LinkTapEvent;
|
|
36
38
|
|
|
37
|
-
import com.facebook.react.bridge.NativeModule;
|
|
38
39
|
import com.facebook.react.bridge.ReactContext;
|
|
39
40
|
import com.facebook.react.bridge.Arguments;
|
|
40
41
|
import com.facebook.react.bridge.WritableMap;
|
|
41
|
-
import com.facebook.react.
|
|
42
|
-
import com.facebook.react.uimanager.
|
|
42
|
+
import com.facebook.react.bridge.ReactContext;
|
|
43
|
+
import com.facebook.react.uimanager.UIManagerModule;
|
|
44
|
+
import com.facebook.react.uimanager.events.EventDispatcher;
|
|
45
|
+
import com.facebook.react.uimanager.events.Event;
|
|
43
46
|
import com.facebook.react.uimanager.events.RCTEventEmitter;
|
|
44
|
-
|
|
45
|
-
import com.facebook.react.modules.core.DeviceEventManagerModule;
|
|
46
|
-
import com.facebook.common.logging.FLog;
|
|
47
|
-
import com.facebook.react.common.ReactConstants;
|
|
47
|
+
|
|
48
48
|
|
|
49
49
|
import static java.lang.String.format;
|
|
50
50
|
|
|
@@ -53,6 +53,8 @@ import java.io.InputStream;
|
|
|
53
53
|
|
|
54
54
|
import com.google.gson.Gson;
|
|
55
55
|
|
|
56
|
+
import org.wonday.pdf.events.TopChangeEvent;
|
|
57
|
+
|
|
56
58
|
public class PdfView extends PDFView implements OnPageChangeListener,OnLoadCompleteListener,OnErrorListener,OnTapListener,OnDrawListener,OnPageScrollListener, LinkHandler {
|
|
57
59
|
private int page = 1; // start from 1
|
|
58
60
|
private boolean horizontal = false;
|
|
@@ -72,6 +74,7 @@ public class PdfView extends PDFView implements OnPageChangeListener,OnLoadCompl
|
|
|
72
74
|
private boolean pageSnap = false;
|
|
73
75
|
private FitPolicy fitPolicy = FitPolicy.WIDTH;
|
|
74
76
|
private boolean singlePage = false;
|
|
77
|
+
private boolean scrollEnabled = true;
|
|
75
78
|
|
|
76
79
|
private float originalWidth = 0;
|
|
77
80
|
private float lastPageWidth = 0;
|
|
@@ -94,12 +97,23 @@ public class PdfView extends PDFView implements OnPageChangeListener,OnLoadCompl
|
|
|
94
97
|
|
|
95
98
|
WritableMap event = Arguments.createMap();
|
|
96
99
|
event.putString("message", "pageChanged|"+page+"|"+numberOfPages);
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
100
|
+
|
|
101
|
+
ThemedReactContext context = (ThemedReactContext) getContext();
|
|
102
|
+
EventDispatcher dispatcher = UIManagerHelper.getEventDispatcherForReactTag(context, getId());
|
|
103
|
+
int surfaceId = UIManagerHelper.getSurfaceId(this);
|
|
104
|
+
|
|
105
|
+
TopChangeEvent tce = new TopChangeEvent(surfaceId, getId(), event);
|
|
106
|
+
|
|
107
|
+
if (dispatcher != null) {
|
|
108
|
+
dispatcher.dispatchEvent(tce);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
// ReactContext reactContext = (ReactContext)this.getContext();
|
|
112
|
+
// reactContext.getJSModule(RCTEventEmitter.class).receiveEvent(
|
|
113
|
+
// this.getId(),
|
|
114
|
+
// "topChange",
|
|
115
|
+
// event
|
|
116
|
+
// );
|
|
103
117
|
}
|
|
104
118
|
|
|
105
119
|
// In some cases Yoga (I think) will measure the view only along one axis first, resulting in
|
|
@@ -135,12 +149,22 @@ public class PdfView extends PDFView implements OnPageChangeListener,OnLoadCompl
|
|
|
135
149
|
//create a new json Object for the TableOfContents
|
|
136
150
|
Gson gson = new Gson();
|
|
137
151
|
event.putString("message", "loadComplete|"+numberOfPages+"|"+width+"|"+height+"|"+gson.toJson(this.getTableOfContents()));
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
152
|
+
|
|
153
|
+
ThemedReactContext context = (ThemedReactContext) getContext();
|
|
154
|
+
EventDispatcher dispatcher = UIManagerHelper.getEventDispatcherForReactTag(context, getId());
|
|
155
|
+
int surfaceId = UIManagerHelper.getSurfaceId(this);
|
|
156
|
+
|
|
157
|
+
TopChangeEvent tce = new TopChangeEvent(surfaceId, getId(), event);
|
|
158
|
+
|
|
159
|
+
if (dispatcher != null) {
|
|
160
|
+
dispatcher.dispatchEvent(tce);
|
|
161
|
+
}
|
|
162
|
+
// ReactContext reactContext = (ReactContext)this.getContext();
|
|
163
|
+
// reactContext.getJSModule(RCTEventEmitter.class).receiveEvent(
|
|
164
|
+
// this.getId(),
|
|
165
|
+
// "topChange",
|
|
166
|
+
// event
|
|
167
|
+
// );
|
|
144
168
|
|
|
145
169
|
//Log.e("ReactNative", gson.toJson(this.getTableOfContents()));
|
|
146
170
|
|
|
@@ -155,12 +179,22 @@ public class PdfView extends PDFView implements OnPageChangeListener,OnLoadCompl
|
|
|
155
179
|
event.putString("message", "error|"+t.getMessage());
|
|
156
180
|
}
|
|
157
181
|
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
182
|
+
ThemedReactContext context = (ThemedReactContext) getContext();
|
|
183
|
+
EventDispatcher dispatcher = UIManagerHelper.getEventDispatcherForReactTag(context, getId());
|
|
184
|
+
int surfaceId = UIManagerHelper.getSurfaceId(this);
|
|
185
|
+
|
|
186
|
+
TopChangeEvent tce = new TopChangeEvent(surfaceId, getId(), event);
|
|
187
|
+
|
|
188
|
+
if (dispatcher != null) {
|
|
189
|
+
dispatcher.dispatchEvent(tce);
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
// ReactContext reactContext = (ReactContext)this.getContext();
|
|
193
|
+
// reactContext.getJSModule(RCTEventEmitter.class).receiveEvent(
|
|
194
|
+
// this.getId(),
|
|
195
|
+
// "topChange",
|
|
196
|
+
// event
|
|
197
|
+
// );
|
|
164
198
|
}
|
|
165
199
|
|
|
166
200
|
@Override
|
|
@@ -182,12 +216,21 @@ public class PdfView extends PDFView implements OnPageChangeListener,OnLoadCompl
|
|
|
182
216
|
WritableMap event = Arguments.createMap();
|
|
183
217
|
event.putString("message", "pageSingleTap|"+page+"|"+e.getX()+"|"+e.getY());
|
|
184
218
|
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
219
|
+
ThemedReactContext context = (ThemedReactContext) getContext();
|
|
220
|
+
EventDispatcher dispatcher = UIManagerHelper.getEventDispatcherForReactTag(context, getId());
|
|
221
|
+
int surfaceId = UIManagerHelper.getSurfaceId(this);
|
|
222
|
+
|
|
223
|
+
TopChangeEvent tce = new TopChangeEvent(surfaceId, getId(), event);
|
|
224
|
+
|
|
225
|
+
if (dispatcher != null) {
|
|
226
|
+
dispatcher.dispatchEvent(tce);
|
|
227
|
+
}
|
|
228
|
+
// ReactContext reactContext = (ReactContext)this.getContext();
|
|
229
|
+
// reactContext.getJSModule(RCTEventEmitter.class).receiveEvent(
|
|
230
|
+
// this.getId(),
|
|
231
|
+
// "topChange",
|
|
232
|
+
// event
|
|
233
|
+
// );
|
|
191
234
|
|
|
192
235
|
// process as tap
|
|
193
236
|
return true;
|
|
@@ -207,13 +250,21 @@ public class PdfView extends PDFView implements OnPageChangeListener,OnLoadCompl
|
|
|
207
250
|
|
|
208
251
|
WritableMap event = Arguments.createMap();
|
|
209
252
|
event.putString("message", "scaleChanged|"+(pageWidth/originalWidth));
|
|
253
|
+
ThemedReactContext context = (ThemedReactContext) getContext();
|
|
254
|
+
EventDispatcher dispatcher = UIManagerHelper.getEventDispatcherForReactTag(context, getId());
|
|
255
|
+
int surfaceId = UIManagerHelper.getSurfaceId(this);
|
|
256
|
+
|
|
257
|
+
TopChangeEvent tce = new TopChangeEvent(surfaceId, getId(), event);
|
|
210
258
|
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
259
|
+
if (dispatcher != null) {
|
|
260
|
+
dispatcher.dispatchEvent(tce);
|
|
261
|
+
}
|
|
262
|
+
// ReactContext reactContext = (ReactContext)this.getContext();
|
|
263
|
+
// reactContext.getJSModule(RCTEventEmitter.class).receiveEvent(
|
|
264
|
+
// this.getId(),
|
|
265
|
+
// "topChange",
|
|
266
|
+
// event
|
|
267
|
+
// );
|
|
217
268
|
}
|
|
218
269
|
|
|
219
270
|
lastPageWidth = pageWidth;
|
|
@@ -269,7 +320,7 @@ public class PdfView extends PDFView implements OnPageChangeListener,OnLoadCompl
|
|
|
269
320
|
.pageSnap(this.pageSnap)
|
|
270
321
|
.autoSpacing(this.autoSpacing)
|
|
271
322
|
.pageFling(this.pageFling)
|
|
272
|
-
.enableSwipe(!this.singlePage)
|
|
323
|
+
.enableSwipe(!this.singlePage && this.scrollEnabled)
|
|
273
324
|
.enableDoubletap(!this.singlePage && this.enableDoubleTapZoom)
|
|
274
325
|
.enableAnnotationRendering(this.enableAnnotationRendering)
|
|
275
326
|
.linkHandler(this);
|
|
@@ -314,6 +365,10 @@ public class PdfView extends PDFView implements OnPageChangeListener,OnLoadCompl
|
|
|
314
365
|
this.horizontal = horizontal;
|
|
315
366
|
}
|
|
316
367
|
|
|
368
|
+
public void setScrollEnabled(boolean scrollEnabled) {
|
|
369
|
+
this.scrollEnabled = scrollEnabled;
|
|
370
|
+
}
|
|
371
|
+
|
|
317
372
|
public void setSpacing(int spacing) {
|
|
318
373
|
this.spacing = spacing;
|
|
319
374
|
}
|
|
@@ -385,12 +440,22 @@ public class PdfView extends PDFView implements OnPageChangeListener,OnLoadCompl
|
|
|
385
440
|
WritableMap event = Arguments.createMap();
|
|
386
441
|
event.putString("message", "linkPressed|"+uri);
|
|
387
442
|
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
443
|
+
ThemedReactContext context = (ThemedReactContext) getContext();
|
|
444
|
+
EventDispatcher dispatcher = UIManagerHelper.getEventDispatcherForReactTag(context, getId());
|
|
445
|
+
int surfaceId = UIManagerHelper.getSurfaceId(this);
|
|
446
|
+
|
|
447
|
+
TopChangeEvent tce = new TopChangeEvent(surfaceId, getId(), event);
|
|
448
|
+
|
|
449
|
+
if (dispatcher != null) {
|
|
450
|
+
dispatcher.dispatchEvent(tce);
|
|
451
|
+
}
|
|
452
|
+
|
|
453
|
+
// ReactContext reactContext = (ReactContext)this.getContext();
|
|
454
|
+
// reactContext.getJSModule(RCTEventEmitter.class).receiveEvent(
|
|
455
|
+
// this.getId(),
|
|
456
|
+
// "topChange",
|
|
457
|
+
// event
|
|
458
|
+
// );
|
|
394
459
|
}
|
|
395
460
|
|
|
396
461
|
/**
|
|
@@ -437,4 +502,4 @@ public class PdfView extends PDFView implements OnPageChangeListener,OnLoadCompl
|
|
|
437
502
|
}
|
|
438
503
|
}
|
|
439
504
|
}
|
|
440
|
-
}
|
|
505
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
package org.wonday.pdf.events;
|
|
2
|
+
|
|
3
|
+
import androidx.annotation.Nullable;
|
|
4
|
+
|
|
5
|
+
import com.facebook.react.bridge.WritableMap;
|
|
6
|
+
import com.facebook.react.uimanager.events.Event;
|
|
7
|
+
|
|
8
|
+
public class TopChangeEvent extends Event<TopChangeEvent> {
|
|
9
|
+
private WritableMap eventData;
|
|
10
|
+
|
|
11
|
+
public TopChangeEvent(int surfaceId, int viewTag, WritableMap data) {
|
|
12
|
+
super(surfaceId, viewTag);
|
|
13
|
+
eventData = data;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
@Override
|
|
17
|
+
public String getEventName() {
|
|
18
|
+
return "topChange";
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
@Nullable
|
|
22
|
+
@Override
|
|
23
|
+
protected WritableMap getEventData() {
|
|
24
|
+
return eventData;
|
|
25
|
+
}
|
|
26
|
+
}
|
package/android/src/paper/java/com/facebook/react/viewmanagers/RNPDFPdfViewManagerDelegate.java
CHANGED
|
@@ -13,9 +13,10 @@ import android.view.View;
|
|
|
13
13
|
import androidx.annotation.Nullable;
|
|
14
14
|
import com.facebook.react.bridge.ReadableArray;
|
|
15
15
|
import com.facebook.react.uimanager.BaseViewManagerDelegate;
|
|
16
|
-
import com.facebook.react.uimanager.
|
|
16
|
+
import com.facebook.react.uimanager.BaseViewManager;
|
|
17
|
+
import com.facebook.react.uimanager.LayoutShadowNode;
|
|
17
18
|
|
|
18
|
-
public class RNPDFPdfViewManagerDelegate<T extends View, U extends
|
|
19
|
+
public class RNPDFPdfViewManagerDelegate<T extends View, U extends BaseViewManager<T, ? extends LayoutShadowNode> & RNPDFPdfViewManagerInterface<T>> extends BaseViewManagerDelegate<T, U> {
|
|
19
20
|
public RNPDFPdfViewManagerDelegate(U viewManager) {
|
|
20
21
|
super(viewManager);
|
|
21
22
|
}
|
|
@@ -46,6 +47,9 @@ public class RNPDFPdfViewManagerDelegate<T extends View, U extends BaseViewManag
|
|
|
46
47
|
case "showsVerticalScrollIndicator":
|
|
47
48
|
mViewManager.setShowsVerticalScrollIndicator(view, value == null ? false : (boolean) value);
|
|
48
49
|
break;
|
|
50
|
+
case "scrollEnabled":
|
|
51
|
+
mViewManager.setScrollEnabled(view, value == null ? false : (boolean) value);
|
|
52
|
+
break;
|
|
49
53
|
case "enablePaging":
|
|
50
54
|
mViewManager.setEnablePaging(view, value == null ? false : (boolean) value);
|
|
51
55
|
break;
|
package/android/src/paper/java/com/facebook/react/viewmanagers/RNPDFPdfViewManagerInterface.java
CHANGED
|
@@ -21,6 +21,7 @@ public interface RNPDFPdfViewManagerInterface<T extends View> {
|
|
|
21
21
|
void setHorizontal(T view, boolean value);
|
|
22
22
|
void setShowsHorizontalScrollIndicator(T view, boolean value);
|
|
23
23
|
void setShowsVerticalScrollIndicator(T view, boolean value);
|
|
24
|
+
void setScrollEnabled(T view, boolean value);
|
|
24
25
|
void setEnablePaging(T view, boolean value);
|
|
25
26
|
void setEnableRTL(T view, boolean value);
|
|
26
27
|
void setEnableAnnotationRendering(T view, boolean value);
|
|
@@ -24,7 +24,9 @@
|
|
|
24
24
|
enableAnnotationRendering: ?boolean,
|
|
25
25
|
showsHorizontalScrollIndicator: ?boolean,
|
|
26
26
|
showsVerticalScrollIndicator: ?boolean,
|
|
27
|
+
scrollEnabled: ?boolean,
|
|
27
28
|
enableAntialiasing: ?boolean,
|
|
29
|
+
enableDoubleTapZoom: ?boolean,
|
|
28
30
|
fitPolicy: ?Int32,
|
|
29
31
|
spacing: ?Int32,
|
|
30
32
|
password: ?string,
|
|
@@ -43,4 +45,4 @@ export const Commands: NativeCommands = codegenNativeCommands<NativeCommands>({
|
|
|
43
45
|
supportedCommands: ['setNativePage'],
|
|
44
46
|
});
|
|
45
47
|
|
|
46
|
-
export default codegenNativeComponent<NativeProps>('RNPDFPdfView');
|
|
48
|
+
export default codegenNativeComponent<NativeProps>('RNPDFPdfView');
|
package/index.d.ts
CHANGED
|
@@ -38,6 +38,7 @@ export interface PdfProps {
|
|
|
38
38
|
horizontal?: boolean,
|
|
39
39
|
showsHorizontalScrollIndicator?: boolean,
|
|
40
40
|
showsVerticalScrollIndicator?: boolean,
|
|
41
|
+
scrollEnabled?: boolean,
|
|
41
42
|
spacing?: number,
|
|
42
43
|
password?: string,
|
|
43
44
|
renderActivityIndicator?: (progress: number) => React.ReactElement,
|
|
@@ -46,7 +47,13 @@ export interface PdfProps {
|
|
|
46
47
|
enableRTL?: boolean,
|
|
47
48
|
enableAnnotationRendering?: boolean,
|
|
48
49
|
enableDoubleTapZoom?: boolean;
|
|
49
|
-
|
|
50
|
+
/**
|
|
51
|
+
* Fit policy. This will adjust the initial zoom of the PDF based on the initial size of the view and the scale factor.
|
|
52
|
+
* 0 = fit width
|
|
53
|
+
* 1 = fit height
|
|
54
|
+
* 2 = fit both
|
|
55
|
+
*/
|
|
56
|
+
fitPolicy?: 0 | 1 | 2,
|
|
50
57
|
trustAllCerts?: boolean,
|
|
51
58
|
singlePage?: boolean,
|
|
52
59
|
onLoadProgress?: (percent: number,) => void,
|
package/index.js
CHANGED
|
@@ -51,6 +51,7 @@ export default class Pdf extends Component {
|
|
|
51
51
|
enableAnnotationRendering: PropTypes.bool,
|
|
52
52
|
showsHorizontalScrollIndicator: PropTypes.bool,
|
|
53
53
|
showsVerticalScrollIndicator: PropTypes.bool,
|
|
54
|
+
scrollEnabled: PropTypes.bool,
|
|
54
55
|
enablePaging: PropTypes.bool,
|
|
55
56
|
enableRTL: PropTypes.bool,
|
|
56
57
|
fitPolicy: PropTypes.number,
|
|
@@ -86,6 +87,7 @@ export default class Pdf extends Component {
|
|
|
86
87
|
enableAnnotationRendering: true,
|
|
87
88
|
showsHorizontalScrollIndicator: true,
|
|
88
89
|
showsVerticalScrollIndicator: true,
|
|
90
|
+
scrollEnabled: true,
|
|
89
91
|
enablePaging: false,
|
|
90
92
|
enableRTL: false,
|
|
91
93
|
trustAllCerts: true,
|
|
@@ -127,7 +129,7 @@ export default class Pdf extends Component {
|
|
|
127
129
|
|
|
128
130
|
if ((nextSource.uri !== curSource.uri)) {
|
|
129
131
|
// if has download task, then cancel it.
|
|
130
|
-
if (this.lastRNBFTask) {
|
|
132
|
+
if (this.lastRNBFTask && this.lastRNBFTask.cancel) {
|
|
131
133
|
this.lastRNBFTask.cancel(err => {
|
|
132
134
|
this._loadFromSource(this.props.source);
|
|
133
135
|
});
|
|
@@ -233,7 +235,7 @@ export default class Pdf extends Component {
|
|
|
233
235
|
} else {
|
|
234
236
|
if (this._mounted) {
|
|
235
237
|
this.setState({
|
|
236
|
-
path:
|
|
238
|
+
path: decodeURIComponent(uri.replace(/file:\/\//i, '')),
|
|
237
239
|
isDownloaded: true,
|
|
238
240
|
});
|
|
239
241
|
}
|
package/index.js.flow
CHANGED
|
@@ -40,6 +40,7 @@ UIView
|
|
|
40
40
|
@property(nonatomic) BOOL horizontal;
|
|
41
41
|
@property(nonatomic) BOOL showsVerticalScrollIndicator;
|
|
42
42
|
@property(nonatomic) BOOL showsHorizontalScrollIndicator;
|
|
43
|
+
@property(nonatomic) BOOL scrollEnabled;
|
|
43
44
|
@property(nonatomic) BOOL enablePaging;
|
|
44
45
|
@property(nonatomic) BOOL enableRTL;
|
|
45
46
|
@property(nonatomic) BOOL enableAnnotationRendering;
|
|
@@ -86,6 +86,12 @@ using namespace facebook::react;
|
|
|
86
86
|
return concreteComponentDescriptorProvider<RNPDFPdfViewComponentDescriptor>();
|
|
87
87
|
}
|
|
88
88
|
|
|
89
|
+
// Needed because of this: https://github.com/facebook/react-native/pull/37274
|
|
90
|
+
+ (void)load
|
|
91
|
+
{
|
|
92
|
+
[super load];
|
|
93
|
+
}
|
|
94
|
+
|
|
89
95
|
- (instancetype)initWithFrame:(CGRect)frame
|
|
90
96
|
{
|
|
91
97
|
if (self = [super initWithFrame:frame]) {
|
|
@@ -165,6 +171,11 @@ using namespace facebook::react;
|
|
|
165
171
|
[updatedPropNames addObject:@"showsVerticalScrollIndicator"];
|
|
166
172
|
}
|
|
167
173
|
|
|
174
|
+
if (_scrollEnabled != newProps.scrollEnabled) {
|
|
175
|
+
_scrollEnabled = newProps.scrollEnabled;
|
|
176
|
+
[updatedPropNames addObject:@"scrollEnabled"];
|
|
177
|
+
}
|
|
178
|
+
|
|
168
179
|
[super updateProps:props oldProps:oldProps];
|
|
169
180
|
[self didSetProps:updatedPropNames];
|
|
170
181
|
}
|
|
@@ -252,6 +263,7 @@ using namespace facebook::react;
|
|
|
252
263
|
_singlePage = NO;
|
|
253
264
|
_showsHorizontalScrollIndicator = YES;
|
|
254
265
|
_showsVerticalScrollIndicator = YES;
|
|
266
|
+
_scrollEnabled = YES;
|
|
255
267
|
|
|
256
268
|
// init and config PDFView
|
|
257
269
|
_pdfView = [[PDFView alloc] initWithFrame:CGRectMake(0, 0, 500, 500)];
|
|
@@ -467,37 +479,23 @@ using namespace facebook::react;
|
|
|
467
479
|
}
|
|
468
480
|
}
|
|
469
481
|
|
|
470
|
-
if (_pdfDocument && ([changedProps containsObject:@"path"] || [changedProps containsObject:@"showsHorizontalScrollIndicator"])) {
|
|
471
|
-
|
|
472
|
-
for (UIView *subview in _pdfView.subviews) {
|
|
473
|
-
if ([subview isKindOfClass:[UIScrollView class]]) {
|
|
474
|
-
UIScrollView *scrollView = (UIScrollView *)subview;
|
|
475
|
-
scrollView.showsHorizontalScrollIndicator = YES;
|
|
476
|
-
}
|
|
477
|
-
}
|
|
478
|
-
} else {
|
|
479
|
-
for (UIView *subview in _pdfView.subviews) {
|
|
480
|
-
if ([subview isKindOfClass:[UIScrollView class]]) {
|
|
481
|
-
UIScrollView *scrollView = (UIScrollView *)subview;
|
|
482
|
-
scrollView.showsHorizontalScrollIndicator = NO;
|
|
483
|
-
}
|
|
484
|
-
}
|
|
485
|
-
}
|
|
482
|
+
if (_pdfDocument && ([changedProps containsObject:@"path"] || [changedProps containsObject:@"showsHorizontalScrollIndicator"] || [changedProps containsObject:@"showsVerticalScrollIndicator"])) {
|
|
483
|
+
[self setScrollIndicators:self horizontal:_showsHorizontalScrollIndicator vertical:_showsVerticalScrollIndicator depth:0];
|
|
486
484
|
}
|
|
487
485
|
|
|
488
|
-
if (_pdfDocument && ([changedProps containsObject:@"path"] || [changedProps containsObject:@"
|
|
489
|
-
if (
|
|
486
|
+
if (_pdfDocument && ([changedProps containsObject:@"path"] || [changedProps containsObject:@"scrollEnabled"])) {
|
|
487
|
+
if (_scrollEnabled) {
|
|
490
488
|
for (UIView *subview in _pdfView.subviews) {
|
|
491
489
|
if ([subview isKindOfClass:[UIScrollView class]]) {
|
|
492
490
|
UIScrollView *scrollView = (UIScrollView *)subview;
|
|
493
|
-
scrollView.
|
|
491
|
+
scrollView.scrollEnabled = YES;
|
|
494
492
|
}
|
|
495
493
|
}
|
|
496
494
|
} else {
|
|
497
495
|
for (UIView *subview in _pdfView.subviews) {
|
|
498
496
|
if ([subview isKindOfClass:[UIScrollView class]]) {
|
|
499
497
|
UIScrollView *scrollView = (UIScrollView *)subview;
|
|
500
|
-
scrollView.
|
|
498
|
+
scrollView.scrollEnabled = NO;
|
|
501
499
|
}
|
|
502
500
|
}
|
|
503
501
|
}
|
|
@@ -732,7 +730,7 @@ using namespace facebook::react;
|
|
|
732
730
|
});
|
|
733
731
|
|
|
734
732
|
// Event appears to be consumed; broadcast for JS.
|
|
735
|
-
_onChange(@{ @"message": @"pageDoubleTap" });
|
|
733
|
+
// _onChange(@{ @"message": @"pageDoubleTap" });
|
|
736
734
|
|
|
737
735
|
if (!_enableDoubleTapZoom) {
|
|
738
736
|
return;
|
|
@@ -898,6 +896,23 @@ using namespace facebook::react;
|
|
|
898
896
|
return !_singlePage;
|
|
899
897
|
}
|
|
900
898
|
|
|
899
|
+
- (void)setScrollIndicators:(UIView *)view horizontal:(BOOL)horizontal vertical:(BOOL)vertical depth:(int)depth {
|
|
900
|
+
// max depth, prevent infinite loop
|
|
901
|
+
if (depth > 10) {
|
|
902
|
+
return;
|
|
903
|
+
}
|
|
904
|
+
|
|
905
|
+
if ([view isKindOfClass:[UIScrollView class]]) {
|
|
906
|
+
UIScrollView *scrollView = (UIScrollView *)view;
|
|
907
|
+
scrollView.showsHorizontalScrollIndicator = horizontal;
|
|
908
|
+
scrollView.showsVerticalScrollIndicator = vertical;
|
|
909
|
+
}
|
|
910
|
+
|
|
911
|
+
for (UIView *subview in view.subviews) {
|
|
912
|
+
[self setScrollIndicators:subview horizontal:horizontal vertical:vertical depth:depth + 1];
|
|
913
|
+
}
|
|
914
|
+
}
|
|
915
|
+
|
|
901
916
|
@end
|
|
902
917
|
|
|
903
918
|
#ifdef RCT_NEW_ARCH_ENABLED
|
|
@@ -35,6 +35,7 @@ RCT_EXPORT_VIEW_PROPERTY(maxScale, float);
|
|
|
35
35
|
RCT_EXPORT_VIEW_PROPERTY(horizontal, BOOL);
|
|
36
36
|
RCT_EXPORT_VIEW_PROPERTY(showsHorizontalScrollIndicator, BOOL);
|
|
37
37
|
RCT_EXPORT_VIEW_PROPERTY(showsVerticalScrollIndicator, BOOL);
|
|
38
|
+
RCT_EXPORT_VIEW_PROPERTY(scrollEnabled, BOOL);
|
|
38
39
|
RCT_EXPORT_VIEW_PROPERTY(enablePaging, BOOL);
|
|
39
40
|
RCT_EXPORT_VIEW_PROPERTY(enableRTL, BOOL);
|
|
40
41
|
RCT_EXPORT_VIEW_PROPERTY(enableAnnotationRendering, BOOL);
|