@archireport/react-native-svg-draw 1.0.1 → 1.1.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/lib/commonjs/components/DrawCore/ColorSlider.js +8 -5
- package/lib/commonjs/components/DrawCore/ColorSlider.js.map +1 -1
- package/lib/commonjs/components/DrawCore/CurrentAnimatedItem.js +56 -6
- package/lib/commonjs/components/DrawCore/CurrentAnimatedItem.js.map +1 -1
- package/lib/commonjs/components/DrawCore/DrawPad.js +4 -4
- package/lib/commonjs/components/DrawCore/DrawPad.js.map +1 -1
- package/lib/commonjs/components/DrawCore/Item.js +3 -5
- package/lib/commonjs/components/DrawCore/Item.js.map +1 -1
- package/lib/commonjs/components/DrawCore/StrokeSlider.js +5 -2
- package/lib/commonjs/components/DrawCore/StrokeSlider.js.map +1 -1
- package/lib/commonjs/components/DrawCore/index.js +139 -52
- package/lib/commonjs/components/DrawCore/index.js.map +1 -1
- package/lib/commonjs/components/DrawWithOptions/CancelSvg.js +35 -0
- package/lib/commonjs/components/DrawWithOptions/CancelSvg.js.map +1 -0
- package/lib/commonjs/components/DrawWithOptions/PenSvg.js +27 -0
- package/lib/commonjs/components/DrawWithOptions/PenSvg.js.map +1 -0
- package/lib/commonjs/components/DrawWithOptions/index.js +30 -1
- package/lib/commonjs/components/DrawWithOptions/index.js.map +1 -1
- package/lib/module/components/DrawCore/ColorSlider.js +9 -6
- package/lib/module/components/DrawCore/ColorSlider.js.map +1 -1
- package/lib/module/components/DrawCore/CurrentAnimatedItem.js +53 -7
- package/lib/module/components/DrawCore/CurrentAnimatedItem.js.map +1 -1
- package/lib/module/components/DrawCore/DrawPad.js +4 -4
- package/lib/module/components/DrawCore/DrawPad.js.map +1 -1
- package/lib/module/components/DrawCore/Item.js +2 -6
- package/lib/module/components/DrawCore/Item.js.map +1 -1
- package/lib/module/components/DrawCore/StrokeSlider.js +5 -2
- package/lib/module/components/DrawCore/StrokeSlider.js.map +1 -1
- package/lib/module/components/DrawCore/index.js +140 -53
- package/lib/module/components/DrawCore/index.js.map +1 -1
- package/lib/module/components/DrawWithOptions/CancelSvg.js +22 -0
- package/lib/module/components/DrawWithOptions/CancelSvg.js.map +1 -0
- package/lib/module/components/DrawWithOptions/PenSvg.js +14 -0
- package/lib/module/components/DrawWithOptions/PenSvg.js.map +1 -0
- package/lib/module/components/DrawWithOptions/index.js +28 -1
- package/lib/module/components/DrawWithOptions/index.js.map +1 -1
- package/lib/typescript/components/DrawCore/ColorSlider.d.ts +2 -1
- package/lib/typescript/components/DrawCore/CurrentAnimatedItem.d.ts +2 -1
- package/lib/typescript/components/DrawCore/StrokeSlider.d.ts +2 -1
- package/lib/typescript/components/DrawCore/index.d.ts +1 -0
- package/lib/typescript/components/DrawWithOptions/CancelSvg.d.ts +2 -0
- package/lib/typescript/components/DrawWithOptions/PenSvg.d.ts +2 -0
- package/package.json +5 -5
- package/src/components/DrawCore/ColorSlider.tsx +11 -6
- package/src/components/DrawCore/CurrentAnimatedItem.tsx +59 -8
- package/src/components/DrawCore/DrawPad.tsx +2 -2
- package/src/components/DrawCore/Item.tsx +3 -11
- package/src/components/DrawCore/StrokeSlider.tsx +5 -1
- package/src/components/DrawCore/index.tsx +1105 -971
- package/src/components/DrawWithOptions/CancelSvg.tsx +23 -0
- package/src/components/DrawWithOptions/PenSvg.tsx +14 -0
- package/src/components/DrawWithOptions/index.tsx +34 -0
- package/src/types.d.ts +4 -1
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import Svg, { Path, SvgProps } from 'react-native-svg';
|
|
3
|
+
|
|
4
|
+
export default function CancelSvg(props: SvgProps) {
|
|
5
|
+
return (
|
|
6
|
+
<Svg viewBox="0 0 24 24" {...props}>
|
|
7
|
+
<Path
|
|
8
|
+
d="M2 4L2 10L8 10"
|
|
9
|
+
stroke="#F1F1F5"
|
|
10
|
+
stroke-width="1.99277"
|
|
11
|
+
stroke-linecap="round"
|
|
12
|
+
stroke-linejoin="round"
|
|
13
|
+
/>
|
|
14
|
+
<Path
|
|
15
|
+
d="M4.51 15.0004C5.15839 16.8408 6.38734 18.4206 8.01166 19.5018C9.63598 20.583 11.5677 21.107 13.5157 20.9949C15.4637 20.8828 17.3226 20.1406 18.8121 18.8802C20.3017 17.6198 21.3413 15.9094 21.7742 14.0068C22.2072 12.1042 22.0101 10.1124 21.2126 8.33154C20.4152 6.55068 19.0605 5.07723 17.3528 4.1332C15.6451 3.18917 13.6769 2.8257 11.7447 3.09755C9.81245 3.36941 8.02091 4.26186 6.64 5.64044L2 10.0004"
|
|
16
|
+
stroke="#F1F1F5"
|
|
17
|
+
stroke-width="1.99277"
|
|
18
|
+
stroke-linecap="round"
|
|
19
|
+
stroke-linejoin="round"
|
|
20
|
+
/>
|
|
21
|
+
</Svg>
|
|
22
|
+
);
|
|
23
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import Svg, { Path, SvgProps } from 'react-native-svg';
|
|
3
|
+
|
|
4
|
+
export default function PenSvg(props: SvgProps) {
|
|
5
|
+
return (
|
|
6
|
+
<Svg viewBox="0 0 22 23" {...props}>
|
|
7
|
+
<Path
|
|
8
|
+
stroke-linecap="round"
|
|
9
|
+
stroke-linejoin="round"
|
|
10
|
+
d="M16.1298 2.09927C16.3947 1.83435 16.7092 1.62421 17.0553 1.48084C17.4015 1.33746 17.7725 1.26367 18.1471 1.26367C18.5217 1.26367 18.8927 1.33746 19.2389 1.48084C19.585 1.62421 19.8995 1.83435 20.1644 2.09927C20.4293 2.36418 20.6395 2.67869 20.7828 3.02482C20.9262 3.37094 21 3.74192 21 4.11657C21 4.49122 20.9262 4.8622 20.7828 5.20833C20.6395 5.55446 20.4293 5.86896 20.1644 6.13388L6.54759 19.7507L1 21.2637L2.51298 15.7161L16.1298 2.09927Z"
|
|
11
|
+
/>
|
|
12
|
+
</Svg>
|
|
13
|
+
);
|
|
14
|
+
}
|
|
@@ -10,6 +10,7 @@ import {
|
|
|
10
10
|
} from 'react-native';
|
|
11
11
|
import DrawCore from '../DrawCore';
|
|
12
12
|
import type { DrawItemType, DrawCoreProps } from '../../types';
|
|
13
|
+
import PenSvg from './PenSvg';
|
|
13
14
|
import DoubleHeadSvg from './DoubleHeadSvg';
|
|
14
15
|
import CircleSvg from './CircleSvg';
|
|
15
16
|
import SquareSvg from './SquareSvg';
|
|
@@ -18,6 +19,7 @@ import TextSvg from './TextSvg';
|
|
|
18
19
|
import CloseSvg from './CloseSvg';
|
|
19
20
|
import ThrashSvg from './ThrashSvg';
|
|
20
21
|
import SendSvg from './SendSvg';
|
|
22
|
+
import CancelSvg from './CancelSvg';
|
|
21
23
|
|
|
22
24
|
const styles = StyleSheet.create({
|
|
23
25
|
container: { flex: 1, backgroundColor: '#000000' },
|
|
@@ -76,6 +78,8 @@ export default function DrawWithOptions({
|
|
|
76
78
|
|
|
77
79
|
const [selectedItem, setSelectedItem] = useState(false);
|
|
78
80
|
|
|
81
|
+
const [cancelEnabled, setCancelEnabled] = useState(false);
|
|
82
|
+
|
|
79
83
|
const onPressSend = useCallback(() => {
|
|
80
84
|
if (drawRef.current) {
|
|
81
85
|
takeSnapshot?.(drawRef.current.takeSnapshot());
|
|
@@ -110,6 +114,20 @@ export default function DrawWithOptions({
|
|
|
110
114
|
<CloseSvg height={20} width={20} fill="#ffffff" />
|
|
111
115
|
</Pressable>
|
|
112
116
|
<View style={styles.drawOptions}>
|
|
117
|
+
<Pressable
|
|
118
|
+
style={styles.option}
|
|
119
|
+
onPress={() => {
|
|
120
|
+
setDrawingMode('pen');
|
|
121
|
+
}}
|
|
122
|
+
>
|
|
123
|
+
<PenSvg
|
|
124
|
+
height={23}
|
|
125
|
+
width={22}
|
|
126
|
+
stroke="#ffffff"
|
|
127
|
+
strokeWidth="2"
|
|
128
|
+
opacity={drawingMode === 'pen' ? 1 : 0.5}
|
|
129
|
+
/>
|
|
130
|
+
</Pressable>
|
|
113
131
|
<Pressable
|
|
114
132
|
style={styles.option}
|
|
115
133
|
onPress={() => {
|
|
@@ -184,6 +202,7 @@ export default function DrawWithOptions({
|
|
|
184
202
|
image={image}
|
|
185
203
|
linearGradient={linearGradient}
|
|
186
204
|
onSelectionChange={setSelectedItem}
|
|
205
|
+
onCancelChange={setCancelEnabled}
|
|
187
206
|
/>
|
|
188
207
|
|
|
189
208
|
{showToolbar ? (
|
|
@@ -198,6 +217,21 @@ export default function DrawWithOptions({
|
|
|
198
217
|
<ThrashSvg width={28} height={28} fill="white" />
|
|
199
218
|
</Pressable>
|
|
200
219
|
) : null}
|
|
220
|
+
{cancelEnabled ? (
|
|
221
|
+
<Pressable
|
|
222
|
+
style={styles.option}
|
|
223
|
+
onPress={() => {
|
|
224
|
+
drawRef.current?.cancelLastAction();
|
|
225
|
+
}}
|
|
226
|
+
>
|
|
227
|
+
<CancelSvg
|
|
228
|
+
width={27}
|
|
229
|
+
height={27}
|
|
230
|
+
stroke="#ffffff"
|
|
231
|
+
strokeWidth={2}
|
|
232
|
+
/>
|
|
233
|
+
</Pressable>
|
|
234
|
+
) : null}
|
|
201
235
|
<Pressable style={styles.sendButton} onPress={onPressSend}>
|
|
202
236
|
<SendSvg fill="#fff" width={20} height={20} />
|
|
203
237
|
</Pressable>
|
package/src/types.d.ts
CHANGED
|
@@ -9,7 +9,9 @@ import {
|
|
|
9
9
|
|
|
10
10
|
export type Point = { x: number; y: number };
|
|
11
11
|
|
|
12
|
-
export type hslColor = `hsl(${number}, ${number}%, ${
|
|
12
|
+
export type hslColor = `hsl(${number}, ${number | string}%, ${
|
|
13
|
+
| number
|
|
14
|
+
| string}%)`;
|
|
13
15
|
|
|
14
16
|
type Size = { width: number; height: number };
|
|
15
17
|
|
|
@@ -27,5 +29,6 @@ export type DrawItemType = DrawItem['type'];
|
|
|
27
29
|
export type DrawCoreProps = {
|
|
28
30
|
drawingContainer: React.Ref<View>;
|
|
29
31
|
deleteSelectedItem: () => void;
|
|
32
|
+
cancelLastAction: () => void;
|
|
30
33
|
takeSnapshot: () => Promise<string | undefined>;
|
|
31
34
|
};
|