@archireport/react-native-svg-draw 2.3.2 → 3.1.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/README.md +34 -35
- package/lib/commonjs/components/DrawCore/DrawContext.js +4 -1
- package/lib/commonjs/components/DrawCore/DrawContext.js.map +1 -1
- package/lib/commonjs/components/DrawCore/DrawPad.js +9 -3
- package/lib/commonjs/components/DrawCore/DrawPad.js.map +1 -1
- package/lib/commonjs/components/DrawCore/DrawProvider.js +16 -2
- package/lib/commonjs/components/DrawCore/DrawProvider.js.map +1 -1
- package/lib/commonjs/components/DrawCore/Item.js +12 -35
- package/lib/commonjs/components/DrawCore/Item.js.map +1 -1
- package/lib/commonjs/components/DrawCore/index.js +574 -576
- package/lib/commonjs/components/DrawCore/index.js.map +1 -1
- package/lib/commonjs/components/DrawCore/useDrawHook.js +15 -13
- package/lib/commonjs/components/DrawCore/useDrawHook.js.map +1 -1
- package/lib/commonjs/components/DrawWithOptions/index.js +7 -11
- package/lib/commonjs/components/DrawWithOptions/index.js.map +1 -1
- package/lib/module/components/DrawCore/DrawContext.js +4 -1
- package/lib/module/components/DrawCore/DrawContext.js.map +1 -1
- package/lib/module/components/DrawCore/DrawPad.js +10 -4
- package/lib/module/components/DrawCore/DrawPad.js.map +1 -1
- package/lib/module/components/DrawCore/DrawProvider.js +17 -3
- package/lib/module/components/DrawCore/DrawProvider.js.map +1 -1
- package/lib/module/components/DrawCore/Item.js +14 -37
- package/lib/module/components/DrawCore/Item.js.map +1 -1
- package/lib/module/components/DrawCore/index.js +575 -577
- package/lib/module/components/DrawCore/index.js.map +1 -1
- package/lib/module/components/DrawCore/useDrawHook.js +15 -13
- package/lib/module/components/DrawCore/useDrawHook.js.map +1 -1
- package/lib/module/components/DrawWithOptions/index.js +8 -12
- package/lib/module/components/DrawWithOptions/index.js.map +1 -1
- package/lib/typescript/components/DrawCore/DrawContext.d.ts +3 -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.map +1 -1
- package/lib/typescript/components/DrawCore/index.d.ts +2 -1
- package/lib/typescript/components/DrawCore/index.d.ts.map +1 -1
- package/lib/typescript/components/DrawCore/useDrawHook.d.ts +4 -1
- package/lib/typescript/components/DrawCore/useDrawHook.d.ts.map +1 -1
- package/lib/typescript/components/DrawWithOptions/index.d.ts +1 -1
- package/lib/typescript/components/DrawWithOptions/index.d.ts.map +1 -1
- package/package.json +5 -1
- package/src/components/DrawCore/DrawContext.tsx +6 -0
- package/src/components/DrawCore/DrawPad.tsx +76 -67
- package/src/components/DrawCore/DrawProvider.tsx +23 -1
- package/src/components/DrawCore/Item.tsx +15 -47
- package/src/components/DrawCore/index.tsx +109 -114
- package/src/components/DrawCore/useDrawHook.tsx +12 -7
- package/src/components/DrawWithOptions/index.tsx +10 -11
- package/src/types.d.ts +5 -3
|
@@ -187,7 +187,8 @@ const DrawCore = _ref => {
|
|
|
187
187
|
var _textInputRef$current4;
|
|
188
188
|
let {
|
|
189
189
|
image,
|
|
190
|
-
backgroundColor
|
|
190
|
+
backgroundColor,
|
|
191
|
+
actionWithSnapShotUri
|
|
191
192
|
} = _ref;
|
|
192
193
|
const {
|
|
193
194
|
drawState,
|
|
@@ -197,8 +198,34 @@ const DrawCore = _ref => {
|
|
|
197
198
|
currentItem,
|
|
198
199
|
itemIsSelected,
|
|
199
200
|
viewShot,
|
|
200
|
-
doubleArrowTextInput
|
|
201
|
+
doubleArrowTextInput,
|
|
202
|
+
captureSnapshot,
|
|
203
|
+
snapShotRequested,
|
|
204
|
+
setSnapShotRequested
|
|
201
205
|
} = (0, _useDrawHook.default)();
|
|
206
|
+
const [drawRegion, setDrawRegion] = (0, _react.useState)(null);
|
|
207
|
+
const [imageSize, setImageSize] = (0, _react.useState)(null);
|
|
208
|
+
const [originalImageSize, setOriginalImageSize] = (0, _react.useState)(null);
|
|
209
|
+
(0, _react.useEffect)(() => {
|
|
210
|
+
if (snapShotRequested) {
|
|
211
|
+
setSnapShotRequested(false);
|
|
212
|
+
setNewLayoutRequested(true);
|
|
213
|
+
if (imageSize !== null && imageSize !== void 0 && imageSize.height && originalImageSize !== null && originalImageSize !== void 0 && originalImageSize.height && originalImageSize !== null && originalImageSize !== void 0 && originalImageSize.width && image) {
|
|
214
|
+
setOpacity(0);
|
|
215
|
+
setRatioImage(originalImageSize.height / (imageSize === null || imageSize === void 0 ? void 0 : imageSize.height));
|
|
216
|
+
setImageSize(originalImageSize);
|
|
217
|
+
} else if (!image && drawRegion !== null && drawRegion !== void 0 && drawRegion.height) {
|
|
218
|
+
const width = 1500;
|
|
219
|
+
const height = width / 1.3333333;
|
|
220
|
+
setOpacity(0);
|
|
221
|
+
setRatioImage(height / drawRegion.height);
|
|
222
|
+
setImageSize({
|
|
223
|
+
width,
|
|
224
|
+
height
|
|
225
|
+
});
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
}, [snapShotRequested, drawRegion === null || drawRegion === void 0 ? void 0 : drawRegion.height, image, imageSize === null || imageSize === void 0 ? void 0 : imageSize.height, originalImageSize, setSnapShotRequested]);
|
|
202
229
|
const onCancelChangeWrapper = arg => {
|
|
203
230
|
dispatchDrawStates({
|
|
204
231
|
type: 'SET_CANCEL_ENABLED',
|
|
@@ -206,13 +233,15 @@ const DrawCore = _ref => {
|
|
|
206
233
|
});
|
|
207
234
|
};
|
|
208
235
|
const mode = (0, _reactNativeReanimated.useSharedValue)('pen');
|
|
209
|
-
const [drawRegion, setDrawRegion] = (0, _react.useState)(null);
|
|
210
|
-
const [originalImageSize, setOriginalImageSize] = (0, _react.useState)(null);
|
|
211
|
-
const [imageSize, setImageSize] = (0, _react.useState)(null);
|
|
212
236
|
const drawContainer = (0, _react.useRef)(null);
|
|
213
237
|
const [textVal, setTextVal] = (0, _react.useState)('');
|
|
214
238
|
const initialItem = (0, _reactNativeReanimated.useSharedValue)(null);
|
|
215
239
|
const textBaseHeight = (0, _reactNativeReanimated.useSharedValue)(null);
|
|
240
|
+
const gestureContext = (0, _reactNativeReanimated.useSharedValue)({
|
|
241
|
+
startX: 0,
|
|
242
|
+
startY: 0,
|
|
243
|
+
newlyCreated: false
|
|
244
|
+
});
|
|
216
245
|
const addDoneItem = (0, _react.useCallback)(item => {
|
|
217
246
|
dispatchDrawStates({
|
|
218
247
|
type: 'ADD_DONE_ITEM',
|
|
@@ -243,19 +272,16 @@ const DrawCore = _ref => {
|
|
|
243
272
|
|
|
244
273
|
const textFocusState = (0, _react.useCallback)(() => {
|
|
245
274
|
var _doubleArrowTextInput;
|
|
246
|
-
//setShowTextInputState(true);
|
|
247
|
-
console.log('textFocusState');
|
|
248
275
|
doubleArrowTextInput === null || doubleArrowTextInput === void 0 ? void 0 : (_doubleArrowTextInput = doubleArrowTextInput.current) === null || _doubleArrowTextInput === void 0 ? void 0 : _doubleArrowTextInput.focus();
|
|
249
276
|
}, [doubleArrowTextInput]);
|
|
250
277
|
const textFocus = (0, _react.useCallback)(() => {
|
|
251
278
|
var _textInputRef$current;
|
|
252
|
-
console.log('textFocus');
|
|
253
279
|
(_textInputRef$current = textInputRef.current) === null || _textInputRef$current === void 0 ? void 0 : _textInputRef$current.focus();
|
|
254
280
|
}, []);
|
|
255
281
|
(0, _react.useEffect)(() => {
|
|
256
282
|
var _currentItem$value2;
|
|
257
283
|
if (((_currentItem$value2 = currentItem.value) === null || _currentItem$value2 === void 0 ? void 0 : _currentItem$value2.type) === 'text') {
|
|
258
|
-
console.log('
|
|
284
|
+
console.log('Updating text value:');
|
|
259
285
|
showTextInput.value = true;
|
|
260
286
|
textFocus();
|
|
261
287
|
currentItem.value = {
|
|
@@ -267,541 +293,527 @@ const DrawCore = _ref => {
|
|
|
267
293
|
};
|
|
268
294
|
}
|
|
269
295
|
}, [currentItem, showTextInput, textFocus, textVal]);
|
|
270
|
-
const
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
if (
|
|
312
|
-
|
|
313
|
-
ctx.zone = 'TOP_LEFT';
|
|
314
|
-
} else if (startY <= y + height + THRESHOLD && startY >= y + height - THRESHOLD) {
|
|
315
|
-
ctx.zone = 'BOTTOM_LEFT';
|
|
316
|
-
}
|
|
317
|
-
} else if (startX <= x + width + THRESHOLD && startX >= x + width - THRESHOLD) {
|
|
318
|
-
if (startY <= y + THRESHOLD && startY >= y - THRESHOLD) {
|
|
319
|
-
ctx.zone = 'TOP_RIGHT';
|
|
320
|
-
} else if (startY <= y + height + THRESHOLD && startY >= y + height - THRESHOLD) {
|
|
321
|
-
ctx.zone = 'BOTTOM_RIGHT';
|
|
322
|
-
}
|
|
323
|
-
} else if ((width > 0 && startX > x && startX < x + width || width < 0 && startX < x && startX > x + width) && (height > 0 && startY > y && startY < y + height || height < 0 && startY < y && startY > y + height)) {
|
|
324
|
-
ctx.zone = 'CENTER';
|
|
325
|
-
} else {
|
|
326
|
-
ctx.zone = 'OUT';
|
|
327
|
-
initialItem.value = null;
|
|
328
|
-
}
|
|
329
|
-
break;
|
|
330
|
-
case 'doubleHead':
|
|
331
|
-
case 'doubleArrows':
|
|
332
|
-
case 'singleHead':
|
|
333
|
-
const x1 = typeof currentItem.value.data.x1 === 'string' ? parseFloat(currentItem.value.data.x1) : currentItem.value.data.x1 || 0;
|
|
334
|
-
const y1 = typeof currentItem.value.data.y1 === 'string' ? parseFloat(currentItem.value.data.y1) : currentItem.value.data.y1 || 0;
|
|
335
|
-
const x2 = typeof currentItem.value.data.x2 === 'string' ? parseFloat(currentItem.value.data.x2) : currentItem.value.data.x2 || 0;
|
|
336
|
-
const y2 = typeof currentItem.value.data.y2 === 'string' ? parseFloat(currentItem.value.data.y2) : currentItem.value.data.y2 || 0;
|
|
337
|
-
if (startX <= x1 + THRESHOLD && startX >= x1 - THRESHOLD && startY <= y1 + THRESHOLD && startY >= y1 - THRESHOLD) {
|
|
338
|
-
ctx.zone = 'TOP';
|
|
339
|
-
} else if (startX <= x2 + THRESHOLD && startX >= x2 - THRESHOLD && startY - THRESHOLD <= y2 + THRESHOLD && startY + THRESHOLD >= y2 - THRESHOLD) {
|
|
340
|
-
ctx.zone = 'BOTTOM';
|
|
341
|
-
} else if (pDistance({
|
|
342
|
-
x: startX,
|
|
343
|
-
y: startY
|
|
344
|
-
}, {
|
|
345
|
-
x1,
|
|
346
|
-
x2,
|
|
347
|
-
y1,
|
|
348
|
-
y2
|
|
349
|
-
}) <= THRESHOLD && (startX > x1 && startX < x2 || startX < x1 && startX > x2) && (startY > y1 && startY < y2 || startY < y1 && startY > y2)) {
|
|
350
|
-
ctx.zone = 'CENTER';
|
|
351
|
-
} else {
|
|
352
|
-
ctx.zone = 'OUT';
|
|
353
|
-
initialItem.value = null;
|
|
354
|
-
}
|
|
355
|
-
break;
|
|
356
|
-
case 'text':
|
|
357
|
-
const xText = typeof currentItem.value.data.x === 'string' ? parseFloat(currentItem.value.data.x) : currentItem.value.data.x || 0;
|
|
358
|
-
const yText = typeof currentItem.value.data.y === 'string' ? parseFloat(currentItem.value.data.y) : currentItem.value.data.y || 0;
|
|
359
|
-
const widthText = typeof currentItem.value.data.width === 'string' ? parseFloat(currentItem.value.data.width) : currentItem.value.data.width || 0;
|
|
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);
|
|
363
|
-
if (startX <= xText + THRESHOLD && startX >= xText - THRESHOLD && startY <= yText + heightText / 2 + THRESHOLD && startY >= yText + heightText / 2 - THRESHOLD) {
|
|
364
|
-
ctx.zone = 'LEFT';
|
|
365
|
-
} else if (startX <= xText + widthText + THRESHOLD && startX >= xText + widthText - THRESHOLD && startY <= yText + heightText / 2 + THRESHOLD && startY >= yText + heightText / 2 - THRESHOLD) {
|
|
366
|
-
ctx.zone = 'RIGHT';
|
|
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)) {
|
|
368
|
-
ctx.zone = 'CENTER';
|
|
369
|
-
console.log('on active center');
|
|
370
|
-
} else {
|
|
371
|
-
ctx.zone = 'OUT';
|
|
372
|
-
console.log('on active out');
|
|
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)();
|
|
296
|
+
const panGesture = _reactNativeGestureHandler.Gesture.Pan().onStart(event => {
|
|
297
|
+
var _currentItem$value3;
|
|
298
|
+
const {
|
|
299
|
+
x: startX,
|
|
300
|
+
y: startY
|
|
301
|
+
} = event;
|
|
302
|
+
gestureContext.value = {
|
|
303
|
+
startX,
|
|
304
|
+
startY,
|
|
305
|
+
newlyCreated: false
|
|
306
|
+
};
|
|
307
|
+
initialItem.value = currentItem.value;
|
|
308
|
+
switch ((_currentItem$value3 = currentItem.value) === null || _currentItem$value3 === void 0 ? void 0 : _currentItem$value3.type) {
|
|
309
|
+
case 'ellipse':
|
|
310
|
+
const cx = typeof currentItem.value.data.cx === 'string' ? parseFloat(currentItem.value.data.cx) : currentItem.value.data.cx || 0;
|
|
311
|
+
const cy = typeof currentItem.value.data.cy === 'string' ? parseFloat(currentItem.value.data.cy) : currentItem.value.data.cy || 0;
|
|
312
|
+
const rx = typeof currentItem.value.data.rx === 'string' ? parseFloat(currentItem.value.data.rx) : currentItem.value.data.rx || 0;
|
|
313
|
+
const ry = typeof currentItem.value.data.ry === 'string' ? parseFloat(currentItem.value.data.ry) : currentItem.value.data.ry || 0;
|
|
314
|
+
if (startX <= cx + THRESHOLD && startX >= cx - THRESHOLD && startY <= cy - ry + THRESHOLD && startY >= cy - ry - THRESHOLD) {
|
|
315
|
+
gestureContext.value.zone = 'TOP';
|
|
316
|
+
} else if (startX <= cx + THRESHOLD && startX >= cx - THRESHOLD && startY <= cy + ry + THRESHOLD && startY >= cy + ry - THRESHOLD) {
|
|
317
|
+
gestureContext.value.zone = 'BOTTOM';
|
|
318
|
+
} else if (startY <= cy + THRESHOLD && startY >= cy - THRESHOLD && startX <= cx - rx + THRESHOLD && startX >= cx - rx - THRESHOLD) {
|
|
319
|
+
gestureContext.value.zone = 'LEFT';
|
|
320
|
+
} else if (startY <= cy + THRESHOLD && startY >= cy - THRESHOLD && startX <= cx + rx + THRESHOLD && startX >= cx + rx - THRESHOLD) {
|
|
321
|
+
gestureContext.value.zone = 'RIGHT';
|
|
322
|
+
} else if ((rx > 0 && startX > cx - rx && startX < cx + rx || rx < 0 && startX < cx - rx && startX > cx + rx) && (ry > 0 && startY > cy - ry && startY < cy + ry || ry < 0 && startY < cy - ry && startY > cy + ry)) {
|
|
323
|
+
gestureContext.value.zone = 'CENTER';
|
|
324
|
+
} else {
|
|
325
|
+
gestureContext.value.zone = 'OUT';
|
|
326
|
+
initialItem.value = null;
|
|
327
|
+
}
|
|
328
|
+
break;
|
|
329
|
+
case 'rectangle':
|
|
330
|
+
const x = typeof currentItem.value.data.x === 'string' ? parseFloat(currentItem.value.data.x) : currentItem.value.data.x || 0;
|
|
331
|
+
const y = typeof currentItem.value.data.y === 'string' ? parseFloat(currentItem.value.data.y) : currentItem.value.data.y || 0;
|
|
332
|
+
const height = typeof currentItem.value.data.height === 'string' ? parseFloat(currentItem.value.data.height) : currentItem.value.data.height || 0;
|
|
333
|
+
const width = typeof currentItem.value.data.width === 'string' ? parseFloat(currentItem.value.data.width) : currentItem.value.data.width || 0;
|
|
334
|
+
if (startX <= x + THRESHOLD && startX >= x - THRESHOLD) {
|
|
335
|
+
if (startY <= y + THRESHOLD && startY >= y - THRESHOLD) {
|
|
336
|
+
gestureContext.value.zone = 'TOP_LEFT';
|
|
337
|
+
} else if (startY <= y + height + THRESHOLD && startY >= y + height - THRESHOLD) {
|
|
338
|
+
gestureContext.value.zone = 'BOTTOM_LEFT';
|
|
387
339
|
}
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
ctx.zone = 'OUT';
|
|
394
|
-
initialItem.value = null;
|
|
340
|
+
} else if (startX <= x + width + THRESHOLD && startX >= x + width - THRESHOLD) {
|
|
341
|
+
if (startY <= y + THRESHOLD && startY >= y - THRESHOLD) {
|
|
342
|
+
gestureContext.value.zone = 'TOP_RIGHT';
|
|
343
|
+
} else if (startY <= y + height + THRESHOLD && startY >= y + height - THRESHOLD) {
|
|
344
|
+
gestureContext.value.zone = 'BOTTOM_RIGHT';
|
|
395
345
|
}
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
346
|
+
} else if ((width > 0 && startX > x && startX < x + width || width < 0 && startX < x && startX > x + width) && (height > 0 && startY > y && startY < y + height || height < 0 && startY < y && startY > y + height)) {
|
|
347
|
+
gestureContext.value.zone = 'CENTER';
|
|
348
|
+
} else {
|
|
349
|
+
gestureContext.value.zone = 'OUT';
|
|
399
350
|
initialItem.value = null;
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
onCancelChangeWrapper && (0, _reactNativeReanimated.runOnJS)(onCancelChangeWrapper)(true);
|
|
415
|
-
(0, _reactNativeReanimated.runOnJS)(textFocus)();
|
|
416
|
-
}
|
|
417
|
-
break;
|
|
418
|
-
}
|
|
419
|
-
},
|
|
420
|
-
onActive: (_ref3, ctx) => {
|
|
421
|
-
var _currentItem$value5, _initialItem$value, _initialItem$value2, _initialItem$value4, _initialItem$value17, _initialItem$value30;
|
|
422
|
-
let {
|
|
423
|
-
x: currentX,
|
|
424
|
-
y: currentY,
|
|
425
|
-
translationX,
|
|
426
|
-
translationY
|
|
427
|
-
} = _ref3;
|
|
428
|
-
const {
|
|
429
|
-
startX,
|
|
430
|
-
startY,
|
|
431
|
-
zone,
|
|
432
|
-
newlyCreated
|
|
433
|
-
} = ctx;
|
|
434
|
-
if (zone === 'OUT' && newlyCreated === false && mode.value !== 'text') {
|
|
435
|
-
console.log('on active out');
|
|
436
|
-
ctx.newlyCreated = true;
|
|
437
|
-
/*
|
|
438
|
-
if (mode.value === 'text') {
|
|
439
|
-
runOnJS(setTextVal)('');
|
|
440
|
-
}*/
|
|
441
|
-
drawNewItem(mode, currentItem, addDoneItem, {
|
|
351
|
+
}
|
|
352
|
+
break;
|
|
353
|
+
case 'doubleHead':
|
|
354
|
+
case 'doubleArrows':
|
|
355
|
+
case 'singleHead':
|
|
356
|
+
const x1 = typeof currentItem.value.data.x1 === 'string' ? parseFloat(currentItem.value.data.x1) : currentItem.value.data.x1 || 0;
|
|
357
|
+
const y1 = typeof currentItem.value.data.y1 === 'string' ? parseFloat(currentItem.value.data.y1) : currentItem.value.data.y1 || 0;
|
|
358
|
+
const x2 = typeof currentItem.value.data.x2 === 'string' ? parseFloat(currentItem.value.data.x2) : currentItem.value.data.x2 || 0;
|
|
359
|
+
const y2 = typeof currentItem.value.data.y2 === 'string' ? parseFloat(currentItem.value.data.y2) : currentItem.value.data.y2 || 0;
|
|
360
|
+
if (startX <= x1 + THRESHOLD && startX >= x1 - THRESHOLD && startY <= y1 + THRESHOLD && startY >= y1 - THRESHOLD) {
|
|
361
|
+
gestureContext.value.zone = 'TOP';
|
|
362
|
+
} else if (startX <= x2 + THRESHOLD && startX >= x2 - THRESHOLD && startY - THRESHOLD <= y2 + THRESHOLD && startY + THRESHOLD >= y2 - THRESHOLD) {
|
|
363
|
+
gestureContext.value.zone = 'BOTTOM';
|
|
364
|
+
} else if (pDistance({
|
|
442
365
|
x: startX,
|
|
443
366
|
y: startY
|
|
444
367
|
}, {
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
368
|
+
x1,
|
|
369
|
+
x2,
|
|
370
|
+
y1,
|
|
371
|
+
y2
|
|
372
|
+
}) <= THRESHOLD && (startX > x1 && startX < x2 || startX < x1 && startX > x2) && (startY > y1 && startY < y2 || startY < y1 && startY > y2)) {
|
|
373
|
+
gestureContext.value.zone = 'CENTER';
|
|
374
|
+
} else {
|
|
375
|
+
gestureContext.value.zone = 'OUT';
|
|
376
|
+
initialItem.value = null;
|
|
377
|
+
}
|
|
378
|
+
break;
|
|
379
|
+
case 'text':
|
|
380
|
+
const xText = typeof currentItem.value.data.x === 'string' ? parseFloat(currentItem.value.data.x) : currentItem.value.data.x || 0;
|
|
381
|
+
const yText = typeof currentItem.value.data.y === 'string' ? parseFloat(currentItem.value.data.y) : currentItem.value.data.y || 0;
|
|
382
|
+
const widthText = typeof currentItem.value.data.width === 'string' ? parseFloat(currentItem.value.data.width) : currentItem.value.data.width || 0;
|
|
383
|
+
const heightText = typeof currentItem.value.data.height === 'string' ? parseFloat(currentItem.value.data.height) : currentItem.value.data.height || 0;
|
|
384
|
+
if (startX <= xText + THRESHOLD && startX >= xText - THRESHOLD && startY <= yText + heightText / 2 + THRESHOLD && startY >= yText + heightText / 2 - THRESHOLD) {
|
|
385
|
+
gestureContext.value.zone = 'LEFT';
|
|
386
|
+
} else if (startX <= xText + widthText + THRESHOLD && startX >= xText + widthText - THRESHOLD && startY <= yText + heightText / 2 + THRESHOLD && startY >= yText + heightText / 2 - THRESHOLD) {
|
|
387
|
+
gestureContext.value.zone = 'RIGHT';
|
|
388
|
+
} 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)) {
|
|
389
|
+
gestureContext.value.zone = 'CENTER';
|
|
390
|
+
} else {
|
|
391
|
+
gestureContext.value.zone = 'OUT';
|
|
392
|
+
initialItem.value = null;
|
|
393
|
+
gestureContext.value.newlyCreated = true;
|
|
394
|
+
(0, _reactNativeReanimated.runOnJS)(setTextVal)('');
|
|
395
|
+
drawNewItem(mode, currentItem, addDoneItem, {
|
|
396
|
+
x: startX,
|
|
397
|
+
y: startY
|
|
398
|
+
}, {
|
|
399
|
+
textBaseHeight,
|
|
400
|
+
strokeWidth,
|
|
401
|
+
color
|
|
402
|
+
});
|
|
403
|
+
itemIsSelected.value = true;
|
|
404
|
+
onCancelChangeWrapper && (0, _reactNativeReanimated.runOnJS)(onCancelChangeWrapper)(true);
|
|
405
|
+
(0, _reactNativeReanimated.runOnJS)(textFocus)();
|
|
406
|
+
}
|
|
407
|
+
break;
|
|
408
|
+
case 'pen':
|
|
409
|
+
if (currentItem.value.data.some(p => startX <= p.x + THRESHOLD && startX >= p.x - THRESHOLD && startY <= p.y + THRESHOLD && startY >= p.y - THRESHOLD)) {
|
|
410
|
+
gestureContext.value.zone = 'CENTER';
|
|
411
|
+
} else {
|
|
412
|
+
gestureContext.value.zone = 'OUT';
|
|
413
|
+
initialItem.value = null;
|
|
414
|
+
}
|
|
415
|
+
break;
|
|
416
|
+
default:
|
|
417
|
+
gestureContext.value.zone = 'OUT';
|
|
418
|
+
initialItem.value = null;
|
|
419
|
+
if (drawState.drawingMode === 'text') {
|
|
420
|
+
gestureContext.value.newlyCreated = true;
|
|
421
|
+
(0, _reactNativeReanimated.runOnJS)(setTextVal)('');
|
|
422
|
+
drawNewItem(mode, currentItem, addDoneItem, {
|
|
423
|
+
x: startX,
|
|
424
|
+
y: startY
|
|
425
|
+
}, {
|
|
426
|
+
textBaseHeight,
|
|
427
|
+
strokeWidth,
|
|
428
|
+
color
|
|
429
|
+
});
|
|
430
|
+
itemIsSelected.value = true;
|
|
431
|
+
onCancelChangeWrapper && (0, _reactNativeReanimated.runOnJS)(onCancelChangeWrapper)(true);
|
|
432
|
+
(0, _reactNativeReanimated.runOnJS)(textFocus)();
|
|
433
|
+
}
|
|
434
|
+
break;
|
|
435
|
+
}
|
|
436
|
+
}).onUpdate(event => {
|
|
437
|
+
var _currentItem$value4, _initialItem$value, _initialItem$value2, _initialItem$value4, _initialItem$value17, _initialItem$value30;
|
|
438
|
+
const {
|
|
439
|
+
x: currentX,
|
|
440
|
+
y: currentY,
|
|
441
|
+
translationX,
|
|
442
|
+
translationY
|
|
443
|
+
} = event;
|
|
444
|
+
const {
|
|
445
|
+
startX,
|
|
446
|
+
startY,
|
|
447
|
+
zone,
|
|
448
|
+
newlyCreated
|
|
449
|
+
} = gestureContext.value;
|
|
450
|
+
if (zone === 'OUT' && newlyCreated === false && mode.value !== 'text') {
|
|
451
|
+
gestureContext.value.newlyCreated = true;
|
|
452
|
+
/*
|
|
453
|
+
if (mode.value === 'text') {
|
|
454
|
+
runOnJS(setTextVal)('');
|
|
455
|
+
}*/
|
|
456
|
+
drawNewItem(mode, currentItem, addDoneItem, {
|
|
457
|
+
x: startX,
|
|
458
|
+
y: startY
|
|
459
|
+
}, {
|
|
460
|
+
textBaseHeight,
|
|
461
|
+
strokeWidth,
|
|
462
|
+
color
|
|
463
|
+
});
|
|
464
|
+
itemIsSelected.value = true;
|
|
465
|
+
onCancelChangeWrapper && (0, _reactNativeReanimated.runOnJS)(onCancelChangeWrapper)(true);
|
|
466
|
+
}
|
|
467
|
+
switch ((_currentItem$value4 = currentItem.value) === null || _currentItem$value4 === void 0 ? void 0 : _currentItem$value4.type) {
|
|
468
|
+
case 'pen':
|
|
469
|
+
if (((_initialItem$value = initialItem.value) === null || _initialItem$value === void 0 ? void 0 : _initialItem$value.type) === currentItem.value.type && zone === 'CENTER') {
|
|
470
|
+
currentItem.value = {
|
|
471
|
+
type: 'pen',
|
|
472
|
+
strokeWidth: currentItem.value.strokeWidth,
|
|
473
|
+
color: currentItem.value.color,
|
|
474
|
+
data: initialItem.value.data.map(p => ({
|
|
475
|
+
x: p.x + translationX,
|
|
476
|
+
y: p.y + translationY
|
|
477
|
+
}))
|
|
478
|
+
};
|
|
479
|
+
} else {
|
|
480
|
+
currentItem.value = {
|
|
481
|
+
type: 'pen',
|
|
482
|
+
strokeWidth: currentItem.value.strokeWidth,
|
|
483
|
+
color: currentItem.value.color,
|
|
484
|
+
data: currentItem.value.data.concat({
|
|
485
|
+
x: currentX,
|
|
486
|
+
y: currentY
|
|
487
|
+
})
|
|
488
|
+
};
|
|
489
|
+
}
|
|
490
|
+
break;
|
|
491
|
+
case 'ellipse':
|
|
492
|
+
if (((_initialItem$value2 = initialItem.value) === null || _initialItem$value2 === void 0 ? void 0 : _initialItem$value2.type) === currentItem.value.type) {
|
|
493
|
+
var _initialItem$value3;
|
|
494
|
+
const rx = typeof initialItem.value.data.rx === 'string' ? parseFloat((_initialItem$value3 = initialItem.value) === null || _initialItem$value3 === void 0 ? void 0 : _initialItem$value3.data.rx) : initialItem.value.data.rx || 0;
|
|
495
|
+
const ry = typeof initialItem.value.data.ry === 'string' ? parseFloat(initialItem.value.data.ry) : initialItem.value.data.ry || 0;
|
|
496
|
+
const cx = typeof initialItem.value.data.cx === 'string' ? parseFloat(initialItem.value.data.cx) : initialItem.value.data.cx || 0;
|
|
497
|
+
const cy = typeof initialItem.value.data.cy === 'string' ? parseFloat(initialItem.value.data.cy) : initialItem.value.data.cy || 0;
|
|
498
|
+
switch (zone) {
|
|
499
|
+
case 'TOP':
|
|
500
|
+
currentItem.value = {
|
|
501
|
+
type: currentItem.value.type,
|
|
502
|
+
strokeWidth: currentItem.value.strokeWidth,
|
|
503
|
+
color: currentItem.value.color,
|
|
504
|
+
data: {
|
|
505
|
+
cx: cx,
|
|
506
|
+
cy: cy + translationY,
|
|
507
|
+
rx: rx,
|
|
508
|
+
ry: ry - translationY
|
|
509
|
+
}
|
|
510
|
+
};
|
|
511
|
+
break;
|
|
512
|
+
case 'BOTTOM':
|
|
513
|
+
currentItem.value = {
|
|
514
|
+
type: currentItem.value.type,
|
|
515
|
+
strokeWidth: currentItem.value.strokeWidth,
|
|
516
|
+
color: currentItem.value.color,
|
|
517
|
+
data: {
|
|
518
|
+
cx: cx,
|
|
519
|
+
cy: cy + translationY,
|
|
520
|
+
rx: rx,
|
|
521
|
+
ry: ry + translationY
|
|
522
|
+
}
|
|
523
|
+
};
|
|
524
|
+
break;
|
|
525
|
+
case 'LEFT':
|
|
526
|
+
currentItem.value = {
|
|
527
|
+
type: currentItem.value.type,
|
|
528
|
+
strokeWidth: currentItem.value.strokeWidth,
|
|
529
|
+
color: currentItem.value.color,
|
|
530
|
+
data: {
|
|
531
|
+
cx: cx + translationX,
|
|
532
|
+
cy: cy,
|
|
533
|
+
rx: rx - translationX,
|
|
534
|
+
ry: ry
|
|
535
|
+
}
|
|
536
|
+
};
|
|
537
|
+
break;
|
|
538
|
+
case 'RIGHT':
|
|
539
|
+
currentItem.value = {
|
|
540
|
+
type: currentItem.value.type,
|
|
541
|
+
strokeWidth: currentItem.value.strokeWidth,
|
|
542
|
+
color: currentItem.value.color,
|
|
543
|
+
data: {
|
|
544
|
+
cx: cx + translationX,
|
|
545
|
+
cy: cy,
|
|
546
|
+
rx: rx + translationX,
|
|
547
|
+
ry: ry
|
|
548
|
+
}
|
|
549
|
+
};
|
|
550
|
+
break;
|
|
551
|
+
case 'CENTER':
|
|
552
|
+
currentItem.value = {
|
|
553
|
+
type: currentItem.value.type,
|
|
554
|
+
strokeWidth: currentItem.value.strokeWidth,
|
|
555
|
+
color: currentItem.value.color,
|
|
556
|
+
data: {
|
|
557
|
+
cx: cx + translationX,
|
|
558
|
+
cy: cy + translationY,
|
|
559
|
+
rx: rx,
|
|
560
|
+
ry: ry
|
|
561
|
+
}
|
|
562
|
+
};
|
|
563
|
+
break;
|
|
474
564
|
}
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
currentItem.value = {
|
|
486
|
-
type: currentItem.value.type,
|
|
487
|
-
strokeWidth: currentItem.value.strokeWidth,
|
|
488
|
-
color: currentItem.value.color,
|
|
489
|
-
data: {
|
|
490
|
-
cx: cx,
|
|
491
|
-
cy: cy + translationY,
|
|
492
|
-
rx: rx,
|
|
493
|
-
ry: ry - translationY
|
|
494
|
-
}
|
|
495
|
-
};
|
|
496
|
-
break;
|
|
497
|
-
case 'BOTTOM':
|
|
498
|
-
currentItem.value = {
|
|
499
|
-
type: currentItem.value.type,
|
|
500
|
-
strokeWidth: currentItem.value.strokeWidth,
|
|
501
|
-
color: currentItem.value.color,
|
|
502
|
-
data: {
|
|
503
|
-
cx: cx,
|
|
504
|
-
cy: cy + translationY,
|
|
505
|
-
rx: rx,
|
|
506
|
-
ry: ry + translationY
|
|
507
|
-
}
|
|
508
|
-
};
|
|
509
|
-
break;
|
|
510
|
-
case 'LEFT':
|
|
511
|
-
currentItem.value = {
|
|
512
|
-
type: currentItem.value.type,
|
|
513
|
-
strokeWidth: currentItem.value.strokeWidth,
|
|
514
|
-
color: currentItem.value.color,
|
|
515
|
-
data: {
|
|
516
|
-
cx: cx + translationX,
|
|
517
|
-
cy: cy,
|
|
518
|
-
rx: rx - translationX,
|
|
519
|
-
ry: ry
|
|
520
|
-
}
|
|
521
|
-
};
|
|
522
|
-
break;
|
|
523
|
-
case 'RIGHT':
|
|
524
|
-
currentItem.value = {
|
|
525
|
-
type: currentItem.value.type,
|
|
526
|
-
strokeWidth: currentItem.value.strokeWidth,
|
|
527
|
-
color: currentItem.value.color,
|
|
528
|
-
data: {
|
|
529
|
-
cx: cx + translationX,
|
|
530
|
-
cy: cy,
|
|
531
|
-
rx: rx + translationX,
|
|
532
|
-
ry: ry
|
|
533
|
-
}
|
|
534
|
-
};
|
|
535
|
-
break;
|
|
536
|
-
case 'CENTER':
|
|
537
|
-
currentItem.value = {
|
|
538
|
-
type: currentItem.value.type,
|
|
539
|
-
strokeWidth: currentItem.value.strokeWidth,
|
|
540
|
-
color: currentItem.value.color,
|
|
541
|
-
data: {
|
|
542
|
-
cx: cx + translationX,
|
|
543
|
-
cy: cy + translationY,
|
|
544
|
-
rx: rx,
|
|
545
|
-
ry: ry
|
|
546
|
-
}
|
|
547
|
-
};
|
|
548
|
-
break;
|
|
565
|
+
} else {
|
|
566
|
+
currentItem.value = {
|
|
567
|
+
type: currentItem.value.type,
|
|
568
|
+
strokeWidth: currentItem.value.strokeWidth,
|
|
569
|
+
color: currentItem.value.color,
|
|
570
|
+
data: {
|
|
571
|
+
cx: startX + translationX,
|
|
572
|
+
cy: startY + translationY,
|
|
573
|
+
rx: translationX,
|
|
574
|
+
ry: translationY
|
|
549
575
|
}
|
|
550
|
-
}
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
576
|
+
};
|
|
577
|
+
}
|
|
578
|
+
break;
|
|
579
|
+
case 'rectangle':
|
|
580
|
+
if (((_initialItem$value4 = initialItem.value) === null || _initialItem$value4 === void 0 ? void 0 : _initialItem$value4.type) === currentItem.value.type) {
|
|
581
|
+
var _initialItem$value5, _initialItem$value6, _initialItem$value7, _initialItem$value8, _initialItem$value9, _initialItem$value10, _initialItem$value11, _initialItem$value12, _initialItem$value13, _initialItem$value14, _initialItem$value15, _initialItem$value16;
|
|
582
|
+
const height = typeof ((_initialItem$value5 = initialItem.value) === null || _initialItem$value5 === void 0 ? void 0 : _initialItem$value5.data.height) === 'string' ? parseFloat((_initialItem$value6 = initialItem.value) === null || _initialItem$value6 === void 0 ? void 0 : _initialItem$value6.data.height) : ((_initialItem$value7 = initialItem.value) === null || _initialItem$value7 === void 0 ? void 0 : _initialItem$value7.data.height) || 0;
|
|
583
|
+
const width = typeof ((_initialItem$value8 = initialItem.value) === null || _initialItem$value8 === void 0 ? void 0 : _initialItem$value8.data.width) === 'string' ? parseFloat((_initialItem$value9 = initialItem.value) === null || _initialItem$value9 === void 0 ? void 0 : _initialItem$value9.data.width) : ((_initialItem$value10 = initialItem.value) === null || _initialItem$value10 === void 0 ? void 0 : _initialItem$value10.data.width) || 0;
|
|
584
|
+
const x = typeof ((_initialItem$value11 = initialItem.value) === null || _initialItem$value11 === void 0 ? void 0 : _initialItem$value11.data.x) === 'string' ? parseFloat((_initialItem$value12 = initialItem.value) === null || _initialItem$value12 === void 0 ? void 0 : _initialItem$value12.data.x) : ((_initialItem$value13 = initialItem.value) === null || _initialItem$value13 === void 0 ? void 0 : _initialItem$value13.data.x) || 0;
|
|
585
|
+
const y = typeof ((_initialItem$value14 = initialItem.value) === null || _initialItem$value14 === void 0 ? void 0 : _initialItem$value14.data.y) === 'string' ? parseFloat((_initialItem$value15 = initialItem.value) === null || _initialItem$value15 === void 0 ? void 0 : _initialItem$value15.data.y) : ((_initialItem$value16 = initialItem.value) === null || _initialItem$value16 === void 0 ? void 0 : _initialItem$value16.data.y) || 0;
|
|
586
|
+
switch (zone) {
|
|
587
|
+
case 'TOP_LEFT':
|
|
588
|
+
currentItem.value = {
|
|
589
|
+
type: 'rectangle',
|
|
590
|
+
strokeWidth: currentItem.value.strokeWidth,
|
|
591
|
+
color: currentItem.value.color,
|
|
592
|
+
data: {
|
|
593
|
+
x: startX + translationX,
|
|
594
|
+
y: startY + translationY,
|
|
595
|
+
width: width - translationX,
|
|
596
|
+
height: height - translationY
|
|
597
|
+
}
|
|
598
|
+
};
|
|
599
|
+
break;
|
|
600
|
+
case 'TOP_RIGHT':
|
|
601
|
+
currentItem.value = {
|
|
602
|
+
type: 'rectangle',
|
|
603
|
+
strokeWidth: currentItem.value.strokeWidth,
|
|
604
|
+
color: currentItem.value.color,
|
|
605
|
+
data: {
|
|
606
|
+
x: x,
|
|
607
|
+
y: startY + translationY,
|
|
608
|
+
width: width + translationX,
|
|
609
|
+
height: height - translationY
|
|
610
|
+
}
|
|
611
|
+
};
|
|
612
|
+
break;
|
|
613
|
+
case 'BOTTOM_LEFT':
|
|
614
|
+
currentItem.value = {
|
|
615
|
+
type: 'rectangle',
|
|
616
|
+
strokeWidth: currentItem.value.strokeWidth,
|
|
617
|
+
color: currentItem.value.color,
|
|
618
|
+
data: {
|
|
619
|
+
x: startX + translationX,
|
|
620
|
+
y: y,
|
|
621
|
+
width: width - translationX,
|
|
622
|
+
height: height + translationY
|
|
623
|
+
}
|
|
624
|
+
};
|
|
625
|
+
break;
|
|
626
|
+
case 'BOTTOM_RIGHT':
|
|
627
|
+
currentItem.value = {
|
|
628
|
+
type: 'rectangle',
|
|
629
|
+
strokeWidth: currentItem.value.strokeWidth,
|
|
630
|
+
color: currentItem.value.color,
|
|
631
|
+
data: {
|
|
632
|
+
x: x,
|
|
633
|
+
y: y,
|
|
634
|
+
width: width + translationX,
|
|
635
|
+
height: height + translationY
|
|
636
|
+
}
|
|
637
|
+
};
|
|
638
|
+
break;
|
|
639
|
+
case 'CENTER':
|
|
640
|
+
currentItem.value = {
|
|
641
|
+
type: 'rectangle',
|
|
642
|
+
strokeWidth: currentItem.value.strokeWidth,
|
|
643
|
+
color: currentItem.value.color,
|
|
644
|
+
data: {
|
|
645
|
+
x: x + translationX,
|
|
646
|
+
y: y + translationY,
|
|
647
|
+
width: width,
|
|
648
|
+
height: height
|
|
649
|
+
}
|
|
650
|
+
};
|
|
651
|
+
break;
|
|
562
652
|
}
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
currentItem.value = {
|
|
574
|
-
type: 'rectangle',
|
|
575
|
-
strokeWidth: currentItem.value.strokeWidth,
|
|
576
|
-
color: currentItem.value.color,
|
|
577
|
-
data: {
|
|
578
|
-
x: startX + translationX,
|
|
579
|
-
y: startY + translationY,
|
|
580
|
-
width: width - translationX,
|
|
581
|
-
height: height - translationY
|
|
582
|
-
}
|
|
583
|
-
};
|
|
584
|
-
break;
|
|
585
|
-
case 'TOP_RIGHT':
|
|
586
|
-
currentItem.value = {
|
|
587
|
-
type: 'rectangle',
|
|
588
|
-
strokeWidth: currentItem.value.strokeWidth,
|
|
589
|
-
color: currentItem.value.color,
|
|
590
|
-
data: {
|
|
591
|
-
x: x,
|
|
592
|
-
y: startY + translationY,
|
|
593
|
-
width: width + translationX,
|
|
594
|
-
height: height - translationY
|
|
595
|
-
}
|
|
596
|
-
};
|
|
597
|
-
break;
|
|
598
|
-
case 'BOTTOM_LEFT':
|
|
599
|
-
currentItem.value = {
|
|
600
|
-
type: 'rectangle',
|
|
601
|
-
strokeWidth: currentItem.value.strokeWidth,
|
|
602
|
-
color: currentItem.value.color,
|
|
603
|
-
data: {
|
|
604
|
-
x: startX + translationX,
|
|
605
|
-
y: y,
|
|
606
|
-
width: width - translationX,
|
|
607
|
-
height: height + translationY
|
|
608
|
-
}
|
|
609
|
-
};
|
|
610
|
-
break;
|
|
611
|
-
case 'BOTTOM_RIGHT':
|
|
612
|
-
currentItem.value = {
|
|
613
|
-
type: 'rectangle',
|
|
614
|
-
strokeWidth: currentItem.value.strokeWidth,
|
|
615
|
-
color: currentItem.value.color,
|
|
616
|
-
data: {
|
|
617
|
-
x: x,
|
|
618
|
-
y: y,
|
|
619
|
-
width: width + translationX,
|
|
620
|
-
height: height + translationY
|
|
621
|
-
}
|
|
622
|
-
};
|
|
623
|
-
break;
|
|
624
|
-
case 'CENTER':
|
|
625
|
-
currentItem.value = {
|
|
626
|
-
type: 'rectangle',
|
|
627
|
-
strokeWidth: currentItem.value.strokeWidth,
|
|
628
|
-
color: currentItem.value.color,
|
|
629
|
-
data: {
|
|
630
|
-
x: x + translationX,
|
|
631
|
-
y: y + translationY,
|
|
632
|
-
width: width,
|
|
633
|
-
height: height
|
|
634
|
-
}
|
|
635
|
-
};
|
|
636
|
-
break;
|
|
653
|
+
} else {
|
|
654
|
+
currentItem.value = {
|
|
655
|
+
type: 'rectangle',
|
|
656
|
+
strokeWidth: currentItem.value.strokeWidth,
|
|
657
|
+
color: currentItem.value.color,
|
|
658
|
+
data: {
|
|
659
|
+
x: currentItem.value.data.x,
|
|
660
|
+
y: currentItem.value.data.y,
|
|
661
|
+
width: translationX,
|
|
662
|
+
height: translationY
|
|
637
663
|
}
|
|
638
|
-
}
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
664
|
+
};
|
|
665
|
+
}
|
|
666
|
+
break;
|
|
667
|
+
case 'singleHead':
|
|
668
|
+
case 'doubleHead':
|
|
669
|
+
case 'doubleArrows':
|
|
670
|
+
if (((_initialItem$value17 = initialItem.value) === null || _initialItem$value17 === void 0 ? void 0 : _initialItem$value17.type) === currentItem.value.type) {
|
|
671
|
+
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;
|
|
672
|
+
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;
|
|
673
|
+
const y1 = typeof ((_initialItem$value21 = initialItem.value) === null || _initialItem$value21 === void 0 ? void 0 : _initialItem$value21.data.y1) === 'string' ? parseFloat((_initialItem$value22 = initialItem.value) === null || _initialItem$value22 === void 0 ? void 0 : _initialItem$value22.data.y1) : ((_initialItem$value23 = initialItem.value) === null || _initialItem$value23 === void 0 ? void 0 : _initialItem$value23.data.y1) || 0;
|
|
674
|
+
const x2 = typeof ((_initialItem$value24 = initialItem.value) === null || _initialItem$value24 === void 0 ? void 0 : _initialItem$value24.data.x2) === 'string' ? parseFloat((_initialItem$value25 = initialItem.value) === null || _initialItem$value25 === void 0 ? void 0 : _initialItem$value25.data.x2) : ((_initialItem$value26 = initialItem.value) === null || _initialItem$value26 === void 0 ? void 0 : _initialItem$value26.data.x2) || 0;
|
|
675
|
+
const y2 = typeof ((_initialItem$value27 = initialItem.value) === null || _initialItem$value27 === void 0 ? void 0 : _initialItem$value27.data.y2) === 'string' ? parseFloat((_initialItem$value28 = initialItem.value) === null || _initialItem$value28 === void 0 ? void 0 : _initialItem$value28.data.y2) : ((_initialItem$value29 = initialItem.value) === null || _initialItem$value29 === void 0 ? void 0 : _initialItem$value29.data.y2) || 0;
|
|
676
|
+
switch (zone) {
|
|
677
|
+
case 'TOP':
|
|
678
|
+
currentItem.value = {
|
|
679
|
+
type: currentItem.value.type,
|
|
680
|
+
strokeWidth: currentItem.value.strokeWidth,
|
|
681
|
+
color: currentItem.value.color,
|
|
682
|
+
text: currentItem.value.type === 'doubleArrows' ? currentItem.value.text ?? '' : '',
|
|
683
|
+
data: {
|
|
684
|
+
x1: x1 + translationX,
|
|
685
|
+
y1: y1 + translationY,
|
|
686
|
+
x2: x2,
|
|
687
|
+
y2: y2
|
|
688
|
+
}
|
|
689
|
+
};
|
|
690
|
+
break;
|
|
691
|
+
case 'BOTTOM':
|
|
692
|
+
currentItem.value = {
|
|
693
|
+
type: currentItem.value.type,
|
|
694
|
+
strokeWidth: currentItem.value.strokeWidth,
|
|
695
|
+
color: currentItem.value.color,
|
|
696
|
+
text: currentItem.value.type === 'doubleArrows' ? currentItem.value.text ?? '' : '',
|
|
697
|
+
data: {
|
|
698
|
+
x1: x1,
|
|
699
|
+
y1: y1,
|
|
700
|
+
x2: x2 + translationX,
|
|
701
|
+
y2: y2 + translationY
|
|
702
|
+
}
|
|
703
|
+
};
|
|
704
|
+
break;
|
|
705
|
+
case 'CENTER':
|
|
706
|
+
currentItem.value = {
|
|
707
|
+
type: currentItem.value.type,
|
|
708
|
+
strokeWidth: currentItem.value.strokeWidth,
|
|
709
|
+
color: currentItem.value.color,
|
|
710
|
+
text: currentItem.value.type === 'doubleArrows' ? currentItem.value.text ?? '' : '',
|
|
711
|
+
data: {
|
|
712
|
+
x1: x1 + translationX,
|
|
713
|
+
y1: y1 + translationY,
|
|
714
|
+
x2: x2 + translationX,
|
|
715
|
+
y2: y2 + translationY
|
|
716
|
+
}
|
|
717
|
+
};
|
|
718
|
+
break;
|
|
650
719
|
}
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
case 'TOP':
|
|
663
|
-
currentItem.value = {
|
|
664
|
-
type: currentItem.value.type,
|
|
665
|
-
strokeWidth: currentItem.value.strokeWidth,
|
|
666
|
-
color: currentItem.value.color,
|
|
667
|
-
text: currentItem.value.type === 'doubleArrows' ? currentItem.value.text ?? '' : '',
|
|
668
|
-
data: {
|
|
669
|
-
x1: x1 + translationX,
|
|
670
|
-
y1: y1 + translationY,
|
|
671
|
-
x2: x2,
|
|
672
|
-
y2: y2
|
|
673
|
-
}
|
|
674
|
-
};
|
|
675
|
-
break;
|
|
676
|
-
case 'BOTTOM':
|
|
677
|
-
currentItem.value = {
|
|
678
|
-
type: currentItem.value.type,
|
|
679
|
-
strokeWidth: currentItem.value.strokeWidth,
|
|
680
|
-
color: currentItem.value.color,
|
|
681
|
-
text: currentItem.value.type === 'doubleArrows' ? currentItem.value.text ?? '' : '',
|
|
682
|
-
data: {
|
|
683
|
-
x1: x1,
|
|
684
|
-
y1: y1,
|
|
685
|
-
x2: x2 + translationX,
|
|
686
|
-
y2: y2 + translationY
|
|
687
|
-
}
|
|
688
|
-
};
|
|
689
|
-
break;
|
|
690
|
-
case 'CENTER':
|
|
691
|
-
currentItem.value = {
|
|
692
|
-
type: currentItem.value.type,
|
|
693
|
-
strokeWidth: currentItem.value.strokeWidth,
|
|
694
|
-
color: currentItem.value.color,
|
|
695
|
-
text: currentItem.value.type === 'doubleArrows' ? currentItem.value.text ?? '' : '',
|
|
696
|
-
data: {
|
|
697
|
-
x1: x1 + translationX,
|
|
698
|
-
y1: y1 + translationY,
|
|
699
|
-
x2: x2 + translationX,
|
|
700
|
-
y2: y2 + translationY
|
|
701
|
-
}
|
|
702
|
-
};
|
|
703
|
-
break;
|
|
720
|
+
} else {
|
|
721
|
+
currentItem.value = {
|
|
722
|
+
type: currentItem.value.type,
|
|
723
|
+
strokeWidth: currentItem.value.strokeWidth,
|
|
724
|
+
color: currentItem.value.color,
|
|
725
|
+
text: currentItem.value.type === 'doubleArrows' ? currentItem.value.text ?? '' : '',
|
|
726
|
+
data: {
|
|
727
|
+
x1: startX,
|
|
728
|
+
y1: startY,
|
|
729
|
+
x2: startX + translationX,
|
|
730
|
+
y2: startY + translationY
|
|
704
731
|
}
|
|
705
|
-
}
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
732
|
+
};
|
|
733
|
+
}
|
|
734
|
+
break;
|
|
735
|
+
case 'text':
|
|
736
|
+
if (((_initialItem$value30 = initialItem.value) === null || _initialItem$value30 === void 0 ? void 0 : _initialItem$value30.type) === currentItem.value.type) {
|
|
737
|
+
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;
|
|
738
|
+
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;
|
|
739
|
+
const yText = typeof ((_initialItem$value34 = initialItem.value) === null || _initialItem$value34 === void 0 ? void 0 : _initialItem$value34.data.y) === 'string' ? parseFloat((_initialItem$value35 = initialItem.value) === null || _initialItem$value35 === void 0 ? void 0 : _initialItem$value35.data.y) : ((_initialItem$value36 = initialItem.value) === null || _initialItem$value36 === void 0 ? void 0 : _initialItem$value36.data.y) || 0;
|
|
740
|
+
const widthText = typeof ((_initialItem$value37 = initialItem.value) === null || _initialItem$value37 === void 0 ? void 0 : _initialItem$value37.data.width) === 'string' ? parseFloat((_initialItem$value38 = initialItem.value) === null || _initialItem$value38 === void 0 ? void 0 : _initialItem$value38.data.width) : ((_initialItem$value39 = initialItem.value) === null || _initialItem$value39 === void 0 ? void 0 : _initialItem$value39.data.width) || 0;
|
|
741
|
+
const heightText = typeof ((_initialItem$value40 = initialItem.value) === null || _initialItem$value40 === void 0 ? void 0 : _initialItem$value40.data.height) === 'string' ? parseFloat((_initialItem$value41 = initialItem.value) === null || _initialItem$value41 === void 0 ? void 0 : _initialItem$value41.data.height) : ((_initialItem$value42 = initialItem.value) === null || _initialItem$value42 === void 0 ? void 0 : _initialItem$value42.data.height) || 0;
|
|
742
|
+
switch (zone) {
|
|
743
|
+
case 'LEFT':
|
|
744
|
+
currentItem.value = {
|
|
745
|
+
type: currentItem.value.type,
|
|
746
|
+
strokeWidth: currentItem.value.strokeWidth,
|
|
747
|
+
color: currentItem.value.color,
|
|
748
|
+
text: currentItem.value.text,
|
|
749
|
+
data: {
|
|
750
|
+
x: xText + translationX,
|
|
751
|
+
y: yText,
|
|
752
|
+
width: widthText - translationX,
|
|
753
|
+
height: heightText
|
|
754
|
+
}
|
|
755
|
+
};
|
|
756
|
+
break;
|
|
757
|
+
case 'RIGHT':
|
|
758
|
+
currentItem.value = {
|
|
759
|
+
type: currentItem.value.type,
|
|
760
|
+
strokeWidth: currentItem.value.strokeWidth,
|
|
761
|
+
color: currentItem.value.color,
|
|
762
|
+
text: currentItem.value.text,
|
|
763
|
+
data: {
|
|
764
|
+
x: xText,
|
|
765
|
+
y: yText,
|
|
766
|
+
width: widthText + translationX,
|
|
767
|
+
height: heightText
|
|
768
|
+
}
|
|
769
|
+
};
|
|
770
|
+
break;
|
|
771
|
+
case 'CENTER':
|
|
772
|
+
currentItem.value = {
|
|
773
|
+
type: currentItem.value.type,
|
|
774
|
+
strokeWidth: currentItem.value.strokeWidth,
|
|
775
|
+
color: currentItem.value.color,
|
|
776
|
+
text: currentItem.value.text,
|
|
777
|
+
data: {
|
|
778
|
+
x: xText + translationX,
|
|
779
|
+
y: yText + translationY,
|
|
780
|
+
width: widthText,
|
|
781
|
+
height: heightText
|
|
782
|
+
}
|
|
783
|
+
};
|
|
784
|
+
break;
|
|
718
785
|
}
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
currentItem.value = {
|
|
731
|
-
type: currentItem.value.type,
|
|
732
|
-
strokeWidth: currentItem.value.strokeWidth,
|
|
733
|
-
color: currentItem.value.color,
|
|
734
|
-
text: currentItem.value.text,
|
|
735
|
-
data: {
|
|
736
|
-
x: xText + translationX,
|
|
737
|
-
y: yText,
|
|
738
|
-
width: widthText - translationX,
|
|
739
|
-
height: heightText
|
|
740
|
-
}
|
|
741
|
-
};
|
|
742
|
-
break;
|
|
743
|
-
case 'RIGHT':
|
|
744
|
-
currentItem.value = {
|
|
745
|
-
type: currentItem.value.type,
|
|
746
|
-
strokeWidth: currentItem.value.strokeWidth,
|
|
747
|
-
color: currentItem.value.color,
|
|
748
|
-
text: currentItem.value.text,
|
|
749
|
-
data: {
|
|
750
|
-
x: xText,
|
|
751
|
-
y: yText,
|
|
752
|
-
width: widthText + translationX,
|
|
753
|
-
height: heightText
|
|
754
|
-
}
|
|
755
|
-
};
|
|
756
|
-
break;
|
|
757
|
-
case 'CENTER':
|
|
758
|
-
currentItem.value = {
|
|
759
|
-
type: currentItem.value.type,
|
|
760
|
-
strokeWidth: currentItem.value.strokeWidth,
|
|
761
|
-
color: currentItem.value.color,
|
|
762
|
-
text: currentItem.value.text,
|
|
763
|
-
data: {
|
|
764
|
-
x: xText + translationX,
|
|
765
|
-
y: yText + translationY,
|
|
766
|
-
width: widthText,
|
|
767
|
-
height: heightText
|
|
768
|
-
}
|
|
769
|
-
};
|
|
770
|
-
break;
|
|
786
|
+
} else {
|
|
787
|
+
currentItem.value = {
|
|
788
|
+
type: currentItem.value.type,
|
|
789
|
+
strokeWidth: currentItem.value.strokeWidth,
|
|
790
|
+
color: currentItem.value.color,
|
|
791
|
+
text: currentItem.value.text,
|
|
792
|
+
data: {
|
|
793
|
+
x: startX + translationX,
|
|
794
|
+
y: startY + translationY,
|
|
795
|
+
width: currentItem.value.data.width,
|
|
796
|
+
height: currentItem.value.data.height
|
|
771
797
|
}
|
|
772
|
-
}
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
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') {
|
|
794
|
-
(0, _reactNativeReanimated.runOnJS)(textFocus)();
|
|
795
|
-
currentItem.value = {
|
|
796
|
-
type: currentItem.value.type,
|
|
797
|
-
strokeWidth: currentItem.value.strokeWidth,
|
|
798
|
-
color: currentItem.value.color,
|
|
799
|
-
data: currentItem.value.data,
|
|
800
|
-
text: currentItem.value.text !== DEFAULT_TEXT ? currentItem.value.text ?? '' : ''
|
|
801
|
-
};
|
|
802
|
-
}
|
|
803
|
-
(0, _reactNativeReanimated.runOnJS)(addScreenStates)(currentItem.value);
|
|
798
|
+
};
|
|
799
|
+
}
|
|
800
|
+
}
|
|
801
|
+
}).onEnd(() => {
|
|
802
|
+
var _currentItem$value5, _currentItem$value6;
|
|
803
|
+
if (((_currentItem$value5 = currentItem.value) === null || _currentItem$value5 === void 0 ? void 0 : _currentItem$value5.type) === 'doubleArrows') {
|
|
804
|
+
(0, _reactNativeReanimated.runOnJS)(textFocusState)();
|
|
805
|
+
}
|
|
806
|
+
if (((_currentItem$value6 = currentItem.value) === null || _currentItem$value6 === void 0 ? void 0 : _currentItem$value6.type) === 'text') {
|
|
807
|
+
(0, _reactNativeReanimated.runOnJS)(textFocus)();
|
|
808
|
+
currentItem.value = {
|
|
809
|
+
type: currentItem.value.type,
|
|
810
|
+
strokeWidth: currentItem.value.strokeWidth,
|
|
811
|
+
color: currentItem.value.color,
|
|
812
|
+
data: currentItem.value.data,
|
|
813
|
+
text: currentItem.value.text !== DEFAULT_TEXT ? currentItem.value.text ?? '' : ''
|
|
814
|
+
};
|
|
804
815
|
}
|
|
816
|
+
(0, _reactNativeReanimated.runOnJS)(addScreenStates)(currentItem.value);
|
|
805
817
|
});
|
|
806
818
|
(0, _react.useEffect)(() => {
|
|
807
819
|
const sudDidHide = _reactNative.Keyboard.addListener('keyboardDidHide', () => {
|
|
@@ -809,7 +821,6 @@ const DrawCore = _ref => {
|
|
|
809
821
|
});
|
|
810
822
|
const sudDidShow = _reactNative.Keyboard.addListener('keyboardDidShow', event => {
|
|
811
823
|
// avoid events triggered by InputAccessoryView
|
|
812
|
-
console.log('keyboardDidShow dc');
|
|
813
824
|
if (event.endCoordinates.height > 100) {
|
|
814
825
|
showTextInput.value = true;
|
|
815
826
|
}
|
|
@@ -827,13 +838,13 @@ const DrawCore = _ref => {
|
|
|
827
838
|
strokeWidth: strokeWidth.value,
|
|
828
839
|
color: color === null || color === void 0 ? void 0 : color.value
|
|
829
840
|
};
|
|
830
|
-
},
|
|
831
|
-
var _currentItem$
|
|
841
|
+
}, _ref2 => {
|
|
842
|
+
var _currentItem$value7;
|
|
832
843
|
let {
|
|
833
844
|
strokeWidth: sw,
|
|
834
845
|
color: c
|
|
835
|
-
} =
|
|
836
|
-
switch ((_currentItem$
|
|
846
|
+
} = _ref2;
|
|
847
|
+
switch ((_currentItem$value7 = currentItem.value) === null || _currentItem$value7 === void 0 ? void 0 : _currentItem$value7.type) {
|
|
837
848
|
case 'singleHead':
|
|
838
849
|
case 'doubleHead':
|
|
839
850
|
case 'doubleArrows':
|
|
@@ -859,12 +870,10 @@ const DrawCore = _ref => {
|
|
|
859
870
|
}
|
|
860
871
|
}, [strokeWidth.value, color === null || color === void 0 ? void 0 : color.value]);
|
|
861
872
|
const onPressItem = (0, _react.useCallback)((item, index) => () => {
|
|
862
|
-
console.log('onPressItem');
|
|
863
|
-
itemIsSelected.value = true;
|
|
864
873
|
const previousItem = currentItem.value;
|
|
874
|
+
itemIsSelected.value = true;
|
|
865
875
|
strokeWidth.value = item.strokeWidth;
|
|
866
876
|
color.value = item.color;
|
|
867
|
-
console.log('item', item);
|
|
868
877
|
currentItem.value = item;
|
|
869
878
|
deleteDoneItem(index);
|
|
870
879
|
if (previousItem) {
|
|
@@ -915,11 +924,11 @@ const DrawCore = _ref => {
|
|
|
915
924
|
onTextHeightUpdate(currentItem, textBaseHeight, height);
|
|
916
925
|
}, [currentItem, textBaseHeight]);
|
|
917
926
|
const calculateSizes = (0, _react.useCallback)((imageWidth, imageHeight) => {
|
|
927
|
+
setOriginalImageSize({
|
|
928
|
+
width: imageWidth,
|
|
929
|
+
height: imageHeight
|
|
930
|
+
});
|
|
918
931
|
if (drawRegion) {
|
|
919
|
-
setOriginalImageSize({
|
|
920
|
-
width: imageWidth,
|
|
921
|
-
height: imageHeight
|
|
922
|
-
});
|
|
923
932
|
const ratioImageHeight = Math.round(imageHeight * drawRegion.width / imageWidth * 100) / 100;
|
|
924
933
|
if (ratioImageHeight < drawRegion.height) {
|
|
925
934
|
setImageSize({
|
|
@@ -949,35 +958,18 @@ const DrawCore = _ref => {
|
|
|
949
958
|
|
|
950
959
|
// do not remove keyboard will appear over the drawing frame and not shift it
|
|
951
960
|
(0, _reactNativeReanimated.useAnimatedKeyboard)();
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
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
|
-
};
|
|
961
|
+
const [newLayoutRequested, setNewLayoutRequested] = (0, _react.useState)(false);
|
|
962
|
+
const onLayout = (0, _react.useCallback)(async () => {
|
|
963
|
+
if (newLayoutRequested) {
|
|
964
|
+
setNewLayoutRequested(false);
|
|
965
|
+
const uri = await captureSnapshot();
|
|
966
|
+
if (uri && typeof actionWithSnapShotUri === 'function') {
|
|
967
|
+
await actionWithSnapShotUri(uri);
|
|
976
968
|
}
|
|
977
|
-
}
|
|
978
|
-
|
|
979
|
-
);
|
|
980
|
-
|
|
969
|
+
}
|
|
970
|
+
}, [actionWithSnapShotUri, newLayoutRequested, captureSnapshot]);
|
|
971
|
+
const [ratioImage, setRatioImage] = (0, _react.useState)(1);
|
|
972
|
+
const [opacity, setOpacity] = (0, _react.useState)(1);
|
|
981
973
|
return /*#__PURE__*/_react.default.createElement(_reactNative.View, {
|
|
982
974
|
style: styles.container
|
|
983
975
|
}, /*#__PURE__*/_react.default.createElement(_reactNative.View, {
|
|
@@ -993,10 +985,14 @@ const DrawCore = _ref => {
|
|
|
993
985
|
}, /*#__PURE__*/_react.default.createElement(_reactNative.KeyboardAvoidingView, {
|
|
994
986
|
behavior: "position",
|
|
995
987
|
keyboardVerticalOffset: 70
|
|
996
|
-
}, /*#__PURE__*/_react.default.createElement(_reactNativeGestureHandler.
|
|
997
|
-
|
|
988
|
+
}, /*#__PURE__*/_react.default.createElement(_reactNativeGestureHandler.GestureDetector, {
|
|
989
|
+
gesture: panGesture
|
|
998
990
|
}, /*#__PURE__*/_react.default.createElement(_reactNativeReanimated.default.View, {
|
|
999
|
-
style:
|
|
991
|
+
style: {
|
|
992
|
+
...(imageSize || drawRegion),
|
|
993
|
+
opacity: opacity
|
|
994
|
+
},
|
|
995
|
+
onLayout: onLayout
|
|
1000
996
|
}, /*#__PURE__*/_react.default.createElement(_reactNative.View, {
|
|
1001
997
|
ref: drawContainer
|
|
1002
998
|
}, image ? imageSize && originalImageSize ? /*#__PURE__*/_react.default.createElement(_reactNativeViewShot.default, {
|
|
@@ -1013,21 +1009,23 @@ const DrawCore = _ref => {
|
|
|
1013
1009
|
currentItem: currentItem,
|
|
1014
1010
|
doneItems: drawState.doneItems,
|
|
1015
1011
|
onPressItem: onPressItem,
|
|
1016
|
-
onTextHeightChange: onTextHeightChange
|
|
1012
|
+
onTextHeightChange: onTextHeightChange,
|
|
1013
|
+
ratioImage: ratioImage
|
|
1017
1014
|
}))) : null : drawRegion ? /*#__PURE__*/_react.default.createElement(_reactNativeViewShot.default, {
|
|
1018
1015
|
ref: viewShot,
|
|
1019
1016
|
options: {
|
|
1020
1017
|
format: 'jpg',
|
|
1021
1018
|
quality: 1,
|
|
1022
|
-
...drawRegion
|
|
1019
|
+
...(imageSize || drawRegion)
|
|
1023
1020
|
},
|
|
1024
|
-
style: drawRegion
|
|
1021
|
+
style: imageSize || drawRegion
|
|
1025
1022
|
}, /*#__PURE__*/_react.default.createElement(_DrawPad.default, {
|
|
1026
1023
|
addBackground: true,
|
|
1027
1024
|
currentItem: currentItem,
|
|
1028
1025
|
doneItems: drawState.doneItems,
|
|
1029
1026
|
onPressItem: onPressItem,
|
|
1030
|
-
onTextHeightChange: onTextHeightChange
|
|
1027
|
+
onTextHeightChange: onTextHeightChange,
|
|
1028
|
+
ratioImage: ratioImage
|
|
1031
1029
|
})) : null))), /*#__PURE__*/_react.default.createElement(_reactNative.TextInput, {
|
|
1032
1030
|
ref: textInputRef,
|
|
1033
1031
|
style: styles.textInput,
|