Skip to content

Commit 4fb8263

Browse files
author
irgendeinich
committed
Remove deprecated UIManager.RCTPSPDFKitView and use UIManager.getViewManagerConfig('RCTPSPDFKitView') instead
Update testing project to use FlatList instead of ListView
1 parent 43cb95b commit 4fb8263

File tree

2 files changed

+20
-27
lines changed

2 files changed

+20
-27
lines changed

index.js

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ class PSPDFKitView extends React.Component {
9393
if (Platform.OS === "android") {
9494
UIManager.dispatchViewManagerCommand(
9595
findNodeHandle(this.refs.pdfView),
96-
UIManager.RCTPSPDFKitView.Commands.enterAnnotationCreationMode,
96+
UIManager.getViewManagerConfig('RCTPSPDFKitView').Commands.enterAnnotationCreationMode,
9797
[]
9898
);
9999
} else if (Platform.OS === "ios") {
@@ -110,7 +110,7 @@ class PSPDFKitView extends React.Component {
110110
if (Platform.OS === "android") {
111111
UIManager.dispatchViewManagerCommand(
112112
findNodeHandle(this.refs.pdfView),
113-
UIManager.RCTPSPDFKitView.Commands.exitCurrentlyActiveMode,
113+
UIManager.getViewManagerConfig('RCTPSPDFKitView').Commands.exitCurrentlyActiveMode,
114114
[]
115115
);
116116
} else if (Platform.OS === "ios") {
@@ -127,7 +127,7 @@ class PSPDFKitView extends React.Component {
127127
if (Platform.OS === "android") {
128128
UIManager.dispatchViewManagerCommand(
129129
findNodeHandle(this.refs.pdfView),
130-
UIManager.RCTPSPDFKitView.Commands.saveCurrentDocument,
130+
UIManager.getViewManagerConfig('RCTPSPDFKitView').Commands.saveCurrentDocument,
131131
[]
132132
);
133133
} else if (Platform.OS === "ios") {
@@ -158,7 +158,7 @@ class PSPDFKitView extends React.Component {
158158

159159
UIManager.dispatchViewManagerCommand(
160160
findNodeHandle(this.refs.pdfView),
161-
UIManager.RCTPSPDFKitView.Commands.getAnnotations,
161+
UIManager.getViewManagerConfig('RCTPSPDFKitView').Commands.getAnnotations,
162162
[requestId, pageIndex, type]
163163
);
164164

@@ -181,7 +181,7 @@ class PSPDFKitView extends React.Component {
181181
if (Platform.OS === "android") {
182182
UIManager.dispatchViewManagerCommand(
183183
findNodeHandle(this.refs.pdfView),
184-
UIManager.RCTPSPDFKitView.Commands.addAnnotation,
184+
UIManager.getViewManagerConfig('RCTPSPDFKitView').Commands.addAnnotation,
185185
[annotation]
186186
);
187187
} else if (Platform.OS === "ios") {
@@ -201,7 +201,7 @@ class PSPDFKitView extends React.Component {
201201
if (Platform.OS === "android") {
202202
UIManager.dispatchViewManagerCommand(
203203
findNodeHandle(this.refs.pdfView),
204-
UIManager.RCTPSPDFKitView.Commands.removeAnnotation,
204+
UIManager.getViewManagerConfig('RCTPSPDFKitView').Commands.removeAnnotation,
205205
[annotation]
206206
);
207207
} else if (Platform.OS === "ios") {
@@ -229,7 +229,7 @@ class PSPDFKitView extends React.Component {
229229

230230
UIManager.dispatchViewManagerCommand(
231231
findNodeHandle(this.refs.pdfView),
232-
UIManager.RCTPSPDFKitView.Commands.getAllUnsavedAnnotations,
232+
UIManager.getViewManagerConfig('RCTPSPDFKitView').Commands.getAllUnsavedAnnotations,
233233
[requestId]
234234
);
235235

@@ -250,7 +250,7 @@ class PSPDFKitView extends React.Component {
250250
if (Platform.OS === "android") {
251251
UIManager.dispatchViewManagerCommand(
252252
findNodeHandle(this.refs.pdfView),
253-
UIManager.RCTPSPDFKitView.Commands.addAnnotations,
253+
UIManager.getViewManagerConfig('RCTPSPDFKitView').Commands.addAnnotations,
254254
[annotations]
255255
);
256256
} else if (Platform.OS === "ios") {
@@ -281,7 +281,7 @@ class PSPDFKitView extends React.Component {
281281

282282
UIManager.dispatchViewManagerCommand(
283283
findNodeHandle(this.refs.pdfView),
284-
UIManager.RCTPSPDFKitView.Commands.getFormFieldValue,
284+
UIManager.getViewManagerConfig('RCTPSPDFKitView').Commands.getFormFieldValue,
285285
[requestId, fullyQualifiedName]
286286
);
287287

@@ -304,7 +304,7 @@ class PSPDFKitView extends React.Component {
304304
if (Platform.OS === "android") {
305305
UIManager.dispatchViewManagerCommand(
306306
findNodeHandle(this.refs.pdfView),
307-
UIManager.RCTPSPDFKitView.Commands.setFormFieldValue,
307+
UIManager.getViewManagerConfig('RCTPSPDFKitView').Commands.setFormFieldValue,
308308
[fullyQualifiedName, value]
309309
);
310310
} else if (Platform.OS === "ios") {

samples/Catalog/testing/Testing.js

Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import {
77
Button,
88
Image,
99
TouchableHighlight,
10-
ListView,
10+
FlatList,
1111
NativeModules,
1212
processColor,
1313
PermissionsAndroid,
@@ -53,23 +53,13 @@ class CatalogScreen extends Component<{}> {
5353
title: "Test Cases"
5454
};
5555

56-
// Initialize the hardcoded data
57-
constructor(props) {
58-
super(props);
59-
const ds = new ListView.DataSource({
60-
rowHasChanged: (r1, r2) => r1 !== r2
61-
});
62-
this.state = {
63-
dataSource: ds.cloneWithRows(examples)
64-
};
65-
}
66-
6756
render() {
6857
return (
6958
<View style={styles.page}>
70-
<ListView
71-
dataSource={this.state.dataSource}
72-
renderRow={this._renderRow}
59+
<FlatList
60+
data={examples}
61+
keyExtractor={this._keyExtractor}
62+
renderItem={this._renderRow}
7363
renderSeparator={this._renderSeparator}
7464
contentContainerStyle={styles.listContainer}
7565
style={styles.list}
@@ -78,21 +68,24 @@ class CatalogScreen extends Component<{}> {
7868
);
7969
}
8070

71+
_keyExtractor = (item, index) => item.name;
72+
8173
_renderSeparator(sectionId, rowId) {
8274
return <View key={rowId} style={styles.separator} />;
8375
}
8476

8577
_renderRow = example => {
78+
console.log(example)
8679
return (
8780
<TouchableHighlight
8881
onPress={() => {
89-
example.action(this);
82+
example.item.action(this);
9083
}}
9184
style={styles.row}
9285
underlayColor="#209cca50"
9386
>
9487
<View style={styles.rowContent}>
95-
<Text style={styles.name}>{example.name}</Text>
88+
<Text style={styles.name}>{example.item.name}</Text>
9689
</View>
9790
</TouchableHighlight>
9891
);

0 commit comments

Comments
 (0)