@archireport/react-native-svg-draw 2.2.0 → 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 +21 -7
- 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 +175 -83
- 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/index.js +14 -0
- package/lib/commonjs/components/DrawWithOptions/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 +21 -7
- 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 +176 -84
- 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/index.js +14 -0
- package/lib/module/components/DrawWithOptions/index.js.map +1 -1
- package/lib/typescript/components/DrawCore/CurrentAnimatedItem.d.ts +3 -5
- package/lib/typescript/components/DrawCore/CurrentAnimatedItem.d.ts.map +1 -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 +2 -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 -0
- package/lib/typescript/components/DrawCore/Item.d.ts.map +1 -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/index.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 +20 -4
- package/src/components/DrawCore/DrawProvider.tsx +6 -0
- package/src/components/DrawCore/Item.tsx +188 -7
- package/src/components/DrawCore/index.tsx +243 -120
- 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';
|
|
@@ -10,9 +10,10 @@ const styles = StyleSheet.create({
|
|
|
10
10
|
flex: 1
|
|
11
11
|
},
|
|
12
12
|
drawZone: {
|
|
13
|
-
flex: 1,
|
|
14
13
|
alignContent: 'center',
|
|
15
|
-
alignItems: 'center'
|
|
14
|
+
alignItems: 'center',
|
|
15
|
+
width: '100%',
|
|
16
|
+
height: '100%'
|
|
16
17
|
},
|
|
17
18
|
bgImage: {
|
|
18
19
|
width: '100%',
|
|
@@ -24,7 +25,10 @@ const styles = StyleSheet.create({
|
|
|
24
25
|
paddingHorizontal: 24,
|
|
25
26
|
fontSize: 16,
|
|
26
27
|
color: 'white',
|
|
27
|
-
width: '100%'
|
|
28
|
+
width: '100%',
|
|
29
|
+
opacity: 0,
|
|
30
|
+
height: 20,
|
|
31
|
+
maxWidth: 20
|
|
28
32
|
}
|
|
29
33
|
});
|
|
30
34
|
const pDistance = (point, line) => {
|
|
@@ -66,7 +70,6 @@ const pDistance = (point, line) => {
|
|
|
66
70
|
var dy = y - yy;
|
|
67
71
|
return Math.sqrt(dx * dx + dy * dy);
|
|
68
72
|
};
|
|
69
|
-
const AnimatedTextInput = Animated.createAnimatedComponent(TextInput);
|
|
70
73
|
const DEFAULT_TEXT = '';
|
|
71
74
|
const THRESHOLD = 20;
|
|
72
75
|
const drawNewItem = (mode, currentItem, addDoneItem, position, style) => {
|
|
@@ -116,6 +119,19 @@ const drawNewItem = (mode, currentItem, addDoneItem, position, style) => {
|
|
|
116
119
|
color: style.color.value
|
|
117
120
|
};
|
|
118
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;
|
|
119
135
|
case 'text':
|
|
120
136
|
currentItem.value = {
|
|
121
137
|
type: mode.value,
|
|
@@ -159,7 +175,7 @@ const onTextHeightUpdate = (currentItem, textBaseHeight, height) => {
|
|
|
159
175
|
}
|
|
160
176
|
};
|
|
161
177
|
const DrawCore = _ref => {
|
|
162
|
-
var _textInputRef$
|
|
178
|
+
var _textInputRef$current4;
|
|
163
179
|
let {
|
|
164
180
|
image,
|
|
165
181
|
backgroundColor
|
|
@@ -171,7 +187,8 @@ const DrawCore = _ref => {
|
|
|
171
187
|
color,
|
|
172
188
|
currentItem,
|
|
173
189
|
itemIsSelected,
|
|
174
|
-
viewShot
|
|
190
|
+
viewShot,
|
|
191
|
+
doubleArrowTextInput
|
|
175
192
|
} = useDrawHook();
|
|
176
193
|
const onCancelChangeWrapper = arg => {
|
|
177
194
|
dispatchDrawStates({
|
|
@@ -213,14 +230,23 @@ const DrawCore = _ref => {
|
|
|
213
230
|
currentItem.value = null;
|
|
214
231
|
itemIsSelected.value = false;
|
|
215
232
|
}, [drawState.drawingMode, mode, currentItem, addDoneItem, itemIsSelected]);
|
|
216
|
-
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]);
|
|
217
241
|
const textFocus = useCallback(() => {
|
|
218
242
|
var _textInputRef$current;
|
|
243
|
+
console.log('textFocus');
|
|
219
244
|
(_textInputRef$current = textInputRef.current) === null || _textInputRef$current === void 0 ? void 0 : _textInputRef$current.focus();
|
|
220
245
|
}, []);
|
|
221
246
|
useEffect(() => {
|
|
222
247
|
var _currentItem$value2;
|
|
223
248
|
if (((_currentItem$value2 = currentItem.value) === null || _currentItem$value2 === void 0 ? void 0 : _currentItem$value2.type) === 'text') {
|
|
249
|
+
console.log('use effect text');
|
|
224
250
|
showTextInput.value = true;
|
|
225
251
|
textFocus();
|
|
226
252
|
currentItem.value = {
|
|
@@ -234,7 +260,7 @@ const DrawCore = _ref => {
|
|
|
234
260
|
}, [currentItem, showTextInput, textFocus, textVal]);
|
|
235
261
|
const onGestureEvent = useAnimatedGestureHandler({
|
|
236
262
|
onStart: (_ref2, ctx) => {
|
|
237
|
-
var _currentItem$value3;
|
|
263
|
+
var _currentItem$value3, _currentItem$value4;
|
|
238
264
|
let {
|
|
239
265
|
x: startX,
|
|
240
266
|
y: startY
|
|
@@ -242,11 +268,12 @@ const DrawCore = _ref => {
|
|
|
242
268
|
ctx.startX = startX;
|
|
243
269
|
ctx.startY = startY;
|
|
244
270
|
ctx.newlyCreated = false;
|
|
245
|
-
|
|
271
|
+
console.log('**********************************');
|
|
272
|
+
console.log('onGestureEvent');
|
|
246
273
|
//panPosition.value = withTiming(RIGHT_PANE_WIDTH);
|
|
247
|
-
|
|
274
|
+
console.log('onStart', (_currentItem$value3 = currentItem.value) === null || _currentItem$value3 === void 0 ? void 0 : _currentItem$value3.type);
|
|
248
275
|
initialItem.value = currentItem.value;
|
|
249
|
-
switch ((_currentItem$
|
|
276
|
+
switch ((_currentItem$value4 = currentItem.value) === null || _currentItem$value4 === void 0 ? void 0 : _currentItem$value4.type) {
|
|
250
277
|
case 'ellipse':
|
|
251
278
|
const cx = typeof currentItem.value.data.cx === 'string' ? parseFloat(currentItem.value.data.cx) : currentItem.value.data.cx || 0;
|
|
252
279
|
const cy = typeof currentItem.value.data.cy === 'string' ? parseFloat(currentItem.value.data.cy) : currentItem.value.data.cy || 0;
|
|
@@ -292,6 +319,7 @@ const DrawCore = _ref => {
|
|
|
292
319
|
}
|
|
293
320
|
break;
|
|
294
321
|
case 'doubleHead':
|
|
322
|
+
case 'doubleArrows':
|
|
295
323
|
case 'singleHead':
|
|
296
324
|
const x1 = typeof currentItem.value.data.x1 === 'string' ? parseFloat(currentItem.value.data.x1) : currentItem.value.data.x1 || 0;
|
|
297
325
|
const y1 = typeof currentItem.value.data.y1 === 'string' ? parseFloat(currentItem.value.data.y1) : currentItem.value.data.y1 || 0;
|
|
@@ -321,15 +349,32 @@ const DrawCore = _ref => {
|
|
|
321
349
|
const yText = typeof currentItem.value.data.y === 'string' ? parseFloat(currentItem.value.data.y) : currentItem.value.data.y || 0;
|
|
322
350
|
const widthText = typeof currentItem.value.data.width === 'string' ? parseFloat(currentItem.value.data.width) : currentItem.value.data.width || 0;
|
|
323
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);
|
|
324
354
|
if (startX <= xText + THRESHOLD && startX >= xText - THRESHOLD && startY <= yText + heightText / 2 + THRESHOLD && startY >= yText + heightText / 2 - THRESHOLD) {
|
|
325
355
|
ctx.zone = 'LEFT';
|
|
326
356
|
} else if (startX <= xText + widthText + THRESHOLD && startX >= xText + widthText - THRESHOLD && startY <= yText + heightText / 2 + THRESHOLD && startY >= yText + heightText / 2 - THRESHOLD) {
|
|
327
357
|
ctx.zone = 'RIGHT';
|
|
328
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)) {
|
|
329
359
|
ctx.zone = 'CENTER';
|
|
360
|
+
console.log('on active center');
|
|
330
361
|
} else {
|
|
331
362
|
ctx.zone = 'OUT';
|
|
363
|
+
console.log('on active out');
|
|
332
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)();
|
|
333
378
|
}
|
|
334
379
|
break;
|
|
335
380
|
case 'pen':
|
|
@@ -343,11 +388,28 @@ const DrawCore = _ref => {
|
|
|
343
388
|
default:
|
|
344
389
|
ctx.zone = 'OUT';
|
|
345
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
|
+
}
|
|
346
408
|
break;
|
|
347
409
|
}
|
|
348
410
|
},
|
|
349
411
|
onActive: (_ref3, ctx) => {
|
|
350
|
-
var _currentItem$
|
|
412
|
+
var _currentItem$value5, _initialItem$value, _initialItem$value2, _initialItem$value4, _initialItem$value17, _initialItem$value30;
|
|
351
413
|
let {
|
|
352
414
|
x: currentX,
|
|
353
415
|
y: currentY,
|
|
@@ -360,11 +422,13 @@ const DrawCore = _ref => {
|
|
|
360
422
|
zone,
|
|
361
423
|
newlyCreated
|
|
362
424
|
} = ctx;
|
|
363
|
-
if (zone === 'OUT' && newlyCreated === false) {
|
|
425
|
+
if (zone === 'OUT' && newlyCreated === false && mode.value !== 'text') {
|
|
426
|
+
console.log('on active out');
|
|
364
427
|
ctx.newlyCreated = true;
|
|
428
|
+
/*
|
|
365
429
|
if (mode.value === 'text') {
|
|
366
430
|
runOnJS(setTextVal)('');
|
|
367
|
-
}
|
|
431
|
+
}*/
|
|
368
432
|
drawNewItem(mode, currentItem, addDoneItem, {
|
|
369
433
|
x: startX,
|
|
370
434
|
y: startY
|
|
@@ -376,7 +440,7 @@ const DrawCore = _ref => {
|
|
|
376
440
|
itemIsSelected.value = true;
|
|
377
441
|
onCancelChangeWrapper && runOnJS(onCancelChangeWrapper)(true);
|
|
378
442
|
}
|
|
379
|
-
switch ((_currentItem$
|
|
443
|
+
switch ((_currentItem$value5 = currentItem.value) === null || _currentItem$value5 === void 0 ? void 0 : _currentItem$value5.type) {
|
|
380
444
|
case 'pen':
|
|
381
445
|
if (((_initialItem$value = initialItem.value) === null || _initialItem$value === void 0 ? void 0 : _initialItem$value.type) === currentItem.value.type && zone === 'CENTER') {
|
|
382
446
|
currentItem.value = {
|
|
@@ -578,6 +642,7 @@ const DrawCore = _ref => {
|
|
|
578
642
|
break;
|
|
579
643
|
case 'singleHead':
|
|
580
644
|
case 'doubleHead':
|
|
645
|
+
case 'doubleArrows':
|
|
581
646
|
if (((_initialItem$value17 = initialItem.value) === null || _initialItem$value17 === void 0 ? void 0 : _initialItem$value17.type) === currentItem.value.type) {
|
|
582
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;
|
|
583
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;
|
|
@@ -590,6 +655,7 @@ const DrawCore = _ref => {
|
|
|
590
655
|
type: currentItem.value.type,
|
|
591
656
|
strokeWidth: currentItem.value.strokeWidth,
|
|
592
657
|
color: currentItem.value.color,
|
|
658
|
+
text: currentItem.value.type === 'doubleArrows' ? currentItem.value.text ?? '' : '',
|
|
593
659
|
data: {
|
|
594
660
|
x1: x1 + translationX,
|
|
595
661
|
y1: y1 + translationY,
|
|
@@ -603,6 +669,7 @@ const DrawCore = _ref => {
|
|
|
603
669
|
type: currentItem.value.type,
|
|
604
670
|
strokeWidth: currentItem.value.strokeWidth,
|
|
605
671
|
color: currentItem.value.color,
|
|
672
|
+
text: currentItem.value.type === 'doubleArrows' ? currentItem.value.text ?? '' : '',
|
|
606
673
|
data: {
|
|
607
674
|
x1: x1,
|
|
608
675
|
y1: y1,
|
|
@@ -616,6 +683,7 @@ const DrawCore = _ref => {
|
|
|
616
683
|
type: currentItem.value.type,
|
|
617
684
|
strokeWidth: currentItem.value.strokeWidth,
|
|
618
685
|
color: currentItem.value.color,
|
|
686
|
+
text: currentItem.value.type === 'doubleArrows' ? currentItem.value.text ?? '' : '',
|
|
619
687
|
data: {
|
|
620
688
|
x1: x1 + translationX,
|
|
621
689
|
y1: y1 + translationY,
|
|
@@ -630,6 +698,7 @@ const DrawCore = _ref => {
|
|
|
630
698
|
type: currentItem.value.type,
|
|
631
699
|
strokeWidth: currentItem.value.strokeWidth,
|
|
632
700
|
color: currentItem.value.color,
|
|
701
|
+
text: currentItem.value.type === 'doubleArrows' ? currentItem.value.text ?? '' : '',
|
|
633
702
|
data: {
|
|
634
703
|
x1: startX,
|
|
635
704
|
y1: startY,
|
|
@@ -640,6 +709,7 @@ const DrawCore = _ref => {
|
|
|
640
709
|
}
|
|
641
710
|
break;
|
|
642
711
|
case 'text':
|
|
712
|
+
console.log('on active text');
|
|
643
713
|
if (((_initialItem$value30 = initialItem.value) === null || _initialItem$value30 === void 0 ? void 0 : _initialItem$value30.type) === currentItem.value.type) {
|
|
644
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;
|
|
645
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;
|
|
@@ -707,8 +777,11 @@ const DrawCore = _ref => {
|
|
|
707
777
|
}
|
|
708
778
|
},
|
|
709
779
|
onEnd: _event => {
|
|
710
|
-
var _currentItem$
|
|
711
|
-
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') {
|
|
712
785
|
runOnJS(textFocus)();
|
|
713
786
|
currentItem.value = {
|
|
714
787
|
type: currentItem.value.type,
|
|
@@ -727,6 +800,7 @@ const DrawCore = _ref => {
|
|
|
727
800
|
});
|
|
728
801
|
const sudDidShow = Keyboard.addListener('keyboardDidShow', event => {
|
|
729
802
|
// avoid events triggered by InputAccessoryView
|
|
803
|
+
console.log('keyboardDidShow dc');
|
|
730
804
|
if (event.endCoordinates.height > 100) {
|
|
731
805
|
showTextInput.value = true;
|
|
732
806
|
}
|
|
@@ -745,44 +819,17 @@ const DrawCore = _ref => {
|
|
|
745
819
|
color: color === null || color === void 0 ? void 0 : color.value
|
|
746
820
|
};
|
|
747
821
|
}, _ref4 => {
|
|
748
|
-
var _currentItem$
|
|
822
|
+
var _currentItem$value8;
|
|
749
823
|
let {
|
|
750
824
|
strokeWidth: sw,
|
|
751
825
|
color: c
|
|
752
826
|
} = _ref4;
|
|
753
|
-
switch ((_currentItem$
|
|
827
|
+
switch ((_currentItem$value8 = currentItem.value) === null || _currentItem$value8 === void 0 ? void 0 : _currentItem$value8.type) {
|
|
754
828
|
case 'singleHead':
|
|
755
|
-
currentItem.value = {
|
|
756
|
-
type: currentItem.value.type,
|
|
757
|
-
data: currentItem.value.data,
|
|
758
|
-
strokeWidth: sw,
|
|
759
|
-
color: c
|
|
760
|
-
};
|
|
761
|
-
break;
|
|
762
829
|
case 'doubleHead':
|
|
763
|
-
|
|
764
|
-
type: currentItem.value.type,
|
|
765
|
-
data: currentItem.value.data,
|
|
766
|
-
strokeWidth: sw,
|
|
767
|
-
color: c
|
|
768
|
-
};
|
|
769
|
-
break;
|
|
830
|
+
case 'doubleArrows':
|
|
770
831
|
case 'ellipse':
|
|
771
|
-
currentItem.value = {
|
|
772
|
-
type: currentItem.value.type,
|
|
773
|
-
data: currentItem.value.data,
|
|
774
|
-
strokeWidth: sw,
|
|
775
|
-
color: c
|
|
776
|
-
};
|
|
777
|
-
break;
|
|
778
832
|
case 'rectangle':
|
|
779
|
-
currentItem.value = {
|
|
780
|
-
type: currentItem.value.type,
|
|
781
|
-
data: currentItem.value.data,
|
|
782
|
-
strokeWidth: sw,
|
|
783
|
-
color: c
|
|
784
|
-
};
|
|
785
|
-
break;
|
|
786
833
|
case 'pen':
|
|
787
834
|
currentItem.value = {
|
|
788
835
|
type: currentItem.value.type,
|
|
@@ -803,22 +850,58 @@ const DrawCore = _ref => {
|
|
|
803
850
|
}
|
|
804
851
|
}, [strokeWidth.value, color === null || color === void 0 ? void 0 : color.value]);
|
|
805
852
|
const onPressItem = useCallback((item, index) => () => {
|
|
853
|
+
console.log('onPressItem');
|
|
806
854
|
itemIsSelected.value = true;
|
|
807
855
|
const previousItem = currentItem.value;
|
|
808
856
|
strokeWidth.value = item.strokeWidth;
|
|
809
857
|
color.value = item.color;
|
|
858
|
+
console.log('item', item);
|
|
810
859
|
currentItem.value = item;
|
|
811
860
|
deleteDoneItem(index);
|
|
812
861
|
if (previousItem) {
|
|
813
862
|
addDoneItem(previousItem);
|
|
814
863
|
}
|
|
815
864
|
if (item.type === 'text') {
|
|
865
|
+
var _textInputRef$current2;
|
|
816
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();
|
|
817
871
|
} else {
|
|
818
|
-
var _textInputRef$
|
|
819
|
-
(_textInputRef$
|
|
872
|
+
var _textInputRef$current3;
|
|
873
|
+
(_textInputRef$current3 = textInputRef.current) === null || _textInputRef$current3 === void 0 ? void 0 : _textInputRef$current3.blur();
|
|
820
874
|
}
|
|
821
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
|
+
|
|
822
905
|
const onTextHeightChange = useCallback(height => {
|
|
823
906
|
onTextHeightUpdate(currentItem, textBaseHeight, height);
|
|
824
907
|
}, [currentItem, textBaseHeight]);
|
|
@@ -857,40 +940,38 @@ const DrawCore = _ref => {
|
|
|
857
940
|
|
|
858
941
|
// do not remove keyboard will appear over the drawing frame and not shift it
|
|
859
942
|
useAnimatedKeyboard();
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
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
|
+
*/
|
|
875
972
|
return /*#__PURE__*/React.createElement(View, {
|
|
876
973
|
style: styles.container
|
|
877
|
-
},
|
|
878
|
-
ref: textInputRef,
|
|
879
|
-
style: [styles.textInput, textInputStyle],
|
|
880
|
-
onEndEditing: (_textInputRef$current3 = textInputRef.current) === null || _textInputRef$current3 === void 0 ? void 0 : _textInputRef$current3.clear,
|
|
881
|
-
onChangeText: setTextVal,
|
|
882
|
-
value: textVal,
|
|
883
|
-
autoCorrect: false
|
|
884
|
-
})) : /*#__PURE__*/React.createElement(Animated.View, {
|
|
885
|
-
style: textInputContainerStyle
|
|
886
|
-
}, ((_currentItem$value7 = currentItem.value) === null || _currentItem$value7 === void 0 ? void 0 : _currentItem$value7.type) === 'text' && /*#__PURE__*/React.createElement(TextInput, {
|
|
887
|
-
ref: textInputRef,
|
|
888
|
-
style: styles.textInput,
|
|
889
|
-
onEndEditing: (_textInputRef$current4 = textInputRef.current) === null || _textInputRef$current4 === void 0 ? void 0 : _textInputRef$current4.clear,
|
|
890
|
-
onChangeText: setTextVal,
|
|
891
|
-
value: textVal,
|
|
892
|
-
autoCorrect: false
|
|
893
|
-
})), /*#__PURE__*/React.createElement(View, {
|
|
974
|
+
}, /*#__PURE__*/React.createElement(View, {
|
|
894
975
|
style: [styles.drawZone, {
|
|
895
976
|
backgroundColor: backgroundColor ?? 'none'
|
|
896
977
|
}],
|
|
@@ -900,6 +981,9 @@ const DrawCore = _ref => {
|
|
|
900
981
|
width: event.nativeEvent.layout.width
|
|
901
982
|
});
|
|
902
983
|
}
|
|
984
|
+
}, /*#__PURE__*/React.createElement(KeyboardAvoidingView, {
|
|
985
|
+
behavior: "position",
|
|
986
|
+
keyboardVerticalOffset: 70
|
|
903
987
|
}, /*#__PURE__*/React.createElement(PanGestureHandler, {
|
|
904
988
|
onGestureEvent: onGestureEvent
|
|
905
989
|
}, /*#__PURE__*/React.createElement(Animated.View, {
|
|
@@ -930,11 +1014,19 @@ const DrawCore = _ref => {
|
|
|
930
1014
|
},
|
|
931
1015
|
style: drawRegion
|
|
932
1016
|
}, /*#__PURE__*/React.createElement(DrawPad, {
|
|
1017
|
+
addBackground: true,
|
|
933
1018
|
currentItem: currentItem,
|
|
934
1019
|
doneItems: drawState.doneItems,
|
|
935
1020
|
onPressItem: onPressItem,
|
|
936
1021
|
onTextHeightChange: onTextHeightChange
|
|
937
|
-
})) : null)))
|
|
1022
|
+
})) : null))), /*#__PURE__*/React.createElement(TextInput, {
|
|
1023
|
+
ref: textInputRef,
|
|
1024
|
+
style: styles.textInput,
|
|
1025
|
+
onEndEditing: (_textInputRef$current4 = textInputRef.current) === null || _textInputRef$current4 === void 0 ? void 0 : _textInputRef$current4.clear,
|
|
1026
|
+
onChangeText: setTextVal,
|
|
1027
|
+
value: textVal,
|
|
1028
|
+
autoCorrect: false
|
|
1029
|
+
}))));
|
|
938
1030
|
};
|
|
939
1031
|
export default DrawCore;
|
|
940
1032
|
//# sourceMappingURL=index.js.map
|