@archireport/react-native-svg-draw 0.3.3 → 1.0.1
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/CurrentAnimatedItem.js +5 -9
- package/lib/commonjs/components/DrawCore/CurrentAnimatedItem.js.map +1 -1
- package/lib/commonjs/components/DrawCore/DrawPad.js +2 -1
- package/lib/commonjs/components/DrawCore/DrawPad.js.map +1 -1
- package/lib/commonjs/components/DrawCore/index.js +6 -1
- package/lib/commonjs/components/DrawCore/index.js.map +1 -1
- package/lib/commonjs/components/DrawWithOptions/index.js +21 -2
- package/lib/commonjs/components/DrawWithOptions/index.js.map +1 -1
- package/lib/module/components/DrawCore/CurrentAnimatedItem.js +5 -9
- package/lib/module/components/DrawCore/CurrentAnimatedItem.js.map +1 -1
- package/lib/module/components/DrawCore/DrawPad.js +2 -1
- package/lib/module/components/DrawCore/DrawPad.js.map +1 -1
- package/lib/module/components/DrawCore/index.js +6 -1
- package/lib/module/components/DrawCore/index.js.map +1 -1
- package/lib/module/components/DrawWithOptions/index.js +21 -4
- package/lib/module/components/DrawWithOptions/index.js.map +1 -1
- package/package.json +19 -19
- package/src/components/DrawCore/CurrentAnimatedItem.tsx +5 -9
- package/src/components/DrawCore/DrawPad.tsx +1 -0
- package/src/components/DrawCore/index.tsx +5 -1
- package/src/components/DrawWithOptions/index.tsx +39 -15
- package/src/types.d.ts +1 -0
|
@@ -86,7 +86,6 @@ export default function CurrentAnimatedItem({
|
|
|
86
86
|
ry: coordinates.ry,
|
|
87
87
|
stroke: hslToRgb(currentItem.value?.color || 'hsl(0, 0%, 0%)'),
|
|
88
88
|
opacity: currentItem.value?.type === 'ellipse' ? 1 : 0,
|
|
89
|
-
fill: 'none',
|
|
90
89
|
strokeWidth:
|
|
91
90
|
currentItem.value?.type === 'ellipse'
|
|
92
91
|
? currentItem.value.strokeWidth
|
|
@@ -107,12 +106,11 @@ export default function CurrentAnimatedItem({
|
|
|
107
106
|
y2: coordinates.y2,
|
|
108
107
|
stroke: hslToRgb(currentItem.value?.color || 'hsl(0, 0%, 0%)'),
|
|
109
108
|
opacity: currentItem.value?.type === 'singleHead' ? 1 : 0,
|
|
110
|
-
fill: 'none',
|
|
111
109
|
strokeWidth:
|
|
112
110
|
currentItem.value?.type === 'singleHead'
|
|
113
111
|
? currentItem.value.strokeWidth
|
|
114
112
|
: 0,
|
|
115
|
-
markerEnd: '
|
|
113
|
+
markerEnd: 'arrowhead',
|
|
116
114
|
};
|
|
117
115
|
}, [currentItem.value]);
|
|
118
116
|
|
|
@@ -129,13 +127,12 @@ export default function CurrentAnimatedItem({
|
|
|
129
127
|
y2: coordinates.y2,
|
|
130
128
|
stroke: hslToRgb(currentItem.value?.color || 'hsl(0, 0%, 0%)'),
|
|
131
129
|
opacity: currentItem.value?.type === 'doubleHead' ? 1 : 0,
|
|
132
|
-
fill: 'none',
|
|
133
130
|
strokeWidth:
|
|
134
131
|
currentItem.value?.type === 'doubleHead'
|
|
135
132
|
? currentItem.value.strokeWidth
|
|
136
133
|
: 0,
|
|
137
|
-
markerStart: '
|
|
138
|
-
markerEnd: '
|
|
134
|
+
markerStart: 'side',
|
|
135
|
+
markerEnd: 'side',
|
|
139
136
|
};
|
|
140
137
|
}, [currentItem.value]);
|
|
141
138
|
|
|
@@ -150,7 +147,6 @@ export default function CurrentAnimatedItem({
|
|
|
150
147
|
width: coordinates.width,
|
|
151
148
|
height: coordinates.height,
|
|
152
149
|
stroke: hslToRgb(currentItem.value?.color || 'hsl(0, 0%, 0%)'),
|
|
153
|
-
fill: 'none',
|
|
154
150
|
opacity: currentItem.value?.type === 'rectangle' ? 1 : 0,
|
|
155
151
|
strokeWidth:
|
|
156
152
|
currentItem.value?.type === 'rectangle'
|
|
@@ -172,8 +168,8 @@ export default function CurrentAnimatedItem({
|
|
|
172
168
|
currentItem.value?.type === 'pen' ? currentItem.value.strokeWidth : 0,
|
|
173
169
|
stroke: hslToRgb(currentItem.value?.color || 'hsl(0, 0%, 0%)'),
|
|
174
170
|
opacity: currentItem.value?.type === 'pen' ? 1 : 0,
|
|
175
|
-
markerStart: '
|
|
176
|
-
markerEnd: '
|
|
171
|
+
markerStart: 'selection',
|
|
172
|
+
markerEnd: 'selection',
|
|
177
173
|
};
|
|
178
174
|
}, [currentItem.value]);
|
|
179
175
|
|
|
@@ -293,10 +293,14 @@ const DrawCore = React.forwardRef<
|
|
|
293
293
|
onSelectionChange?.(false);
|
|
294
294
|
},
|
|
295
295
|
takeSnapshot: async (): Promise<string | undefined> => {
|
|
296
|
+
if (currentItem.value) {
|
|
297
|
+
updateDoneItems(currentItem.value);
|
|
298
|
+
currentItem.value = null;
|
|
299
|
+
}
|
|
296
300
|
return viewShot.current?.capture?.();
|
|
297
301
|
},
|
|
298
302
|
}),
|
|
299
|
-
[currentItem, onSelectionChange]
|
|
303
|
+
[currentItem, onSelectionChange, updateDoneItems]
|
|
300
304
|
);
|
|
301
305
|
|
|
302
306
|
useEffect(() => {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { useCallback, useRef, useState } from 'react';
|
|
1
|
+
import React, { useCallback, useEffect, useRef, useState } from 'react';
|
|
2
2
|
import {
|
|
3
3
|
Pressable,
|
|
4
4
|
View,
|
|
@@ -6,6 +6,7 @@ import {
|
|
|
6
6
|
ViewProps,
|
|
7
7
|
ImageRequireSource,
|
|
8
8
|
ImageURISource,
|
|
9
|
+
Keyboard,
|
|
9
10
|
} from 'react-native';
|
|
10
11
|
import DrawCore from '../DrawCore';
|
|
11
12
|
import type { DrawItemType, DrawCoreProps } from '../../types';
|
|
@@ -81,6 +82,27 @@ export default function DrawWithOptions({
|
|
|
81
82
|
}
|
|
82
83
|
}, [takeSnapshot]);
|
|
83
84
|
|
|
85
|
+
const [showToolbar, setShowToolbar] = useState(true);
|
|
86
|
+
|
|
87
|
+
useEffect(() => {
|
|
88
|
+
const sudDidHide = Keyboard.addListener('keyboardDidHide', () => {
|
|
89
|
+
setShowToolbar(true);
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
const sudDidShow = Keyboard.addListener('keyboardDidShow', (event) => {
|
|
93
|
+
// avoid events triggered by InputAccessoryView
|
|
94
|
+
if (event.endCoordinates.height > 100) {
|
|
95
|
+
setShowToolbar(false);
|
|
96
|
+
}
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
// cleanup function
|
|
100
|
+
return () => {
|
|
101
|
+
sudDidShow.remove();
|
|
102
|
+
sudDidHide.remove();
|
|
103
|
+
};
|
|
104
|
+
}, []);
|
|
105
|
+
|
|
84
106
|
return (
|
|
85
107
|
<View style={styles.container}>
|
|
86
108
|
<View style={styles.toolbar}>
|
|
@@ -164,21 +186,23 @@ export default function DrawWithOptions({
|
|
|
164
186
|
onSelectionChange={setSelectedItem}
|
|
165
187
|
/>
|
|
166
188
|
|
|
167
|
-
|
|
168
|
-
{
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
189
|
+
{showToolbar ? (
|
|
190
|
+
<View style={styles.bottomToolBar}>
|
|
191
|
+
{selectedItem ? (
|
|
192
|
+
<Pressable
|
|
193
|
+
style={styles.option}
|
|
194
|
+
onPress={() => {
|
|
195
|
+
drawRef.current?.deleteSelectedItem();
|
|
196
|
+
}}
|
|
197
|
+
>
|
|
198
|
+
<ThrashSvg width={28} height={28} fill="white" />
|
|
199
|
+
</Pressable>
|
|
200
|
+
) : null}
|
|
201
|
+
<Pressable style={styles.sendButton} onPress={onPressSend}>
|
|
202
|
+
<SendSvg fill="#fff" width={20} height={20} />
|
|
176
203
|
</Pressable>
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
<SendSvg fill="#fff" width={20} height={20} />
|
|
180
|
-
</Pressable>
|
|
181
|
-
</View>
|
|
204
|
+
</View>
|
|
205
|
+
) : null}
|
|
182
206
|
</View>
|
|
183
207
|
);
|
|
184
208
|
}
|
package/src/types.d.ts
CHANGED