File tree Expand file tree Collapse file tree 2 files changed +13
-4
lines changed Expand file tree Collapse file tree 2 files changed +13
-4
lines changed Original file line number Diff line number Diff line change @@ -4,26 +4,30 @@ import {
4
4
type LayoutChangeEvent ,
5
5
View ,
6
6
StyleSheet ,
7
+ type ViewStyle ,
8
+ type StyleProp ,
7
9
} from 'react-native' ;
8
10
import Svg , { G , Polyline } from 'react-native-svg' ;
9
11
10
12
type CaptureSignatureProps = {
11
13
paths : number [ ] [ ] ;
14
+ canvasStyle ?: StyleProp < ViewStyle > ;
12
15
handleOnTouchStart : ( e : GestureResponderEvent ) => void ;
13
16
handleOnTouchMove : ( e : GestureResponderEvent ) => void ;
14
17
handleLayout : ( e : LayoutChangeEvent ) => void ;
15
18
} ;
16
19
17
20
const SvgCapture = ( {
18
21
paths,
22
+ canvasStyle,
19
23
handleOnTouchStart,
20
24
handleOnTouchMove,
21
25
handleLayout,
22
26
} : CaptureSignatureProps ) => {
23
27
return (
24
28
< View style = { styles . canvasAndControlWrapper } >
25
29
< View
26
- style = { styles . canvas }
30
+ style = { [ styles . canvas , canvasStyle ] }
27
31
onTouchStart = { handleOnTouchStart }
28
32
onTouchMove = { handleOnTouchMove }
29
33
onLayout = { handleLayout }
@@ -55,7 +59,6 @@ const styles = StyleSheet.create({
55
59
} ,
56
60
canvas : {
57
61
flex : 1 ,
58
- backgroundColor : '#e0e0e0' ,
59
62
} ,
60
63
} ) ;
61
64
Original file line number Diff line number Diff line change @@ -8,7 +8,7 @@ const useSvgCapture = () => {
8
8
9
9
const handleSetLowestPoints = ( x : number , y : number ) => {
10
10
if ( x < lowestPoints . current . x ) {
11
- lowestPoints . current . x = y ;
11
+ lowestPoints . current . x = x ;
12
12
}
13
13
if ( y < lowestPoints . current . y ) {
14
14
lowestPoints . current . y = y ;
@@ -90,9 +90,14 @@ const useSvgCapture = () => {
90
90
</svg>` ;
91
91
} ;
92
92
93
- const getFilePath = ( ) => {
93
+ const getSvgAsString = ( ) => {
94
94
const cleanedSvgPath = getCleanedSvgImage ( ) ;
95
95
const svgString = pathsToSVG ( cleanedSvgPath ) ;
96
+ return svgString ;
97
+ } ;
98
+
99
+ const getFilePath = async ( ) : Promise < string > => {
100
+ const svgString = getSvgAsString ( ) ;
96
101
const svgBlob = svgStringToBlob ( svgString ) ;
97
102
return svgBlob ;
98
103
} ;
@@ -104,6 +109,7 @@ const useSvgCapture = () => {
104
109
handleLayout,
105
110
clearPad,
106
111
getFilePath,
112
+ getSvgAsString,
107
113
} ;
108
114
} ;
109
115
You can’t perform that action at this time.
0 commit comments