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

@archireport/react-native-svg-draw

v2.2.1

Published

React Native drawing component based on SVG with editable annotations

Downloads

110

Readme

react-native-svg-draw

React Native drawing component based on SVG with editable annotations

Drawing Example

Features

  • Draw arrow, rectangle, ellipse ... on picture or blank view
  • Compatible with Expo
  • Built with react-native-reanimated v2
  • Save result with react-native-view-shot
  • Fully customisable

Installation

Bare react native app


npm install @archireport/react-native-svg-draw react-native-reanimated react-native-gesture-handler react-native-svg react-native-view-shot react-native-linear-gradient

Expo


expo install @archireport/react-native-svg-draw react-native-reanimated react-native-gesture-handler react-native-svg react-native-view-shot expo-linear-gradient

⚠️ extra steps are required

React Native Gesture Handler needs extra steps to finalize its installation, please follow their installation instructions.

React Native Reanimated needs extra steps to finalize its installation, please follow their installation instructions.


Usage

Bare react native app

import { DrawWithOptions } from 'react-native-svg-draw';
import LinearGradient from 'react-native-linear-gradient';

// ...
  <DrawWithOptions linearGradient={LinearGradient} />

Expo

import { DrawWithOptions } from 'react-native-svg-draw';
import { LinearGradient } from 'expo-linear-gradient';

// ...
  <DrawWithOptions linearGradient={LinearGradient} />

How it works

You have 2 options

Use DrawWithOptions provided by the lib

Fast and easy way to use the lib. Example :

  <DrawWithOptions
    linearGradient={LinearGradient}
    image={require('./pexels-sebastian-palomino-2847766.jpg')}
    close={() => true}
    takeSnapshot={(snap) => {
      snap.then((uri) => console.log('snapShot uri:', uri));
    }}
  />

Use your own "DrawWithOptions" component

You can create your own "DrawWithOptions" component and customize the ui.

You will need to use DrawCore component wrapped in DrawProvider context.

<DrawProvider>
  <DrawCore image={require('./pexels-sebastian-palomino-2847766.jpg')}/>
</DrawProvider>

Then you can use the hook "useDrawHook" inside your components to interact with the context. This hook expose a lot of functions and objects that can be used to interact with the DrawCore.

  const {
    drawState,
    dispatchDrawStates,
    itemIsSelected,
    cancelLastAction,
    deleteSelectedItem,
    ...
  } = useDrawHook();

useDrawHook

| Name | Type | Description | | --------------------- | ---------------------- | --------------------------------------------------------------------------------------------------------- | | strokeWidth | shared value(number) | Object from react-native-reanimated, get and set value => strokeWidth.value | | color | shared value(hslColor) | Object from react-native-reanimated, get and set value => color.value | | onColorStrokeChange | function | Function use when changing color or strokeWidth is done to memorize action for undo | | drawState | object | Get the selected drawingMode : 'singleHead','doubleHead','rectangle','ellipse','text','pen', cancelEnabled is true when last action can be canceled, doneItems contains all previous draw items and screenStates helps to go back in time (cancel pops last state) | | dispatchDrawStates | function | Can be used to update drawingMode | | itemIsSelected | shared value(boolean) | Object from react-native-reanimated Indicate if an item is selected, to get value => itemIsSelected.value | | cancelLastAction | function | Call this function when user press your undo button | | takeSnapshot | function | This async function will return the uri of your drawing | | deleteSelectedItem | function | Call this function when you want to delete the selected item |

Recommendation

Copy the drawWithOptions component, sliders component and adjust styles to match your theme

Components

DrawWithOptions

Component with header and footer, based on DrawCore

Properties

| Name | Type | Description | | ---------------- | --------------- | ---------------------------------------------------------------------------------------- | | close | function | (optional) called when cross is pressed | | takeSnapshot | function | (optional) called when send button (at the top right) is pressed | | linearGradient | React Component | implementation used for linear gradient (differs between expo and bare react native app) | | image | image | (optional) background picture | | backgroundColor | string | (optional) background color of the draw zone |

DrawCore

Component where the user can draw

Properties

| Name | Type | Description | | ----------------- | ------ | -------------------------------------------- | | image | image | (optional) background picture | | backgroundColor | string | (optional) background color of the draw zone |

Contributing

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

License

MIT