@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
|
@@ -34,7 +34,10 @@ const styles = _reactNative.StyleSheet.create({
|
|
|
34
34
|
paddingHorizontal: 24,
|
|
35
35
|
fontSize: 16,
|
|
36
36
|
color: 'white',
|
|
37
|
-
width: '100%'
|
|
37
|
+
width: '100%',
|
|
38
|
+
opacity: 0,
|
|
39
|
+
height: 20,
|
|
40
|
+
maxWidth: 20
|
|
38
41
|
}
|
|
39
42
|
});
|
|
40
43
|
const pDistance = (point, line) => {
|
|
@@ -76,7 +79,6 @@ const pDistance = (point, line) => {
|
|
|
76
79
|
var dy = y - yy;
|
|
77
80
|
return Math.sqrt(dx * dx + dy * dy);
|
|
78
81
|
};
|
|
79
|
-
const AnimatedTextInput = _reactNativeReanimated.default.createAnimatedComponent(_reactNative.TextInput);
|
|
80
82
|
const DEFAULT_TEXT = '';
|
|
81
83
|
const THRESHOLD = 20;
|
|
82
84
|
const drawNewItem = (mode, currentItem, addDoneItem, position, style) => {
|
|
@@ -126,6 +128,19 @@ const drawNewItem = (mode, currentItem, addDoneItem, position, style) => {
|
|
|
126
128
|
color: style.color.value
|
|
127
129
|
};
|
|
128
130
|
break;
|
|
131
|
+
case 'doubleArrows':
|
|
132
|
+
currentItem.value = {
|
|
133
|
+
type: mode.value,
|
|
134
|
+
data: {
|
|
135
|
+
x1: position.x,
|
|
136
|
+
y1: position.y,
|
|
137
|
+
x2: position.x,
|
|
138
|
+
y2: position.y
|
|
139
|
+
},
|
|
140
|
+
strokeWidth: style.strokeWidth.value,
|
|
141
|
+
color: style.color.value
|
|
142
|
+
};
|
|
143
|
+
break;
|
|
129
144
|
case 'text':
|
|
130
145
|
currentItem.value = {
|
|
131
146
|
type: mode.value,
|
|
@@ -169,7 +184,7 @@ const onTextHeightUpdate = (currentItem, textBaseHeight, height) => {
|
|
|
169
184
|
}
|
|
170
185
|
};
|
|
171
186
|
const DrawCore = _ref => {
|
|
172
|
-
var _textInputRef$
|
|
187
|
+
var _textInputRef$current4;
|
|
173
188
|
let {
|
|
174
189
|
image,
|
|
175
190
|
backgroundColor
|
|
@@ -181,7 +196,8 @@ const DrawCore = _ref => {
|
|
|
181
196
|
color,
|
|
182
197
|
currentItem,
|
|
183
198
|
itemIsSelected,
|
|
184
|
-
viewShot
|
|
199
|
+
viewShot,
|
|
200
|
+
doubleArrowTextInput
|
|
185
201
|
} = (0, _useDrawHook.default)();
|
|
186
202
|
const onCancelChangeWrapper = arg => {
|
|
187
203
|
dispatchDrawStates({
|
|
@@ -223,14 +239,23 @@ const DrawCore = _ref => {
|
|
|
223
239
|
currentItem.value = null;
|
|
224
240
|
itemIsSelected.value = false;
|
|
225
241
|
}, [drawState.drawingMode, mode, currentItem, addDoneItem, itemIsSelected]);
|
|
226
|
-
const showTextInput = (0, _reactNativeReanimated.useSharedValue)(false);
|
|
242
|
+
const showTextInput = (0, _reactNativeReanimated.useSharedValue)(false); //TODO: remove
|
|
243
|
+
|
|
244
|
+
const textFocusState = (0, _react.useCallback)(() => {
|
|
245
|
+
var _doubleArrowTextInput;
|
|
246
|
+
//setShowTextInputState(true);
|
|
247
|
+
console.log('textFocusState');
|
|
248
|
+
doubleArrowTextInput === null || doubleArrowTextInput === void 0 ? void 0 : (_doubleArrowTextInput = doubleArrowTextInput.current) === null || _doubleArrowTextInput === void 0 ? void 0 : _doubleArrowTextInput.focus();
|
|
249
|
+
}, [doubleArrowTextInput]);
|
|
227
250
|
const textFocus = (0, _react.useCallback)(() => {
|
|
228
251
|
var _textInputRef$current;
|
|
252
|
+
console.log('textFocus');
|
|
229
253
|
(_textInputRef$current = textInputRef.current) === null || _textInputRef$current === void 0 ? void 0 : _textInputRef$current.focus();
|
|
230
254
|
}, []);
|
|
231
255
|
(0, _react.useEffect)(() => {
|
|
232
256
|
var _currentItem$value2;
|
|
233
257
|
if (((_currentItem$value2 = currentItem.value) === null || _currentItem$value2 === void 0 ? void 0 : _currentItem$value2.type) === 'text') {
|
|
258
|
+
console.log('use effect text');
|
|
234
259
|
showTextInput.value = true;
|
|
235
260
|
textFocus();
|
|
236
261
|
currentItem.value = {
|
|
@@ -244,7 +269,7 @@ const DrawCore = _ref => {
|
|
|
244
269
|
}, [currentItem, showTextInput, textFocus, textVal]);
|
|
245
270
|
const onGestureEvent = (0, _reactNativeReanimated.useAnimatedGestureHandler)({
|
|
246
271
|
onStart: (_ref2, ctx) => {
|
|
247
|
-
var _currentItem$value3;
|
|
272
|
+
var _currentItem$value3, _currentItem$value4;
|
|
248
273
|
let {
|
|
249
274
|
x: startX,
|
|
250
275
|
y: startY
|
|
@@ -252,11 +277,12 @@ const DrawCore = _ref => {
|
|
|
252
277
|
ctx.startX = startX;
|
|
253
278
|
ctx.startY = startY;
|
|
254
279
|
ctx.newlyCreated = false;
|
|
255
|
-
|
|
280
|
+
console.log('**********************************');
|
|
281
|
+
console.log('onGestureEvent');
|
|
256
282
|
//panPosition.value = withTiming(RIGHT_PANE_WIDTH);
|
|
257
|
-
|
|
283
|
+
console.log('onStart', (_currentItem$value3 = currentItem.value) === null || _currentItem$value3 === void 0 ? void 0 : _currentItem$value3.type);
|
|
258
284
|
initialItem.value = currentItem.value;
|
|
259
|
-
switch ((_currentItem$
|
|
285
|
+
switch ((_currentItem$value4 = currentItem.value) === null || _currentItem$value4 === void 0 ? void 0 : _currentItem$value4.type) {
|
|
260
286
|
case 'ellipse':
|
|
261
287
|
const cx = typeof currentItem.value.data.cx === 'string' ? parseFloat(currentItem.value.data.cx) : currentItem.value.data.cx || 0;
|
|
262
288
|
const cy = typeof currentItem.value.data.cy === 'string' ? parseFloat(currentItem.value.data.cy) : currentItem.value.data.cy || 0;
|
|
@@ -302,6 +328,7 @@ const DrawCore = _ref => {
|
|
|
302
328
|
}
|
|
303
329
|
break;
|
|
304
330
|
case 'doubleHead':
|
|
331
|
+
case 'doubleArrows':
|
|
305
332
|
case 'singleHead':
|
|
306
333
|
const x1 = typeof currentItem.value.data.x1 === 'string' ? parseFloat(currentItem.value.data.x1) : currentItem.value.data.x1 || 0;
|
|
307
334
|
const y1 = typeof currentItem.value.data.y1 === 'string' ? parseFloat(currentItem.value.data.y1) : currentItem.value.data.y1 || 0;
|
|
@@ -331,15 +358,32 @@ const DrawCore = _ref => {
|
|
|
331
358
|
const yText = typeof currentItem.value.data.y === 'string' ? parseFloat(currentItem.value.data.y) : currentItem.value.data.y || 0;
|
|
332
359
|
const widthText = typeof currentItem.value.data.width === 'string' ? parseFloat(currentItem.value.data.width) : currentItem.value.data.width || 0;
|
|
333
360
|
const heightText = typeof currentItem.value.data.height === 'string' ? parseFloat(currentItem.value.data.height) : currentItem.value.data.height || 0;
|
|
361
|
+
console.log(heightText);
|
|
362
|
+
console.log(widthText);
|
|
334
363
|
if (startX <= xText + THRESHOLD && startX >= xText - THRESHOLD && startY <= yText + heightText / 2 + THRESHOLD && startY >= yText + heightText / 2 - THRESHOLD) {
|
|
335
364
|
ctx.zone = 'LEFT';
|
|
336
365
|
} else if (startX <= xText + widthText + THRESHOLD && startX >= xText + widthText - THRESHOLD && startY <= yText + heightText / 2 + THRESHOLD && startY >= yText + heightText / 2 - THRESHOLD) {
|
|
337
366
|
ctx.zone = 'RIGHT';
|
|
338
367
|
} 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)) {
|
|
339
368
|
ctx.zone = 'CENTER';
|
|
369
|
+
console.log('on active center');
|
|
340
370
|
} else {
|
|
341
371
|
ctx.zone = 'OUT';
|
|
372
|
+
console.log('on active out');
|
|
342
373
|
initialItem.value = null;
|
|
374
|
+
ctx.newlyCreated = true;
|
|
375
|
+
(0, _reactNativeReanimated.runOnJS)(setTextVal)('');
|
|
376
|
+
drawNewItem(mode, currentItem, addDoneItem, {
|
|
377
|
+
x: startX,
|
|
378
|
+
y: startY
|
|
379
|
+
}, {
|
|
380
|
+
textBaseHeight,
|
|
381
|
+
strokeWidth,
|
|
382
|
+
color
|
|
383
|
+
});
|
|
384
|
+
itemIsSelected.value = true;
|
|
385
|
+
onCancelChangeWrapper && (0, _reactNativeReanimated.runOnJS)(onCancelChangeWrapper)(true);
|
|
386
|
+
(0, _reactNativeReanimated.runOnJS)(textFocus)();
|
|
343
387
|
}
|
|
344
388
|
break;
|
|
345
389
|
case 'pen':
|
|
@@ -353,11 +397,28 @@ const DrawCore = _ref => {
|
|
|
353
397
|
default:
|
|
354
398
|
ctx.zone = 'OUT';
|
|
355
399
|
initialItem.value = null;
|
|
400
|
+
if (drawState.drawingMode === 'text') {
|
|
401
|
+
/* NEW GEOFF */
|
|
402
|
+
console.log('on active out');
|
|
403
|
+
ctx.newlyCreated = true;
|
|
404
|
+
(0, _reactNativeReanimated.runOnJS)(setTextVal)('');
|
|
405
|
+
drawNewItem(mode, currentItem, addDoneItem, {
|
|
406
|
+
x: startX,
|
|
407
|
+
y: startY
|
|
408
|
+
}, {
|
|
409
|
+
textBaseHeight,
|
|
410
|
+
strokeWidth,
|
|
411
|
+
color
|
|
412
|
+
});
|
|
413
|
+
itemIsSelected.value = true;
|
|
414
|
+
onCancelChangeWrapper && (0, _reactNativeReanimated.runOnJS)(onCancelChangeWrapper)(true);
|
|
415
|
+
(0, _reactNativeReanimated.runOnJS)(textFocus)();
|
|
416
|
+
}
|
|
356
417
|
break;
|
|
357
418
|
}
|
|
358
419
|
},
|
|
359
420
|
onActive: (_ref3, ctx) => {
|
|
360
|
-
var _currentItem$
|
|
421
|
+
var _currentItem$value5, _initialItem$value, _initialItem$value2, _initialItem$value4, _initialItem$value17, _initialItem$value30;
|
|
361
422
|
let {
|
|
362
423
|
x: currentX,
|
|
363
424
|
y: currentY,
|
|
@@ -370,11 +431,13 @@ const DrawCore = _ref => {
|
|
|
370
431
|
zone,
|
|
371
432
|
newlyCreated
|
|
372
433
|
} = ctx;
|
|
373
|
-
if (zone === 'OUT' && newlyCreated === false) {
|
|
434
|
+
if (zone === 'OUT' && newlyCreated === false && mode.value !== 'text') {
|
|
435
|
+
console.log('on active out');
|
|
374
436
|
ctx.newlyCreated = true;
|
|
437
|
+
/*
|
|
375
438
|
if (mode.value === 'text') {
|
|
376
|
-
|
|
377
|
-
}
|
|
439
|
+
runOnJS(setTextVal)('');
|
|
440
|
+
}*/
|
|
378
441
|
drawNewItem(mode, currentItem, addDoneItem, {
|
|
379
442
|
x: startX,
|
|
380
443
|
y: startY
|
|
@@ -386,7 +449,7 @@ const DrawCore = _ref => {
|
|
|
386
449
|
itemIsSelected.value = true;
|
|
387
450
|
onCancelChangeWrapper && (0, _reactNativeReanimated.runOnJS)(onCancelChangeWrapper)(true);
|
|
388
451
|
}
|
|
389
|
-
switch ((_currentItem$
|
|
452
|
+
switch ((_currentItem$value5 = currentItem.value) === null || _currentItem$value5 === void 0 ? void 0 : _currentItem$value5.type) {
|
|
390
453
|
case 'pen':
|
|
391
454
|
if (((_initialItem$value = initialItem.value) === null || _initialItem$value === void 0 ? void 0 : _initialItem$value.type) === currentItem.value.type && zone === 'CENTER') {
|
|
392
455
|
currentItem.value = {
|
|
@@ -588,6 +651,7 @@ const DrawCore = _ref => {
|
|
|
588
651
|
break;
|
|
589
652
|
case 'singleHead':
|
|
590
653
|
case 'doubleHead':
|
|
654
|
+
case 'doubleArrows':
|
|
591
655
|
if (((_initialItem$value17 = initialItem.value) === null || _initialItem$value17 === void 0 ? void 0 : _initialItem$value17.type) === currentItem.value.type) {
|
|
592
656
|
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;
|
|
593
657
|
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;
|
|
@@ -600,6 +664,7 @@ const DrawCore = _ref => {
|
|
|
600
664
|
type: currentItem.value.type,
|
|
601
665
|
strokeWidth: currentItem.value.strokeWidth,
|
|
602
666
|
color: currentItem.value.color,
|
|
667
|
+
text: currentItem.value.type === 'doubleArrows' ? currentItem.value.text ?? '' : '',
|
|
603
668
|
data: {
|
|
604
669
|
x1: x1 + translationX,
|
|
605
670
|
y1: y1 + translationY,
|
|
@@ -613,6 +678,7 @@ const DrawCore = _ref => {
|
|
|
613
678
|
type: currentItem.value.type,
|
|
614
679
|
strokeWidth: currentItem.value.strokeWidth,
|
|
615
680
|
color: currentItem.value.color,
|
|
681
|
+
text: currentItem.value.type === 'doubleArrows' ? currentItem.value.text ?? '' : '',
|
|
616
682
|
data: {
|
|
617
683
|
x1: x1,
|
|
618
684
|
y1: y1,
|
|
@@ -626,6 +692,7 @@ const DrawCore = _ref => {
|
|
|
626
692
|
type: currentItem.value.type,
|
|
627
693
|
strokeWidth: currentItem.value.strokeWidth,
|
|
628
694
|
color: currentItem.value.color,
|
|
695
|
+
text: currentItem.value.type === 'doubleArrows' ? currentItem.value.text ?? '' : '',
|
|
629
696
|
data: {
|
|
630
697
|
x1: x1 + translationX,
|
|
631
698
|
y1: y1 + translationY,
|
|
@@ -640,6 +707,7 @@ const DrawCore = _ref => {
|
|
|
640
707
|
type: currentItem.value.type,
|
|
641
708
|
strokeWidth: currentItem.value.strokeWidth,
|
|
642
709
|
color: currentItem.value.color,
|
|
710
|
+
text: currentItem.value.type === 'doubleArrows' ? currentItem.value.text ?? '' : '',
|
|
643
711
|
data: {
|
|
644
712
|
x1: startX,
|
|
645
713
|
y1: startY,
|
|
@@ -650,6 +718,7 @@ const DrawCore = _ref => {
|
|
|
650
718
|
}
|
|
651
719
|
break;
|
|
652
720
|
case 'text':
|
|
721
|
+
console.log('on active text');
|
|
653
722
|
if (((_initialItem$value30 = initialItem.value) === null || _initialItem$value30 === void 0 ? void 0 : _initialItem$value30.type) === currentItem.value.type) {
|
|
654
723
|
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;
|
|
655
724
|
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;
|
|
@@ -717,8 +786,11 @@ const DrawCore = _ref => {
|
|
|
717
786
|
}
|
|
718
787
|
},
|
|
719
788
|
onEnd: _event => {
|
|
720
|
-
var _currentItem$
|
|
721
|
-
if (((_currentItem$
|
|
789
|
+
var _currentItem$value6, _currentItem$value7;
|
|
790
|
+
if (((_currentItem$value6 = currentItem.value) === null || _currentItem$value6 === void 0 ? void 0 : _currentItem$value6.type) === 'doubleArrows') {
|
|
791
|
+
(0, _reactNativeReanimated.runOnJS)(textFocusState)();
|
|
792
|
+
}
|
|
793
|
+
if (((_currentItem$value7 = currentItem.value) === null || _currentItem$value7 === void 0 ? void 0 : _currentItem$value7.type) === 'text') {
|
|
722
794
|
(0, _reactNativeReanimated.runOnJS)(textFocus)();
|
|
723
795
|
currentItem.value = {
|
|
724
796
|
type: currentItem.value.type,
|
|
@@ -737,6 +809,7 @@ const DrawCore = _ref => {
|
|
|
737
809
|
});
|
|
738
810
|
const sudDidShow = _reactNative.Keyboard.addListener('keyboardDidShow', event => {
|
|
739
811
|
// avoid events triggered by InputAccessoryView
|
|
812
|
+
console.log('keyboardDidShow dc');
|
|
740
813
|
if (event.endCoordinates.height > 100) {
|
|
741
814
|
showTextInput.value = true;
|
|
742
815
|
}
|
|
@@ -755,44 +828,17 @@ const DrawCore = _ref => {
|
|
|
755
828
|
color: color === null || color === void 0 ? void 0 : color.value
|
|
756
829
|
};
|
|
757
830
|
}, _ref4 => {
|
|
758
|
-
var _currentItem$
|
|
831
|
+
var _currentItem$value8;
|
|
759
832
|
let {
|
|
760
833
|
strokeWidth: sw,
|
|
761
834
|
color: c
|
|
762
835
|
} = _ref4;
|
|
763
|
-
switch ((_currentItem$
|
|
836
|
+
switch ((_currentItem$value8 = currentItem.value) === null || _currentItem$value8 === void 0 ? void 0 : _currentItem$value8.type) {
|
|
764
837
|
case 'singleHead':
|
|
765
|
-
currentItem.value = {
|
|
766
|
-
type: currentItem.value.type,
|
|
767
|
-
data: currentItem.value.data,
|
|
768
|
-
strokeWidth: sw,
|
|
769
|
-
color: c
|
|
770
|
-
};
|
|
771
|
-
break;
|
|
772
838
|
case 'doubleHead':
|
|
773
|
-
|
|
774
|
-
type: currentItem.value.type,
|
|
775
|
-
data: currentItem.value.data,
|
|
776
|
-
strokeWidth: sw,
|
|
777
|
-
color: c
|
|
778
|
-
};
|
|
779
|
-
break;
|
|
839
|
+
case 'doubleArrows':
|
|
780
840
|
case 'ellipse':
|
|
781
|
-
currentItem.value = {
|
|
782
|
-
type: currentItem.value.type,
|
|
783
|
-
data: currentItem.value.data,
|
|
784
|
-
strokeWidth: sw,
|
|
785
|
-
color: c
|
|
786
|
-
};
|
|
787
|
-
break;
|
|
788
841
|
case 'rectangle':
|
|
789
|
-
currentItem.value = {
|
|
790
|
-
type: currentItem.value.type,
|
|
791
|
-
data: currentItem.value.data,
|
|
792
|
-
strokeWidth: sw,
|
|
793
|
-
color: c
|
|
794
|
-
};
|
|
795
|
-
break;
|
|
796
842
|
case 'pen':
|
|
797
843
|
currentItem.value = {
|
|
798
844
|
type: currentItem.value.type,
|
|
@@ -813,22 +859,58 @@ const DrawCore = _ref => {
|
|
|
813
859
|
}
|
|
814
860
|
}, [strokeWidth.value, color === null || color === void 0 ? void 0 : color.value]);
|
|
815
861
|
const onPressItem = (0, _react.useCallback)((item, index) => () => {
|
|
862
|
+
console.log('onPressItem');
|
|
816
863
|
itemIsSelected.value = true;
|
|
817
864
|
const previousItem = currentItem.value;
|
|
818
865
|
strokeWidth.value = item.strokeWidth;
|
|
819
866
|
color.value = item.color;
|
|
867
|
+
console.log('item', item);
|
|
820
868
|
currentItem.value = item;
|
|
821
869
|
deleteDoneItem(index);
|
|
822
870
|
if (previousItem) {
|
|
823
871
|
addDoneItem(previousItem);
|
|
824
872
|
}
|
|
825
873
|
if (item.type === 'text') {
|
|
874
|
+
var _textInputRef$current2;
|
|
826
875
|
setTextVal(item.text ?? '');
|
|
876
|
+
(_textInputRef$current2 = textInputRef.current) === null || _textInputRef$current2 === void 0 ? void 0 : _textInputRef$current2.focus();
|
|
877
|
+
} else if (item.type === 'doubleArrows') {
|
|
878
|
+
//setTextVal(item.text ?? '');
|
|
879
|
+
//textInputRef.current?.focus();
|
|
827
880
|
} else {
|
|
828
|
-
var _textInputRef$
|
|
829
|
-
(_textInputRef$
|
|
881
|
+
var _textInputRef$current3;
|
|
882
|
+
(_textInputRef$current3 = textInputRef.current) === null || _textInputRef$current3 === void 0 ? void 0 : _textInputRef$current3.blur();
|
|
830
883
|
}
|
|
831
884
|
}, [itemIsSelected, currentItem, strokeWidth, color, deleteDoneItem, addDoneItem]);
|
|
885
|
+
/*
|
|
886
|
+
const onPressItemText = useCallback(
|
|
887
|
+
(item: DrawItem, index: number) => () => {
|
|
888
|
+
itemIsSelected.value = true;
|
|
889
|
+
const previousItem = currentItem.value;
|
|
890
|
+
strokeWidth.value = item.strokeWidth;
|
|
891
|
+
color.value = item.color;
|
|
892
|
+
currentItem.value = item;
|
|
893
|
+
deleteDoneItem(index);
|
|
894
|
+
if (previousItem) {
|
|
895
|
+
addDoneItem(previousItem);
|
|
896
|
+
}
|
|
897
|
+
if (item.type === 'text') {
|
|
898
|
+
setTextVal(item.text ?? '');
|
|
899
|
+
|
|
900
|
+
} else {
|
|
901
|
+
textInputRef.current?.blur();
|
|
902
|
+
}
|
|
903
|
+
},
|
|
904
|
+
[
|
|
905
|
+
itemIsSelected,
|
|
906
|
+
currentItem,
|
|
907
|
+
strokeWidth,
|
|
908
|
+
color,
|
|
909
|
+
deleteDoneItem,
|
|
910
|
+
addDoneItem,
|
|
911
|
+
]
|
|
912
|
+
);*/
|
|
913
|
+
|
|
832
914
|
const onTextHeightChange = (0, _react.useCallback)(height => {
|
|
833
915
|
onTextHeightUpdate(currentItem, textBaseHeight, height);
|
|
834
916
|
}, [currentItem, textBaseHeight]);
|
|
@@ -867,24 +949,35 @@ const DrawCore = _ref => {
|
|
|
867
949
|
|
|
868
950
|
// do not remove keyboard will appear over the drawing frame and not shift it
|
|
869
951
|
(0, _reactNativeReanimated.useAnimatedKeyboard)();
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
}
|
|
879
|
-
}, [
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
952
|
+
|
|
953
|
+
/*
|
|
954
|
+
const onEndEditingTextInput = useCallback(() => {
|
|
955
|
+
console.log('onEndEditingTextInput');
|
|
956
|
+
setShowTextInputState(false);
|
|
957
|
+
if (currentItem.value && currentItem.value.type === 'doubleArrows') {
|
|
958
|
+
console.log(currentItem.value.text);
|
|
959
|
+
addScreenStates(currentItem.value);
|
|
960
|
+
}
|
|
961
|
+
}, [currentItem, addScreenStates]);
|
|
962
|
+
const onChangeText = useCallback(
|
|
963
|
+
(value: string) => {
|
|
964
|
+
if (
|
|
965
|
+
value &&
|
|
966
|
+
currentItem.value &&
|
|
967
|
+
currentItem.value.type === 'doubleArrows'
|
|
968
|
+
) {
|
|
969
|
+
console.log('******************');
|
|
970
|
+
console.log(value);
|
|
971
|
+
console.log(currentItem.value);
|
|
972
|
+
currentItem.value = {
|
|
973
|
+
...currentItem.value,
|
|
974
|
+
text: value,
|
|
975
|
+
};
|
|
976
|
+
}
|
|
977
|
+
},
|
|
978
|
+
[currentItem]
|
|
979
|
+
);
|
|
980
|
+
*/
|
|
888
981
|
return /*#__PURE__*/_react.default.createElement(_reactNative.View, {
|
|
889
982
|
style: styles.container
|
|
890
983
|
}, /*#__PURE__*/_react.default.createElement(_reactNative.View, {
|
|
@@ -897,6 +990,9 @@ const DrawCore = _ref => {
|
|
|
897
990
|
width: event.nativeEvent.layout.width
|
|
898
991
|
});
|
|
899
992
|
}
|
|
993
|
+
}, /*#__PURE__*/_react.default.createElement(_reactNative.KeyboardAvoidingView, {
|
|
994
|
+
behavior: "position",
|
|
995
|
+
keyboardVerticalOffset: 70
|
|
900
996
|
}, /*#__PURE__*/_react.default.createElement(_reactNativeGestureHandler.PanGestureHandler, {
|
|
901
997
|
onGestureEvent: onGestureEvent
|
|
902
998
|
}, /*#__PURE__*/_react.default.createElement(_reactNativeReanimated.default.View, {
|
|
@@ -932,16 +1028,7 @@ const DrawCore = _ref => {
|
|
|
932
1028
|
doneItems: drawState.doneItems,
|
|
933
1029
|
onPressItem: onPressItem,
|
|
934
1030
|
onTextHeightChange: onTextHeightChange
|
|
935
|
-
})) : null))),
|
|
936
|
-
ref: textInputRef,
|
|
937
|
-
style: [styles.textInput, textInputStyle],
|
|
938
|
-
onEndEditing: (_textInputRef$current3 = textInputRef.current) === null || _textInputRef$current3 === void 0 ? void 0 : _textInputRef$current3.clear,
|
|
939
|
-
onChangeText: setTextVal,
|
|
940
|
-
value: textVal,
|
|
941
|
-
autoCorrect: false
|
|
942
|
-
})) : /*#__PURE__*/_react.default.createElement(_reactNativeReanimated.default.View, {
|
|
943
|
-
style: textInputContainerStyle
|
|
944
|
-
}, ((_currentItem$value7 = currentItem.value) === null || _currentItem$value7 === void 0 ? void 0 : _currentItem$value7.type) === 'text' && /*#__PURE__*/_react.default.createElement(_reactNative.TextInput, {
|
|
1031
|
+
})) : null))), /*#__PURE__*/_react.default.createElement(_reactNative.TextInput, {
|
|
945
1032
|
ref: textInputRef,
|
|
946
1033
|
style: styles.textInput,
|
|
947
1034
|
onEndEditing: (_textInputRef$current4 = textInputRef.current) === null || _textInputRef$current4 === void 0 ? void 0 : _textInputRef$current4.clear,
|