Skip to content

documentation simplification for Android install and use #298

Description

@Productivix

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions