@archireport/react-native-svg-draw 1.0.2 → 1.2.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.
Files changed (107) hide show
  1. package/lib/commonjs/components/DrawCore/ColorSlider.js +23 -16
  2. package/lib/commonjs/components/DrawCore/ColorSlider.js.map +1 -1
  3. package/lib/commonjs/components/DrawCore/CurrentAnimatedItem.js +60 -9
  4. package/lib/commonjs/components/DrawCore/CurrentAnimatedItem.js.map +1 -1
  5. package/lib/commonjs/components/DrawCore/CurrentAnimatedText.js +5 -4
  6. package/lib/commonjs/components/DrawCore/CurrentAnimatedText.js.map +1 -1
  7. package/lib/commonjs/components/DrawCore/DrawPad.js +11 -10
  8. package/lib/commonjs/components/DrawCore/DrawPad.js.map +1 -1
  9. package/lib/commonjs/components/DrawCore/Item.js +10 -10
  10. package/lib/commonjs/components/DrawCore/Item.js.map +1 -1
  11. package/lib/commonjs/components/DrawCore/StrokeSlider.js +21 -14
  12. package/lib/commonjs/components/DrawCore/StrokeSlider.js.map +1 -1
  13. package/lib/commonjs/components/DrawCore/index.js +156 -63
  14. package/lib/commonjs/components/DrawCore/index.js.map +1 -1
  15. package/lib/commonjs/components/DrawWithOptions/ArrowSvg.js +1 -1
  16. package/lib/commonjs/components/DrawWithOptions/ArrowSvg.js.map +1 -1
  17. package/lib/commonjs/components/DrawWithOptions/CancelSvg.js +35 -0
  18. package/lib/commonjs/components/DrawWithOptions/CancelSvg.js.map +1 -0
  19. package/lib/commonjs/components/DrawWithOptions/CircleSvg.js +1 -1
  20. package/lib/commonjs/components/DrawWithOptions/CircleSvg.js.map +1 -1
  21. package/lib/commonjs/components/DrawWithOptions/CloseSvg.js +1 -1
  22. package/lib/commonjs/components/DrawWithOptions/CloseSvg.js.map +1 -1
  23. package/lib/commonjs/components/DrawWithOptions/DoubleHeadSvg.js +1 -1
  24. package/lib/commonjs/components/DrawWithOptions/DoubleHeadSvg.js.map +1 -1
  25. package/lib/commonjs/components/DrawWithOptions/PenSvg.js +27 -0
  26. package/lib/commonjs/components/DrawWithOptions/PenSvg.js.map +1 -0
  27. package/lib/commonjs/components/DrawWithOptions/SendSvg.js +1 -1
  28. package/lib/commonjs/components/DrawWithOptions/SendSvg.js.map +1 -1
  29. package/lib/commonjs/components/DrawWithOptions/SquareSvg.js +1 -1
  30. package/lib/commonjs/components/DrawWithOptions/SquareSvg.js.map +1 -1
  31. package/lib/commonjs/components/DrawWithOptions/TextSvg.js +1 -1
  32. package/lib/commonjs/components/DrawWithOptions/TextSvg.js.map +1 -1
  33. package/lib/commonjs/components/DrawWithOptions/ThrashSvg.js +1 -1
  34. package/lib/commonjs/components/DrawWithOptions/ThrashSvg.js.map +1 -1
  35. package/lib/commonjs/components/DrawWithOptions/index.js +39 -8
  36. package/lib/commonjs/components/DrawWithOptions/index.js.map +1 -1
  37. package/lib/commonjs/index.js.map +1 -1
  38. package/lib/commonjs/types.d.js +4 -0
  39. package/lib/commonjs/types.d.js.map +1 -1
  40. package/lib/module/components/DrawCore/ColorSlider.js +24 -17
  41. package/lib/module/components/DrawCore/ColorSlider.js.map +1 -1
  42. package/lib/module/components/DrawCore/CurrentAnimatedItem.js +57 -10
  43. package/lib/module/components/DrawCore/CurrentAnimatedItem.js.map +1 -1
  44. package/lib/module/components/DrawCore/CurrentAnimatedText.js +5 -4
  45. package/lib/module/components/DrawCore/CurrentAnimatedText.js.map +1 -1
  46. package/lib/module/components/DrawCore/DrawPad.js +11 -10
  47. package/lib/module/components/DrawCore/DrawPad.js.map +1 -1
  48. package/lib/module/components/DrawCore/Item.js +9 -11
  49. package/lib/module/components/DrawCore/Item.js.map +1 -1
  50. package/lib/module/components/DrawCore/StrokeSlider.js +21 -14
  51. package/lib/module/components/DrawCore/StrokeSlider.js.map +1 -1
  52. package/lib/module/components/DrawCore/index.js +157 -64
  53. package/lib/module/components/DrawCore/index.js.map +1 -1
  54. package/lib/module/components/DrawWithOptions/ArrowSvg.js +1 -1
  55. package/lib/module/components/DrawWithOptions/ArrowSvg.js.map +1 -1
  56. package/lib/module/components/DrawWithOptions/CancelSvg.js +22 -0
  57. package/lib/module/components/DrawWithOptions/CancelSvg.js.map +1 -0
  58. package/lib/module/components/DrawWithOptions/CircleSvg.js +1 -1
  59. package/lib/module/components/DrawWithOptions/CircleSvg.js.map +1 -1
  60. package/lib/module/components/DrawWithOptions/CloseSvg.js +1 -1
  61. package/lib/module/components/DrawWithOptions/CloseSvg.js.map +1 -1
  62. package/lib/module/components/DrawWithOptions/DoubleHeadSvg.js +1 -1
  63. package/lib/module/components/DrawWithOptions/DoubleHeadSvg.js.map +1 -1
  64. package/lib/module/components/DrawWithOptions/PenSvg.js +14 -0
  65. package/lib/module/components/DrawWithOptions/PenSvg.js.map +1 -0
  66. package/lib/module/components/DrawWithOptions/SendSvg.js +1 -1
  67. package/lib/module/components/DrawWithOptions/SendSvg.js.map +1 -1
  68. package/lib/module/components/DrawWithOptions/SquareSvg.js +1 -1
  69. package/lib/module/components/DrawWithOptions/SquareSvg.js.map +1 -1
  70. package/lib/module/components/DrawWithOptions/TextSvg.js +1 -1
  71. package/lib/module/components/DrawWithOptions/TextSvg.js.map +1 -1
  72. package/lib/module/components/DrawWithOptions/ThrashSvg.js +1 -1
  73. package/lib/module/components/DrawWithOptions/ThrashSvg.js.map +1 -1
  74. package/lib/module/components/DrawWithOptions/index.js +37 -8
  75. package/lib/module/components/DrawWithOptions/index.js.map +1 -1
  76. package/lib/module/index.js.map +1 -1
  77. package/lib/module/types.d.js +1 -1
  78. package/lib/module/types.d.js.map +1 -1
  79. package/lib/typescript/components/DrawCore/ColorSlider.d.ts +2 -1
  80. package/lib/typescript/components/DrawCore/CurrentAnimatedItem.d.ts +3 -1
  81. package/lib/typescript/components/DrawCore/CurrentAnimatedText.d.ts +1 -0
  82. package/lib/typescript/components/DrawCore/DrawPad.d.ts +1 -0
  83. package/lib/typescript/components/DrawCore/Item.d.ts +1 -0
  84. package/lib/typescript/components/DrawCore/StrokeSlider.d.ts +3 -1
  85. package/lib/typescript/components/DrawCore/index.d.ts +1 -0
  86. package/lib/typescript/components/DrawWithOptions/ArrowSvg.d.ts +1 -0
  87. package/lib/typescript/components/DrawWithOptions/CancelSvg.d.ts +3 -0
  88. package/lib/typescript/components/DrawWithOptions/CircleSvg.d.ts +1 -0
  89. package/lib/typescript/components/DrawWithOptions/CloseSvg.d.ts +1 -0
  90. package/lib/typescript/components/DrawWithOptions/DoubleHeadSvg.d.ts +1 -0
  91. package/lib/typescript/components/DrawWithOptions/PenSvg.d.ts +3 -0
  92. package/lib/typescript/components/DrawWithOptions/SendSvg.d.ts +1 -0
  93. package/lib/typescript/components/DrawWithOptions/SquareSvg.d.ts +1 -0
  94. package/lib/typescript/components/DrawWithOptions/TextSvg.d.ts +1 -0
  95. package/lib/typescript/components/DrawWithOptions/ThrashSvg.d.ts +1 -0
  96. package/lib/typescript/components/DrawWithOptions/index.d.ts +3 -1
  97. package/package.json +5 -5
  98. package/src/components/DrawCore/ColorSlider.tsx +11 -6
  99. package/src/components/DrawCore/CurrentAnimatedItem.tsx +59 -8
  100. package/src/components/DrawCore/DrawPad.tsx +2 -2
  101. package/src/components/DrawCore/Item.tsx +3 -11
  102. package/src/components/DrawCore/StrokeSlider.tsx +5 -1
  103. package/src/components/DrawCore/index.tsx +1105 -970
  104. package/src/components/DrawWithOptions/CancelSvg.tsx +23 -0
  105. package/src/components/DrawWithOptions/PenSvg.tsx +14 -0
  106. package/src/components/DrawWithOptions/index.tsx +38 -1
  107. package/src/types.d.ts +4 -1
@@ -1,4 +1,4 @@
1
- import React, { useCallback, useEffect, useImperativeHandle, useRef, useState } from 'react';
1
+ import React, { useCallback, useEffect, useImperativeHandle, useReducer, useRef, useState } from 'react';
2
2
  import { StyleSheet, TextInput, View, Keyboard, ImageBackground, Image, Platform, InputAccessoryView } from 'react-native';
3
3
  import Animated, { runOnJS, useAnimatedGestureHandler, useAnimatedReaction, useAnimatedStyle, useSharedValue, withTiming } from 'react-native-reanimated';
4
4
  import { PanGestureHandler } from 'react-native-gesture-handler';
@@ -54,7 +54,7 @@ const styles = StyleSheet.create({
54
54
  }
55
55
  });
56
56
 
57
- function pDistance(point, line) {
57
+ const pDistance = (point, line) => {
58
58
  'worklet';
59
59
 
60
60
  const {
@@ -96,17 +96,17 @@ function pDistance(point, line) {
96
96
  var dx = x - xx;
97
97
  var dy = y - yy;
98
98
  return Math.sqrt(dx * dx + dy * dy);
99
- }
99
+ };
100
100
 
101
101
  const AnimatedTextInput = Animated.createAnimatedComponent(TextInput);
102
102
  const DEFAULT_TEXT = '';
103
103
  const THRESHOLD = 20;
104
104
 
105
- const drawNewItem = (mode, currentItem, updateDoneItems, position, style) => {
105
+ const drawNewItem = (mode, currentItem, addDoneItem, position, style) => {
106
106
  'worklet';
107
107
 
108
108
  if (currentItem.value) {
109
- runOnJS(updateDoneItems)(currentItem.value);
109
+ runOnJS(addDoneItem)(currentItem.value);
110
110
  }
111
111
 
112
112
  switch (mode.value) {
@@ -198,14 +198,67 @@ const onTextHeightUpdate = (currentItem, textBaseHeight, height) => {
198
198
  }
199
199
  };
200
200
 
201
- const DrawCore = /*#__PURE__*/React.forwardRef(({
202
- drawingMode,
203
- image,
204
- linearGradient,
205
- onSelectionChange
206
- }, ref) => {
201
+ const reducerDrawStates = (drawStates, action) => {
202
+ 'worklet';
203
+
204
+ switch (action.type) {
205
+ case 'ADD_DONE_ITEM':
206
+ return { ...drawStates,
207
+ doneItems: drawStates.doneItems.concat(action.item)
208
+ };
209
+
210
+ case 'DELETE_DONE_ITEM':
211
+ const newDoneItems = drawStates.doneItems;
212
+ newDoneItems.splice(action.indice, 1);
213
+ return { ...drawStates,
214
+ doneItems: newDoneItems
215
+ };
216
+
217
+ case 'ADD_SCREEN_STATE':
218
+ if (action.currentItem) {
219
+ return { ...drawStates,
220
+ screenStates: drawStates.screenStates.concat([[...drawStates.doneItems, action.currentItem]])
221
+ };
222
+ } else {
223
+ return { ...drawStates,
224
+ screenStates: drawStates.screenStates.concat([[...drawStates.doneItems]])
225
+ };
226
+ }
227
+
228
+ case 'CANCEL':
229
+ const len = drawStates.screenStates.length;
230
+
231
+ if (len > 1) {
232
+ const newScreenStates = drawStates.screenStates;
233
+ newScreenStates.pop();
234
+
235
+ if (newScreenStates.length === 1) {
236
+ var _action$onCancelChang;
237
+
238
+ (_action$onCancelChang = action.onCancelChange) === null || _action$onCancelChang === void 0 ? void 0 : _action$onCancelChang.call(action, false);
239
+ }
240
+
241
+ return {
242
+ doneItems: drawStates.screenStates[len - 2],
243
+ screenStates: newScreenStates
244
+ };
245
+ } else {
246
+ return drawStates;
247
+ }
248
+
249
+ }
250
+ };
251
+
252
+ const DrawCore = /*#__PURE__*/React.forwardRef((_ref, ref) => {
207
253
  var _textInputRef$current3, _textInputRef$current4;
208
254
 
255
+ let {
256
+ drawingMode,
257
+ image,
258
+ linearGradient,
259
+ onSelectionChange,
260
+ onCancelChange
261
+ } = _ref;
209
262
  const mode = useSharedValue('pen');
210
263
  const [drawRegion, setDrawRegion] = useState(null);
211
264
  const [originalImageSize, setOriginalImageSize] = useState(null);
@@ -215,42 +268,76 @@ const DrawCore = /*#__PURE__*/React.forwardRef(({
215
268
  const [textVal, setTextVal] = useState('');
216
269
  const currentItem = useSharedValue(null);
217
270
  const initialItem = useSharedValue(null);
218
- const [doneItems, setDoneItems] = useState([]);
271
+ const [drawStates, dispatchDrawStates] = useReducer(reducerDrawStates, {
272
+ doneItems: [],
273
+ screenStates: [[]]
274
+ });
219
275
  const textBaseHeight = useSharedValue(null);
220
- const updateDoneItems = useCallback(done => {
221
- setDoneItems(previous => previous.concat(done));
276
+ const addDoneItem = useCallback(item => {
277
+ dispatchDrawStates({
278
+ type: 'ADD_DONE_ITEM',
279
+ item: item
280
+ });
281
+ }, []);
282
+ const deleteDoneItem = useCallback(indice => {
283
+ dispatchDrawStates({
284
+ type: 'DELETE_DONE_ITEM',
285
+ indice: indice
286
+ });
222
287
  }, []);
288
+ const addScreenStates = useCallback(item => {
289
+ dispatchDrawStates({
290
+ type: 'ADD_SCREEN_STATE',
291
+ currentItem: item
292
+ });
293
+ }, []);
294
+ const cancelAction = useCallback(() => {
295
+ dispatchDrawStates({
296
+ type: 'CANCEL',
297
+ onCancelChange: onCancelChange
298
+ });
299
+ }, [onCancelChange]);
223
300
  useImperativeHandle(ref, () => ({
224
301
  drawingContainer: drawContainer,
225
302
  deleteSelectedItem: () => {
226
303
  if (currentItem.value) {
227
304
  currentItem.value = null;
305
+ addScreenStates(null);
228
306
  }
229
307
 
230
308
  onSelectionChange === null || onSelectionChange === void 0 ? void 0 : onSelectionChange(false);
309
+ onCancelChange === null || onCancelChange === void 0 ? void 0 : onCancelChange(true);
310
+ },
311
+ cancelLastAction: () => {
312
+ onSelectionChange === null || onSelectionChange === void 0 ? void 0 : onSelectionChange(false);
313
+
314
+ if (currentItem.value) {
315
+ currentItem.value = null;
316
+ }
317
+
318
+ cancelAction();
231
319
  },
232
320
  takeSnapshot: async () => {
233
321
  var _viewShot$current, _viewShot$current$cap;
234
322
 
235
323
  if (currentItem.value) {
236
- updateDoneItems(currentItem.value);
324
+ addDoneItem(currentItem.value);
237
325
  currentItem.value = null;
238
326
  }
239
327
 
240
328
  return (_viewShot$current = viewShot.current) === null || _viewShot$current === void 0 ? void 0 : (_viewShot$current$cap = _viewShot$current.capture) === null || _viewShot$current$cap === void 0 ? void 0 : _viewShot$current$cap.call(_viewShot$current);
241
329
  }
242
- }), [currentItem, onSelectionChange, updateDoneItems]);
330
+ }), [currentItem, onSelectionChange, onCancelChange, addScreenStates, cancelAction, addDoneItem]);
243
331
  useEffect(() => {
244
332
  mode.value = drawingMode;
245
333
 
246
334
  if (currentItem.value) {
247
- updateDoneItems(currentItem.value);
335
+ addDoneItem(currentItem.value);
248
336
  }
249
337
 
250
338
  currentItem.value = null;
251
339
  onSelectionChange === null || onSelectionChange === void 0 ? void 0 : onSelectionChange(false);
252
- }, [drawingMode, mode, currentItem, updateDoneItems, onSelectionChange]);
253
- const addNewItem = runOnJS(updateDoneItems);
340
+ }, [drawingMode, mode, currentItem, onSelectionChange, addDoneItem]);
254
341
  const strokeWidth = useSharedValue(2);
255
342
  const color = useSharedValue('hsl(0, 100%, 0%)');
256
343
  const panPosition = useSharedValue(0);
@@ -260,6 +347,11 @@ const DrawCore = /*#__PURE__*/React.forwardRef(({
260
347
 
261
348
  (_textInputRef$current = textInputRef.current) === null || _textInputRef$current === void 0 ? void 0 : _textInputRef$current.focus();
262
349
  }, []);
350
+ const onColorStrokeChange = useCallback(() => {
351
+ if (currentItem.value) {
352
+ addScreenStates(currentItem.value);
353
+ }
354
+ }, [addScreenStates, currentItem.value]);
263
355
  useEffect(() => {
264
356
  var _currentItem$value2;
265
357
 
@@ -274,14 +366,13 @@ const DrawCore = /*#__PURE__*/React.forwardRef(({
274
366
  }
275
367
  }, [currentItem, textVal]);
276
368
  const onGestureEvent = useAnimatedGestureHandler({
277
- onStart: ({
278
- x,
279
- y
280
- }, ctx) => {
369
+ onStart: (_ref2, ctx) => {
281
370
  var _currentItem$value3;
282
371
 
283
- const startX = x;
284
- const startY = y;
372
+ let {
373
+ x: startX,
374
+ y: startY
375
+ } = _ref2;
285
376
  ctx.startX = startX;
286
377
  ctx.startY = startY;
287
378
  ctx.newlyCreated = false;
@@ -402,14 +493,15 @@ const DrawCore = /*#__PURE__*/React.forwardRef(({
402
493
  break;
403
494
  }
404
495
  },
405
- onActive: ({
406
- x,
407
- y,
408
- translationX,
409
- translationY
410
- }, ctx) => {
496
+ onActive: (_ref3, ctx) => {
411
497
  var _currentItem$value4, _initialItem$value, _initialItem$value2, _initialItem$value4, _initialItem$value17, _initialItem$value30;
412
498
 
499
+ let {
500
+ x: currentX,
501
+ y: currentY,
502
+ translationX,
503
+ translationY
504
+ } = _ref3;
413
505
  const {
414
506
  startX,
415
507
  startY,
@@ -424,7 +516,7 @@ const DrawCore = /*#__PURE__*/React.forwardRef(({
424
516
  runOnJS(setTextVal)('');
425
517
  }
426
518
 
427
- drawNewItem(mode, currentItem, addNewItem, {
519
+ drawNewItem(mode, currentItem, addDoneItem, {
428
520
  x: startX,
429
521
  y: startY
430
522
  }, {
@@ -433,6 +525,7 @@ const DrawCore = /*#__PURE__*/React.forwardRef(({
433
525
  color
434
526
  });
435
527
  onSelectionChange && runOnJS(onSelectionChange)(true);
528
+ onCancelChange && runOnJS(onCancelChange)(true);
436
529
  }
437
530
 
438
531
  switch ((_currentItem$value4 = currentItem.value) === null || _currentItem$value4 === void 0 ? void 0 : _currentItem$value4.type) {
@@ -453,8 +546,8 @@ const DrawCore = /*#__PURE__*/React.forwardRef(({
453
546
  strokeWidth: currentItem.value.strokeWidth,
454
547
  color: currentItem.value.color,
455
548
  data: currentItem.value.data.concat({
456
- x: x,
457
- y: y
549
+ x: currentX,
550
+ y: currentY
458
551
  })
459
552
  };
460
553
  }
@@ -811,6 +904,8 @@ const DrawCore = /*#__PURE__*/React.forwardRef(({
811
904
  text: currentItem.value.text !== DEFAULT_TEXT ? (_currentItem$value$te = currentItem.value.text) !== null && _currentItem$value$te !== void 0 ? _currentItem$value$te : '' : ''
812
905
  };
813
906
  }
907
+
908
+ runOnJS(addScreenStates)(currentItem.value);
814
909
  }
815
910
  }, []);
816
911
  const rightPaneStyle = useAnimatedStyle(() => {
@@ -819,7 +914,7 @@ const DrawCore = /*#__PURE__*/React.forwardRef(({
819
914
  translateX: panPosition.value
820
915
  }]
821
916
  };
822
- }, [panPosition.value]);
917
+ });
823
918
  useEffect(() => {
824
919
  const sudDidHide = Keyboard.addListener('keyboardDidHide', () => {
825
920
  showTextInput.value = false;
@@ -856,19 +951,21 @@ const DrawCore = /*#__PURE__*/React.forwardRef(({
856
951
  strokeWidth: strokeWidth.value,
857
952
  color: color.value
858
953
  };
859
- }, ({
860
- strokeWidth,
861
- color
862
- }) => {
954
+ }, _ref4 => {
863
955
  var _currentItem$value6;
864
956
 
957
+ let {
958
+ strokeWidth: sw,
959
+ color: c
960
+ } = _ref4;
961
+
865
962
  switch ((_currentItem$value6 = currentItem.value) === null || _currentItem$value6 === void 0 ? void 0 : _currentItem$value6.type) {
866
963
  case 'singleHead':
867
964
  currentItem.value = {
868
965
  type: currentItem.value.type,
869
966
  data: currentItem.value.data,
870
- strokeWidth,
871
- color
967
+ strokeWidth: sw,
968
+ color: c
872
969
  };
873
970
  break;
874
971
 
@@ -876,8 +973,8 @@ const DrawCore = /*#__PURE__*/React.forwardRef(({
876
973
  currentItem.value = {
877
974
  type: currentItem.value.type,
878
975
  data: currentItem.value.data,
879
- strokeWidth,
880
- color
976
+ strokeWidth: sw,
977
+ color: c
881
978
  };
882
979
  break;
883
980
 
@@ -885,8 +982,8 @@ const DrawCore = /*#__PURE__*/React.forwardRef(({
885
982
  currentItem.value = {
886
983
  type: currentItem.value.type,
887
984
  data: currentItem.value.data,
888
- strokeWidth,
889
- color
985
+ strokeWidth: sw,
986
+ color: c
890
987
  };
891
988
  break;
892
989
 
@@ -894,8 +991,8 @@ const DrawCore = /*#__PURE__*/React.forwardRef(({
894
991
  currentItem.value = {
895
992
  type: currentItem.value.type,
896
993
  data: currentItem.value.data,
897
- strokeWidth,
898
- color
994
+ strokeWidth: sw,
995
+ color: c
899
996
  };
900
997
  break;
901
998
 
@@ -903,8 +1000,8 @@ const DrawCore = /*#__PURE__*/React.forwardRef(({
903
1000
  currentItem.value = {
904
1001
  type: currentItem.value.type,
905
1002
  data: currentItem.value.data,
906
- strokeWidth,
907
- color
1003
+ strokeWidth: sw,
1004
+ color: c
908
1005
  };
909
1006
  break;
910
1007
 
@@ -912,8 +1009,8 @@ const DrawCore = /*#__PURE__*/React.forwardRef(({
912
1009
  currentItem.value = {
913
1010
  type: currentItem.value.type,
914
1011
  data: currentItem.value.data,
915
- strokeWidth,
916
- color,
1012
+ strokeWidth: sw,
1013
+ color: c,
917
1014
  text: currentItem.value.text
918
1015
  };
919
1016
  break;
@@ -925,14 +1022,10 @@ const DrawCore = /*#__PURE__*/React.forwardRef(({
925
1022
  strokeWidth.value = item.strokeWidth;
926
1023
  color.value = item.color;
927
1024
  currentItem.value = item;
928
- setDoneItems(done => {
929
- const copy = [...done];
930
- copy.splice(index, 1);
931
- return copy;
932
- });
1025
+ deleteDoneItem(index);
933
1026
 
934
1027
  if (previousItem) {
935
- updateDoneItems(previousItem);
1028
+ addDoneItem(previousItem);
936
1029
  }
937
1030
 
938
1031
  if (item.type === 'text') {
@@ -944,7 +1037,7 @@ const DrawCore = /*#__PURE__*/React.forwardRef(({
944
1037
 
945
1038
  (_textInputRef$current2 = textInputRef.current) === null || _textInputRef$current2 === void 0 ? void 0 : _textInputRef$current2.blur();
946
1039
  }
947
- }, [color, currentItem, strokeWidth, updateDoneItems, onSelectionChange]);
1040
+ }, [onSelectionChange, currentItem, strokeWidth, color, deleteDoneItem, addDoneItem]);
948
1041
  const onTextHeightChange = useCallback(height => {
949
1042
  onTextHeightUpdate(currentItem, textBaseHeight, height);
950
1043
  }, [currentItem, textBaseHeight]);
@@ -992,8 +1085,6 @@ const DrawCore = /*#__PURE__*/React.forwardRef(({
992
1085
  });
993
1086
  }
994
1087
  }, /*#__PURE__*/React.createElement(PanGestureHandler, {
995
- activeOffsetX: 2,
996
- activeOffsetY: 2,
997
1088
  onGestureEvent: onGestureEvent
998
1089
  }, /*#__PURE__*/React.createElement(Animated.View, {
999
1090
  style: imageSize || drawRegion
@@ -1011,7 +1102,7 @@ const DrawCore = /*#__PURE__*/React.forwardRef(({
1011
1102
  style: styles.bgImage
1012
1103
  }, /*#__PURE__*/React.createElement(DrawPad, {
1013
1104
  currentItem: currentItem,
1014
- doneItems: doneItems,
1105
+ doneItems: drawStates.doneItems,
1015
1106
  onPressItem: onPressItem,
1016
1107
  onTextHeightChange: onTextHeightChange
1017
1108
  }))) : null : drawRegion ? /*#__PURE__*/React.createElement(ViewShot, {
@@ -1024,7 +1115,7 @@ const DrawCore = /*#__PURE__*/React.forwardRef(({
1024
1115
  style: drawRegion
1025
1116
  }, /*#__PURE__*/React.createElement(DrawPad, {
1026
1117
  currentItem: currentItem,
1027
- doneItems: doneItems,
1118
+ doneItems: drawStates.doneItems,
1028
1119
  onPressItem: onPressItem,
1029
1120
  onTextHeightChange: onTextHeightChange
1030
1121
  })) : null))), /*#__PURE__*/React.createElement(Animated.View, {
@@ -1034,12 +1125,14 @@ const DrawCore = /*#__PURE__*/React.forwardRef(({
1034
1125
  }, /*#__PURE__*/React.createElement(StrokeSlider, {
1035
1126
  minValue: 2,
1036
1127
  maxValue: 10,
1037
- stroke: strokeWidth
1128
+ stroke: strokeWidth,
1129
+ onStrokeChange: onColorStrokeChange
1038
1130
  })), /*#__PURE__*/React.createElement(View, {
1039
1131
  style: styles.colorSliderContainer
1040
1132
  }, /*#__PURE__*/React.createElement(ColorSlider, {
1041
1133
  color: color,
1042
- linearGradient: linearGradient
1134
+ linearGradient: linearGradient,
1135
+ onColorChange: onColorStrokeChange
1043
1136
  })))), Platform.OS === 'ios' ? /*#__PURE__*/React.createElement(InputAccessoryView, null, /*#__PURE__*/React.createElement(AnimatedTextInput, {
1044
1137
  ref: textInputRef,
1045
1138
  style: [styles.textInput, textInputStyle],