1.0.35 • Published 2 months ago
rn-signature-view v1.0.35
This is signature View for React Native, made with Java / Swift + Objective-C
Properties
Prop | Type | Description |
---|---|---|
addListener | (e: Event) => void | e: "ON_STARTED" or "ON_CLEARED" |
Methods
Function | Description |
---|---|
onClear() | Clear the current signature |
onSave() | Returns base64 format of the signature with white background |
To call the methods use the useRef
hook:
import RNFS from 'react-native-fs';
import {PERMISSIONS, requestMultiple} from 'react-native-permissions';
import SignatureView from 'rn-signature-view';
export default function App() {
const ref = useRef<SignatureView>(null);
useEffect(() => {
requestMultiple(
Platform.OS === 'ios' ? [PERMISSIONS.IOS.PHOTO_LIBRARY] : [],
);
}, []);
async function onSave() {
const image_data = await ref.current?.onSave();
if (!image_data) {
return;
}
const fileName = 'signature_' + new Date().getTime().toString() + '.png';
const file_path = RNFS.DocumentDirectoryPath + '/' + fileName;
RNFS.writeFile(file_path, image_data, 'base64').then(() =>
CameraRoll.saveAsset(file_path, {}),
);
}
async function onClear() {
ref.current?.onClear();
}
return (
<SafeAreaView style={styles.container}>
<View style={styles.padContainer}>
<SignatureView
ref={ref}
addListener={e => console.log(e.nativeEvent.event)}
/>
</View>
<Button title="Save" onPress={onSave} />
<Button title="Clear" onPress={onClear} />
</SafeAreaView>
);
}
1.0.26
2 months ago
1.0.25
2 months ago
1.0.29
2 months ago
1.0.28
2 months ago
1.0.27
2 months ago
1.0.33
2 months ago
1.0.32
2 months ago
1.0.31
2 months ago
1.0.30
2 months ago
1.0.35
2 months ago
1.0.34
2 months ago
1.0.24
3 months ago
1.0.19
3 months ago
1.0.18
3 months ago
1.0.17
3 months ago
1.0.16
3 months ago
1.0.22
3 months ago
1.0.21
3 months ago
1.0.20
3 months ago
1.0.23
3 months ago
1.0.11
3 months ago
1.0.15
3 months ago
1.0.14
3 months ago
1.0.13
3 months ago
1.0.12
3 months ago
1.0.10
3 months ago
1.0.9
3 months ago
1.0.8
3 months ago
1.0.7
3 months ago
1.0.6
3 months ago
1.0.5
3 months ago
1.0.4
3 months ago
1.0.3
3 months ago
1.0.2
3 months ago
1.0.1
3 months ago
1.0.0
3 months ago