npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@cbawa/react-native-signature-view

v1.0.0

Published

This package provide options to draw and type your signature. This package does not require any dependency module.

Downloads

10

Readme

@cbawa/react-native-signature-view

demo-gif

React Native Sign View module is developed for both Android and iOS. This package offers two signing options: Draw and Type. It does not require any dependencies, like react-native-webview.

  • Supports Android and iOS
  • Tested with RN 0.72
  • Draw your Signature
  • Type your Signature and plugin will draw it for you
  • Change font size of typed signature via slider.
  • No dependencies required, like react-native-webview

Installation(for React Native v0.60.0 or greater)

yarn add @cbawa/react-native-signature-view

or

npm install --save @cbawa/react-native-signature-view

- For Android - Autolinking will do it's magic.

- For iOS

$ npx pod-install

If you want to use the same font in iOS as we have in Android. You can download the font form here and follow the steps below:

  • Create new group Assets inside root folder of your project
  • Create new group Fonts inside Assets folder.
  • Drap and Drop the downloaded font inside Fonts folder.
  • Check copy items if needed
  • Select create groups
  • Inside Add to targets, select project name as target
  • Open info.plist form your project
  • Add a new row inside info.plist and type Fonts provided by application
  • Expand Fonts provided by application and add font name (eg: Signature.ttf) as the value of item 0

Usage

import * as React from 'react';
import { StyleSheet } from 'react-native';
import RNSignatureView from '@cbawa/react-native-signature-view';

const App = () => {
  return (
    <RNSignatureView
      style={styles.signatureView}
      onGetSign={(event) => {
        console.log(event.nativeEvent.sign);
      }}
    />
  );
};

const styles = StyleSheet.create({
  signatureView: {
    width: '100%',
    height: 200,
    borderWidth: 1,
  },
});

export default App;

Properties


| Prop | Type | Description | | :---------------------------------- | :--------------------------------------: | :---------------------------------------------------------------------------------------------------------------------------------------------------- | | style | object | styles the RNSignatureView container | | onGetSign| (event) => { console.log(event.nativeEvent.sign) } | gives you base64 string for your signature | | selectedTabColor| string | changes selected tab color. Default color is "#333" | | selectedTabTextColor| string | changes selected tab text color. Default color is "#fff" | | unselectedTabColor| string | changes unselected tab color. Default color is "#ddd" | | unselectedTabTextColor| string | changes unselected tab text color. Default color is "#333" | | seekBarColor| string | changes slider color inside Type option. Default color is "#333" | | clearText| string | changes Clear button text. Default text is "Clear" | | getSignText| string | changes Get Sign button text. Default text is "Get Sign" | | capsTabText| boolean | shows tabs text in capital letters. Default is false | | capsButtonText| boolean | shows buttons text in capital letters. Default is false | | clearButtonBgColor| string | changes Clear button background color. Default color is "#ddd" | | clearTextColor| string | changes Clear button text color. Default color is "#333" | | getSignButtonBgColor| string | changes Get Sign button background color. Default color is "#333" | | getSignTextColor| string | changes Get Sign button text color. Default color is "#fff" | | strokeColor| string | changes stroke color in both Draw and Type options. Default color is "#000" | | drawStrokeWidth| number | changes stroke width in Draw option. Default value is 10 | | onDrawBegin| () => void | is called when a stroke is started in Draw option | | onDrawEnd| () => void | is called when a stroke is ended in Draw option | | onClear| () => void | is called when Clear button is pressed. |

Example

import * as React from 'react';
import { Image, Platform, StyleSheet, View } from 'react-native';
import RNSignatureView from '@cbawa/react-native-signature-view';

const App = () => {
  const [sign, setSign] = React.useState('');
  return (
    <View style={styles.container}>
      <RNSignatureView
        style={styles.signatureView}
        selectedTabColor="#080"
        selectedTabTextColor="#fff"
        unselectedTabColor="#ddd"
        unselectedTabTextColor="#333"
        seekBarColor="#080"
        clearText="Wipe"
        getSignText="Capture"
        capsTabText
        capsButtonText
        clearButtonBgColor="#ddd"
        clearTextColor="#333"
        getSignButtonBgColor="#080"
        getSignTextColor="#fff"
        strokeColor="#080"
        drawStrokeWidth={14}
        onGetSign={(event) => {
          setSign(event.nativeEvent.sign);
        }}
        onClear={() => setSign('')}
      />
      {sign && (
        <View style={styles.view}>
          <Image
            source={{ uri: `data:image/png;base64,${sign}` }}
            alt="sign"
            style={styles.signImage}
          />
        </View>
      )}
    </View>
  );
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    alignItems: 'center',
    justifyContent: 'center',
    padding: 20,
  },
  signatureView: {
    width: '100%',
    height: 200,
    borderWidth: 1,
  },
  view: {
    width: '100%',
    height: 100,
    padding: 5,
    borderWidth: 1,
    borderColor: 'black',
    marginTop: 10,
  },
  signImage: {
    width: '100%',
    height: '100%',
    objectFit: 'contain',
    backgroundColor: 'white',
  },
});

export default App;

Example inside ScrollView

If you are going to use RNSignatureView inside a ScrollView, you must use onDrawBegin and onDrawEnd functions to enable/disable the scroll event of the Scrollview. Otherwise, Scrollview would highjack the touch and move event form RNSignatureView's canvas, while drawing a signature. Here's an example:

import * as React from 'react';
import { Image, ScrollView, StyleSheet, View, Text } from 'react-native';
import RNSignatureView from '@cbawa/react-native-signature-view';

const App = () => {
  const [scrollEnabled, setScrollEnabled] = React.useState(true);
  const [sign, setSign] = React.useState('');
  return (
    <ScrollView scrollEnabled={scrollEnabled}>
      <View style={styles.container}>
        <View style={styles.view}>
          <Text style={styles.text}>One View</Text>
        </View>
        <RNSignatureView
          style={styles.signatureView}
          onGetSign={(event) => {
            setSign(event.nativeEvent.sign);
          }}
          onDrawBegin={() => setScrollEnabled(false)}
          onDrawEnd={() => setScrollEnabled(true)}
          onClear={() => setSign('')}
        />
        {sign && (
          <View style={styles.view}>
            <Image
              source={{ uri: `data:image/png;base64,${sign}` }}
              alt="sign"
              style={styles.signImage}
            />
          </View>
        )}
        <View style={styles.view}>
          <Text style={styles.text}>Another View</Text>
        </View>
      </View>
    </ScrollView>
  );
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    padding: 20,
  },
  signatureView: {
    width: '100%',
    height: 180,
    marginTop: 10,
  },
  view: {
    width: '100%',
    height: 140,
    padding: 5,
    borderWidth: 1,
    borderColor: 'black',
    marginTop: 10,
  },
  signImage: {
    width: '100%',
    height: '100%',
    objectFit: 'contain',
    backgroundColor: 'white',
  },
  text: {
    color: '#333',
    textAlign: 'center',
    fontWeight: '600',
  },
});

export default App;

Contributing

See the contributing guide to learn how to contribute to the repository and the development workflow.

License

MIT


Made with create-react-native-library