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