-
Notifications
You must be signed in to change notification settings - Fork 7
/
index.android.js
88 lines (67 loc) · 2.22 KB
/
index.android.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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
/**
* Sample React Native App
* https://github.com/facebook/react-native
*/
import React, {
AppRegistry,
Component,
StyleSheet,
Text,
View, TouchableHighlight
} from 'react-native';
import SignatureCapture from 'react-native-signature-capture';
class SignaturExample extends Component {
render() {
return (
<View style={{ flex: 1, flexDirection: "column" }}>
<Text style={{alignItems:"center",justifyContent:"center"}}>Signature Capture Extended </Text>
<SignatureCapture
style={[{flex:1},styles.signature]}
ref="sign"
onSaveEvent={this._onSaveEvent}
onDragEvent={this._onDragEvent}
saveImageFileInExtStorage={false}
showNativeButtons={false}
viewMode={"portrait"}/>
<View style={{ flex: 1, flexDirection: "row" }}>
<TouchableHighlight style={styles.buttonStyle}
onPress={() => { this.saveSign() } } >
<Text>Save</Text>
</TouchableHighlight>
<TouchableHighlight style={styles.buttonStyle}
onPress={() => { this.resetSign() } } >
<Text>Reset</Text>
</TouchableHighlight>
</View>
</View>
);
}
saveSign() {
this.refs["sign"].saveImage();
}
resetSign() {
this.refs["sign"].resetImage();
}
_onSaveEvent(result) {
//result.encoded - for the base64 encoded png
//result.pathName - for the file path name
console.log(result);
}
_onDragEvent() {
// This callback will be called when the user enters signature
console.log("dragged");
}
}
const styles = StyleSheet.create({
signature: {
flex: 1,
borderColor: '#000033',
borderWidth: 1,
},
buttonStyle: {
flex: 1, justifyContent: "center", alignItems: "center", height: 50,
backgroundColor: "#eeeeee",
margin: 10
}
});
AppRegistry.registerComponent('SignaturExample', () => SignaturExample);