-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.js
69 lines (61 loc) · 1.44 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
import React from 'react';
import {
requireNativeComponent,
findNodeHandle,
UIManager,
} from 'react-native';
const MuPdfView = requireNativeComponent('RCTMuPdfMini');
export default class extends React.Component {
static defaultProps = {
page: Number,
scale: Number,
minScale: Number,
maxScale: Number,
};
_setReference = ref => {
if (ref) {
this._handle = findNodeHandle(ref);
} else {
this._handle = null;
}
};
/**
* Search text
*
* @param startPage Int
* @param direction 1:search next, -1:search forward
* @param needle String key word
*
* **/
search = (startPage, direction, needle) => {
UIManager.dispatchViewManagerCommand(
this._handle,
UIManager.RCTMuPdfMini.Commands.search,
[startPage, direction, needle],
);
};
resetSearch = () => {
UIManager.dispatchViewManagerCommand(
this._handle,
UIManager.RCTMuPdfMini.Commands.resetSearch,
null,
);
};
render() {
return <MuPdfView ref={this._setReference} {...this.props} />;
}
addAnnotation = (annotation) => {
UIManager.dispatchViewManagerCommand(
this._handle,
UIManager.RCTMuPdfMini.Commands.addAnnotation,
[annotation],
);
};
deleteAnnotation = index => {
UIManager.dispatchViewManagerCommand(
this._handle,
UIManager.RCTMuPdfMini.Commands.deleteAnnotation,
[index],
);
};
}