代码拉取完成,页面将自动刷新
'use strict';
var ReactNative = require('react-native');
var React = require('react');
var PropTypes = require('prop-types');
var {
requireNativeComponent,
View,
UIManager,
DeviceEventEmitter
} = ReactNative;
class SignatureCapture extends React.Component {
constructor() {
super();
this.onChange = this.onChange.bind(this);
this.subscriptions = [];
}
onChange(event) {
if (event.nativeEvent.pathName) {
if (!this.props.onSaveEvent) {
return;
}
this.props.onSaveEvent({
pathName: event.nativeEvent.pathName,
encoded: event.nativeEvent.encoded,
});
}
if (event.nativeEvent.dragged) {
if (!this.props.onDragEvent) {
return;
}
this.props.onDragEvent({
dragged: event.nativeEvent.dragged
});
}
}
componentDidMount() {
if (this.props.onSaveEvent) {
let sub = DeviceEventEmitter.addListener(
'onSaveEvent',
this.props.onSaveEvent
);
this.subscriptions.push(sub);
}
if (this.props.onDragEvent) {
let sub = DeviceEventEmitter.addListener(
'onDragEvent',
this.props.onDragEvent
);
this.subscriptions.push(sub);
}
}
componentWillUnmount() {
this.subscriptions.forEach(sub => sub.remove());
this.subscriptions = [];
}
render() {
return (
<RSSignatureView {...this.props} onChange={this.onChange}/>
);
}
getViewManagerConfig = (
viewManagerName
) => {
if (!UIManager.getViewManagerConfig) {
return UIManager[viewManagerName];
}
return UIManager.getViewManagerConfig(viewManagerName);
};
saveImage() {
UIManager.dispatchViewManagerCommand(
ReactNative.findNodeHandle(this),
this.getViewManagerConfig('RSSignatureView').Commands.saveImage,
[],
);
}
resetImage() {
UIManager.dispatchViewManagerCommand(
ReactNative.findNodeHandle(this),
this.getViewManagerConfig('RSSignatureView').Commands.resetImage,
[],
);
}
}
SignatureCapture.propTypes = {
...View.propTypes,
rotateClockwise: PropTypes.bool,
square: PropTypes.bool,
saveImageFileInExtStorage: PropTypes.bool,
viewMode: PropTypes.string,
showBorder: PropTypes.bool,
showNativeButtons: PropTypes.bool,
showTitleLabel: PropTypes.bool,
maxSize: PropTypes.number,
minStrokeWidth: PropTypes.number,
maxStrokeWidth: PropTypes.number,
strokeColor: PropTypes.string,
backgroundColor: PropTypes.string
};
var RSSignatureView = requireNativeComponent('RSSignatureView', SignatureCapture, {
nativeOnly: {onChange: true}
});
module.exports = SignatureCapture;
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。