@archireport/react-native-svg-draw 2.2.1 → 2.3.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/CurrentAnimatedItem.js +284 -29
- package/lib/commonjs/components/DrawCore/CurrentAnimatedItem.js.map +1 -1
- package/lib/commonjs/components/DrawCore/CurrentAnimatedText.js +12 -11
- package/lib/commonjs/components/DrawCore/CurrentAnimatedText.js.map +1 -1
- package/lib/commonjs/components/DrawCore/DrawContext.js.map +1 -1
- package/lib/commonjs/components/DrawCore/DrawPad.js +14 -5
- package/lib/commonjs/components/DrawCore/DrawPad.js.map +1 -1
- package/lib/commonjs/components/DrawCore/DrawProvider.js +6 -2
- package/lib/commonjs/components/DrawCore/DrawProvider.js.map +1 -1
- package/lib/commonjs/components/DrawCore/Item.js +154 -7
- package/lib/commonjs/components/DrawCore/Item.js.map +1 -1
- package/lib/commonjs/components/DrawCore/index.js +163 -76
- package/lib/commonjs/components/DrawCore/index.js.map +1 -1
- package/lib/commonjs/components/DrawCore/useDrawHook.js +4 -2
- package/lib/commonjs/components/DrawCore/useDrawHook.js.map +1 -1
- 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.map +1 -1
- 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.map +1 -1
- package/lib/commonjs/components/DrawWithOptions/index.js +14 -0
- package/lib/commonjs/components/DrawWithOptions/index.js.map +1 -1
- package/lib/commonjs/components/Slider/ColorSlider.js.map +1 -1
- package/lib/commonjs/components/Slider/Sliders.js.map +1 -1
- package/lib/commonjs/components/Slider/StrokeSlider.js.map +1 -1
- package/lib/commonjs/components/Slider/sliderStyle.js.map +1 -1
- package/lib/commonjs/index.js.map +1 -1
- package/lib/module/components/DrawCore/CurrentAnimatedItem.js +286 -31
- package/lib/module/components/DrawCore/CurrentAnimatedItem.js.map +1 -1
- package/lib/module/components/DrawCore/CurrentAnimatedText.js +12 -11
- package/lib/module/components/DrawCore/CurrentAnimatedText.js.map +1 -1
- package/lib/module/components/DrawCore/DrawContext.js.map +1 -1
- package/lib/module/components/DrawCore/DrawPad.js +14 -5
- package/lib/module/components/DrawCore/DrawPad.js.map +1 -1
- package/lib/module/components/DrawCore/DrawProvider.js +6 -2
- package/lib/module/components/DrawCore/DrawProvider.js.map +1 -1
- package/lib/module/components/DrawCore/Item.js +150 -9
- package/lib/module/components/DrawCore/Item.js.map +1 -1
- package/lib/module/components/DrawCore/index.js +164 -77
- package/lib/module/components/DrawCore/index.js.map +1 -1
- package/lib/module/components/DrawCore/useDrawHook.js +4 -2
- package/lib/module/components/DrawCore/useDrawHook.js.map +1 -1
- 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.map +1 -1
- 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.map +1 -1
- package/lib/module/components/DrawWithOptions/index.js +14 -0
- package/lib/module/components/DrawWithOptions/index.js.map +1 -1
- package/lib/module/components/Slider/ColorSlider.js.map +1 -1
- package/lib/module/components/Slider/Sliders.js.map +1 -1
- package/lib/module/components/Slider/StrokeSlider.js.map +1 -1
- package/lib/typescript/components/DrawCore/CurrentAnimatedItem.d.ts +3 -6
- package/lib/typescript/components/DrawCore/CurrentAnimatedItem.d.ts.map +1 -1
- package/lib/typescript/components/DrawCore/CurrentAnimatedText.d.ts +0 -1
- package/lib/typescript/components/DrawCore/CurrentAnimatedText.d.ts.map +1 -1
- package/lib/typescript/components/DrawCore/DrawContext.d.ts +2 -0
- package/lib/typescript/components/DrawCore/DrawContext.d.ts.map +1 -1
- package/lib/typescript/components/DrawCore/DrawPad.d.ts +0 -1
- package/lib/typescript/components/DrawCore/DrawPad.d.ts.map +1 -1
- package/lib/typescript/components/DrawCore/DrawProvider.d.ts.map +1 -1
- package/lib/typescript/components/DrawCore/Item.d.ts +27 -1
- package/lib/typescript/components/DrawCore/Item.d.ts.map +1 -1
- package/lib/typescript/components/DrawCore/index.d.ts +0 -1
- package/lib/typescript/components/DrawCore/index.d.ts.map +1 -1
- package/lib/typescript/components/DrawCore/useDrawHook.d.ts +1 -0
- package/lib/typescript/components/DrawCore/useDrawHook.d.ts.map +1 -1
- package/lib/typescript/components/DrawWithOptions/ArrowSvg.d.ts +0 -1
- package/lib/typescript/components/DrawWithOptions/ArrowSvg.d.ts.map +1 -1
- package/lib/typescript/components/DrawWithOptions/CancelSvg.d.ts +0 -1
- package/lib/typescript/components/DrawWithOptions/CancelSvg.d.ts.map +1 -1
- package/lib/typescript/components/DrawWithOptions/CircleSvg.d.ts +0 -1
- package/lib/typescript/components/DrawWithOptions/CircleSvg.d.ts.map +1 -1
- package/lib/typescript/components/DrawWithOptions/CloseSvg.d.ts +0 -1
- package/lib/typescript/components/DrawWithOptions/CloseSvg.d.ts.map +1 -1
- package/lib/typescript/components/DrawWithOptions/DoubleHeadSvg.d.ts +0 -1
- package/lib/typescript/components/DrawWithOptions/DoubleHeadSvg.d.ts.map +1 -1
- package/lib/typescript/components/DrawWithOptions/PenSvg.d.ts +0 -1
- package/lib/typescript/components/DrawWithOptions/PenSvg.d.ts.map +1 -1
- package/lib/typescript/components/DrawWithOptions/SendSvg.d.ts +0 -1
- package/lib/typescript/components/DrawWithOptions/SendSvg.d.ts.map +1 -1
- package/lib/typescript/components/DrawWithOptions/SliderSvg.d.ts +0 -1
- package/lib/typescript/components/DrawWithOptions/SliderSvg.d.ts.map +1 -1
- package/lib/typescript/components/DrawWithOptions/SquareSvg.d.ts +0 -1
- package/lib/typescript/components/DrawWithOptions/SquareSvg.d.ts.map +1 -1
- package/lib/typescript/components/DrawWithOptions/TextSvg.d.ts +0 -1
- package/lib/typescript/components/DrawWithOptions/TextSvg.d.ts.map +1 -1
- package/lib/typescript/components/DrawWithOptions/ThrashSvg.d.ts +0 -1
- package/lib/typescript/components/DrawWithOptions/ThrashSvg.d.ts.map +1 -1
- package/lib/typescript/components/DrawWithOptions/index.d.ts.map +1 -1
- package/lib/typescript/components/Slider/StrokeSlider.d.ts +0 -1
- package/lib/typescript/components/Slider/StrokeSlider.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/components/DrawCore/CurrentAnimatedItem.tsx +307 -7
- package/src/components/DrawCore/CurrentAnimatedText.tsx +5 -2
- package/src/components/DrawCore/DrawContext.tsx +2 -0
- package/src/components/DrawCore/DrawPad.tsx +17 -3
- package/src/components/DrawCore/DrawProvider.tsx +6 -0
- package/src/components/DrawCore/Item.tsx +188 -7
- package/src/components/DrawCore/index.tsx +219 -100
- package/src/components/DrawCore/useDrawHook.tsx +2 -0
- package/src/components/DrawWithOptions/index.tsx +18 -0
- package/src/types.d.ts +7 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React, { useCallback, useEffect, useRef, useState } from 'react';
|
|
2
|
-
import { StyleSheet, TextInput, View, Keyboard, ImageBackground, Image,
|
|
3
|
-
import Animated, { runOnJS, useAnimatedGestureHandler, useAnimatedKeyboard, useAnimatedReaction,
|
|
2
|
+
import { StyleSheet, TextInput, View, Keyboard, ImageBackground, Image, KeyboardAvoidingView } from 'react-native';
|
|
3
|
+
import Animated, { runOnJS, useAnimatedGestureHandler, useAnimatedKeyboard, useAnimatedReaction, useSharedValue } from 'react-native-reanimated';
|
|
4
4
|
import { PanGestureHandler } from 'react-native-gesture-handler';
|
|
5
5
|
import DrawPad from './DrawPad';
|
|
6
6
|
import ViewShot from 'react-native-view-shot';
|
|
@@ -25,7 +25,10 @@ const styles = StyleSheet.create({
|
|
|
25
25
|
paddingHorizontal: 24,
|
|
26
26
|
fontSize: 16,
|
|
27
27
|
color: 'white',
|
|
28
|
-
width: '100%'
|
|
28
|
+
width: '100%',
|
|
29
|
+
opacity: 0,
|
|
30
|
+
height: 20,
|
|
31
|
+
maxWidth: 20
|
|
29
32
|
}
|
|
30
33
|
});
|
|
31
34
|
const pDistance = (point, line) => {
|
|
@@ -67,7 +70,6 @@ const pDistance = (point, line) => {
|
|
|
67
70
|
var dy = y - yy;
|
|
68
71
|
return Math.sqrt(dx * dx + dy * dy);
|
|
69
72
|
};
|
|
70
|
-
const AnimatedTextInput = Animated.createAnimatedComponent(TextInput);
|
|
71
73
|
const DEFAULT_TEXT = '';
|
|
72
74
|
const THRESHOLD = 20;
|
|
73
75
|
const drawNewItem = (mode, currentItem, addDoneItem, position, style) => {
|
|
@@ -117,6 +119,19 @@ const drawNewItem = (mode, currentItem, addDoneItem, position, style) => {
|
|
|
117
119
|
color: style.color.value
|
|
118
120
|
};
|
|
119
121
|
break;
|
|
122
|
+
case 'doubleArrows':
|
|
123
|
+
currentItem.value = {
|
|
124
|
+
type: mode.value,
|
|
125
|
+
data: {
|
|
126
|
+
x1: position.x,
|
|
127
|
+
y1: position.y,
|
|
128
|
+
x2: position.x,
|
|
129
|
+
y2: position.y
|
|
130
|
+
},
|
|
131
|
+
strokeWidth: style.strokeWidth.value,
|
|
132
|
+
color: style.color.value
|
|
133
|
+
};
|
|
134
|
+
break;
|
|
120
135
|
case 'text':
|
|
121
136
|
currentItem.value = {
|
|
122
137
|
type: mode.value,
|
|
@@ -160,7 +175,7 @@ const onTextHeightUpdate = (currentItem, textBaseHeight, height) => {
|
|
|
160
175
|
}
|
|
161
176
|
};
|
|
162
177
|
const DrawCore = _ref => {
|
|
163
|
-
var _textInputRef$
|
|
178
|
+
var _textInputRef$current4;
|
|
164
179
|
let {
|
|
165
180
|
image,
|
|
166
181
|
backgroundColor
|
|
@@ -172,7 +187,8 @@ const DrawCore = _ref => {
|
|
|
172
187
|
color,
|
|
173
188
|
currentItem,
|
|
174
189
|
itemIsSelected,
|
|
175
|
-
viewShot
|
|
190
|
+
viewShot,
|
|
191
|
+
doubleArrowTextInput
|
|
176
192
|
} = useDrawHook();
|
|
177
193
|
const onCancelChangeWrapper = arg => {
|
|
178
194
|
dispatchDrawStates({
|
|
@@ -214,14 +230,23 @@ const DrawCore = _ref => {
|
|
|
214
230
|
currentItem.value = null;
|
|
215
231
|
itemIsSelected.value = false;
|
|
216
232
|
}, [drawState.drawingMode, mode, currentItem, addDoneItem, itemIsSelected]);
|
|
217
|
-
const showTextInput = useSharedValue(false);
|
|
233
|
+
const showTextInput = useSharedValue(false); //TODO: remove
|
|
234
|
+
|
|
235
|
+
const textFocusState = useCallback(() => {
|
|
236
|
+
var _doubleArrowTextInput;
|
|
237
|
+
//setShowTextInputState(true);
|
|
238
|
+
console.log('textFocusState');
|
|
239
|
+
doubleArrowTextInput === null || doubleArrowTextInput === void 0 ? void 0 : (_doubleArrowTextInput = doubleArrowTextInput.current) === null || _doubleArrowTextInput === void 0 ? void 0 : _doubleArrowTextInput.focus();
|
|
240
|
+
}, [doubleArrowTextInput]);
|
|
218
241
|
const textFocus = useCallback(() => {
|
|
219
242
|
var _textInputRef$current;
|
|
243
|
+
console.log('textFocus');
|
|
220
244
|
(_textInputRef$current = textInputRef.current) === null || _textInputRef$current === void 0 ? void 0 : _textInputRef$current.focus();
|
|
221
245
|
}, []);
|
|
222
246
|
useEffect(() => {
|
|
223
247
|
var _currentItem$value2;
|
|
224
248
|
if (((_currentItem$value2 = currentItem.value) === null || _currentItem$value2 === void 0 ? void 0 : _currentItem$value2.type) === 'text') {
|
|
249
|
+
console.log('use effect text');
|
|
225
250
|
showTextInput.value = true;
|
|
226
251
|
textFocus();
|
|
227
252
|
currentItem.value = {
|
|
@@ -235,7 +260,7 @@ const DrawCore = _ref => {
|
|
|
235
260
|
}, [currentItem, showTextInput, textFocus, textVal]);
|
|
236
261
|
const onGestureEvent = useAnimatedGestureHandler({
|
|
237
262
|
onStart: (_ref2, ctx) => {
|
|
238
|
-
var _currentItem$value3;
|
|
263
|
+
var _currentItem$value3, _currentItem$value4;
|
|
239
264
|
let {
|
|
240
265
|
x: startX,
|
|
241
266
|
y: startY
|
|
@@ -243,11 +268,12 @@ const DrawCore = _ref => {
|
|
|
243
268
|
ctx.startX = startX;
|
|
244
269
|
ctx.startY = startY;
|
|
245
270
|
ctx.newlyCreated = false;
|
|
246
|
-
|
|
271
|
+
console.log('**********************************');
|
|
272
|
+
console.log('onGestureEvent');
|
|
247
273
|
//panPosition.value = withTiming(RIGHT_PANE_WIDTH);
|
|
248
|
-
|
|
274
|
+
console.log('onStart', (_currentItem$value3 = currentItem.value) === null || _currentItem$value3 === void 0 ? void 0 : _currentItem$value3.type);
|
|
249
275
|
initialItem.value = currentItem.value;
|
|
250
|
-
switch ((_currentItem$
|
|
276
|
+
switch ((_currentItem$value4 = currentItem.value) === null || _currentItem$value4 === void 0 ? void 0 : _currentItem$value4.type) {
|
|
251
277
|
case 'ellipse':
|
|
252
278
|
const cx = typeof currentItem.value.data.cx === 'string' ? parseFloat(currentItem.value.data.cx) : currentItem.value.data.cx || 0;
|
|
253
279
|
const cy = typeof currentItem.value.data.cy === 'string' ? parseFloat(currentItem.value.data.cy) : currentItem.value.data.cy || 0;
|
|
@@ -293,6 +319,7 @@ const DrawCore = _ref => {
|
|
|
293
319
|
}
|
|
294
320
|
break;
|
|
295
321
|
case 'doubleHead':
|
|
322
|
+
case 'doubleArrows':
|
|
296
323
|
case 'singleHead':
|
|
297
324
|
const x1 = typeof currentItem.value.data.x1 === 'string' ? parseFloat(currentItem.value.data.x1) : currentItem.value.data.x1 || 0;
|
|
298
325
|
const y1 = typeof currentItem.value.data.y1 === 'string' ? parseFloat(currentItem.value.data.y1) : currentItem.value.data.y1 || 0;
|
|
@@ -322,15 +349,32 @@ const DrawCore = _ref => {
|
|
|
322
349
|
const yText = typeof currentItem.value.data.y === 'string' ? parseFloat(currentItem.value.data.y) : currentItem.value.data.y || 0;
|
|
323
350
|
const widthText = typeof currentItem.value.data.width === 'string' ? parseFloat(currentItem.value.data.width) : currentItem.value.data.width || 0;
|
|
324
351
|
const heightText = typeof currentItem.value.data.height === 'string' ? parseFloat(currentItem.value.data.height) : currentItem.value.data.height || 0;
|
|
352
|
+
console.log(heightText);
|
|
353
|
+
console.log(widthText);
|
|
325
354
|
if (startX <= xText + THRESHOLD && startX >= xText - THRESHOLD && startY <= yText + heightText / 2 + THRESHOLD && startY >= yText + heightText / 2 - THRESHOLD) {
|
|
326
355
|
ctx.zone = 'LEFT';
|
|
327
356
|
} else if (startX <= xText + widthText + THRESHOLD && startX >= xText + widthText - THRESHOLD && startY <= yText + heightText / 2 + THRESHOLD && startY >= yText + heightText / 2 - THRESHOLD) {
|
|
328
357
|
ctx.zone = 'RIGHT';
|
|
329
358
|
} else if ((widthText > 0 && startX > xText && startX < xText + widthText || widthText < 0 && startX < xText && startX > xText + widthText) && (heightText > 0 && startY > yText && startY < yText + heightText || heightText < 0 && startY < yText && startY > yText + heightText)) {
|
|
330
359
|
ctx.zone = 'CENTER';
|
|
360
|
+
console.log('on active center');
|
|
331
361
|
} else {
|
|
332
362
|
ctx.zone = 'OUT';
|
|
363
|
+
console.log('on active out');
|
|
333
364
|
initialItem.value = null;
|
|
365
|
+
ctx.newlyCreated = true;
|
|
366
|
+
runOnJS(setTextVal)('');
|
|
367
|
+
drawNewItem(mode, currentItem, addDoneItem, {
|
|
368
|
+
x: startX,
|
|
369
|
+
y: startY
|
|
370
|
+
}, {
|
|
371
|
+
textBaseHeight,
|
|
372
|
+
strokeWidth,
|
|
373
|
+
color
|
|
374
|
+
});
|
|
375
|
+
itemIsSelected.value = true;
|
|
376
|
+
onCancelChangeWrapper && runOnJS(onCancelChangeWrapper)(true);
|
|
377
|
+
runOnJS(textFocus)();
|
|
334
378
|
}
|
|
335
379
|
break;
|
|
336
380
|
case 'pen':
|
|
@@ -344,11 +388,28 @@ const DrawCore = _ref => {
|
|
|
344
388
|
default:
|
|
345
389
|
ctx.zone = 'OUT';
|
|
346
390
|
initialItem.value = null;
|
|
391
|
+
if (drawState.drawingMode === 'text') {
|
|
392
|
+
/* NEW GEOFF */
|
|
393
|
+
console.log('on active out');
|
|
394
|
+
ctx.newlyCreated = true;
|
|
395
|
+
runOnJS(setTextVal)('');
|
|
396
|
+
drawNewItem(mode, currentItem, addDoneItem, {
|
|
397
|
+
x: startX,
|
|
398
|
+
y: startY
|
|
399
|
+
}, {
|
|
400
|
+
textBaseHeight,
|
|
401
|
+
strokeWidth,
|
|
402
|
+
color
|
|
403
|
+
});
|
|
404
|
+
itemIsSelected.value = true;
|
|
405
|
+
onCancelChangeWrapper && runOnJS(onCancelChangeWrapper)(true);
|
|
406
|
+
runOnJS(textFocus)();
|
|
407
|
+
}
|
|
347
408
|
break;
|
|
348
409
|
}
|
|
349
410
|
},
|
|
350
411
|
onActive: (_ref3, ctx) => {
|
|
351
|
-
var _currentItem$
|
|
412
|
+
var _currentItem$value5, _initialItem$value, _initialItem$value2, _initialItem$value4, _initialItem$value17, _initialItem$value30;
|
|
352
413
|
let {
|
|
353
414
|
x: currentX,
|
|
354
415
|
y: currentY,
|
|
@@ -361,11 +422,13 @@ const DrawCore = _ref => {
|
|
|
361
422
|
zone,
|
|
362
423
|
newlyCreated
|
|
363
424
|
} = ctx;
|
|
364
|
-
if (zone === 'OUT' && newlyCreated === false) {
|
|
425
|
+
if (zone === 'OUT' && newlyCreated === false && mode.value !== 'text') {
|
|
426
|
+
console.log('on active out');
|
|
365
427
|
ctx.newlyCreated = true;
|
|
428
|
+
/*
|
|
366
429
|
if (mode.value === 'text') {
|
|
367
430
|
runOnJS(setTextVal)('');
|
|
368
|
-
}
|
|
431
|
+
}*/
|
|
369
432
|
drawNewItem(mode, currentItem, addDoneItem, {
|
|
370
433
|
x: startX,
|
|
371
434
|
y: startY
|
|
@@ -377,7 +440,7 @@ const DrawCore = _ref => {
|
|
|
377
440
|
itemIsSelected.value = true;
|
|
378
441
|
onCancelChangeWrapper && runOnJS(onCancelChangeWrapper)(true);
|
|
379
442
|
}
|
|
380
|
-
switch ((_currentItem$
|
|
443
|
+
switch ((_currentItem$value5 = currentItem.value) === null || _currentItem$value5 === void 0 ? void 0 : _currentItem$value5.type) {
|
|
381
444
|
case 'pen':
|
|
382
445
|
if (((_initialItem$value = initialItem.value) === null || _initialItem$value === void 0 ? void 0 : _initialItem$value.type) === currentItem.value.type && zone === 'CENTER') {
|
|
383
446
|
currentItem.value = {
|
|
@@ -579,6 +642,7 @@ const DrawCore = _ref => {
|
|
|
579
642
|
break;
|
|
580
643
|
case 'singleHead':
|
|
581
644
|
case 'doubleHead':
|
|
645
|
+
case 'doubleArrows':
|
|
582
646
|
if (((_initialItem$value17 = initialItem.value) === null || _initialItem$value17 === void 0 ? void 0 : _initialItem$value17.type) === currentItem.value.type) {
|
|
583
647
|
var _initialItem$value18, _initialItem$value19, _initialItem$value20, _initialItem$value21, _initialItem$value22, _initialItem$value23, _initialItem$value24, _initialItem$value25, _initialItem$value26, _initialItem$value27, _initialItem$value28, _initialItem$value29;
|
|
584
648
|
const x1 = typeof ((_initialItem$value18 = initialItem.value) === null || _initialItem$value18 === void 0 ? void 0 : _initialItem$value18.data.x1) === 'string' ? parseFloat((_initialItem$value19 = initialItem.value) === null || _initialItem$value19 === void 0 ? void 0 : _initialItem$value19.data.x1) : ((_initialItem$value20 = initialItem.value) === null || _initialItem$value20 === void 0 ? void 0 : _initialItem$value20.data.x1) || 0;
|
|
@@ -591,6 +655,7 @@ const DrawCore = _ref => {
|
|
|
591
655
|
type: currentItem.value.type,
|
|
592
656
|
strokeWidth: currentItem.value.strokeWidth,
|
|
593
657
|
color: currentItem.value.color,
|
|
658
|
+
text: currentItem.value.type === 'doubleArrows' ? currentItem.value.text ?? '' : '',
|
|
594
659
|
data: {
|
|
595
660
|
x1: x1 + translationX,
|
|
596
661
|
y1: y1 + translationY,
|
|
@@ -604,6 +669,7 @@ const DrawCore = _ref => {
|
|
|
604
669
|
type: currentItem.value.type,
|
|
605
670
|
strokeWidth: currentItem.value.strokeWidth,
|
|
606
671
|
color: currentItem.value.color,
|
|
672
|
+
text: currentItem.value.type === 'doubleArrows' ? currentItem.value.text ?? '' : '',
|
|
607
673
|
data: {
|
|
608
674
|
x1: x1,
|
|
609
675
|
y1: y1,
|
|
@@ -617,6 +683,7 @@ const DrawCore = _ref => {
|
|
|
617
683
|
type: currentItem.value.type,
|
|
618
684
|
strokeWidth: currentItem.value.strokeWidth,
|
|
619
685
|
color: currentItem.value.color,
|
|
686
|
+
text: currentItem.value.type === 'doubleArrows' ? currentItem.value.text ?? '' : '',
|
|
620
687
|
data: {
|
|
621
688
|
x1: x1 + translationX,
|
|
622
689
|
y1: y1 + translationY,
|
|
@@ -631,6 +698,7 @@ const DrawCore = _ref => {
|
|
|
631
698
|
type: currentItem.value.type,
|
|
632
699
|
strokeWidth: currentItem.value.strokeWidth,
|
|
633
700
|
color: currentItem.value.color,
|
|
701
|
+
text: currentItem.value.type === 'doubleArrows' ? currentItem.value.text ?? '' : '',
|
|
634
702
|
data: {
|
|
635
703
|
x1: startX,
|
|
636
704
|
y1: startY,
|
|
@@ -641,6 +709,7 @@ const DrawCore = _ref => {
|
|
|
641
709
|
}
|
|
642
710
|
break;
|
|
643
711
|
case 'text':
|
|
712
|
+
console.log('on active text');
|
|
644
713
|
if (((_initialItem$value30 = initialItem.value) === null || _initialItem$value30 === void 0 ? void 0 : _initialItem$value30.type) === currentItem.value.type) {
|
|
645
714
|
var _initialItem$value31, _initialItem$value32, _initialItem$value33, _initialItem$value34, _initialItem$value35, _initialItem$value36, _initialItem$value37, _initialItem$value38, _initialItem$value39, _initialItem$value40, _initialItem$value41, _initialItem$value42;
|
|
646
715
|
const xText = typeof ((_initialItem$value31 = initialItem.value) === null || _initialItem$value31 === void 0 ? void 0 : _initialItem$value31.data.x) === 'string' ? parseFloat((_initialItem$value32 = initialItem.value) === null || _initialItem$value32 === void 0 ? void 0 : _initialItem$value32.data.x) : ((_initialItem$value33 = initialItem.value) === null || _initialItem$value33 === void 0 ? void 0 : _initialItem$value33.data.x) || 0;
|
|
@@ -708,8 +777,11 @@ const DrawCore = _ref => {
|
|
|
708
777
|
}
|
|
709
778
|
},
|
|
710
779
|
onEnd: _event => {
|
|
711
|
-
var _currentItem$
|
|
712
|
-
if (((_currentItem$
|
|
780
|
+
var _currentItem$value6, _currentItem$value7;
|
|
781
|
+
if (((_currentItem$value6 = currentItem.value) === null || _currentItem$value6 === void 0 ? void 0 : _currentItem$value6.type) === 'doubleArrows') {
|
|
782
|
+
runOnJS(textFocusState)();
|
|
783
|
+
}
|
|
784
|
+
if (((_currentItem$value7 = currentItem.value) === null || _currentItem$value7 === void 0 ? void 0 : _currentItem$value7.type) === 'text') {
|
|
713
785
|
runOnJS(textFocus)();
|
|
714
786
|
currentItem.value = {
|
|
715
787
|
type: currentItem.value.type,
|
|
@@ -728,6 +800,7 @@ const DrawCore = _ref => {
|
|
|
728
800
|
});
|
|
729
801
|
const sudDidShow = Keyboard.addListener('keyboardDidShow', event => {
|
|
730
802
|
// avoid events triggered by InputAccessoryView
|
|
803
|
+
console.log('keyboardDidShow dc');
|
|
731
804
|
if (event.endCoordinates.height > 100) {
|
|
732
805
|
showTextInput.value = true;
|
|
733
806
|
}
|
|
@@ -746,44 +819,17 @@ const DrawCore = _ref => {
|
|
|
746
819
|
color: color === null || color === void 0 ? void 0 : color.value
|
|
747
820
|
};
|
|
748
821
|
}, _ref4 => {
|
|
749
|
-
var _currentItem$
|
|
822
|
+
var _currentItem$value8;
|
|
750
823
|
let {
|
|
751
824
|
strokeWidth: sw,
|
|
752
825
|
color: c
|
|
753
826
|
} = _ref4;
|
|
754
|
-
switch ((_currentItem$
|
|
827
|
+
switch ((_currentItem$value8 = currentItem.value) === null || _currentItem$value8 === void 0 ? void 0 : _currentItem$value8.type) {
|
|
755
828
|
case 'singleHead':
|
|
756
|
-
currentItem.value = {
|
|
757
|
-
type: currentItem.value.type,
|
|
758
|
-
data: currentItem.value.data,
|
|
759
|
-
strokeWidth: sw,
|
|
760
|
-
color: c
|
|
761
|
-
};
|
|
762
|
-
break;
|
|
763
829
|
case 'doubleHead':
|
|
764
|
-
|
|
765
|
-
type: currentItem.value.type,
|
|
766
|
-
data: currentItem.value.data,
|
|
767
|
-
strokeWidth: sw,
|
|
768
|
-
color: c
|
|
769
|
-
};
|
|
770
|
-
break;
|
|
830
|
+
case 'doubleArrows':
|
|
771
831
|
case 'ellipse':
|
|
772
|
-
currentItem.value = {
|
|
773
|
-
type: currentItem.value.type,
|
|
774
|
-
data: currentItem.value.data,
|
|
775
|
-
strokeWidth: sw,
|
|
776
|
-
color: c
|
|
777
|
-
};
|
|
778
|
-
break;
|
|
779
832
|
case 'rectangle':
|
|
780
|
-
currentItem.value = {
|
|
781
|
-
type: currentItem.value.type,
|
|
782
|
-
data: currentItem.value.data,
|
|
783
|
-
strokeWidth: sw,
|
|
784
|
-
color: c
|
|
785
|
-
};
|
|
786
|
-
break;
|
|
787
833
|
case 'pen':
|
|
788
834
|
currentItem.value = {
|
|
789
835
|
type: currentItem.value.type,
|
|
@@ -804,22 +850,58 @@ const DrawCore = _ref => {
|
|
|
804
850
|
}
|
|
805
851
|
}, [strokeWidth.value, color === null || color === void 0 ? void 0 : color.value]);
|
|
806
852
|
const onPressItem = useCallback((item, index) => () => {
|
|
853
|
+
console.log('onPressItem');
|
|
807
854
|
itemIsSelected.value = true;
|
|
808
855
|
const previousItem = currentItem.value;
|
|
809
856
|
strokeWidth.value = item.strokeWidth;
|
|
810
857
|
color.value = item.color;
|
|
858
|
+
console.log('item', item);
|
|
811
859
|
currentItem.value = item;
|
|
812
860
|
deleteDoneItem(index);
|
|
813
861
|
if (previousItem) {
|
|
814
862
|
addDoneItem(previousItem);
|
|
815
863
|
}
|
|
816
864
|
if (item.type === 'text') {
|
|
865
|
+
var _textInputRef$current2;
|
|
817
866
|
setTextVal(item.text ?? '');
|
|
867
|
+
(_textInputRef$current2 = textInputRef.current) === null || _textInputRef$current2 === void 0 ? void 0 : _textInputRef$current2.focus();
|
|
868
|
+
} else if (item.type === 'doubleArrows') {
|
|
869
|
+
//setTextVal(item.text ?? '');
|
|
870
|
+
//textInputRef.current?.focus();
|
|
818
871
|
} else {
|
|
819
|
-
var _textInputRef$
|
|
820
|
-
(_textInputRef$
|
|
872
|
+
var _textInputRef$current3;
|
|
873
|
+
(_textInputRef$current3 = textInputRef.current) === null || _textInputRef$current3 === void 0 ? void 0 : _textInputRef$current3.blur();
|
|
821
874
|
}
|
|
822
875
|
}, [itemIsSelected, currentItem, strokeWidth, color, deleteDoneItem, addDoneItem]);
|
|
876
|
+
/*
|
|
877
|
+
const onPressItemText = useCallback(
|
|
878
|
+
(item: DrawItem, index: number) => () => {
|
|
879
|
+
itemIsSelected.value = true;
|
|
880
|
+
const previousItem = currentItem.value;
|
|
881
|
+
strokeWidth.value = item.strokeWidth;
|
|
882
|
+
color.value = item.color;
|
|
883
|
+
currentItem.value = item;
|
|
884
|
+
deleteDoneItem(index);
|
|
885
|
+
if (previousItem) {
|
|
886
|
+
addDoneItem(previousItem);
|
|
887
|
+
}
|
|
888
|
+
if (item.type === 'text') {
|
|
889
|
+
setTextVal(item.text ?? '');
|
|
890
|
+
|
|
891
|
+
} else {
|
|
892
|
+
textInputRef.current?.blur();
|
|
893
|
+
}
|
|
894
|
+
},
|
|
895
|
+
[
|
|
896
|
+
itemIsSelected,
|
|
897
|
+
currentItem,
|
|
898
|
+
strokeWidth,
|
|
899
|
+
color,
|
|
900
|
+
deleteDoneItem,
|
|
901
|
+
addDoneItem,
|
|
902
|
+
]
|
|
903
|
+
);*/
|
|
904
|
+
|
|
823
905
|
const onTextHeightChange = useCallback(height => {
|
|
824
906
|
onTextHeightUpdate(currentItem, textBaseHeight, height);
|
|
825
907
|
}, [currentItem, textBaseHeight]);
|
|
@@ -858,24 +940,35 @@ const DrawCore = _ref => {
|
|
|
858
940
|
|
|
859
941
|
// do not remove keyboard will appear over the drawing frame and not shift it
|
|
860
942
|
useAnimatedKeyboard();
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
}
|
|
870
|
-
}, [
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
943
|
+
|
|
944
|
+
/*
|
|
945
|
+
const onEndEditingTextInput = useCallback(() => {
|
|
946
|
+
console.log('onEndEditingTextInput');
|
|
947
|
+
setShowTextInputState(false);
|
|
948
|
+
if (currentItem.value && currentItem.value.type === 'doubleArrows') {
|
|
949
|
+
console.log(currentItem.value.text);
|
|
950
|
+
addScreenStates(currentItem.value);
|
|
951
|
+
}
|
|
952
|
+
}, [currentItem, addScreenStates]);
|
|
953
|
+
const onChangeText = useCallback(
|
|
954
|
+
(value: string) => {
|
|
955
|
+
if (
|
|
956
|
+
value &&
|
|
957
|
+
currentItem.value &&
|
|
958
|
+
currentItem.value.type === 'doubleArrows'
|
|
959
|
+
) {
|
|
960
|
+
console.log('******************');
|
|
961
|
+
console.log(value);
|
|
962
|
+
console.log(currentItem.value);
|
|
963
|
+
currentItem.value = {
|
|
964
|
+
...currentItem.value,
|
|
965
|
+
text: value,
|
|
966
|
+
};
|
|
967
|
+
}
|
|
968
|
+
},
|
|
969
|
+
[currentItem]
|
|
970
|
+
);
|
|
971
|
+
*/
|
|
879
972
|
return /*#__PURE__*/React.createElement(View, {
|
|
880
973
|
style: styles.container
|
|
881
974
|
}, /*#__PURE__*/React.createElement(View, {
|
|
@@ -888,6 +981,9 @@ const DrawCore = _ref => {
|
|
|
888
981
|
width: event.nativeEvent.layout.width
|
|
889
982
|
});
|
|
890
983
|
}
|
|
984
|
+
}, /*#__PURE__*/React.createElement(KeyboardAvoidingView, {
|
|
985
|
+
behavior: "position",
|
|
986
|
+
keyboardVerticalOffset: 70
|
|
891
987
|
}, /*#__PURE__*/React.createElement(PanGestureHandler, {
|
|
892
988
|
onGestureEvent: onGestureEvent
|
|
893
989
|
}, /*#__PURE__*/React.createElement(Animated.View, {
|
|
@@ -923,16 +1019,7 @@ const DrawCore = _ref => {
|
|
|
923
1019
|
doneItems: drawState.doneItems,
|
|
924
1020
|
onPressItem: onPressItem,
|
|
925
1021
|
onTextHeightChange: onTextHeightChange
|
|
926
|
-
})) : null))),
|
|
927
|
-
ref: textInputRef,
|
|
928
|
-
style: [styles.textInput, textInputStyle],
|
|
929
|
-
onEndEditing: (_textInputRef$current3 = textInputRef.current) === null || _textInputRef$current3 === void 0 ? void 0 : _textInputRef$current3.clear,
|
|
930
|
-
onChangeText: setTextVal,
|
|
931
|
-
value: textVal,
|
|
932
|
-
autoCorrect: false
|
|
933
|
-
})) : /*#__PURE__*/React.createElement(Animated.View, {
|
|
934
|
-
style: textInputContainerStyle
|
|
935
|
-
}, ((_currentItem$value7 = currentItem.value) === null || _currentItem$value7 === void 0 ? void 0 : _currentItem$value7.type) === 'text' && /*#__PURE__*/React.createElement(TextInput, {
|
|
1022
|
+
})) : null))), /*#__PURE__*/React.createElement(TextInput, {
|
|
936
1023
|
ref: textInputRef,
|
|
937
1024
|
style: styles.textInput,
|
|
938
1025
|
onEndEditing: (_textInputRef$current4 = textInputRef.current) === null || _textInputRef$current4 === void 0 ? void 0 : _textInputRef$current4.clear,
|