I just want here to update and simplify Android install and code : I use last 0.72.6 React Native
install:
just yarn add react-native-signature-capture
usage example:
import React, {useRef} from 'react';
const EcranSignature = () => {
const signRef = useRef(null);
saveSign = () => {
signRef.current.saveImage();
//then reset
resetSign();
};
resetSign = () => {
signRef.current.resetImage();
console.log('image reseted');
};
onSaveEvent = result => {
//result.encoded - for the base64 encoded png
//result.pathName - for the file path name
console.log('signature:', result);
};
onDragEvent = () => {
// This callback will be called when the user enters signature
console.log('dragged');
};
return (
<SafeAreaView style={{flex: 1, flexDirection: 'column'}}>
<Text style={{alignItems: 'center', justifyContent: 'center'}}>
signature reception
</Text>
<SignatureCapture
style={[{flex:1},styles.signature]}
ref={signRef}
onSaveEvent={onSaveEvent}
onDragEvent={onDragEvent}
saveImageFileInExtStorage={false}
showNativeButtons={false}
showTitleLabel={false}
backgroundColor="#ff00ff"
strokeColor="#ffffff"
minStrokeWidth={4}
maxStrokeWidth={4}
viewMode={'portrait'}
/>
<View style={{flex: 1, flexDirection: 'row'}}>
<TouchableOpacity
style={styles.buttonStyle}
onPress={() => {
saveSign();
}}>
<Text>Save</Text>
</TouchableOpacity>
<TouchableOpacity
style={styles.buttonStyle}
onPress={() => {
resetSign();
}}>
<Text>Reset</Text>
</TouchableOpacity>
</View>
</SafeAreaView>
);
};
then use this component as
I just want here to update and simplify Android install and code : I use last 0.72.6 React Native
install:
just
yarn add react-native-signature-captureusage example:
then use this component as