### Run the Expo example app (start, android, ios) Source: https://github.com/sectiontn/react-native-inkpad/blob/main/CONTRIBUTING.md Start Metro with `yarn example start`, then build and launch the app with `yarn example android` or `yarn example ios`. The first native run creates `example/android` and `example/ios` via `expo prebuild`. ```sh yarn example start yarn example android yarn example ios ``` -------------------------------- ### Install React Native Inkpad Source: https://github.com/sectiontn/react-native-inkpad/blob/main/README.md Install the package via npm and install the necessary iOS pods. ```sh npm install react-native-inkpad cd ios && pod install ``` -------------------------------- ### Install dependencies with Yarn Source: https://github.com/sectiontn/react-native-inkpad/blob/main/CONTRIBUTING.md Run from the repo root after selecting the Node version in .nvmrc. The repo is a Yarn workspace, so npm will not install it without changes. ```sh yarn ``` -------------------------------- ### getStrokes() Source: https://github.com/sectiontn/react-native-inkpad/blob/main/README.md Get the strokes as a plain object you can store as JSON. ```APIDOC ## getStrokes() ### Description Get the strokes as a plain object you can store as JSON. ### Method getStrokes ### Parameters None ### Response Returns a plain object representing the strokes. ``` -------------------------------- ### redo() Source: https://github.com/sectiontn/react-native-inkpad/blob/main/README.md Step forward through the history. ```APIDOC ## redo() ### Description Step forward through the history. ### Method redo ### Parameters None ### Response None ``` -------------------------------- ### toImage({ format, quality, scale, trim, background, base64 }) Source: https://github.com/sectiontn/react-native-inkpad/blob/main/README.md Export a PNG or JPEG. Resolves to `{ uri, width, height, base64? }`. ```APIDOC ## toImage({ format, quality, scale, trim, background, base64 }) ### Description Export a PNG or JPEG. Resolves to `{ uri, width, height, base64? }`. ### Method toImage ### Parameters - **format** (string) - Optional - Image format (e.g., 'png' or 'jpeg'). - **quality** (number) - Optional - Image quality. - **scale** (number) - Optional - Scale factor. - **trim** (object) - Optional - Trim options. - **background** (object) - Optional - Background color. - **base64** (boolean) - Optional - Whether to include base64 data. ### Response Resolves to an object with `uri`, `width`, `height`, and optionally `base64`. ``` -------------------------------- ### undo() Source: https://github.com/sectiontn/react-native-inkpad/blob/main/README.md Step back through the history. ```APIDOC ## undo() ### Description Step back through the history. ### Method undo ### Parameters None ### Response None ``` -------------------------------- ### toSVG({ trim, background }) Source: https://github.com/sectiontn/react-native-inkpad/blob/main/README.md Export an SVG string. ```APIDOC ## toSVG({ trim, background }) ### Description Export an SVG string. ### Method toSVG ### Parameters - **trim** (object) - Optional - Trim options. - **background** (object) - Optional - Background color. ### Response Returns an SVG string. ``` -------------------------------- ### Update import statement Source: https://github.com/sectiontn/react-native-inkpad/blob/main/README.md Replace the existing react-native-signature-canvas import with the new react-native-inkpad path. ```diff - import SignatureCanvas from 'react-native-signature-canvas'; + import SignatureCanvas from 'react-native-inkpad/signature-canvas'; ``` -------------------------------- ### Implement InkCanvas in a React Native component Source: https://github.com/sectiontn/react-native-inkpad/blob/main/README.md Shows how to use the InkCanvas component with a reference to trigger the toImage method for saving the drawing. ```tsx import { useRef } from 'react'; import { Button, View } from 'react-native'; import { InkCanvas, type InkCanvasRef } from 'react-native-inkpad'; export function SignatureField() { const canvas = useRef(null); const save = async () => { const image = await canvas.current?.toImage({ trim: { padding: 8 } }); console.log(image?.uri); }; return (