Skip to content

Commit 3963653

Browse files
author
Reinhard Hafenscher
authored
Merge pull request #248 from PSPDFKit/reinhard/0.57-compatibility
Add support for old way of accessing the view manager config
2 parents 7ca348c + dc8ae8a commit 3963653

File tree

4 files changed

+22
-13
lines changed

4 files changed

+22
-13
lines changed

index.js

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ class PSPDFKitView extends React.Component {
100100
if (Platform.OS === "android") {
101101
UIManager.dispatchViewManagerCommand(
102102
findNodeHandle(this.refs.pdfView),
103-
UIManager.getViewManagerConfig('RCTPSPDFKitView').Commands.enterAnnotationCreationMode,
103+
this._getViewManagerConfig('RCTPSPDFKitView').Commands.enterAnnotationCreationMode,
104104
[]
105105
);
106106
} else if (Platform.OS === "ios") {
@@ -117,7 +117,7 @@ class PSPDFKitView extends React.Component {
117117
if (Platform.OS === "android") {
118118
UIManager.dispatchViewManagerCommand(
119119
findNodeHandle(this.refs.pdfView),
120-
UIManager.getViewManagerConfig('RCTPSPDFKitView').Commands.exitCurrentlyActiveMode,
120+
this._getViewManagerConfig('RCTPSPDFKitView').Commands.exitCurrentlyActiveMode,
121121
[]
122122
);
123123
} else if (Platform.OS === "ios") {
@@ -134,7 +134,7 @@ class PSPDFKitView extends React.Component {
134134
if (Platform.OS === "android") {
135135
UIManager.dispatchViewManagerCommand(
136136
findNodeHandle(this.refs.pdfView),
137-
UIManager.getViewManagerConfig('RCTPSPDFKitView').Commands.saveCurrentDocument,
137+
this._getViewManagerConfig('RCTPSPDFKitView').Commands.saveCurrentDocument,
138138
[]
139139
);
140140
} else if (Platform.OS === "ios") {
@@ -165,7 +165,7 @@ class PSPDFKitView extends React.Component {
165165

166166
UIManager.dispatchViewManagerCommand(
167167
findNodeHandle(this.refs.pdfView),
168-
UIManager.getViewManagerConfig('RCTPSPDFKitView').Commands.getAnnotations,
168+
this._getViewManagerConfig('RCTPSPDFKitView').Commands.getAnnotations,
169169
[requestId, pageIndex, type]
170170
);
171171

@@ -188,7 +188,7 @@ class PSPDFKitView extends React.Component {
188188
if (Platform.OS === "android") {
189189
UIManager.dispatchViewManagerCommand(
190190
findNodeHandle(this.refs.pdfView),
191-
UIManager.getViewManagerConfig('RCTPSPDFKitView').Commands.addAnnotation,
191+
this._getViewManagerConfig('RCTPSPDFKitView').Commands.addAnnotation,
192192
[annotation]
193193
);
194194
} else if (Platform.OS === "ios") {
@@ -208,7 +208,7 @@ class PSPDFKitView extends React.Component {
208208
if (Platform.OS === "android") {
209209
UIManager.dispatchViewManagerCommand(
210210
findNodeHandle(this.refs.pdfView),
211-
UIManager.getViewManagerConfig('RCTPSPDFKitView').Commands.removeAnnotation,
211+
this._getViewManagerConfig('RCTPSPDFKitView').Commands.removeAnnotation,
212212
[annotation]
213213
);
214214
} else if (Platform.OS === "ios") {
@@ -236,7 +236,7 @@ class PSPDFKitView extends React.Component {
236236

237237
UIManager.dispatchViewManagerCommand(
238238
findNodeHandle(this.refs.pdfView),
239-
UIManager.getViewManagerConfig('RCTPSPDFKitView').Commands.getAllUnsavedAnnotations,
239+
this._getViewManagerConfig('RCTPSPDFKitView').Commands.getAllUnsavedAnnotations,
240240
[requestId]
241241
);
242242

@@ -257,7 +257,7 @@ class PSPDFKitView extends React.Component {
257257
if (Platform.OS === "android") {
258258
UIManager.dispatchViewManagerCommand(
259259
findNodeHandle(this.refs.pdfView),
260-
UIManager.getViewManagerConfig('RCTPSPDFKitView').Commands.addAnnotations,
260+
this._getViewManagerConfig('RCTPSPDFKitView').Commands.addAnnotations,
261261
[annotations]
262262
);
263263
} else if (Platform.OS === "ios") {
@@ -288,7 +288,7 @@ class PSPDFKitView extends React.Component {
288288

289289
UIManager.dispatchViewManagerCommand(
290290
findNodeHandle(this.refs.pdfView),
291-
UIManager.getViewManagerConfig('RCTPSPDFKitView').Commands.getFormFieldValue,
291+
this._getViewManagerConfig('RCTPSPDFKitView').Commands.getFormFieldValue,
292292
[requestId, fullyQualifiedName]
293293
);
294294

@@ -311,7 +311,7 @@ class PSPDFKitView extends React.Component {
311311
if (Platform.OS === "android") {
312312
UIManager.dispatchViewManagerCommand(
313313
findNodeHandle(this.refs.pdfView),
314-
UIManager.getViewManagerConfig('RCTPSPDFKitView').Commands.setFormFieldValue,
314+
this._getViewManagerConfig('RCTPSPDFKitView').Commands.setFormFieldValue,
315315
[fullyQualifiedName, value]
316316
);
317317
} else if (Platform.OS === "ios") {
@@ -396,6 +396,15 @@ class PSPDFKitView extends React.Component {
396396
);
397397
}
398398
};
399+
400+
_getViewManagerConfig = viewManagerName => {
401+
const version = NativeModules.PlatformConstants.reactNativeVersion.minor
402+
if (version >= 58) {
403+
return UIManager.getViewManagerConfig(viewManagerName);
404+
} else {
405+
return UIManager[viewManagerName];
406+
}
407+
};
399408
}
400409

401410
PSPDFKitView.propTypes = {

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-native-pspdfkit",
3-
"version": "1.24.3",
3+
"version": "1.24.4",
44
"description": "A React Native module for the PSPDFKit library.",
55
"keywords": [
66
"react native",

samples/Catalog/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "Catalog",
3-
"version": "1.24.3",
3+
"version": "1.24.4",
44
"private": true,
55
"scripts": {
66
"start": "node node_modules/react-native/local-cli/cli.js start"

0 commit comments

Comments
 (0)