-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
41 lines (34 loc) · 875 Bytes
/
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
import React, { Component } from 'react'
import PropTypes from 'prop-types';
import {
requireNativeComponent,
NativeModules,
findNodeHandle,
processColor
} from 'react-native'
const Canvas = requireNativeComponent('Canvas', CanvasView);
export default class CanvasView extends Component {
getSnapshot = () => {
const snapshot = NativeModules.ViewSnapshot;
const viewId = findNodeHandle(this.view);
return snapshot.getSnapshot(viewId);
}
render () {
const { documentName, paths, ...props } = this.props;
const parsedPaths = paths.map(path => ({
...path,
color: processColor(path.color)
}));
return (
<Canvas
ref={canvas => (this.view = canvas)}
{...props}
paths={parsedPaths}
/>
)
}
}
CanvasView.propTypes = {
strokeWidth: PropTypes.number,
color: PropTypes.string,
};