forked from prscX/react-native-photo-editor
-
Notifications
You must be signed in to change notification settings - Fork 0
/
RNPhotoEditor.js
58 lines (50 loc) · 1.31 KB
/
RNPhotoEditor.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
import React, { PureComponent } from "react";
import { ViewPropTypes, NativeModules, Platform } from "react-native";
import PropTypes from "prop-types";
const { RNPhotoEditor } = NativeModules;
class PhotoEditor extends PureComponent {
static propTypes = {
...ViewPropTypes,
path: PropTypes.string,
stickers: PropTypes.array,
controls: PropTypes.array,
colors: PropTypes.array,
onDone: PropTypes.func,
onCancel: PropTypes.func
};
static defaultProps = {
stickers: [],
hiddenControls: [],
colors: [
"#000000",
"#808080",
"#a9a9a9",
"#FFFFFE",
"#0000ff",
"#00ff00",
"#ff0000",
"#ffff00",
"#ffa500",
"#800080",
"#00ffff",
"#a52a2a",
"#ff00ff"
]
};
static Edit(props) {
if (props.stickers === undefined)
props.stickers = PhotoEditor.defaultProps.stickers;
if (props.hiddenControls === undefined) props.hiddenControls = PhotoEditor.defaultProps.hiddenControls;
if (props.colors === undefined) props.colors = PhotoEditor.defaultProps.colors
RNPhotoEditor.Edit(
props,
(...args) => {
props.onDone && props.onDone(...args);
},
(...args) => {
props.onCancel && props.onCancel(...args);
}
);
}
}
export { PhotoEditor as RNPhotoEditor }