File tree Expand file tree Collapse file tree 3 files changed +28
-8
lines changed Expand file tree Collapse file tree 3 files changed +28
-8
lines changed Original file line number Diff line number Diff line change @@ -5,24 +5,28 @@ React native package to capture user scribbling on screen and converting it to a
5
5
## Installation
6
6
7
7
``` sh
8
- npm install react-native-scribble
8
+ npm i @keyvaluesystems/ react-native-scribble
9
9
```
10
10
11
11
## Usage
12
12
13
13
``` jsx
14
+ import { SvgCapture ,useSvgCapture } from ' @keyvaluesystems/react-native-scribble' ;
15
+ // ...
14
16
const signatureProps = useSvgCapture ();
15
17
const { clearPad , getFilePath } = signatureProps;
16
18
17
19
const handleFileGeneration = async () => {
18
20
const filePath = await getFilePath ();
19
21
};
20
22
// ...
21
- <>
22
- < SvgCapture {... signatureProps} / >
23
- < Button title= " Clear" onClick= {clearPad} / >
24
- < Button title= " Save" onClick= {handleFileGeneration} / >
25
- < / >
23
+ return (
24
+ <>
25
+ < SvgCapture {... signatureProps} / >
26
+ < Button title= " Clear" onClick= {clearPad} / >
27
+ < Button title= " Save" onClick= {handleFileGeneration} / >
28
+ < / >
29
+ );
26
30
```
27
31
28
32
## Contributing
Original file line number Diff line number Diff line change 1
1
import React from 'react' ;
2
+ import type { ColorValue } from 'react-native' ;
2
3
import {
3
4
type GestureResponderEvent ,
4
5
type LayoutChangeEvent ,
@@ -8,10 +9,18 @@ import {
8
9
type StyleProp ,
9
10
} from 'react-native' ;
10
11
import Svg , { G , Polyline } from 'react-native-svg' ;
12
+ import {
13
+ DEFAULT_STROKE_COLOR ,
14
+ DEFAULT_STROKE_WIDTH ,
15
+ } from '../constants/common' ;
11
16
12
17
type CaptureSignatureProps = {
13
18
paths : number [ ] [ ] ;
14
19
canvasStyle ?: StyleProp < ViewStyle > ;
20
+ strokeConfig ?: {
21
+ strokeColor : ColorValue ;
22
+ strokeWidth : number ;
23
+ } ;
15
24
handleOnTouchStart : ( e : GestureResponderEvent ) => void ;
16
25
handleOnTouchMove : ( e : GestureResponderEvent ) => void ;
17
26
handleLayout : ( e : LayoutChangeEvent ) => void ;
@@ -20,6 +29,7 @@ type CaptureSignatureProps = {
20
29
const SvgCapture = ( {
21
30
paths,
22
31
canvasStyle,
32
+ strokeConfig,
23
33
handleOnTouchStart,
24
34
handleOnTouchMove,
25
35
handleLayout,
@@ -40,8 +50,10 @@ const SvgCapture = ({
40
50
key = { JSON . stringify ( item ) }
41
51
points = { item }
42
52
fill = "transparent"
43
- stroke = "blue"
44
- strokeWidth = "3"
53
+ stroke = { strokeConfig ?. strokeColor || DEFAULT_STROKE_COLOR }
54
+ strokeWidth = {
55
+ strokeConfig ?. strokeWidth || DEFAULT_STROKE_WIDTH
56
+ }
45
57
/>
46
58
) ;
47
59
} ) }
Original file line number Diff line number Diff line change
1
+ const DEFAULT_STROKE_WIDTH = 3 ;
2
+ const DEFAULT_STROKE_COLOR = 'black' ;
3
+
4
+ export { DEFAULT_STROKE_COLOR , DEFAULT_STROKE_WIDTH } ;
You can’t perform that action at this time.
0 commit comments