@archireport/react-native-svg-draw 1.3.0 → 2.0.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 (179) hide show
  1. package/README.md +73 -27
  2. package/lib/commonjs/components/DrawCore/CurrentAnimatedItem.js +55 -54
  3. package/lib/commonjs/components/DrawCore/CurrentAnimatedItem.js.map +1 -1
  4. package/lib/commonjs/components/DrawCore/CurrentAnimatedText.js +3 -14
  5. package/lib/commonjs/components/DrawCore/CurrentAnimatedText.js.map +1 -1
  6. package/lib/commonjs/components/DrawCore/DrawContext.js +18 -0
  7. package/lib/commonjs/components/DrawCore/DrawContext.js.map +1 -0
  8. package/lib/commonjs/components/DrawCore/DrawPad.js +1 -13
  9. package/lib/commonjs/components/DrawCore/DrawPad.js.map +1 -1
  10. package/lib/commonjs/components/DrawCore/DrawProvider.js +103 -0
  11. package/lib/commonjs/components/DrawCore/DrawProvider.js.map +1 -0
  12. package/lib/commonjs/components/DrawCore/Item.js +0 -15
  13. package/lib/commonjs/components/DrawCore/Item.js.map +1 -1
  14. package/lib/commonjs/components/DrawCore/index.js +47 -287
  15. package/lib/commonjs/components/DrawCore/index.js.map +1 -1
  16. package/lib/commonjs/components/DrawCore/useDrawHook.js +76 -0
  17. package/lib/commonjs/components/DrawCore/useDrawHook.js.map +1 -0
  18. package/lib/commonjs/components/DrawWithOptions/ArrowSvg.js +0 -6
  19. package/lib/commonjs/components/DrawWithOptions/ArrowSvg.js.map +1 -1
  20. package/lib/commonjs/components/DrawWithOptions/CancelSvg.js +0 -6
  21. package/lib/commonjs/components/DrawWithOptions/CancelSvg.js.map +1 -1
  22. package/lib/commonjs/components/DrawWithOptions/CircleSvg.js +0 -6
  23. package/lib/commonjs/components/DrawWithOptions/CircleSvg.js.map +1 -1
  24. package/lib/commonjs/components/DrawWithOptions/CloseSvg.js +0 -6
  25. package/lib/commonjs/components/DrawWithOptions/CloseSvg.js.map +1 -1
  26. package/lib/commonjs/components/DrawWithOptions/DoubleHeadSvg.js +0 -7
  27. package/lib/commonjs/components/DrawWithOptions/DoubleHeadSvg.js.map +1 -1
  28. package/lib/commonjs/components/DrawWithOptions/PenSvg.js +0 -6
  29. package/lib/commonjs/components/DrawWithOptions/PenSvg.js.map +1 -1
  30. package/lib/commonjs/components/DrawWithOptions/SendSvg.js +0 -7
  31. package/lib/commonjs/components/DrawWithOptions/SendSvg.js.map +1 -1
  32. package/lib/commonjs/components/DrawWithOptions/SliderSvg.js +31 -0
  33. package/lib/commonjs/components/DrawWithOptions/SliderSvg.js.map +1 -0
  34. package/lib/commonjs/components/DrawWithOptions/SquareSvg.js +0 -7
  35. package/lib/commonjs/components/DrawWithOptions/SquareSvg.js.map +1 -1
  36. package/lib/commonjs/components/DrawWithOptions/TextSvg.js +0 -7
  37. package/lib/commonjs/components/DrawWithOptions/TextSvg.js.map +1 -1
  38. package/lib/commonjs/components/DrawWithOptions/ThrashSvg.js +27 -10
  39. package/lib/commonjs/components/DrawWithOptions/ThrashSvg.js.map +1 -1
  40. package/lib/commonjs/components/DrawWithOptions/index.js +126 -93
  41. package/lib/commonjs/components/DrawWithOptions/index.js.map +1 -1
  42. package/lib/commonjs/components/{DrawCore → Slider}/ColorSlider.js +47 -78
  43. package/lib/commonjs/components/Slider/ColorSlider.js.map +1 -0
  44. package/lib/commonjs/components/Slider/Sliders.js +88 -0
  45. package/lib/commonjs/components/Slider/Sliders.js.map +1 -0
  46. package/lib/commonjs/components/{DrawCore → Slider}/StrokeSlider.js +38 -57
  47. package/lib/commonjs/components/Slider/StrokeSlider.js.map +1 -0
  48. package/lib/commonjs/components/Slider/sliderStyle.js +37 -0
  49. package/lib/commonjs/components/Slider/sliderStyle.js.map +1 -0
  50. package/lib/commonjs/index.js +7 -3
  51. package/lib/commonjs/index.js.map +1 -1
  52. package/lib/commonjs/types.d.js.map +1 -1
  53. package/lib/module/components/DrawCore/CurrentAnimatedItem.js +56 -43
  54. package/lib/module/components/DrawCore/CurrentAnimatedItem.js.map +1 -1
  55. package/lib/module/components/DrawCore/CurrentAnimatedText.js +3 -7
  56. package/lib/module/components/DrawCore/CurrentAnimatedText.js.map +1 -1
  57. package/lib/module/components/DrawCore/DrawContext.js +11 -0
  58. package/lib/module/components/DrawCore/DrawContext.js.map +1 -0
  59. package/lib/module/components/DrawCore/DrawPad.js +1 -5
  60. package/lib/module/components/DrawCore/DrawPad.js.map +1 -1
  61. package/lib/module/components/DrawCore/DrawProvider.js +94 -0
  62. package/lib/module/components/DrawCore/DrawProvider.js.map +1 -0
  63. package/lib/module/components/DrawCore/Item.js +0 -8
  64. package/lib/module/components/DrawCore/Item.js.map +1 -1
  65. package/lib/module/components/DrawCore/index.js +49 -271
  66. package/lib/module/components/DrawCore/index.js.map +1 -1
  67. package/lib/module/components/DrawCore/useDrawHook.js +69 -0
  68. package/lib/module/components/DrawCore/useDrawHook.js.map +1 -0
  69. package/lib/module/components/DrawWithOptions/ArrowSvg.js +0 -1
  70. package/lib/module/components/DrawWithOptions/ArrowSvg.js.map +1 -1
  71. package/lib/module/components/DrawWithOptions/CancelSvg.js +0 -1
  72. package/lib/module/components/DrawWithOptions/CancelSvg.js.map +1 -1
  73. package/lib/module/components/DrawWithOptions/CircleSvg.js +0 -1
  74. package/lib/module/components/DrawWithOptions/CircleSvg.js.map +1 -1
  75. package/lib/module/components/DrawWithOptions/CloseSvg.js +0 -1
  76. package/lib/module/components/DrawWithOptions/CloseSvg.js.map +1 -1
  77. package/lib/module/components/DrawWithOptions/DoubleHeadSvg.js +0 -1
  78. package/lib/module/components/DrawWithOptions/DoubleHeadSvg.js.map +1 -1
  79. package/lib/module/components/DrawWithOptions/PenSvg.js +0 -1
  80. package/lib/module/components/DrawWithOptions/PenSvg.js.map +1 -1
  81. package/lib/module/components/DrawWithOptions/SendSvg.js +0 -3
  82. package/lib/module/components/DrawWithOptions/SendSvg.js.map +1 -1
  83. package/lib/module/components/DrawWithOptions/SliderSvg.js +22 -0
  84. package/lib/module/components/DrawWithOptions/SliderSvg.js.map +1 -0
  85. package/lib/module/components/DrawWithOptions/SquareSvg.js +0 -1
  86. package/lib/module/components/DrawWithOptions/SquareSvg.js.map +1 -1
  87. package/lib/module/components/DrawWithOptions/TextSvg.js +0 -3
  88. package/lib/module/components/DrawWithOptions/TextSvg.js.map +1 -1
  89. package/lib/module/components/DrawWithOptions/ThrashSvg.js +27 -5
  90. package/lib/module/components/DrawWithOptions/ThrashSvg.js.map +1 -1
  91. package/lib/module/components/DrawWithOptions/index.js +126 -73
  92. package/lib/module/components/DrawWithOptions/index.js.map +1 -1
  93. package/lib/module/components/Slider/ColorSlider.js +95 -0
  94. package/lib/module/components/Slider/ColorSlider.js.map +1 -0
  95. package/lib/module/components/Slider/Sliders.js +79 -0
  96. package/lib/module/components/Slider/Sliders.js.map +1 -0
  97. package/lib/module/components/Slider/StrokeSlider.js +82 -0
  98. package/lib/module/components/Slider/StrokeSlider.js.map +1 -0
  99. package/lib/module/components/Slider/sliderStyle.js +29 -0
  100. package/lib/module/components/Slider/sliderStyle.js.map +1 -0
  101. package/lib/module/index.js +1 -0
  102. package/lib/module/index.js.map +1 -1
  103. package/lib/module/types.d.js.map +1 -1
  104. package/lib/typescript/components/DrawCore/CurrentAnimatedItem.d.ts +1 -1
  105. package/lib/typescript/components/DrawCore/CurrentAnimatedItem.d.ts.map +1 -0
  106. package/lib/typescript/components/DrawCore/CurrentAnimatedText.d.ts +1 -1
  107. package/lib/typescript/components/DrawCore/CurrentAnimatedText.d.ts.map +1 -0
  108. package/lib/typescript/components/DrawCore/DrawContext.d.ts +14 -0
  109. package/lib/typescript/components/DrawCore/DrawContext.d.ts.map +1 -0
  110. package/lib/typescript/components/DrawCore/DrawPad.d.ts +1 -1
  111. package/lib/typescript/components/DrawCore/DrawPad.d.ts.map +1 -0
  112. package/lib/typescript/components/DrawCore/DrawProvider.d.ts +6 -0
  113. package/lib/typescript/components/DrawCore/DrawProvider.d.ts.map +1 -0
  114. package/lib/typescript/components/DrawCore/Item.d.ts +1 -1
  115. package/lib/typescript/components/DrawCore/Item.d.ts.map +1 -0
  116. package/lib/typescript/components/DrawCore/index.d.ts +4 -11
  117. package/lib/typescript/components/DrawCore/index.d.ts.map +1 -0
  118. package/lib/typescript/components/DrawCore/useDrawHook.d.ts +18 -0
  119. package/lib/typescript/components/DrawCore/useDrawHook.d.ts.map +1 -0
  120. package/lib/typescript/components/DrawWithOptions/ArrowSvg.d.ts +1 -1
  121. package/lib/typescript/components/DrawWithOptions/ArrowSvg.d.ts.map +1 -0
  122. package/lib/typescript/components/DrawWithOptions/CancelSvg.d.ts +1 -1
  123. package/lib/typescript/components/DrawWithOptions/CancelSvg.d.ts.map +1 -0
  124. package/lib/typescript/components/DrawWithOptions/CircleSvg.d.ts +1 -1
  125. package/lib/typescript/components/DrawWithOptions/CircleSvg.d.ts.map +1 -0
  126. package/lib/typescript/components/DrawWithOptions/CloseSvg.d.ts +1 -1
  127. package/lib/typescript/components/DrawWithOptions/CloseSvg.d.ts.map +1 -0
  128. package/lib/typescript/components/DrawWithOptions/DoubleHeadSvg.d.ts +1 -1
  129. package/lib/typescript/components/DrawWithOptions/DoubleHeadSvg.d.ts.map +1 -0
  130. package/lib/typescript/components/DrawWithOptions/PenSvg.d.ts +1 -1
  131. package/lib/typescript/components/DrawWithOptions/PenSvg.d.ts.map +1 -0
  132. package/lib/typescript/components/DrawWithOptions/SendSvg.d.ts +1 -1
  133. package/lib/typescript/components/DrawWithOptions/SendSvg.d.ts.map +1 -0
  134. package/lib/typescript/components/DrawWithOptions/SliderSvg.d.ts +4 -0
  135. package/lib/typescript/components/DrawWithOptions/SliderSvg.d.ts.map +1 -0
  136. package/lib/typescript/components/DrawWithOptions/SquareSvg.d.ts +1 -1
  137. package/lib/typescript/components/DrawWithOptions/SquareSvg.d.ts.map +1 -0
  138. package/lib/typescript/components/DrawWithOptions/TextSvg.d.ts +1 -1
  139. package/lib/typescript/components/DrawWithOptions/TextSvg.d.ts.map +1 -0
  140. package/lib/typescript/components/DrawWithOptions/ThrashSvg.d.ts +1 -1
  141. package/lib/typescript/components/DrawWithOptions/ThrashSvg.d.ts.map +1 -0
  142. package/lib/typescript/components/DrawWithOptions/index.d.ts +4 -5
  143. package/lib/typescript/components/DrawWithOptions/index.d.ts.map +1 -0
  144. package/lib/typescript/components/Slider/ColorSlider.d.ts +8 -0
  145. package/lib/typescript/components/Slider/ColorSlider.d.ts.map +1 -0
  146. package/lib/typescript/components/Slider/Sliders.d.ts +8 -0
  147. package/lib/typescript/components/Slider/Sliders.d.ts.map +1 -0
  148. package/lib/typescript/components/Slider/StrokeSlider.d.ts +6 -0
  149. package/lib/typescript/components/Slider/StrokeSlider.d.ts.map +1 -0
  150. package/lib/typescript/components/Slider/sliderStyle.d.ts +28 -0
  151. package/lib/typescript/components/Slider/sliderStyle.d.ts.map +1 -0
  152. package/lib/typescript/index.d.ts +2 -0
  153. package/lib/typescript/index.d.ts.map +1 -0
  154. package/package.json +32 -33
  155. package/src/components/DrawCore/CurrentAnimatedItem.tsx +166 -106
  156. package/src/components/DrawCore/DrawContext.tsx +22 -0
  157. package/src/components/DrawCore/DrawPad.tsx +3 -10
  158. package/src/components/DrawCore/DrawProvider.tsx +122 -0
  159. package/src/components/DrawCore/index.tsx +938 -1132
  160. package/src/components/DrawCore/useDrawHook.tsx +70 -0
  161. package/src/components/DrawWithOptions/SliderSvg.tsx +24 -0
  162. package/src/components/DrawWithOptions/ThrashSvg.tsx +29 -2
  163. package/src/components/DrawWithOptions/index.tsx +199 -146
  164. package/src/components/Slider/ColorSlider.tsx +144 -0
  165. package/src/components/Slider/Sliders.tsx +75 -0
  166. package/src/components/Slider/StrokeSlider.tsx +104 -0
  167. package/src/components/Slider/sliderStyle.tsx +28 -0
  168. package/src/index.tsx +1 -0
  169. package/src/types.d.ts +35 -1
  170. package/lib/commonjs/components/DrawCore/ColorSlider.js.map +0 -1
  171. package/lib/commonjs/components/DrawCore/StrokeSlider.js.map +0 -1
  172. package/lib/module/components/DrawCore/ColorSlider.js +0 -119
  173. package/lib/module/components/DrawCore/ColorSlider.js.map +0 -1
  174. package/lib/module/components/DrawCore/StrokeSlider.js +0 -93
  175. package/lib/module/components/DrawCore/StrokeSlider.js.map +0 -1
  176. package/lib/typescript/components/DrawCore/ColorSlider.d.ts +0 -12
  177. package/lib/typescript/components/DrawCore/StrokeSlider.d.ts +0 -9
  178. package/src/components/DrawCore/ColorSlider.tsx +0 -169
  179. package/src/components/DrawCore/StrokeSlider.tsx +0 -117
@@ -4,69 +4,31 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
-
8
7
  var _react = _interopRequireWildcard(require("react"));
9
-
10
8
  var _reactNative = require("react-native");
11
-
12
9
  var _reactNativeReanimated = _interopRequireWildcard(require("react-native-reanimated"));
13
-
14
10
  var _reactNativeGestureHandler = require("react-native-gesture-handler");
15
-
16
- var _ColorSlider = _interopRequireDefault(require("./ColorSlider"));
17
-
18
- var _StrokeSlider = _interopRequireDefault(require("./StrokeSlider"));
19
-
20
11
  var _DrawPad = _interopRequireDefault(require("./DrawPad"));
21
-
22
12
  var _reactNativeViewShot = _interopRequireDefault(require("react-native-view-shot"));
23
-
13
+ var _useDrawHook = _interopRequireDefault(require("./useDrawHook"));
24
14
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
25
-
26
15
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
27
-
28
16
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
29
-
30
- const RIGHT_PANE_WIDTH = 60;
31
-
32
17
  const styles = _reactNative.StyleSheet.create({
33
18
  container: {
34
19
  flex: 1
35
20
  },
36
21
  drawZone: {
37
22
  flex: 1,
38
- justifyContent: 'center',
23
+ alignContent: 'center',
39
24
  alignItems: 'center'
40
25
  },
41
- rightPaneBaseStyle: {
42
- position: 'absolute',
43
- right: 0,
44
- top: 0,
45
- bottom: 0,
46
- backgroundColor: '#000000cc',
47
- width: RIGHT_PANE_WIDTH,
48
- justifyContent: 'space-evenly',
49
- marginVertical: 20,
50
- borderTopLeftRadius: 20,
51
- borderBottomLeftRadius: 20,
52
- paddingVertical: 30
53
- },
54
- strokeSliderContainer: {
55
- flex: 1,
56
- paddingBottom: 15,
57
- borderBottomColor: '#000000',
58
- borderBottomWidth: 2
59
- },
60
- colorSliderContainer: {
61
- flex: 1,
62
- paddingTop: 15
63
- },
64
26
  bgImage: {
65
27
  width: '100%',
66
28
  height: '100%'
67
29
  },
68
30
  textInput: {
69
- backgroundColor: '#000000c5',
31
+ backgroundColor: '#262626',
70
32
  paddingVertical: 16,
71
33
  paddingHorizontal: 24,
72
34
  fontSize: 16,
@@ -74,7 +36,6 @@ const styles = _reactNative.StyleSheet.create({
74
36
  width: '100%'
75
37
  }
76
38
  });
77
-
78
39
  const pDistance = (point, line) => {
79
40
  'worklet';
80
41
 
@@ -95,14 +56,11 @@ const pDistance = (point, line) => {
95
56
  var dot = A * C + B * D;
96
57
  var len_sq = C * C + D * D;
97
58
  var param = -1;
98
-
99
59
  if (len_sq !== 0) {
100
60
  //in case of 0 length line
101
61
  param = dot / len_sq;
102
62
  }
103
-
104
63
  var xx, yy;
105
-
106
64
  if (param < 0) {
107
65
  xx = x1;
108
66
  yy = y1;
@@ -113,24 +71,19 @@ const pDistance = (point, line) => {
113
71
  xx = x1 + param * C;
114
72
  yy = y1 + param * D;
115
73
  }
116
-
117
74
  var dx = x - xx;
118
75
  var dy = y - yy;
119
76
  return Math.sqrt(dx * dx + dy * dy);
120
77
  };
121
-
122
78
  const AnimatedTextInput = _reactNativeReanimated.default.createAnimatedComponent(_reactNative.TextInput);
123
-
124
79
  const DEFAULT_TEXT = '';
125
80
  const THRESHOLD = 20;
126
-
127
81
  const drawNewItem = (mode, currentItem, addDoneItem, position, style) => {
128
82
  'worklet';
129
83
 
130
84
  if (currentItem.value) {
131
85
  (0, _reactNativeReanimated.runOnJS)(addDoneItem)(currentItem.value);
132
86
  }
133
-
134
87
  switch (mode.value) {
135
88
  case 'ellipse':
136
89
  currentItem.value = {
@@ -145,7 +98,6 @@ const drawNewItem = (mode, currentItem, addDoneItem, position, style) => {
145
98
  color: style.color.value
146
99
  };
147
100
  break;
148
-
149
101
  case 'rectangle':
150
102
  currentItem.value = {
151
103
  type: mode.value,
@@ -159,7 +111,6 @@ const drawNewItem = (mode, currentItem, addDoneItem, position, style) => {
159
111
  color: style.color.value
160
112
  };
161
113
  break;
162
-
163
114
  case 'singleHead':
164
115
  case 'doubleHead':
165
116
  currentItem.value = {
@@ -174,7 +125,6 @@ const drawNewItem = (mode, currentItem, addDoneItem, position, style) => {
174
125
  color: style.color.value
175
126
  };
176
127
  break;
177
-
178
128
  case 'text':
179
129
  currentItem.value = {
180
130
  type: mode.value,
@@ -189,7 +139,6 @@ const drawNewItem = (mode, currentItem, addDoneItem, position, style) => {
189
139
  color: style.color.value
190
140
  };
191
141
  break;
192
-
193
142
  case 'pen':
194
143
  currentItem.value = {
195
144
  type: mode.value,
@@ -200,16 +149,15 @@ const drawNewItem = (mode, currentItem, addDoneItem, position, style) => {
200
149
  break;
201
150
  }
202
151
  };
203
-
204
152
  const onTextHeightUpdate = (currentItem, textBaseHeight, height) => {
205
153
  'worklet';
206
154
 
207
155
  var _currentItem$value;
208
-
209
156
  if (((_currentItem$value = currentItem.value) === null || _currentItem$value === void 0 ? void 0 : _currentItem$value.type) === 'text') {
210
157
  textBaseHeight.value = textBaseHeight.value || height;
211
158
  currentItem.value = {
212
- data: { ...currentItem.value.data,
159
+ data: {
160
+ ...currentItem.value.data,
213
161
  height: height
214
162
  },
215
163
  type: currentItem.value.type,
@@ -219,165 +167,68 @@ const onTextHeightUpdate = (currentItem, textBaseHeight, height) => {
219
167
  };
220
168
  }
221
169
  };
222
-
223
- const reducerDrawStates = (drawStates, action) => {
224
- 'worklet';
225
-
226
- switch (action.type) {
227
- case 'ADD_DONE_ITEM':
228
- return { ...drawStates,
229
- doneItems: drawStates.doneItems.concat(action.item)
230
- };
231
-
232
- case 'DELETE_DONE_ITEM':
233
- const newDoneItems = drawStates.doneItems;
234
- newDoneItems.splice(action.indice, 1);
235
- return { ...drawStates,
236
- doneItems: newDoneItems
237
- };
238
-
239
- case 'ADD_SCREEN_STATE':
240
- if (action.currentItem) {
241
- return { ...drawStates,
242
- screenStates: drawStates.screenStates.concat([[...drawStates.doneItems, action.currentItem]])
243
- };
244
- } else {
245
- return { ...drawStates,
246
- screenStates: drawStates.screenStates.concat([[...drawStates.doneItems]])
247
- };
248
- }
249
-
250
- case 'CANCEL':
251
- const len = drawStates.screenStates.length;
252
-
253
- if (len > 1) {
254
- const newScreenStates = drawStates.screenStates;
255
- newScreenStates.pop();
256
-
257
- if (newScreenStates.length === 1) {
258
- var _action$onCancelChang;
259
-
260
- (_action$onCancelChang = action.onCancelChange) === null || _action$onCancelChang === void 0 ? void 0 : _action$onCancelChang.call(action, false);
261
- }
262
-
263
- return {
264
- doneItems: drawStates.screenStates[len - 2],
265
- screenStates: newScreenStates
266
- };
267
- } else {
268
- return drawStates;
269
- }
270
-
271
- }
272
- };
273
-
274
- const DrawCore = /*#__PURE__*/_react.default.forwardRef((_ref, ref) => {
170
+ const DrawCore = _ref => {
275
171
  var _textInputRef$current3, _textInputRef$current4;
276
-
277
172
  let {
278
- drawingMode,
279
173
  image,
280
- linearGradient,
281
- onSelectionChange,
282
- onCancelChange,
283
174
  backgroundColor
284
175
  } = _ref;
176
+ const {
177
+ drawState,
178
+ dispatchDrawStates,
179
+ strokeWidth,
180
+ color,
181
+ currentItem,
182
+ itemIsSelected,
183
+ viewShot
184
+ } = (0, _useDrawHook.default)();
185
+ const onCancelChangeWrapper = arg => {
186
+ dispatchDrawStates({
187
+ type: 'SET_CANCEL_ENABLED',
188
+ cancelEnabled: arg
189
+ });
190
+ };
285
191
  const mode = (0, _reactNativeReanimated.useSharedValue)('pen');
286
192
  const [drawRegion, setDrawRegion] = (0, _react.useState)(null);
287
193
  const [originalImageSize, setOriginalImageSize] = (0, _react.useState)(null);
288
194
  const [imageSize, setImageSize] = (0, _react.useState)(null);
289
195
  const drawContainer = (0, _react.useRef)(null);
290
- const viewShot = (0, _react.useRef)(null);
291
196
  const [textVal, setTextVal] = (0, _react.useState)('');
292
- const currentItem = (0, _reactNativeReanimated.useSharedValue)(null);
293
197
  const initialItem = (0, _reactNativeReanimated.useSharedValue)(null);
294
- const [drawStates, dispatchDrawStates] = (0, _react.useReducer)(reducerDrawStates, {
295
- doneItems: [],
296
- screenStates: [[]]
297
- });
298
198
  const textBaseHeight = (0, _reactNativeReanimated.useSharedValue)(null);
299
199
  const addDoneItem = (0, _react.useCallback)(item => {
300
200
  dispatchDrawStates({
301
201
  type: 'ADD_DONE_ITEM',
302
202
  item: item
303
203
  });
304
- }, []);
204
+ }, [dispatchDrawStates]);
305
205
  const deleteDoneItem = (0, _react.useCallback)(indice => {
306
206
  dispatchDrawStates({
307
207
  type: 'DELETE_DONE_ITEM',
308
208
  indice: indice
309
209
  });
310
- }, []);
210
+ }, [dispatchDrawStates]);
311
211
  const addScreenStates = (0, _react.useCallback)(item => {
312
212
  dispatchDrawStates({
313
213
  type: 'ADD_SCREEN_STATE',
314
214
  currentItem: item
315
215
  });
316
- }, []);
317
- const cancelAction = (0, _react.useCallback)(() => {
318
- dispatchDrawStates({
319
- type: 'CANCEL',
320
- onCancelChange: onCancelChange
321
- });
322
- }, [onCancelChange]);
323
- (0, _react.useImperativeHandle)(ref, () => ({
324
- drawingContainer: drawContainer,
325
- deleteSelectedItem: () => {
326
- if (currentItem.value) {
327
- currentItem.value = null;
328
- addScreenStates(null);
329
- }
330
-
331
- onSelectionChange === null || onSelectionChange === void 0 ? void 0 : onSelectionChange(false);
332
- onCancelChange === null || onCancelChange === void 0 ? void 0 : onCancelChange(true);
333
- },
334
- cancelLastAction: () => {
335
- onSelectionChange === null || onSelectionChange === void 0 ? void 0 : onSelectionChange(false);
336
-
337
- if (currentItem.value) {
338
- currentItem.value = null;
339
- }
340
-
341
- cancelAction();
342
- },
343
- takeSnapshot: async () => {
344
- var _viewShot$current, _viewShot$current$cap;
345
-
346
- if (currentItem.value) {
347
- addDoneItem(currentItem.value);
348
- currentItem.value = null;
349
- }
350
-
351
- 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);
352
- }
353
- }), [currentItem, onSelectionChange, onCancelChange, addScreenStates, cancelAction, addDoneItem]);
216
+ }, [dispatchDrawStates]);
354
217
  (0, _react.useEffect)(() => {
355
- mode.value = drawingMode;
356
-
218
+ mode.value = drawState.drawingMode;
357
219
  if (currentItem.value) {
358
220
  addDoneItem(currentItem.value);
359
221
  }
360
-
361
222
  currentItem.value = null;
362
- onSelectionChange === null || onSelectionChange === void 0 ? void 0 : onSelectionChange(false);
363
- }, [drawingMode, mode, currentItem, onSelectionChange, addDoneItem]);
364
- const strokeWidth = (0, _reactNativeReanimated.useSharedValue)(2);
365
- const color = (0, _reactNativeReanimated.useSharedValue)('hsl(0, 100%, 0%)');
366
- const panPosition = (0, _reactNativeReanimated.useSharedValue)(0);
223
+ itemIsSelected.value = false;
224
+ }, [drawState.drawingMode, mode, currentItem, addDoneItem, itemIsSelected]);
367
225
  const showTextInput = (0, _reactNativeReanimated.useSharedValue)(false);
368
226
  const textFocus = (0, _react.useCallback)(() => {
369
227
  var _textInputRef$current;
370
-
371
228
  (_textInputRef$current = textInputRef.current) === null || _textInputRef$current === void 0 ? void 0 : _textInputRef$current.focus();
372
229
  }, []);
373
- const onColorStrokeChange = (0, _react.useCallback)(() => {
374
- if (currentItem.value) {
375
- addScreenStates(currentItem.value);
376
- }
377
- }, [addScreenStates, currentItem.value]);
378
230
  (0, _react.useEffect)(() => {
379
231
  var _currentItem$value2;
380
-
381
232
  if (((_currentItem$value2 = currentItem.value) === null || _currentItem$value2 === void 0 ? void 0 : _currentItem$value2.type) === 'text') {
382
233
  currentItem.value = {
383
234
  data: currentItem.value.data,
@@ -391,7 +242,6 @@ const DrawCore = /*#__PURE__*/_react.default.forwardRef((_ref, ref) => {
391
242
  const onGestureEvent = (0, _reactNativeReanimated.useAnimatedGestureHandler)({
392
243
  onStart: (_ref2, ctx) => {
393
244
  var _currentItem$value3;
394
-
395
245
  let {
396
246
  x: startX,
397
247
  y: startY
@@ -399,16 +249,16 @@ const DrawCore = /*#__PURE__*/_react.default.forwardRef((_ref, ref) => {
399
249
  ctx.startX = startX;
400
250
  ctx.startY = startY;
401
251
  ctx.newlyCreated = false;
402
- panPosition.value = (0, _reactNativeReanimated.withTiming)(RIGHT_PANE_WIDTH);
403
- initialItem.value = currentItem.value;
404
252
 
253
+ //panPosition.value = withTiming(RIGHT_PANE_WIDTH);
254
+
255
+ initialItem.value = currentItem.value;
405
256
  switch ((_currentItem$value3 = currentItem.value) === null || _currentItem$value3 === void 0 ? void 0 : _currentItem$value3.type) {
406
257
  case 'ellipse':
407
258
  const cx = typeof currentItem.value.data.cx === 'string' ? parseFloat(currentItem.value.data.cx) : currentItem.value.data.cx || 0;
408
259
  const cy = typeof currentItem.value.data.cy === 'string' ? parseFloat(currentItem.value.data.cy) : currentItem.value.data.cy || 0;
409
260
  const rx = typeof currentItem.value.data.rx === 'string' ? parseFloat(currentItem.value.data.rx) : currentItem.value.data.rx || 0;
410
261
  const ry = typeof currentItem.value.data.ry === 'string' ? parseFloat(currentItem.value.data.ry) : currentItem.value.data.ry || 0;
411
-
412
262
  if (startX <= cx + THRESHOLD && startX >= cx - THRESHOLD && startY <= cy - ry + THRESHOLD && startY >= cy - ry - THRESHOLD) {
413
263
  ctx.zone = 'TOP';
414
264
  } else if (startX <= cx + THRESHOLD && startX >= cx - THRESHOLD && startY <= cy + ry + THRESHOLD && startY >= cy + ry - THRESHOLD) {
@@ -423,15 +273,12 @@ const DrawCore = /*#__PURE__*/_react.default.forwardRef((_ref, ref) => {
423
273
  ctx.zone = 'OUT';
424
274
  initialItem.value = null;
425
275
  }
426
-
427
276
  break;
428
-
429
277
  case 'rectangle':
430
278
  const x = typeof currentItem.value.data.x === 'string' ? parseFloat(currentItem.value.data.x) : currentItem.value.data.x || 0;
431
279
  const y = typeof currentItem.value.data.y === 'string' ? parseFloat(currentItem.value.data.y) : currentItem.value.data.y || 0;
432
280
  const height = typeof currentItem.value.data.height === 'string' ? parseFloat(currentItem.value.data.height) : currentItem.value.data.height || 0;
433
281
  const width = typeof currentItem.value.data.width === 'string' ? parseFloat(currentItem.value.data.width) : currentItem.value.data.width || 0;
434
-
435
282
  if (startX <= x + THRESHOLD && startX >= x - THRESHOLD) {
436
283
  if (startY <= y + THRESHOLD && startY >= y - THRESHOLD) {
437
284
  ctx.zone = 'TOP_LEFT';
@@ -450,16 +297,13 @@ const DrawCore = /*#__PURE__*/_react.default.forwardRef((_ref, ref) => {
450
297
  ctx.zone = 'OUT';
451
298
  initialItem.value = null;
452
299
  }
453
-
454
300
  break;
455
-
456
301
  case 'doubleHead':
457
302
  case 'singleHead':
458
303
  const x1 = typeof currentItem.value.data.x1 === 'string' ? parseFloat(currentItem.value.data.x1) : currentItem.value.data.x1 || 0;
459
304
  const y1 = typeof currentItem.value.data.y1 === 'string' ? parseFloat(currentItem.value.data.y1) : currentItem.value.data.y1 || 0;
460
305
  const x2 = typeof currentItem.value.data.x2 === 'string' ? parseFloat(currentItem.value.data.x2) : currentItem.value.data.x2 || 0;
461
306
  const y2 = typeof currentItem.value.data.y2 === 'string' ? parseFloat(currentItem.value.data.y2) : currentItem.value.data.y2 || 0;
462
-
463
307
  if (startX <= x1 + THRESHOLD && startX >= x1 - THRESHOLD && startY <= y1 + THRESHOLD && startY >= y1 - THRESHOLD) {
464
308
  ctx.zone = 'TOP';
465
309
  } else if (startX <= x2 + THRESHOLD && startX >= x2 - THRESHOLD && startY - THRESHOLD <= y2 + THRESHOLD && startY + THRESHOLD >= y2 - THRESHOLD) {
@@ -478,15 +322,12 @@ const DrawCore = /*#__PURE__*/_react.default.forwardRef((_ref, ref) => {
478
322
  ctx.zone = 'OUT';
479
323
  initialItem.value = null;
480
324
  }
481
-
482
325
  break;
483
-
484
326
  case 'text':
485
327
  const xText = typeof currentItem.value.data.x === 'string' ? parseFloat(currentItem.value.data.x) : currentItem.value.data.x || 0;
486
328
  const yText = typeof currentItem.value.data.y === 'string' ? parseFloat(currentItem.value.data.y) : currentItem.value.data.y || 0;
487
329
  const widthText = typeof currentItem.value.data.width === 'string' ? parseFloat(currentItem.value.data.width) : currentItem.value.data.width || 0;
488
330
  const heightText = typeof currentItem.value.data.height === 'string' ? parseFloat(currentItem.value.data.height) : currentItem.value.data.height || 0;
489
-
490
331
  if (startX <= xText + THRESHOLD && startX >= xText - THRESHOLD && startY <= yText + heightText / 2 + THRESHOLD && startY >= yText + heightText / 2 - THRESHOLD) {
491
332
  ctx.zone = 'LEFT';
492
333
  } else if (startX <= xText + widthText + THRESHOLD && startX >= xText + widthText - THRESHOLD && startY <= yText + heightText / 2 + THRESHOLD && startY >= yText + heightText / 2 - THRESHOLD) {
@@ -497,9 +338,7 @@ const DrawCore = /*#__PURE__*/_react.default.forwardRef((_ref, ref) => {
497
338
  ctx.zone = 'OUT';
498
339
  initialItem.value = null;
499
340
  }
500
-
501
341
  break;
502
-
503
342
  case 'pen':
504
343
  if (currentItem.value.data.some(p => startX <= p.x + THRESHOLD && startX >= p.x - THRESHOLD && startY <= p.y + THRESHOLD && startY >= p.y - THRESHOLD)) {
505
344
  ctx.zone = 'CENTER';
@@ -507,9 +346,7 @@ const DrawCore = /*#__PURE__*/_react.default.forwardRef((_ref, ref) => {
507
346
  ctx.zone = 'OUT';
508
347
  initialItem.value = null;
509
348
  }
510
-
511
349
  break;
512
-
513
350
  default:
514
351
  ctx.zone = 'OUT';
515
352
  initialItem.value = null;
@@ -518,7 +355,6 @@ const DrawCore = /*#__PURE__*/_react.default.forwardRef((_ref, ref) => {
518
355
  },
519
356
  onActive: (_ref3, ctx) => {
520
357
  var _currentItem$value4, _initialItem$value, _initialItem$value2, _initialItem$value4, _initialItem$value17, _initialItem$value30;
521
-
522
358
  let {
523
359
  x: currentX,
524
360
  y: currentY,
@@ -531,14 +367,11 @@ const DrawCore = /*#__PURE__*/_react.default.forwardRef((_ref, ref) => {
531
367
  zone,
532
368
  newlyCreated
533
369
  } = ctx;
534
-
535
370
  if (zone === 'OUT' && newlyCreated === false) {
536
371
  ctx.newlyCreated = true;
537
-
538
372
  if (mode.value === 'text') {
539
373
  (0, _reactNativeReanimated.runOnJS)(setTextVal)('');
540
374
  }
541
-
542
375
  drawNewItem(mode, currentItem, addDoneItem, {
543
376
  x: startX,
544
377
  y: startY
@@ -547,10 +380,9 @@ const DrawCore = /*#__PURE__*/_react.default.forwardRef((_ref, ref) => {
547
380
  strokeWidth,
548
381
  color
549
382
  });
550
- onSelectionChange && (0, _reactNativeReanimated.runOnJS)(onSelectionChange)(true);
551
- onCancelChange && (0, _reactNativeReanimated.runOnJS)(onCancelChange)(true);
383
+ itemIsSelected.value = true;
384
+ onCancelChangeWrapper && (0, _reactNativeReanimated.runOnJS)(onCancelChangeWrapper)(true);
552
385
  }
553
-
554
386
  switch ((_currentItem$value4 = currentItem.value) === null || _currentItem$value4 === void 0 ? void 0 : _currentItem$value4.type) {
555
387
  case 'pen':
556
388
  if (((_initialItem$value = initialItem.value) === null || _initialItem$value === void 0 ? void 0 : _initialItem$value.type) === currentItem.value.type && zone === 'CENTER') {
@@ -574,18 +406,14 @@ const DrawCore = /*#__PURE__*/_react.default.forwardRef((_ref, ref) => {
574
406
  })
575
407
  };
576
408
  }
577
-
578
409
  break;
579
-
580
410
  case 'ellipse':
581
411
  if (((_initialItem$value2 = initialItem.value) === null || _initialItem$value2 === void 0 ? void 0 : _initialItem$value2.type) === currentItem.value.type) {
582
412
  var _initialItem$value3;
583
-
584
413
  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;
585
414
  const ry = typeof initialItem.value.data.ry === 'string' ? parseFloat(initialItem.value.data.ry) : initialItem.value.data.ry || 0;
586
415
  const cx = typeof initialItem.value.data.cx === 'string' ? parseFloat(initialItem.value.data.cx) : initialItem.value.data.cx || 0;
587
416
  const cy = typeof initialItem.value.data.cy === 'string' ? parseFloat(initialItem.value.data.cy) : initialItem.value.data.cy || 0;
588
-
589
417
  switch (zone) {
590
418
  case 'TOP':
591
419
  currentItem.value = {
@@ -600,7 +428,6 @@ const DrawCore = /*#__PURE__*/_react.default.forwardRef((_ref, ref) => {
600
428
  }
601
429
  };
602
430
  break;
603
-
604
431
  case 'BOTTOM':
605
432
  currentItem.value = {
606
433
  type: currentItem.value.type,
@@ -614,7 +441,6 @@ const DrawCore = /*#__PURE__*/_react.default.forwardRef((_ref, ref) => {
614
441
  }
615
442
  };
616
443
  break;
617
-
618
444
  case 'LEFT':
619
445
  currentItem.value = {
620
446
  type: currentItem.value.type,
@@ -628,7 +454,6 @@ const DrawCore = /*#__PURE__*/_react.default.forwardRef((_ref, ref) => {
628
454
  }
629
455
  };
630
456
  break;
631
-
632
457
  case 'RIGHT':
633
458
  currentItem.value = {
634
459
  type: currentItem.value.type,
@@ -642,7 +467,6 @@ const DrawCore = /*#__PURE__*/_react.default.forwardRef((_ref, ref) => {
642
467
  }
643
468
  };
644
469
  break;
645
-
646
470
  case 'CENTER':
647
471
  currentItem.value = {
648
472
  type: currentItem.value.type,
@@ -670,18 +494,14 @@ const DrawCore = /*#__PURE__*/_react.default.forwardRef((_ref, ref) => {
670
494
  }
671
495
  };
672
496
  }
673
-
674
497
  break;
675
-
676
498
  case 'rectangle':
677
499
  if (((_initialItem$value4 = initialItem.value) === null || _initialItem$value4 === void 0 ? void 0 : _initialItem$value4.type) === currentItem.value.type) {
678
500
  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;
679
-
680
501
  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;
681
502
  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;
682
503
  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;
683
504
  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;
684
-
685
505
  switch (zone) {
686
506
  case 'TOP_LEFT':
687
507
  currentItem.value = {
@@ -696,7 +516,6 @@ const DrawCore = /*#__PURE__*/_react.default.forwardRef((_ref, ref) => {
696
516
  }
697
517
  };
698
518
  break;
699
-
700
519
  case 'TOP_RIGHT':
701
520
  currentItem.value = {
702
521
  type: 'rectangle',
@@ -710,7 +529,6 @@ const DrawCore = /*#__PURE__*/_react.default.forwardRef((_ref, ref) => {
710
529
  }
711
530
  };
712
531
  break;
713
-
714
532
  case 'BOTTOM_LEFT':
715
533
  currentItem.value = {
716
534
  type: 'rectangle',
@@ -724,7 +542,6 @@ const DrawCore = /*#__PURE__*/_react.default.forwardRef((_ref, ref) => {
724
542
  }
725
543
  };
726
544
  break;
727
-
728
545
  case 'BOTTOM_RIGHT':
729
546
  currentItem.value = {
730
547
  type: 'rectangle',
@@ -738,7 +555,6 @@ const DrawCore = /*#__PURE__*/_react.default.forwardRef((_ref, ref) => {
738
555
  }
739
556
  };
740
557
  break;
741
-
742
558
  case 'CENTER':
743
559
  currentItem.value = {
744
560
  type: 'rectangle',
@@ -766,19 +582,15 @@ const DrawCore = /*#__PURE__*/_react.default.forwardRef((_ref, ref) => {
766
582
  }
767
583
  };
768
584
  }
769
-
770
585
  break;
771
-
772
586
  case 'singleHead':
773
587
  case 'doubleHead':
774
588
  if (((_initialItem$value17 = initialItem.value) === null || _initialItem$value17 === void 0 ? void 0 : _initialItem$value17.type) === currentItem.value.type) {
775
589
  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;
776
-
777
590
  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;
778
591
  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;
779
592
  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;
780
593
  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;
781
-
782
594
  switch (zone) {
783
595
  case 'TOP':
784
596
  currentItem.value = {
@@ -793,7 +605,6 @@ const DrawCore = /*#__PURE__*/_react.default.forwardRef((_ref, ref) => {
793
605
  }
794
606
  };
795
607
  break;
796
-
797
608
  case 'BOTTOM':
798
609
  currentItem.value = {
799
610
  type: currentItem.value.type,
@@ -807,7 +618,6 @@ const DrawCore = /*#__PURE__*/_react.default.forwardRef((_ref, ref) => {
807
618
  }
808
619
  };
809
620
  break;
810
-
811
621
  case 'CENTER':
812
622
  currentItem.value = {
813
623
  type: currentItem.value.type,
@@ -835,18 +645,14 @@ const DrawCore = /*#__PURE__*/_react.default.forwardRef((_ref, ref) => {
835
645
  }
836
646
  };
837
647
  }
838
-
839
648
  break;
840
-
841
649
  case 'text':
842
650
  if (((_initialItem$value30 = initialItem.value) === null || _initialItem$value30 === void 0 ? void 0 : _initialItem$value30.type) === currentItem.value.type) {
843
651
  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;
844
-
845
652
  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;
846
653
  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;
847
654
  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;
848
655
  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;
849
-
850
656
  switch (zone) {
851
657
  case 'LEFT':
852
658
  currentItem.value = {
@@ -862,7 +668,6 @@ const DrawCore = /*#__PURE__*/_react.default.forwardRef((_ref, ref) => {
862
668
  }
863
669
  };
864
670
  break;
865
-
866
671
  case 'RIGHT':
867
672
  currentItem.value = {
868
673
  type: currentItem.value.type,
@@ -877,7 +682,6 @@ const DrawCore = /*#__PURE__*/_react.default.forwardRef((_ref, ref) => {
877
682
  }
878
683
  };
879
684
  break;
880
-
881
685
  case 'CENTER':
882
686
  currentItem.value = {
883
687
  type: currentItem.value.type,
@@ -907,50 +711,35 @@ const DrawCore = /*#__PURE__*/_react.default.forwardRef((_ref, ref) => {
907
711
  }
908
712
  };
909
713
  }
910
-
911
714
  }
912
715
  },
913
716
  onEnd: _event => {
914
717
  var _currentItem$value5;
915
-
916
- panPosition.value = (0, _reactNativeReanimated.withTiming)(0);
917
-
918
718
  if (((_currentItem$value5 = currentItem.value) === null || _currentItem$value5 === void 0 ? void 0 : _currentItem$value5.type) === 'text') {
919
- var _currentItem$value$te;
920
-
921
719
  (0, _reactNativeReanimated.runOnJS)(textFocus)();
922
720
  currentItem.value = {
923
721
  type: currentItem.value.type,
924
722
  strokeWidth: currentItem.value.strokeWidth,
925
723
  color: currentItem.value.color,
926
724
  data: currentItem.value.data,
927
- text: currentItem.value.text !== DEFAULT_TEXT ? (_currentItem$value$te = currentItem.value.text) !== null && _currentItem$value$te !== void 0 ? _currentItem$value$te : '' : ''
725
+ text: currentItem.value.text !== DEFAULT_TEXT ? currentItem.value.text ?? '' : ''
928
726
  };
929
727
  }
930
-
931
728
  (0, _reactNativeReanimated.runOnJS)(addScreenStates)(currentItem.value);
932
729
  }
933
- }, []);
934
- const rightPaneStyle = (0, _reactNativeReanimated.useAnimatedStyle)(() => {
935
- return {
936
- transform: [{
937
- translateX: panPosition.value
938
- }]
939
- };
940
730
  });
941
731
  (0, _react.useEffect)(() => {
942
732
  const sudDidHide = _reactNative.Keyboard.addListener('keyboardDidHide', () => {
943
733
  showTextInput.value = false;
944
734
  });
945
-
946
735
  const sudDidShow = _reactNative.Keyboard.addListener('keyboardDidShow', event => {
947
736
  // avoid events triggered by InputAccessoryView
948
737
  if (event.endCoordinates.height > 100) {
949
738
  showTextInput.value = true;
950
739
  }
951
- }); // cleanup function
952
-
740
+ });
953
741
 
742
+ // cleanup function
954
743
  return () => {
955
744
  sudDidShow.remove();
956
745
  sudDidHide.remove();
@@ -960,13 +749,14 @@ const DrawCore = /*#__PURE__*/_react.default.forwardRef((_ref, ref) => {
960
749
  const textInputContainerStyle = (0, _reactNativeReanimated.useAnimatedStyle)(() => {
961
750
  return {
962
751
  height: 'auto',
963
- backgroundColor: 'white',
752
+ backgroundColor: 'red',
964
753
  display: 'flex',
965
754
  opacity: showTextInput.value ? (0, _reactNativeReanimated.withTiming)(1) : (0, _reactNativeReanimated.withTiming)(0)
966
755
  };
967
756
  }, [showTextInput.value]);
968
757
  const textInputStyle = (0, _reactNativeReanimated.useAnimatedStyle)(() => {
969
758
  return {
759
+ backgroundColor: 'blue',
970
760
  display: showTextInput.value ? 'flex' : 'none',
971
761
  opacity: showTextInput.value ? (0, _reactNativeReanimated.withTiming)(1) : (0, _reactNativeReanimated.withTiming)(0)
972
762
  };
@@ -974,16 +764,14 @@ const DrawCore = /*#__PURE__*/_react.default.forwardRef((_ref, ref) => {
974
764
  (0, _reactNativeReanimated.useAnimatedReaction)(() => {
975
765
  return {
976
766
  strokeWidth: strokeWidth.value,
977
- color: color.value
767
+ color: color === null || color === void 0 ? void 0 : color.value
978
768
  };
979
769
  }, _ref4 => {
980
770
  var _currentItem$value6;
981
-
982
771
  let {
983
772
  strokeWidth: sw,
984
773
  color: c
985
774
  } = _ref4;
986
-
987
775
  switch ((_currentItem$value6 = currentItem.value) === null || _currentItem$value6 === void 0 ? void 0 : _currentItem$value6.type) {
988
776
  case 'singleHead':
989
777
  currentItem.value = {
@@ -993,7 +781,6 @@ const DrawCore = /*#__PURE__*/_react.default.forwardRef((_ref, ref) => {
993
781
  color: c
994
782
  };
995
783
  break;
996
-
997
784
  case 'doubleHead':
998
785
  currentItem.value = {
999
786
  type: currentItem.value.type,
@@ -1002,7 +789,6 @@ const DrawCore = /*#__PURE__*/_react.default.forwardRef((_ref, ref) => {
1002
789
  color: c
1003
790
  };
1004
791
  break;
1005
-
1006
792
  case 'ellipse':
1007
793
  currentItem.value = {
1008
794
  type: currentItem.value.type,
@@ -1011,7 +797,6 @@ const DrawCore = /*#__PURE__*/_react.default.forwardRef((_ref, ref) => {
1011
797
  color: c
1012
798
  };
1013
799
  break;
1014
-
1015
800
  case 'rectangle':
1016
801
  currentItem.value = {
1017
802
  type: currentItem.value.type,
@@ -1020,7 +805,6 @@ const DrawCore = /*#__PURE__*/_react.default.forwardRef((_ref, ref) => {
1020
805
  color: c
1021
806
  };
1022
807
  break;
1023
-
1024
808
  case 'pen':
1025
809
  currentItem.value = {
1026
810
  type: currentItem.value.type,
@@ -1029,7 +813,6 @@ const DrawCore = /*#__PURE__*/_react.default.forwardRef((_ref, ref) => {
1029
813
  color: c
1030
814
  };
1031
815
  break;
1032
-
1033
816
  case 'text':
1034
817
  currentItem.value = {
1035
818
  type: currentItem.value.type,
@@ -1040,29 +823,24 @@ const DrawCore = /*#__PURE__*/_react.default.forwardRef((_ref, ref) => {
1040
823
  };
1041
824
  break;
1042
825
  }
1043
- }, [strokeWidth.value, color.value]);
826
+ }, [strokeWidth.value, color === null || color === void 0 ? void 0 : color.value]);
1044
827
  const onPressItem = (0, _react.useCallback)((item, index) => () => {
1045
- onSelectionChange === null || onSelectionChange === void 0 ? void 0 : onSelectionChange(true);
828
+ itemIsSelected.value = true;
1046
829
  const previousItem = currentItem.value;
1047
830
  strokeWidth.value = item.strokeWidth;
1048
831
  color.value = item.color;
1049
832
  currentItem.value = item;
1050
833
  deleteDoneItem(index);
1051
-
1052
834
  if (previousItem) {
1053
835
  addDoneItem(previousItem);
1054
836
  }
1055
-
1056
837
  if (item.type === 'text') {
1057
- var _item$text;
1058
-
1059
- setTextVal((_item$text = item.text) !== null && _item$text !== void 0 ? _item$text : '');
838
+ setTextVal(item.text ?? '');
1060
839
  } else {
1061
840
  var _textInputRef$current2;
1062
-
1063
841
  (_textInputRef$current2 = textInputRef.current) === null || _textInputRef$current2 === void 0 ? void 0 : _textInputRef$current2.blur();
1064
842
  }
1065
- }, [onSelectionChange, currentItem, strokeWidth, color, deleteDoneItem, addDoneItem]);
843
+ }, [itemIsSelected, currentItem, strokeWidth, color, deleteDoneItem, addDoneItem]);
1066
844
  const onTextHeightChange = (0, _react.useCallback)(height => {
1067
845
  onTextHeightUpdate(currentItem, textBaseHeight, height);
1068
846
  }, [currentItem, textBaseHeight]);
@@ -1073,7 +851,6 @@ const DrawCore = /*#__PURE__*/_react.default.forwardRef((_ref, ref) => {
1073
851
  height: imageHeight
1074
852
  });
1075
853
  const ratioImageHeight = Math.round(imageHeight * drawRegion.width / imageWidth * 100) / 100;
1076
-
1077
854
  if (ratioImageHeight < drawRegion.height) {
1078
855
  setImageSize({
1079
856
  width: drawRegion.width,
@@ -1091,7 +868,6 @@ const DrawCore = /*#__PURE__*/_react.default.forwardRef((_ref, ref) => {
1091
868
  if (drawRegion && image) {
1092
869
  if (typeof image === 'number') {
1093
870
  const infos = _reactNative.Image.resolveAssetSource(image);
1094
-
1095
871
  calculateSizes(infos.width, infos.height);
1096
872
  } else if (image.uri) {
1097
873
  _reactNative.Image.getSize(image.uri, (imageWidth, imageHeight) => {
@@ -1104,7 +880,7 @@ const DrawCore = /*#__PURE__*/_react.default.forwardRef((_ref, ref) => {
1104
880
  style: styles.container
1105
881
  }, /*#__PURE__*/_react.default.createElement(_reactNative.View, {
1106
882
  style: [styles.drawZone, {
1107
- backgroundColor: backgroundColor !== null && backgroundColor !== void 0 ? backgroundColor : '#FFF'
883
+ backgroundColor: backgroundColor ?? 'none'
1108
884
  }],
1109
885
  onLayout: event => {
1110
886
  setDrawRegion({
@@ -1130,7 +906,7 @@ const DrawCore = /*#__PURE__*/_react.default.forwardRef((_ref, ref) => {
1130
906
  style: styles.bgImage
1131
907
  }, /*#__PURE__*/_react.default.createElement(_DrawPad.default, {
1132
908
  currentItem: currentItem,
1133
- doneItems: drawStates.doneItems,
909
+ doneItems: drawState.doneItems,
1134
910
  onPressItem: onPressItem,
1135
911
  onTextHeightChange: onTextHeightChange
1136
912
  }))) : null : drawRegion ? /*#__PURE__*/_react.default.createElement(_reactNativeViewShot.default, {
@@ -1143,25 +919,10 @@ const DrawCore = /*#__PURE__*/_react.default.forwardRef((_ref, ref) => {
1143
919
  style: drawRegion
1144
920
  }, /*#__PURE__*/_react.default.createElement(_DrawPad.default, {
1145
921
  currentItem: currentItem,
1146
- doneItems: drawStates.doneItems,
922
+ doneItems: drawState.doneItems,
1147
923
  onPressItem: onPressItem,
1148
924
  onTextHeightChange: onTextHeightChange
1149
- })) : null))), /*#__PURE__*/_react.default.createElement(_reactNativeReanimated.default.View, {
1150
- style: [styles.rightPaneBaseStyle, rightPaneStyle]
1151
- }, /*#__PURE__*/_react.default.createElement(_reactNative.View, {
1152
- style: styles.strokeSliderContainer
1153
- }, /*#__PURE__*/_react.default.createElement(_StrokeSlider.default, {
1154
- minValue: 2,
1155
- maxValue: 10,
1156
- stroke: strokeWidth,
1157
- onStrokeChange: onColorStrokeChange
1158
- })), /*#__PURE__*/_react.default.createElement(_reactNative.View, {
1159
- style: styles.colorSliderContainer
1160
- }, /*#__PURE__*/_react.default.createElement(_ColorSlider.default, {
1161
- color: color,
1162
- linearGradient: linearGradient,
1163
- onColorChange: onColorStrokeChange
1164
- })))), _reactNative.Platform.OS === 'ios' ? /*#__PURE__*/_react.default.createElement(_reactNative.InputAccessoryView, null, /*#__PURE__*/_react.default.createElement(AnimatedTextInput, {
925
+ })) : null)))), _reactNative.Platform.OS === 'ios' ? /*#__PURE__*/_react.default.createElement(_reactNative.InputAccessoryView, null, /*#__PURE__*/_react.default.createElement(AnimatedTextInput, {
1165
926
  ref: textInputRef,
1166
927
  style: [styles.textInput, textInputStyle],
1167
928
  onEndEditing: (_textInputRef$current3 = textInputRef.current) === null || _textInputRef$current3 === void 0 ? void 0 : _textInputRef$current3.clear,
@@ -1178,8 +939,7 @@ const DrawCore = /*#__PURE__*/_react.default.forwardRef((_ref, ref) => {
1178
939
  value: textVal,
1179
940
  autoCorrect: false
1180
941
  })));
1181
- });
1182
-
942
+ };
1183
943
  var _default = DrawCore;
1184
944
  exports.default = _default;
1185
945
  //# sourceMappingURL=index.js.map