1.0.35 • Published 1 year 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
1 year ago
1.0.25
1 year ago
1.0.29
1 year ago
1.0.28
1 year ago
1.0.27
1 year ago
1.0.33
1 year ago
1.0.32
1 year ago
1.0.31
1 year ago
1.0.30
1 year ago
1.0.35
1 year ago
1.0.34
1 year ago
1.0.24
1 year ago
1.0.19
1 year ago
1.0.18
1 year ago
1.0.17
1 year ago
1.0.16
1 year ago
1.0.22
1 year ago
1.0.21
1 year ago
1.0.20
1 year ago
1.0.23
1 year ago
1.0.11
1 year ago
1.0.15
1 year ago
1.0.14
1 year ago
1.0.13
1 year ago
1.0.12
1 year ago
1.0.10
1 year ago
1.0.9
1 year ago
1.0.8
1 year ago
1.0.7
1 year ago
1.0.6
1 year ago
1.0.5
1 year ago
1.0.4
1 year ago
1.0.3
1 year ago
1.0.2
1 year ago
1.0.1
1 year ago
1.0.0
1 year ago