@archireport/react-native-svg-draw 1.4.0 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +73 -27
- package/lib/commonjs/components/DrawCore/CurrentAnimatedItem.js +10 -5
- package/lib/commonjs/components/DrawCore/CurrentAnimatedItem.js.map +1 -1
- package/lib/commonjs/components/DrawCore/CurrentAnimatedText.js.map +1 -1
- package/lib/commonjs/components/DrawCore/DrawContext.js +18 -0
- package/lib/commonjs/components/DrawCore/DrawContext.js.map +1 -0
- package/lib/commonjs/components/DrawCore/DrawPad.js.map +1 -1
- package/lib/commonjs/components/DrawCore/DrawProvider.js +103 -0
- package/lib/commonjs/components/DrawCore/DrawProvider.js.map +1 -0
- package/lib/commonjs/components/DrawCore/Item.js.map +1 -1
- package/lib/commonjs/components/DrawCore/index.js +41 -168
- package/lib/commonjs/components/DrawCore/index.js.map +1 -1
- package/lib/commonjs/components/DrawCore/useDrawHook.js +76 -0
- package/lib/commonjs/components/DrawCore/useDrawHook.js.map +1 -0
- package/lib/commonjs/components/DrawWithOptions/ArrowSvg.js.map +1 -1
- package/lib/commonjs/components/DrawWithOptions/CancelSvg.js.map +1 -1
- package/lib/commonjs/components/DrawWithOptions/CircleSvg.js.map +1 -1
- package/lib/commonjs/components/DrawWithOptions/CloseSvg.js.map +1 -1
- package/lib/commonjs/components/DrawWithOptions/DoubleHeadSvg.js.map +1 -1
- package/lib/commonjs/components/DrawWithOptions/PenSvg.js.map +1 -1
- package/lib/commonjs/components/DrawWithOptions/SendSvg.js.map +1 -1
- package/lib/commonjs/components/DrawWithOptions/SliderSvg.js +31 -0
- package/lib/commonjs/components/DrawWithOptions/SliderSvg.js.map +1 -0
- package/lib/commonjs/components/DrawWithOptions/SquareSvg.js.map +1 -1
- package/lib/commonjs/components/DrawWithOptions/TextSvg.js.map +1 -1
- package/lib/commonjs/components/DrawWithOptions/ThrashSvg.js +27 -2
- package/lib/commonjs/components/DrawWithOptions/ThrashSvg.js.map +1 -1
- package/lib/commonjs/components/DrawWithOptions/index.js +124 -70
- package/lib/commonjs/components/DrawWithOptions/index.js.map +1 -1
- package/lib/commonjs/components/{DrawCore → Slider}/ColorSlider.js +45 -62
- package/lib/commonjs/components/Slider/ColorSlider.js.map +1 -0
- package/lib/commonjs/components/Slider/Sliders.js +88 -0
- package/lib/commonjs/components/Slider/Sliders.js.map +1 -0
- package/lib/commonjs/components/{DrawCore → Slider}/StrokeSlider.js +38 -47
- package/lib/commonjs/components/Slider/StrokeSlider.js.map +1 -0
- package/lib/commonjs/components/Slider/sliderStyle.js +37 -0
- package/lib/commonjs/components/Slider/sliderStyle.js.map +1 -0
- package/lib/commonjs/index.js +7 -0
- package/lib/commonjs/index.js.map +1 -1
- package/lib/module/components/DrawCore/CurrentAnimatedItem.js +10 -5
- package/lib/module/components/DrawCore/CurrentAnimatedItem.js.map +1 -1
- package/lib/module/components/DrawCore/CurrentAnimatedText.js.map +1 -1
- package/lib/module/components/DrawCore/DrawContext.js +11 -0
- package/lib/module/components/DrawCore/DrawContext.js.map +1 -0
- package/lib/module/components/DrawCore/DrawPad.js.map +1 -1
- package/lib/module/components/DrawCore/DrawProvider.js +94 -0
- package/lib/module/components/DrawCore/DrawProvider.js.map +1 -0
- package/lib/module/components/DrawCore/Item.js.map +1 -1
- package/lib/module/components/DrawCore/index.js +43 -170
- package/lib/module/components/DrawCore/index.js.map +1 -1
- package/lib/module/components/DrawCore/useDrawHook.js +69 -0
- package/lib/module/components/DrawCore/useDrawHook.js.map +1 -0
- package/lib/module/components/DrawWithOptions/ArrowSvg.js.map +1 -1
- package/lib/module/components/DrawWithOptions/CancelSvg.js.map +1 -1
- package/lib/module/components/DrawWithOptions/CircleSvg.js.map +1 -1
- package/lib/module/components/DrawWithOptions/CloseSvg.js.map +1 -1
- package/lib/module/components/DrawWithOptions/DoubleHeadSvg.js.map +1 -1
- package/lib/module/components/DrawWithOptions/PenSvg.js.map +1 -1
- package/lib/module/components/DrawWithOptions/SendSvg.js.map +1 -1
- package/lib/module/components/DrawWithOptions/SliderSvg.js +22 -0
- package/lib/module/components/DrawWithOptions/SliderSvg.js.map +1 -0
- package/lib/module/components/DrawWithOptions/SquareSvg.js.map +1 -1
- package/lib/module/components/DrawWithOptions/TextSvg.js.map +1 -1
- package/lib/module/components/DrawWithOptions/ThrashSvg.js +27 -2
- package/lib/module/components/DrawWithOptions/ThrashSvg.js.map +1 -1
- package/lib/module/components/DrawWithOptions/index.js +124 -70
- package/lib/module/components/DrawWithOptions/index.js.map +1 -1
- package/lib/module/components/Slider/ColorSlider.js +95 -0
- package/lib/module/components/Slider/ColorSlider.js.map +1 -0
- package/lib/module/components/Slider/Sliders.js +79 -0
- package/lib/module/components/Slider/Sliders.js.map +1 -0
- package/lib/module/components/Slider/StrokeSlider.js +82 -0
- package/lib/module/components/Slider/StrokeSlider.js.map +1 -0
- package/lib/module/components/Slider/sliderStyle.js +29 -0
- package/lib/module/components/Slider/sliderStyle.js.map +1 -0
- package/lib/module/index.js +1 -0
- package/lib/module/index.js.map +1 -1
- package/lib/typescript/components/DrawCore/CurrentAnimatedItem.d.ts.map +1 -1
- package/lib/typescript/components/DrawCore/DrawContext.d.ts +14 -0
- package/lib/typescript/components/DrawCore/DrawContext.d.ts.map +1 -0
- package/lib/typescript/components/DrawCore/DrawPad.d.ts.map +1 -1
- package/lib/typescript/components/DrawCore/DrawProvider.d.ts +6 -0
- package/lib/typescript/components/DrawCore/DrawProvider.d.ts.map +1 -0
- package/lib/typescript/components/DrawCore/index.d.ts +3 -11
- package/lib/typescript/components/DrawCore/index.d.ts.map +1 -1
- package/lib/typescript/components/DrawCore/useDrawHook.d.ts +18 -0
- package/lib/typescript/components/DrawCore/useDrawHook.d.ts.map +1 -0
- package/lib/typescript/components/DrawWithOptions/SliderSvg.d.ts +4 -0
- package/lib/typescript/components/DrawWithOptions/SliderSvg.d.ts.map +1 -0
- package/lib/typescript/components/DrawWithOptions/ThrashSvg.d.ts.map +1 -1
- package/lib/typescript/components/DrawWithOptions/index.d.ts +3 -5
- package/lib/typescript/components/DrawWithOptions/index.d.ts.map +1 -1
- package/lib/typescript/components/Slider/ColorSlider.d.ts +8 -0
- package/lib/typescript/components/Slider/ColorSlider.d.ts.map +1 -0
- package/lib/typescript/components/Slider/Sliders.d.ts +8 -0
- package/lib/typescript/components/Slider/Sliders.d.ts.map +1 -0
- package/lib/typescript/components/Slider/StrokeSlider.d.ts +6 -0
- package/lib/typescript/components/Slider/StrokeSlider.d.ts.map +1 -0
- package/lib/typescript/components/Slider/sliderStyle.d.ts +28 -0
- package/lib/typescript/components/Slider/sliderStyle.d.ts.map +1 -0
- package/lib/typescript/index.d.ts +1 -0
- package/lib/typescript/index.d.ts.map +1 -1
- package/package.json +22 -22
- package/src/components/DrawCore/CurrentAnimatedItem.tsx +10 -5
- package/src/components/DrawCore/DrawContext.tsx +22 -0
- package/src/components/DrawCore/DrawPad.tsx +0 -1
- package/src/components/DrawCore/DrawProvider.tsx +122 -0
- package/src/components/DrawCore/index.tsx +938 -1139
- package/src/components/DrawCore/useDrawHook.tsx +70 -0
- package/src/components/DrawWithOptions/SliderSvg.tsx +24 -0
- package/src/components/DrawWithOptions/ThrashSvg.tsx +29 -2
- package/src/components/DrawWithOptions/index.tsx +199 -146
- package/src/components/Slider/ColorSlider.tsx +144 -0
- package/src/components/Slider/Sliders.tsx +75 -0
- package/src/components/Slider/StrokeSlider.tsx +104 -0
- package/src/components/Slider/sliderStyle.tsx +28 -0
- package/src/index.tsx +1 -0
- package/src/types.d.ts +35 -1
- package/lib/commonjs/components/DrawCore/ColorSlider.js.map +0 -1
- package/lib/commonjs/components/DrawCore/StrokeSlider.js.map +0 -1
- package/lib/module/components/DrawCore/ColorSlider.js +0 -113
- package/lib/module/components/DrawCore/ColorSlider.js.map +0 -1
- package/lib/module/components/DrawCore/StrokeSlider.js +0 -91
- package/lib/module/components/DrawCore/StrokeSlider.js.map +0 -1
- package/lib/typescript/components/DrawCore/ColorSlider.d.ts +0 -13
- package/lib/typescript/components/DrawCore/ColorSlider.d.ts.map +0 -1
- package/lib/typescript/components/DrawCore/StrokeSlider.d.ts +0 -9
- package/lib/typescript/components/DrawCore/StrokeSlider.d.ts.map +0 -1
- package/src/components/DrawCore/ColorSlider.tsx +0 -169
- package/src/components/DrawCore/StrokeSlider.tsx +0 -117
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { DrawContext } from './DrawContext';
|
|
2
|
+
import { useCallback, useContext } from 'react';
|
|
3
|
+
|
|
4
|
+
const useDrawHook = () => {
|
|
5
|
+
const {
|
|
6
|
+
drawState,
|
|
7
|
+
dispatchDrawStates,
|
|
8
|
+
strokeWidth,
|
|
9
|
+
color,
|
|
10
|
+
currentItem,
|
|
11
|
+
itemIsSelected,
|
|
12
|
+
viewShot,
|
|
13
|
+
} = useContext(DrawContext);
|
|
14
|
+
|
|
15
|
+
const takeSnapshot = useCallback(async () => {
|
|
16
|
+
if (currentItem?.value) {
|
|
17
|
+
dispatchDrawStates({ type: 'ADD_DONE_ITEM', item: currentItem.value });
|
|
18
|
+
currentItem.value = null;
|
|
19
|
+
}
|
|
20
|
+
return viewShot!.current?.capture?.();
|
|
21
|
+
}, [currentItem, dispatchDrawStates, viewShot]);
|
|
22
|
+
|
|
23
|
+
const cancelLastAction = useCallback(() => {
|
|
24
|
+
itemIsSelected!.value = false;
|
|
25
|
+
if (currentItem?.value) {
|
|
26
|
+
currentItem.value = null;
|
|
27
|
+
}
|
|
28
|
+
dispatchDrawStates({
|
|
29
|
+
type: 'CANCEL',
|
|
30
|
+
});
|
|
31
|
+
}, [currentItem, dispatchDrawStates, itemIsSelected]);
|
|
32
|
+
|
|
33
|
+
const deleteSelectedItem = useCallback(() => {
|
|
34
|
+
if (currentItem?.value) {
|
|
35
|
+
currentItem.value = null;
|
|
36
|
+
dispatchDrawStates({
|
|
37
|
+
type: 'ADD_SCREEN_STATE',
|
|
38
|
+
currentItem: currentItem.value,
|
|
39
|
+
cancelEnabled: true,
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
itemIsSelected!.value = false;
|
|
43
|
+
}, [currentItem, dispatchDrawStates, itemIsSelected]);
|
|
44
|
+
|
|
45
|
+
const onColorStrokeChange = useCallback(() => {
|
|
46
|
+
'worklet';
|
|
47
|
+
if (currentItem?.value) {
|
|
48
|
+
dispatchDrawStates({
|
|
49
|
+
type: 'ADD_SCREEN_STATE',
|
|
50
|
+
currentItem: currentItem.value,
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
}, [currentItem?.value, dispatchDrawStates]);
|
|
54
|
+
|
|
55
|
+
return {
|
|
56
|
+
drawState: drawState!,
|
|
57
|
+
dispatchDrawStates,
|
|
58
|
+
currentItem: currentItem!,
|
|
59
|
+
strokeWidth: strokeWidth!,
|
|
60
|
+
color: color!,
|
|
61
|
+
onColorStrokeChange,
|
|
62
|
+
itemIsSelected: itemIsSelected!,
|
|
63
|
+
cancelLastAction,
|
|
64
|
+
takeSnapshot: takeSnapshot!,
|
|
65
|
+
viewShot: viewShot!,
|
|
66
|
+
deleteSelectedItem,
|
|
67
|
+
};
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
export default useDrawHook;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { View } from 'react-native';
|
|
3
|
+
import Svg, { SvgProps, Path } from 'react-native-svg';
|
|
4
|
+
|
|
5
|
+
function SvgSlider(props: SvgProps) {
|
|
6
|
+
return (
|
|
7
|
+
<View style={{ aspectRatio: 10, justifyContent: 'center' }}>
|
|
8
|
+
<Svg
|
|
9
|
+
width="100%"
|
|
10
|
+
height="100%"
|
|
11
|
+
viewBox="0 0 189 6"
|
|
12
|
+
fill="none"
|
|
13
|
+
{...props}
|
|
14
|
+
>
|
|
15
|
+
<Path
|
|
16
|
+
d="M0.99994 4.01059C0.445985 4.00473 -7.21155e-08 3.554 -1.31135e-07 3.00001C-1.90155e-07 2.44602 0.445985 1.99529 0.999941 1.98943L186 0.0317445C187.652 0.0142669 189 1.3483 189 3C189 4.65169 187.652 5.98572 186 5.96825L0.99994 4.01059Z"
|
|
17
|
+
fill="currentColor"
|
|
18
|
+
/>
|
|
19
|
+
</Svg>
|
|
20
|
+
</View>
|
|
21
|
+
);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export default SvgSlider;
|
|
@@ -3,8 +3,35 @@ import Svg, { SvgProps, Path } from 'react-native-svg';
|
|
|
3
3
|
|
|
4
4
|
function ThrashSvg(props: SvgProps) {
|
|
5
5
|
return (
|
|
6
|
-
<Svg viewBox="0 0
|
|
7
|
-
<Path
|
|
6
|
+
<Svg width="25" height="25" viewBox="0 0 25 25" fill="none" {...props}>
|
|
7
|
+
<Path
|
|
8
|
+
d="M3.5 6.5L5.5 6.5L21.5 6.5"
|
|
9
|
+
stroke="currentColor"
|
|
10
|
+
stroke-width="2"
|
|
11
|
+
stroke-linecap="round"
|
|
12
|
+
stroke-linejoin="round"
|
|
13
|
+
/>
|
|
14
|
+
<Path
|
|
15
|
+
d="M8.5 6.5V4.5C8.5 3.96957 8.71071 3.46086 9.08579 3.08579C9.46086 2.71071 9.96957 2.5 10.5 2.5L14.5 2.5C15.0304 2.5 15.5391 2.71071 15.9142 3.08579C16.2893 3.46086 16.5 3.96957 16.5 4.5V6.5M19.5 6.5L19.5 20.5C19.5 21.0304 19.2893 21.5391 18.9142 21.9142C18.5391 22.2893 18.0304 22.5 17.5 22.5L7.5 22.5C6.96957 22.5 6.46086 22.2893 6.08579 21.9142C5.71071 21.5391 5.5 21.0304 5.5 20.5L5.5 6.5L19.5 6.5Z"
|
|
16
|
+
stroke="currentColor"
|
|
17
|
+
stroke-width="2"
|
|
18
|
+
stroke-linecap="round"
|
|
19
|
+
stroke-linejoin="round"
|
|
20
|
+
/>
|
|
21
|
+
<Path
|
|
22
|
+
d="M10.5 11.5L10.5 17.5"
|
|
23
|
+
stroke="currentColor"
|
|
24
|
+
stroke-width="2"
|
|
25
|
+
stroke-linecap="round"
|
|
26
|
+
stroke-linejoin="round"
|
|
27
|
+
/>
|
|
28
|
+
<Path
|
|
29
|
+
d="M14.5 11.5L14.5 17.5"
|
|
30
|
+
stroke="currentColor"
|
|
31
|
+
stroke-width="2"
|
|
32
|
+
stroke-linecap="round"
|
|
33
|
+
stroke-linejoin="round"
|
|
34
|
+
/>
|
|
8
35
|
</Svg>
|
|
9
36
|
);
|
|
10
37
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { useCallback, useEffect,
|
|
1
|
+
import React, { useCallback, useEffect, useState } from 'react';
|
|
2
2
|
import {
|
|
3
3
|
Pressable,
|
|
4
4
|
View,
|
|
@@ -8,39 +8,49 @@ import {
|
|
|
8
8
|
ImageURISource,
|
|
9
9
|
Keyboard,
|
|
10
10
|
} from 'react-native';
|
|
11
|
-
import DrawCore from '../DrawCore';
|
|
12
|
-
import type { DrawItemType, DrawCoreProps } from '../../types';
|
|
13
|
-
import PenSvg from './PenSvg';
|
|
14
11
|
import DoubleHeadSvg from './DoubleHeadSvg';
|
|
15
12
|
import CircleSvg from './CircleSvg';
|
|
16
13
|
import SquareSvg from './SquareSvg';
|
|
17
14
|
import ArrowSvg from './ArrowSvg';
|
|
18
15
|
import TextSvg from './TextSvg';
|
|
19
16
|
import CloseSvg from './CloseSvg';
|
|
17
|
+
import PenSvg from './PenSvg';
|
|
18
|
+
import useDrawHook from '../DrawCore/useDrawHook';
|
|
19
|
+
import Sliders from '../Slider/Sliders';
|
|
20
|
+
import DrawCore from '../DrawCore';
|
|
20
21
|
import ThrashSvg from './ThrashSvg';
|
|
21
|
-
import SendSvg from './SendSvg';
|
|
22
22
|
import CancelSvg from './CancelSvg';
|
|
23
|
+
import SendSvg from './SendSvg';
|
|
23
24
|
|
|
24
25
|
const styles = StyleSheet.create({
|
|
25
|
-
container: { flex: 1
|
|
26
|
+
container: { flex: 1 },
|
|
27
|
+
actionButton: {
|
|
28
|
+
backgroundColor: 'grey',
|
|
29
|
+
padding: 10,
|
|
30
|
+
justifyContent: 'center',
|
|
31
|
+
alignContent: 'center',
|
|
32
|
+
alignItems: 'center',
|
|
33
|
+
height: 40,
|
|
34
|
+
borderRadius: 20,
|
|
35
|
+
width: 40,
|
|
36
|
+
},
|
|
26
37
|
option: {
|
|
27
|
-
width:
|
|
28
|
-
height:
|
|
38
|
+
width: 22,
|
|
39
|
+
height: 20,
|
|
29
40
|
justifyContent: 'center',
|
|
30
41
|
alignItems: 'center',
|
|
31
|
-
marginHorizontal:
|
|
42
|
+
marginHorizontal: 8,
|
|
32
43
|
},
|
|
33
44
|
toolbar: {
|
|
34
45
|
flexDirection: 'row',
|
|
35
|
-
alignItems: 'center',
|
|
36
46
|
justifyContent: 'space-between',
|
|
37
47
|
paddingBottom: 30,
|
|
38
48
|
paddingTop: 15,
|
|
39
49
|
paddingHorizontal: 15,
|
|
40
50
|
},
|
|
41
51
|
drawOptions: {
|
|
42
|
-
|
|
43
|
-
|
|
52
|
+
flex: 1,
|
|
53
|
+
paddingHorizontal: 10,
|
|
44
54
|
},
|
|
45
55
|
sendButton: {
|
|
46
56
|
backgroundColor: '#3a6cff',
|
|
@@ -61,33 +71,25 @@ const styles = StyleSheet.create({
|
|
|
61
71
|
},
|
|
62
72
|
});
|
|
63
73
|
|
|
64
|
-
export default function
|
|
65
|
-
close,
|
|
66
|
-
takeSnapshot,
|
|
74
|
+
export default function DrawWithOption({
|
|
67
75
|
linearGradient,
|
|
68
76
|
image,
|
|
69
|
-
|
|
77
|
+
close,
|
|
78
|
+
takeSnapshot,
|
|
70
79
|
}: {
|
|
71
|
-
close?: () => void;
|
|
72
|
-
takeSnapshot?: (snap: Promise<string | undefined>) => void;
|
|
73
80
|
linearGradient: React.ComponentType<{ colors: any[] } & ViewProps>;
|
|
74
81
|
image?: ImageRequireSource | ImageURISource;
|
|
75
|
-
|
|
82
|
+
close?: () => void;
|
|
83
|
+
takeSnapshot?: (snap: Promise<string | undefined>) => void;
|
|
76
84
|
}) {
|
|
77
|
-
const
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
const onPressSend = useCallback(() => {
|
|
87
|
-
if (drawRef.current) {
|
|
88
|
-
takeSnapshot?.(drawRef.current.takeSnapshot());
|
|
89
|
-
}
|
|
90
|
-
}, [takeSnapshot]);
|
|
85
|
+
const {
|
|
86
|
+
itemIsSelected,
|
|
87
|
+
cancelLastAction,
|
|
88
|
+
takeSnapshot: takeSnapshotAction,
|
|
89
|
+
deleteSelectedItem,
|
|
90
|
+
dispatchDrawStates,
|
|
91
|
+
drawState,
|
|
92
|
+
} = useDrawHook();
|
|
91
93
|
|
|
92
94
|
const [showToolbar, setShowToolbar] = useState(true);
|
|
93
95
|
|
|
@@ -96,12 +98,15 @@ export default function DrawWithOptions({
|
|
|
96
98
|
setShowToolbar(true);
|
|
97
99
|
});
|
|
98
100
|
|
|
99
|
-
const sudDidShow = Keyboard.addListener(
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
101
|
+
const sudDidShow = Keyboard.addListener(
|
|
102
|
+
'keyboardDidShow',
|
|
103
|
+
(event: { endCoordinates: { height: number } }) => {
|
|
104
|
+
// avoid events triggered by InputAccessoryView
|
|
105
|
+
if (event.endCoordinates.height > 100) {
|
|
106
|
+
setShowToolbar(false);
|
|
107
|
+
}
|
|
103
108
|
}
|
|
104
|
-
|
|
109
|
+
);
|
|
105
110
|
|
|
106
111
|
// cleanup function
|
|
107
112
|
return () => {
|
|
@@ -110,136 +115,184 @@ export default function DrawWithOptions({
|
|
|
110
115
|
};
|
|
111
116
|
}, []);
|
|
112
117
|
|
|
118
|
+
const takeSnapshotAndGetUri = useCallback(async () => {
|
|
119
|
+
if (takeSnapshot) {
|
|
120
|
+
takeSnapshot(takeSnapshotAction());
|
|
121
|
+
}
|
|
122
|
+
}, [takeSnapshot, takeSnapshotAction]);
|
|
113
123
|
return (
|
|
114
124
|
<View style={styles.container}>
|
|
115
125
|
<View style={styles.toolbar}>
|
|
116
|
-
<
|
|
117
|
-
<
|
|
118
|
-
|
|
119
|
-
<View style={styles.drawOptions}>
|
|
120
|
-
<Pressable
|
|
121
|
-
style={styles.option}
|
|
122
|
-
onPress={() => {
|
|
123
|
-
setDrawingMode('pen');
|
|
124
|
-
}}
|
|
125
|
-
>
|
|
126
|
-
<PenSvg
|
|
127
|
-
height={23}
|
|
128
|
-
width={22}
|
|
129
|
-
stroke="#ffffff"
|
|
130
|
-
strokeWidth="2"
|
|
131
|
-
opacity={drawingMode === 'pen' ? 1 : 0.5}
|
|
132
|
-
/>
|
|
133
|
-
</Pressable>
|
|
134
|
-
<Pressable
|
|
135
|
-
style={styles.option}
|
|
136
|
-
onPress={() => {
|
|
137
|
-
setDrawingMode('doubleHead');
|
|
138
|
-
}}
|
|
139
|
-
>
|
|
140
|
-
<DoubleHeadSvg
|
|
141
|
-
height={20}
|
|
142
|
-
width={20}
|
|
143
|
-
fill="#ffffff"
|
|
144
|
-
opacity={drawingMode === 'doubleHead' ? 1 : 0.5}
|
|
145
|
-
/>
|
|
146
|
-
</Pressable>
|
|
147
|
-
<Pressable
|
|
148
|
-
style={styles.option}
|
|
149
|
-
onPress={() => {
|
|
150
|
-
setDrawingMode('singleHead');
|
|
151
|
-
}}
|
|
152
|
-
>
|
|
153
|
-
<ArrowSvg
|
|
154
|
-
height={23}
|
|
155
|
-
width={23}
|
|
156
|
-
fill="#ffffff"
|
|
157
|
-
opacity={drawingMode === 'singleHead' ? 1 : 0.5}
|
|
158
|
-
/>
|
|
159
|
-
</Pressable>
|
|
160
|
-
<Pressable
|
|
161
|
-
style={styles.option}
|
|
162
|
-
onPress={() => {
|
|
163
|
-
setDrawingMode('rectangle');
|
|
164
|
-
}}
|
|
165
|
-
>
|
|
166
|
-
<SquareSvg
|
|
167
|
-
height={27}
|
|
168
|
-
width={27}
|
|
169
|
-
fill="#ffffff"
|
|
170
|
-
opacity={drawingMode === 'rectangle' ? 1 : 0.5}
|
|
171
|
-
/>
|
|
126
|
+
<View style={styles.actionButton}>
|
|
127
|
+
<Pressable onPress={close}>
|
|
128
|
+
<CloseSvg height={20} width={20} fill="#ffffff" />
|
|
172
129
|
</Pressable>
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
</Pressable>
|
|
186
|
-
|
|
187
|
-
<Pressable
|
|
188
|
-
style={styles.option}
|
|
189
|
-
onPress={() => {
|
|
190
|
-
setDrawingMode('text');
|
|
130
|
+
</View>
|
|
131
|
+
<View style={styles.drawOptions}>
|
|
132
|
+
<View
|
|
133
|
+
style={{
|
|
134
|
+
flexDirection: 'row',
|
|
135
|
+
alignSelf: 'center',
|
|
136
|
+
borderWidth: 1,
|
|
137
|
+
borderColor: 'grey',
|
|
138
|
+
borderRadius: 25,
|
|
139
|
+
height: 40,
|
|
140
|
+
paddingHorizontal: 10,
|
|
141
|
+
paddingVertical: 10,
|
|
191
142
|
}}
|
|
192
143
|
>
|
|
193
|
-
<TextSvg
|
|
194
|
-
height={28}
|
|
195
|
-
width={28}
|
|
196
|
-
fill="#ffffff"
|
|
197
|
-
opacity={drawingMode === 'text' ? 1 : 0.5}
|
|
198
|
-
/>
|
|
199
|
-
</Pressable>
|
|
200
|
-
</View>
|
|
201
|
-
</View>
|
|
202
|
-
<DrawCore
|
|
203
|
-
ref={drawRef}
|
|
204
|
-
drawingMode={drawingMode}
|
|
205
|
-
image={image}
|
|
206
|
-
linearGradient={linearGradient}
|
|
207
|
-
onSelectionChange={setSelectedItem}
|
|
208
|
-
onCancelChange={setCancelEnabled}
|
|
209
|
-
/>
|
|
210
|
-
|
|
211
|
-
{showToolbar ? (
|
|
212
|
-
<View style={styles.bottomToolBar}>
|
|
213
|
-
{selectedItem ? (
|
|
214
144
|
<Pressable
|
|
215
145
|
style={styles.option}
|
|
216
146
|
onPress={() => {
|
|
217
|
-
|
|
147
|
+
dispatchDrawStates({
|
|
148
|
+
type: 'SET_DRAWING_MODE',
|
|
149
|
+
drawingMode: 'pen',
|
|
150
|
+
});
|
|
218
151
|
}}
|
|
219
152
|
>
|
|
220
|
-
<
|
|
153
|
+
<PenSvg
|
|
154
|
+
height={23}
|
|
155
|
+
width={22}
|
|
156
|
+
stroke="#ffffff"
|
|
157
|
+
strokeWidth="2"
|
|
158
|
+
opacity={drawState.drawingMode === 'pen' ? 1 : 0.5}
|
|
159
|
+
/>
|
|
221
160
|
</Pressable>
|
|
222
|
-
) : null}
|
|
223
|
-
{cancelEnabled ? (
|
|
224
161
|
<Pressable
|
|
225
162
|
style={styles.option}
|
|
226
163
|
onPress={() => {
|
|
227
|
-
|
|
164
|
+
dispatchDrawStates({
|
|
165
|
+
type: 'SET_DRAWING_MODE',
|
|
166
|
+
drawingMode: 'doubleHead',
|
|
167
|
+
});
|
|
228
168
|
}}
|
|
229
169
|
>
|
|
230
|
-
<
|
|
231
|
-
|
|
170
|
+
<DoubleHeadSvg
|
|
171
|
+
height={20}
|
|
172
|
+
width={20}
|
|
173
|
+
fill="#ffffff"
|
|
174
|
+
opacity={drawState.drawingMode === 'doubleHead' ? 1 : 0.5}
|
|
175
|
+
/>
|
|
176
|
+
</Pressable>
|
|
177
|
+
<Pressable
|
|
178
|
+
style={styles.option}
|
|
179
|
+
onPress={() => {
|
|
180
|
+
dispatchDrawStates({
|
|
181
|
+
type: 'SET_DRAWING_MODE',
|
|
182
|
+
drawingMode: 'singleHead',
|
|
183
|
+
});
|
|
184
|
+
}}
|
|
185
|
+
>
|
|
186
|
+
<ArrowSvg
|
|
187
|
+
height={23}
|
|
188
|
+
width={23}
|
|
189
|
+
fill="#ffffff"
|
|
190
|
+
opacity={drawState.drawingMode === 'singleHead' ? 1 : 0.5}
|
|
191
|
+
/>
|
|
192
|
+
</Pressable>
|
|
193
|
+
<Pressable
|
|
194
|
+
style={styles.option}
|
|
195
|
+
onPress={() => {
|
|
196
|
+
dispatchDrawStates({
|
|
197
|
+
type: 'SET_DRAWING_MODE',
|
|
198
|
+
drawingMode: 'rectangle',
|
|
199
|
+
});
|
|
200
|
+
}}
|
|
201
|
+
>
|
|
202
|
+
<SquareSvg
|
|
232
203
|
height={27}
|
|
233
|
-
|
|
234
|
-
|
|
204
|
+
width={27}
|
|
205
|
+
fill="#ffffff"
|
|
206
|
+
opacity={drawState.drawingMode === 'rectangle' ? 1 : 0.5}
|
|
235
207
|
/>
|
|
236
208
|
</Pressable>
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
209
|
+
<Pressable
|
|
210
|
+
style={styles.option}
|
|
211
|
+
onPress={() => {
|
|
212
|
+
dispatchDrawStates({
|
|
213
|
+
type: 'SET_DRAWING_MODE',
|
|
214
|
+
drawingMode: 'ellipse',
|
|
215
|
+
});
|
|
216
|
+
}}
|
|
217
|
+
>
|
|
218
|
+
<CircleSvg
|
|
219
|
+
fill="#ffffff"
|
|
220
|
+
height={26}
|
|
221
|
+
width={26}
|
|
222
|
+
opacity={drawState.drawingMode === 'ellipse' ? 1 : 0.5}
|
|
223
|
+
/>
|
|
224
|
+
</Pressable>
|
|
225
|
+
|
|
226
|
+
<Pressable
|
|
227
|
+
style={styles.option}
|
|
228
|
+
onPress={() => {
|
|
229
|
+
dispatchDrawStates({
|
|
230
|
+
type: 'SET_DRAWING_MODE',
|
|
231
|
+
drawingMode: 'text',
|
|
232
|
+
});
|
|
233
|
+
}}
|
|
234
|
+
>
|
|
235
|
+
<TextSvg
|
|
236
|
+
height={28}
|
|
237
|
+
width={28}
|
|
238
|
+
color={'grey'}
|
|
239
|
+
opacity={drawState.drawingMode === 'text' ? 1 : 0.5}
|
|
240
|
+
/>
|
|
241
|
+
</Pressable>
|
|
242
|
+
</View>
|
|
243
|
+
</View>
|
|
244
|
+
|
|
245
|
+
<View style={styles.actionButton}>
|
|
246
|
+
<Pressable onPress={takeSnapshotAndGetUri}>
|
|
247
|
+
<SendSvg height={20} width={20} fill="#ffffff" />
|
|
240
248
|
</Pressable>
|
|
241
249
|
</View>
|
|
242
|
-
|
|
250
|
+
</View>
|
|
251
|
+
<View
|
|
252
|
+
style={{
|
|
253
|
+
marginHorizontal: 0,
|
|
254
|
+
flex: 1,
|
|
255
|
+
}}
|
|
256
|
+
>
|
|
257
|
+
<DrawCore image={image} />
|
|
258
|
+
</View>
|
|
259
|
+
|
|
260
|
+
<Sliders linearGradient={linearGradient} />
|
|
261
|
+
|
|
262
|
+
<View style={{ height: 70 }}>
|
|
263
|
+
{showToolbar ? (
|
|
264
|
+
<View style={styles.bottomToolBar}>
|
|
265
|
+
{itemIsSelected.value ? (
|
|
266
|
+
<View style={{ ...styles.actionButton, marginRight: 10 }}>
|
|
267
|
+
<Pressable style={styles.option} onPress={deleteSelectedItem}>
|
|
268
|
+
<ThrashSvg
|
|
269
|
+
width={28}
|
|
270
|
+
height={28}
|
|
271
|
+
color="white"
|
|
272
|
+
strokeWidth={2}
|
|
273
|
+
/>
|
|
274
|
+
</Pressable>
|
|
275
|
+
</View>
|
|
276
|
+
) : null}
|
|
277
|
+
{drawState.cancelEnabled ? (
|
|
278
|
+
<View
|
|
279
|
+
style={{
|
|
280
|
+
...styles.actionButton,
|
|
281
|
+
}}
|
|
282
|
+
>
|
|
283
|
+
<Pressable style={styles.option} onPress={cancelLastAction}>
|
|
284
|
+
<CancelSvg
|
|
285
|
+
width={28}
|
|
286
|
+
height={28}
|
|
287
|
+
color={'grey'}
|
|
288
|
+
strokeWidth={2}
|
|
289
|
+
/>
|
|
290
|
+
</Pressable>
|
|
291
|
+
</View>
|
|
292
|
+
) : null}
|
|
293
|
+
</View>
|
|
294
|
+
) : null}
|
|
295
|
+
</View>
|
|
243
296
|
</View>
|
|
244
297
|
);
|
|
245
298
|
}
|