@archireport/react-native-svg-draw 1.2.0 → 1.4.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 +3 -2
- package/lib/commonjs/components/DrawCore/ColorSlider.js +2 -16
- package/lib/commonjs/components/DrawCore/ColorSlider.js.map +1 -1
- package/lib/commonjs/components/DrawCore/CurrentAnimatedItem.js +50 -54
- package/lib/commonjs/components/DrawCore/CurrentAnimatedItem.js.map +1 -1
- package/lib/commonjs/components/DrawCore/CurrentAnimatedText.js +3 -14
- package/lib/commonjs/components/DrawCore/CurrentAnimatedText.js.map +1 -1
- package/lib/commonjs/components/DrawCore/DrawPad.js +1 -13
- package/lib/commonjs/components/DrawCore/DrawPad.js.map +1 -1
- package/lib/commonjs/components/DrawCore/Item.js +0 -15
- package/lib/commonjs/components/DrawCore/Item.js.map +1 -1
- package/lib/commonjs/components/DrawCore/StrokeSlider.js +0 -10
- package/lib/commonjs/components/DrawCore/StrokeSlider.js.map +1 -1
- package/lib/commonjs/components/DrawCore/index.js +26 -137
- package/lib/commonjs/components/DrawCore/index.js.map +1 -1
- package/lib/commonjs/components/DrawWithOptions/ArrowSvg.js +0 -6
- package/lib/commonjs/components/DrawWithOptions/ArrowSvg.js.map +1 -1
- package/lib/commonjs/components/DrawWithOptions/CancelSvg.js +0 -6
- package/lib/commonjs/components/DrawWithOptions/CancelSvg.js.map +1 -1
- package/lib/commonjs/components/DrawWithOptions/CircleSvg.js +0 -6
- package/lib/commonjs/components/DrawWithOptions/CircleSvg.js.map +1 -1
- package/lib/commonjs/components/DrawWithOptions/CloseSvg.js +0 -6
- package/lib/commonjs/components/DrawWithOptions/CloseSvg.js.map +1 -1
- package/lib/commonjs/components/DrawWithOptions/DoubleHeadSvg.js +0 -7
- package/lib/commonjs/components/DrawWithOptions/DoubleHeadSvg.js.map +1 -1
- package/lib/commonjs/components/DrawWithOptions/PenSvg.js +0 -6
- package/lib/commonjs/components/DrawWithOptions/PenSvg.js.map +1 -1
- package/lib/commonjs/components/DrawWithOptions/SendSvg.js +0 -7
- package/lib/commonjs/components/DrawWithOptions/SendSvg.js.map +1 -1
- package/lib/commonjs/components/DrawWithOptions/SquareSvg.js +0 -7
- package/lib/commonjs/components/DrawWithOptions/SquareSvg.js.map +1 -1
- package/lib/commonjs/components/DrawWithOptions/TextSvg.js +0 -7
- package/lib/commonjs/components/DrawWithOptions/TextSvg.js.map +1 -1
- package/lib/commonjs/components/DrawWithOptions/ThrashSvg.js +0 -8
- package/lib/commonjs/components/DrawWithOptions/ThrashSvg.js.map +1 -1
- package/lib/commonjs/components/DrawWithOptions/index.js +2 -23
- package/lib/commonjs/components/DrawWithOptions/index.js.map +1 -1
- package/lib/commonjs/index.js +0 -3
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/types.d.js.map +1 -1
- package/lib/module/components/DrawCore/ColorSlider.js +2 -8
- package/lib/module/components/DrawCore/ColorSlider.js.map +1 -1
- package/lib/module/components/DrawCore/CurrentAnimatedItem.js +51 -43
- package/lib/module/components/DrawCore/CurrentAnimatedItem.js.map +1 -1
- package/lib/module/components/DrawCore/CurrentAnimatedText.js +3 -7
- package/lib/module/components/DrawCore/CurrentAnimatedText.js.map +1 -1
- package/lib/module/components/DrawCore/DrawPad.js +1 -5
- package/lib/module/components/DrawCore/DrawPad.js.map +1 -1
- package/lib/module/components/DrawCore/Item.js +0 -8
- package/lib/module/components/DrawCore/Item.js.map +1 -1
- package/lib/module/components/DrawCore/StrokeSlider.js +0 -2
- package/lib/module/components/DrawCore/StrokeSlider.js.map +1 -1
- package/lib/module/components/DrawCore/index.js +26 -119
- package/lib/module/components/DrawCore/index.js.map +1 -1
- package/lib/module/components/DrawWithOptions/ArrowSvg.js +0 -1
- package/lib/module/components/DrawWithOptions/ArrowSvg.js.map +1 -1
- package/lib/module/components/DrawWithOptions/CancelSvg.js +0 -1
- package/lib/module/components/DrawWithOptions/CancelSvg.js.map +1 -1
- package/lib/module/components/DrawWithOptions/CircleSvg.js +0 -1
- package/lib/module/components/DrawWithOptions/CircleSvg.js.map +1 -1
- package/lib/module/components/DrawWithOptions/CloseSvg.js +0 -1
- package/lib/module/components/DrawWithOptions/CloseSvg.js.map +1 -1
- package/lib/module/components/DrawWithOptions/DoubleHeadSvg.js +0 -1
- package/lib/module/components/DrawWithOptions/DoubleHeadSvg.js.map +1 -1
- package/lib/module/components/DrawWithOptions/PenSvg.js +0 -1
- package/lib/module/components/DrawWithOptions/PenSvg.js.map +1 -1
- package/lib/module/components/DrawWithOptions/SendSvg.js +0 -3
- package/lib/module/components/DrawWithOptions/SendSvg.js.map +1 -1
- package/lib/module/components/DrawWithOptions/SquareSvg.js +0 -1
- package/lib/module/components/DrawWithOptions/SquareSvg.js.map +1 -1
- package/lib/module/components/DrawWithOptions/TextSvg.js +0 -3
- package/lib/module/components/DrawWithOptions/TextSvg.js.map +1 -1
- package/lib/module/components/DrawWithOptions/ThrashSvg.js +0 -3
- package/lib/module/components/DrawWithOptions/ThrashSvg.js.map +1 -1
- package/lib/module/components/DrawWithOptions/index.js +2 -3
- package/lib/module/components/DrawWithOptions/index.js.map +1 -1
- package/lib/module/index.js.map +1 -1
- package/lib/module/types.d.js.map +1 -1
- package/lib/typescript/components/DrawCore/ColorSlider.d.ts +1 -0
- package/lib/typescript/components/DrawCore/ColorSlider.d.ts.map +1 -0
- package/lib/typescript/components/DrawCore/CurrentAnimatedItem.d.ts +1 -1
- package/lib/typescript/components/DrawCore/CurrentAnimatedItem.d.ts.map +1 -0
- package/lib/typescript/components/DrawCore/CurrentAnimatedText.d.ts +1 -1
- package/lib/typescript/components/DrawCore/CurrentAnimatedText.d.ts.map +1 -0
- package/lib/typescript/components/DrawCore/DrawPad.d.ts +1 -1
- package/lib/typescript/components/DrawCore/DrawPad.d.ts.map +1 -0
- package/lib/typescript/components/DrawCore/Item.d.ts +1 -1
- package/lib/typescript/components/DrawCore/Item.d.ts.map +1 -0
- package/lib/typescript/components/DrawCore/StrokeSlider.d.ts +1 -1
- package/lib/typescript/components/DrawCore/StrokeSlider.d.ts.map +1 -0
- package/lib/typescript/components/DrawCore/index.d.ts +2 -0
- package/lib/typescript/components/DrawCore/index.d.ts.map +1 -0
- package/lib/typescript/components/DrawWithOptions/ArrowSvg.d.ts +1 -1
- package/lib/typescript/components/DrawWithOptions/ArrowSvg.d.ts.map +1 -0
- package/lib/typescript/components/DrawWithOptions/CancelSvg.d.ts +1 -1
- package/lib/typescript/components/DrawWithOptions/CancelSvg.d.ts.map +1 -0
- package/lib/typescript/components/DrawWithOptions/CircleSvg.d.ts +1 -1
- package/lib/typescript/components/DrawWithOptions/CircleSvg.d.ts.map +1 -0
- package/lib/typescript/components/DrawWithOptions/CloseSvg.d.ts +1 -1
- package/lib/typescript/components/DrawWithOptions/CloseSvg.d.ts.map +1 -0
- package/lib/typescript/components/DrawWithOptions/DoubleHeadSvg.d.ts +1 -1
- package/lib/typescript/components/DrawWithOptions/DoubleHeadSvg.d.ts.map +1 -0
- package/lib/typescript/components/DrawWithOptions/PenSvg.d.ts +1 -1
- package/lib/typescript/components/DrawWithOptions/PenSvg.d.ts.map +1 -0
- package/lib/typescript/components/DrawWithOptions/SendSvg.d.ts +1 -1
- package/lib/typescript/components/DrawWithOptions/SendSvg.d.ts.map +1 -0
- package/lib/typescript/components/DrawWithOptions/SquareSvg.d.ts +1 -1
- package/lib/typescript/components/DrawWithOptions/SquareSvg.d.ts.map +1 -0
- package/lib/typescript/components/DrawWithOptions/TextSvg.d.ts +1 -1
- package/lib/typescript/components/DrawWithOptions/TextSvg.d.ts.map +1 -0
- package/lib/typescript/components/DrawWithOptions/ThrashSvg.d.ts +1 -1
- package/lib/typescript/components/DrawWithOptions/ThrashSvg.d.ts.map +1 -0
- package/lib/typescript/components/DrawWithOptions/index.d.ts +1 -0
- package/lib/typescript/components/DrawWithOptions/index.d.ts.map +1 -0
- package/lib/typescript/index.d.ts +1 -0
- package/lib/typescript/index.d.ts.map +1 -0
- package/package.json +29 -30
- package/src/components/DrawCore/ColorSlider.tsx +2 -2
- package/src/components/DrawCore/CurrentAnimatedItem.tsx +161 -106
- package/src/components/DrawCore/DrawPad.tsx +3 -9
- package/src/components/DrawCore/index.tsx +27 -10
|
@@ -4,31 +4,18 @@ 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
11
|
var _ColorSlider = _interopRequireDefault(require("./ColorSlider"));
|
|
17
|
-
|
|
18
12
|
var _StrokeSlider = _interopRequireDefault(require("./StrokeSlider"));
|
|
19
|
-
|
|
20
13
|
var _DrawPad = _interopRequireDefault(require("./DrawPad"));
|
|
21
|
-
|
|
22
14
|
var _reactNativeViewShot = _interopRequireDefault(require("react-native-view-shot"));
|
|
23
|
-
|
|
24
15
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
25
|
-
|
|
26
16
|
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
17
|
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
18
|
const RIGHT_PANE_WIDTH = 60;
|
|
31
|
-
|
|
32
19
|
const styles = _reactNative.StyleSheet.create({
|
|
33
20
|
container: {
|
|
34
21
|
flex: 1
|
|
@@ -36,8 +23,7 @@ const styles = _reactNative.StyleSheet.create({
|
|
|
36
23
|
drawZone: {
|
|
37
24
|
flex: 1,
|
|
38
25
|
justifyContent: 'center',
|
|
39
|
-
alignItems: 'center'
|
|
40
|
-
backgroundColor: 'white'
|
|
26
|
+
alignItems: 'center'
|
|
41
27
|
},
|
|
42
28
|
rightPaneBaseStyle: {
|
|
43
29
|
position: 'absolute',
|
|
@@ -75,7 +61,6 @@ const styles = _reactNative.StyleSheet.create({
|
|
|
75
61
|
width: '100%'
|
|
76
62
|
}
|
|
77
63
|
});
|
|
78
|
-
|
|
79
64
|
const pDistance = (point, line) => {
|
|
80
65
|
'worklet';
|
|
81
66
|
|
|
@@ -96,14 +81,11 @@ const pDistance = (point, line) => {
|
|
|
96
81
|
var dot = A * C + B * D;
|
|
97
82
|
var len_sq = C * C + D * D;
|
|
98
83
|
var param = -1;
|
|
99
|
-
|
|
100
84
|
if (len_sq !== 0) {
|
|
101
85
|
//in case of 0 length line
|
|
102
86
|
param = dot / len_sq;
|
|
103
87
|
}
|
|
104
|
-
|
|
105
88
|
var xx, yy;
|
|
106
|
-
|
|
107
89
|
if (param < 0) {
|
|
108
90
|
xx = x1;
|
|
109
91
|
yy = y1;
|
|
@@ -114,24 +96,19 @@ const pDistance = (point, line) => {
|
|
|
114
96
|
xx = x1 + param * C;
|
|
115
97
|
yy = y1 + param * D;
|
|
116
98
|
}
|
|
117
|
-
|
|
118
99
|
var dx = x - xx;
|
|
119
100
|
var dy = y - yy;
|
|
120
101
|
return Math.sqrt(dx * dx + dy * dy);
|
|
121
102
|
};
|
|
122
|
-
|
|
123
103
|
const AnimatedTextInput = _reactNativeReanimated.default.createAnimatedComponent(_reactNative.TextInput);
|
|
124
|
-
|
|
125
104
|
const DEFAULT_TEXT = '';
|
|
126
105
|
const THRESHOLD = 20;
|
|
127
|
-
|
|
128
106
|
const drawNewItem = (mode, currentItem, addDoneItem, position, style) => {
|
|
129
107
|
'worklet';
|
|
130
108
|
|
|
131
109
|
if (currentItem.value) {
|
|
132
110
|
(0, _reactNativeReanimated.runOnJS)(addDoneItem)(currentItem.value);
|
|
133
111
|
}
|
|
134
|
-
|
|
135
112
|
switch (mode.value) {
|
|
136
113
|
case 'ellipse':
|
|
137
114
|
currentItem.value = {
|
|
@@ -146,7 +123,6 @@ const drawNewItem = (mode, currentItem, addDoneItem, position, style) => {
|
|
|
146
123
|
color: style.color.value
|
|
147
124
|
};
|
|
148
125
|
break;
|
|
149
|
-
|
|
150
126
|
case 'rectangle':
|
|
151
127
|
currentItem.value = {
|
|
152
128
|
type: mode.value,
|
|
@@ -160,7 +136,6 @@ const drawNewItem = (mode, currentItem, addDoneItem, position, style) => {
|
|
|
160
136
|
color: style.color.value
|
|
161
137
|
};
|
|
162
138
|
break;
|
|
163
|
-
|
|
164
139
|
case 'singleHead':
|
|
165
140
|
case 'doubleHead':
|
|
166
141
|
currentItem.value = {
|
|
@@ -175,7 +150,6 @@ const drawNewItem = (mode, currentItem, addDoneItem, position, style) => {
|
|
|
175
150
|
color: style.color.value
|
|
176
151
|
};
|
|
177
152
|
break;
|
|
178
|
-
|
|
179
153
|
case 'text':
|
|
180
154
|
currentItem.value = {
|
|
181
155
|
type: mode.value,
|
|
@@ -190,7 +164,6 @@ const drawNewItem = (mode, currentItem, addDoneItem, position, style) => {
|
|
|
190
164
|
color: style.color.value
|
|
191
165
|
};
|
|
192
166
|
break;
|
|
193
|
-
|
|
194
167
|
case 'pen':
|
|
195
168
|
currentItem.value = {
|
|
196
169
|
type: mode.value,
|
|
@@ -201,16 +174,15 @@ const drawNewItem = (mode, currentItem, addDoneItem, position, style) => {
|
|
|
201
174
|
break;
|
|
202
175
|
}
|
|
203
176
|
};
|
|
204
|
-
|
|
205
177
|
const onTextHeightUpdate = (currentItem, textBaseHeight, height) => {
|
|
206
178
|
'worklet';
|
|
207
179
|
|
|
208
180
|
var _currentItem$value;
|
|
209
|
-
|
|
210
181
|
if (((_currentItem$value = currentItem.value) === null || _currentItem$value === void 0 ? void 0 : _currentItem$value.type) === 'text') {
|
|
211
182
|
textBaseHeight.value = textBaseHeight.value || height;
|
|
212
183
|
currentItem.value = {
|
|
213
|
-
data: {
|
|
184
|
+
data: {
|
|
185
|
+
...currentItem.value.data,
|
|
214
186
|
height: height
|
|
215
187
|
},
|
|
216
188
|
type: currentItem.value.type,
|
|
@@ -220,67 +192,65 @@ const onTextHeightUpdate = (currentItem, textBaseHeight, height) => {
|
|
|
220
192
|
};
|
|
221
193
|
}
|
|
222
194
|
};
|
|
223
|
-
|
|
224
195
|
const reducerDrawStates = (drawStates, action) => {
|
|
225
196
|
'worklet';
|
|
226
197
|
|
|
227
198
|
switch (action.type) {
|
|
228
199
|
case 'ADD_DONE_ITEM':
|
|
229
|
-
return {
|
|
200
|
+
return {
|
|
201
|
+
...drawStates,
|
|
230
202
|
doneItems: drawStates.doneItems.concat(action.item)
|
|
231
203
|
};
|
|
232
|
-
|
|
233
204
|
case 'DELETE_DONE_ITEM':
|
|
234
205
|
const newDoneItems = drawStates.doneItems;
|
|
235
206
|
newDoneItems.splice(action.indice, 1);
|
|
236
|
-
return {
|
|
207
|
+
return {
|
|
208
|
+
...drawStates,
|
|
237
209
|
doneItems: newDoneItems
|
|
238
210
|
};
|
|
239
|
-
|
|
240
211
|
case 'ADD_SCREEN_STATE':
|
|
241
212
|
if (action.currentItem) {
|
|
242
|
-
return {
|
|
213
|
+
return {
|
|
214
|
+
...drawStates,
|
|
243
215
|
screenStates: drawStates.screenStates.concat([[...drawStates.doneItems, action.currentItem]])
|
|
244
216
|
};
|
|
245
217
|
} else {
|
|
246
|
-
return {
|
|
218
|
+
return {
|
|
219
|
+
...drawStates,
|
|
247
220
|
screenStates: drawStates.screenStates.concat([[...drawStates.doneItems]])
|
|
248
221
|
};
|
|
249
222
|
}
|
|
250
|
-
|
|
251
223
|
case 'CANCEL':
|
|
252
224
|
const len = drawStates.screenStates.length;
|
|
253
|
-
|
|
254
225
|
if (len > 1) {
|
|
255
226
|
const newScreenStates = drawStates.screenStates;
|
|
256
227
|
newScreenStates.pop();
|
|
257
|
-
|
|
258
228
|
if (newScreenStates.length === 1) {
|
|
259
229
|
var _action$onCancelChang;
|
|
260
|
-
|
|
261
230
|
(_action$onCancelChang = action.onCancelChange) === null || _action$onCancelChang === void 0 ? void 0 : _action$onCancelChang.call(action, false);
|
|
262
231
|
}
|
|
263
|
-
|
|
264
232
|
return {
|
|
265
|
-
doneItems: drawStates.screenStates[len - 2],
|
|
233
|
+
doneItems: drawStates.screenStates[len - 2] ?? [],
|
|
266
234
|
screenStates: newScreenStates
|
|
267
235
|
};
|
|
268
236
|
} else {
|
|
269
237
|
return drawStates;
|
|
270
238
|
}
|
|
271
|
-
|
|
272
239
|
}
|
|
273
240
|
};
|
|
274
|
-
|
|
241
|
+
const initialState = {
|
|
242
|
+
doneItems: [],
|
|
243
|
+
screenStates: [[]]
|
|
244
|
+
};
|
|
275
245
|
const DrawCore = /*#__PURE__*/_react.default.forwardRef((_ref, ref) => {
|
|
276
246
|
var _textInputRef$current3, _textInputRef$current4;
|
|
277
|
-
|
|
278
247
|
let {
|
|
279
248
|
drawingMode,
|
|
280
249
|
image,
|
|
281
250
|
linearGradient,
|
|
282
251
|
onSelectionChange,
|
|
283
|
-
onCancelChange
|
|
252
|
+
onCancelChange,
|
|
253
|
+
backgroundColor
|
|
284
254
|
} = _ref;
|
|
285
255
|
const mode = (0, _reactNativeReanimated.useSharedValue)('pen');
|
|
286
256
|
const [drawRegion, setDrawRegion] = (0, _react.useState)(null);
|
|
@@ -291,10 +261,7 @@ const DrawCore = /*#__PURE__*/_react.default.forwardRef((_ref, ref) => {
|
|
|
291
261
|
const [textVal, setTextVal] = (0, _react.useState)('');
|
|
292
262
|
const currentItem = (0, _reactNativeReanimated.useSharedValue)(null);
|
|
293
263
|
const initialItem = (0, _reactNativeReanimated.useSharedValue)(null);
|
|
294
|
-
const [drawStates, dispatchDrawStates] = (0, _react.useReducer)(reducerDrawStates,
|
|
295
|
-
doneItems: [],
|
|
296
|
-
screenStates: [[]]
|
|
297
|
-
});
|
|
264
|
+
const [drawStates, dispatchDrawStates] = (0, _react.useReducer)(reducerDrawStates, initialState);
|
|
298
265
|
const textBaseHeight = (0, _reactNativeReanimated.useSharedValue)(null);
|
|
299
266
|
const addDoneItem = (0, _react.useCallback)(item => {
|
|
300
267
|
dispatchDrawStates({
|
|
@@ -327,37 +294,30 @@ const DrawCore = /*#__PURE__*/_react.default.forwardRef((_ref, ref) => {
|
|
|
327
294
|
currentItem.value = null;
|
|
328
295
|
addScreenStates(null);
|
|
329
296
|
}
|
|
330
|
-
|
|
331
297
|
onSelectionChange === null || onSelectionChange === void 0 ? void 0 : onSelectionChange(false);
|
|
332
298
|
onCancelChange === null || onCancelChange === void 0 ? void 0 : onCancelChange(true);
|
|
333
299
|
},
|
|
334
300
|
cancelLastAction: () => {
|
|
335
301
|
onSelectionChange === null || onSelectionChange === void 0 ? void 0 : onSelectionChange(false);
|
|
336
|
-
|
|
337
302
|
if (currentItem.value) {
|
|
338
303
|
currentItem.value = null;
|
|
339
304
|
}
|
|
340
|
-
|
|
341
305
|
cancelAction();
|
|
342
306
|
},
|
|
343
307
|
takeSnapshot: async () => {
|
|
344
308
|
var _viewShot$current, _viewShot$current$cap;
|
|
345
|
-
|
|
346
309
|
if (currentItem.value) {
|
|
347
310
|
addDoneItem(currentItem.value);
|
|
348
311
|
currentItem.value = null;
|
|
349
312
|
}
|
|
350
|
-
|
|
351
313
|
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
314
|
}
|
|
353
315
|
}), [currentItem, onSelectionChange, onCancelChange, addScreenStates, cancelAction, addDoneItem]);
|
|
354
316
|
(0, _react.useEffect)(() => {
|
|
355
317
|
mode.value = drawingMode;
|
|
356
|
-
|
|
357
318
|
if (currentItem.value) {
|
|
358
319
|
addDoneItem(currentItem.value);
|
|
359
320
|
}
|
|
360
|
-
|
|
361
321
|
currentItem.value = null;
|
|
362
322
|
onSelectionChange === null || onSelectionChange === void 0 ? void 0 : onSelectionChange(false);
|
|
363
323
|
}, [drawingMode, mode, currentItem, onSelectionChange, addDoneItem]);
|
|
@@ -367,7 +327,6 @@ const DrawCore = /*#__PURE__*/_react.default.forwardRef((_ref, ref) => {
|
|
|
367
327
|
const showTextInput = (0, _reactNativeReanimated.useSharedValue)(false);
|
|
368
328
|
const textFocus = (0, _react.useCallback)(() => {
|
|
369
329
|
var _textInputRef$current;
|
|
370
|
-
|
|
371
330
|
(_textInputRef$current = textInputRef.current) === null || _textInputRef$current === void 0 ? void 0 : _textInputRef$current.focus();
|
|
372
331
|
}, []);
|
|
373
332
|
const onColorStrokeChange = (0, _react.useCallback)(() => {
|
|
@@ -377,7 +336,6 @@ const DrawCore = /*#__PURE__*/_react.default.forwardRef((_ref, ref) => {
|
|
|
377
336
|
}, [addScreenStates, currentItem.value]);
|
|
378
337
|
(0, _react.useEffect)(() => {
|
|
379
338
|
var _currentItem$value2;
|
|
380
|
-
|
|
381
339
|
if (((_currentItem$value2 = currentItem.value) === null || _currentItem$value2 === void 0 ? void 0 : _currentItem$value2.type) === 'text') {
|
|
382
340
|
currentItem.value = {
|
|
383
341
|
data: currentItem.value.data,
|
|
@@ -391,7 +349,6 @@ const DrawCore = /*#__PURE__*/_react.default.forwardRef((_ref, ref) => {
|
|
|
391
349
|
const onGestureEvent = (0, _reactNativeReanimated.useAnimatedGestureHandler)({
|
|
392
350
|
onStart: (_ref2, ctx) => {
|
|
393
351
|
var _currentItem$value3;
|
|
394
|
-
|
|
395
352
|
let {
|
|
396
353
|
x: startX,
|
|
397
354
|
y: startY
|
|
@@ -401,14 +358,12 @@ const DrawCore = /*#__PURE__*/_react.default.forwardRef((_ref, ref) => {
|
|
|
401
358
|
ctx.newlyCreated = false;
|
|
402
359
|
panPosition.value = (0, _reactNativeReanimated.withTiming)(RIGHT_PANE_WIDTH);
|
|
403
360
|
initialItem.value = currentItem.value;
|
|
404
|
-
|
|
405
361
|
switch ((_currentItem$value3 = currentItem.value) === null || _currentItem$value3 === void 0 ? void 0 : _currentItem$value3.type) {
|
|
406
362
|
case 'ellipse':
|
|
407
363
|
const cx = typeof currentItem.value.data.cx === 'string' ? parseFloat(currentItem.value.data.cx) : currentItem.value.data.cx || 0;
|
|
408
364
|
const cy = typeof currentItem.value.data.cy === 'string' ? parseFloat(currentItem.value.data.cy) : currentItem.value.data.cy || 0;
|
|
409
365
|
const rx = typeof currentItem.value.data.rx === 'string' ? parseFloat(currentItem.value.data.rx) : currentItem.value.data.rx || 0;
|
|
410
366
|
const ry = typeof currentItem.value.data.ry === 'string' ? parseFloat(currentItem.value.data.ry) : currentItem.value.data.ry || 0;
|
|
411
|
-
|
|
412
367
|
if (startX <= cx + THRESHOLD && startX >= cx - THRESHOLD && startY <= cy - ry + THRESHOLD && startY >= cy - ry - THRESHOLD) {
|
|
413
368
|
ctx.zone = 'TOP';
|
|
414
369
|
} else if (startX <= cx + THRESHOLD && startX >= cx - THRESHOLD && startY <= cy + ry + THRESHOLD && startY >= cy + ry - THRESHOLD) {
|
|
@@ -423,15 +378,12 @@ const DrawCore = /*#__PURE__*/_react.default.forwardRef((_ref, ref) => {
|
|
|
423
378
|
ctx.zone = 'OUT';
|
|
424
379
|
initialItem.value = null;
|
|
425
380
|
}
|
|
426
|
-
|
|
427
381
|
break;
|
|
428
|
-
|
|
429
382
|
case 'rectangle':
|
|
430
383
|
const x = typeof currentItem.value.data.x === 'string' ? parseFloat(currentItem.value.data.x) : currentItem.value.data.x || 0;
|
|
431
384
|
const y = typeof currentItem.value.data.y === 'string' ? parseFloat(currentItem.value.data.y) : currentItem.value.data.y || 0;
|
|
432
385
|
const height = typeof currentItem.value.data.height === 'string' ? parseFloat(currentItem.value.data.height) : currentItem.value.data.height || 0;
|
|
433
386
|
const width = typeof currentItem.value.data.width === 'string' ? parseFloat(currentItem.value.data.width) : currentItem.value.data.width || 0;
|
|
434
|
-
|
|
435
387
|
if (startX <= x + THRESHOLD && startX >= x - THRESHOLD) {
|
|
436
388
|
if (startY <= y + THRESHOLD && startY >= y - THRESHOLD) {
|
|
437
389
|
ctx.zone = 'TOP_LEFT';
|
|
@@ -450,16 +402,13 @@ const DrawCore = /*#__PURE__*/_react.default.forwardRef((_ref, ref) => {
|
|
|
450
402
|
ctx.zone = 'OUT';
|
|
451
403
|
initialItem.value = null;
|
|
452
404
|
}
|
|
453
|
-
|
|
454
405
|
break;
|
|
455
|
-
|
|
456
406
|
case 'doubleHead':
|
|
457
407
|
case 'singleHead':
|
|
458
408
|
const x1 = typeof currentItem.value.data.x1 === 'string' ? parseFloat(currentItem.value.data.x1) : currentItem.value.data.x1 || 0;
|
|
459
409
|
const y1 = typeof currentItem.value.data.y1 === 'string' ? parseFloat(currentItem.value.data.y1) : currentItem.value.data.y1 || 0;
|
|
460
410
|
const x2 = typeof currentItem.value.data.x2 === 'string' ? parseFloat(currentItem.value.data.x2) : currentItem.value.data.x2 || 0;
|
|
461
411
|
const y2 = typeof currentItem.value.data.y2 === 'string' ? parseFloat(currentItem.value.data.y2) : currentItem.value.data.y2 || 0;
|
|
462
|
-
|
|
463
412
|
if (startX <= x1 + THRESHOLD && startX >= x1 - THRESHOLD && startY <= y1 + THRESHOLD && startY >= y1 - THRESHOLD) {
|
|
464
413
|
ctx.zone = 'TOP';
|
|
465
414
|
} else if (startX <= x2 + THRESHOLD && startX >= x2 - THRESHOLD && startY - THRESHOLD <= y2 + THRESHOLD && startY + THRESHOLD >= y2 - THRESHOLD) {
|
|
@@ -478,15 +427,12 @@ const DrawCore = /*#__PURE__*/_react.default.forwardRef((_ref, ref) => {
|
|
|
478
427
|
ctx.zone = 'OUT';
|
|
479
428
|
initialItem.value = null;
|
|
480
429
|
}
|
|
481
|
-
|
|
482
430
|
break;
|
|
483
|
-
|
|
484
431
|
case 'text':
|
|
485
432
|
const xText = typeof currentItem.value.data.x === 'string' ? parseFloat(currentItem.value.data.x) : currentItem.value.data.x || 0;
|
|
486
433
|
const yText = typeof currentItem.value.data.y === 'string' ? parseFloat(currentItem.value.data.y) : currentItem.value.data.y || 0;
|
|
487
434
|
const widthText = typeof currentItem.value.data.width === 'string' ? parseFloat(currentItem.value.data.width) : currentItem.value.data.width || 0;
|
|
488
435
|
const heightText = typeof currentItem.value.data.height === 'string' ? parseFloat(currentItem.value.data.height) : currentItem.value.data.height || 0;
|
|
489
|
-
|
|
490
436
|
if (startX <= xText + THRESHOLD && startX >= xText - THRESHOLD && startY <= yText + heightText / 2 + THRESHOLD && startY >= yText + heightText / 2 - THRESHOLD) {
|
|
491
437
|
ctx.zone = 'LEFT';
|
|
492
438
|
} else if (startX <= xText + widthText + THRESHOLD && startX >= xText + widthText - THRESHOLD && startY <= yText + heightText / 2 + THRESHOLD && startY >= yText + heightText / 2 - THRESHOLD) {
|
|
@@ -497,9 +443,7 @@ const DrawCore = /*#__PURE__*/_react.default.forwardRef((_ref, ref) => {
|
|
|
497
443
|
ctx.zone = 'OUT';
|
|
498
444
|
initialItem.value = null;
|
|
499
445
|
}
|
|
500
|
-
|
|
501
446
|
break;
|
|
502
|
-
|
|
503
447
|
case 'pen':
|
|
504
448
|
if (currentItem.value.data.some(p => startX <= p.x + THRESHOLD && startX >= p.x - THRESHOLD && startY <= p.y + THRESHOLD && startY >= p.y - THRESHOLD)) {
|
|
505
449
|
ctx.zone = 'CENTER';
|
|
@@ -507,9 +451,7 @@ const DrawCore = /*#__PURE__*/_react.default.forwardRef((_ref, ref) => {
|
|
|
507
451
|
ctx.zone = 'OUT';
|
|
508
452
|
initialItem.value = null;
|
|
509
453
|
}
|
|
510
|
-
|
|
511
454
|
break;
|
|
512
|
-
|
|
513
455
|
default:
|
|
514
456
|
ctx.zone = 'OUT';
|
|
515
457
|
initialItem.value = null;
|
|
@@ -518,7 +460,6 @@ const DrawCore = /*#__PURE__*/_react.default.forwardRef((_ref, ref) => {
|
|
|
518
460
|
},
|
|
519
461
|
onActive: (_ref3, ctx) => {
|
|
520
462
|
var _currentItem$value4, _initialItem$value, _initialItem$value2, _initialItem$value4, _initialItem$value17, _initialItem$value30;
|
|
521
|
-
|
|
522
463
|
let {
|
|
523
464
|
x: currentX,
|
|
524
465
|
y: currentY,
|
|
@@ -531,14 +472,11 @@ const DrawCore = /*#__PURE__*/_react.default.forwardRef((_ref, ref) => {
|
|
|
531
472
|
zone,
|
|
532
473
|
newlyCreated
|
|
533
474
|
} = ctx;
|
|
534
|
-
|
|
535
475
|
if (zone === 'OUT' && newlyCreated === false) {
|
|
536
476
|
ctx.newlyCreated = true;
|
|
537
|
-
|
|
538
477
|
if (mode.value === 'text') {
|
|
539
478
|
(0, _reactNativeReanimated.runOnJS)(setTextVal)('');
|
|
540
479
|
}
|
|
541
|
-
|
|
542
480
|
drawNewItem(mode, currentItem, addDoneItem, {
|
|
543
481
|
x: startX,
|
|
544
482
|
y: startY
|
|
@@ -550,7 +488,6 @@ const DrawCore = /*#__PURE__*/_react.default.forwardRef((_ref, ref) => {
|
|
|
550
488
|
onSelectionChange && (0, _reactNativeReanimated.runOnJS)(onSelectionChange)(true);
|
|
551
489
|
onCancelChange && (0, _reactNativeReanimated.runOnJS)(onCancelChange)(true);
|
|
552
490
|
}
|
|
553
|
-
|
|
554
491
|
switch ((_currentItem$value4 = currentItem.value) === null || _currentItem$value4 === void 0 ? void 0 : _currentItem$value4.type) {
|
|
555
492
|
case 'pen':
|
|
556
493
|
if (((_initialItem$value = initialItem.value) === null || _initialItem$value === void 0 ? void 0 : _initialItem$value.type) === currentItem.value.type && zone === 'CENTER') {
|
|
@@ -574,18 +511,14 @@ const DrawCore = /*#__PURE__*/_react.default.forwardRef((_ref, ref) => {
|
|
|
574
511
|
})
|
|
575
512
|
};
|
|
576
513
|
}
|
|
577
|
-
|
|
578
514
|
break;
|
|
579
|
-
|
|
580
515
|
case 'ellipse':
|
|
581
516
|
if (((_initialItem$value2 = initialItem.value) === null || _initialItem$value2 === void 0 ? void 0 : _initialItem$value2.type) === currentItem.value.type) {
|
|
582
517
|
var _initialItem$value3;
|
|
583
|
-
|
|
584
518
|
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
519
|
const ry = typeof initialItem.value.data.ry === 'string' ? parseFloat(initialItem.value.data.ry) : initialItem.value.data.ry || 0;
|
|
586
520
|
const cx = typeof initialItem.value.data.cx === 'string' ? parseFloat(initialItem.value.data.cx) : initialItem.value.data.cx || 0;
|
|
587
521
|
const cy = typeof initialItem.value.data.cy === 'string' ? parseFloat(initialItem.value.data.cy) : initialItem.value.data.cy || 0;
|
|
588
|
-
|
|
589
522
|
switch (zone) {
|
|
590
523
|
case 'TOP':
|
|
591
524
|
currentItem.value = {
|
|
@@ -600,7 +533,6 @@ const DrawCore = /*#__PURE__*/_react.default.forwardRef((_ref, ref) => {
|
|
|
600
533
|
}
|
|
601
534
|
};
|
|
602
535
|
break;
|
|
603
|
-
|
|
604
536
|
case 'BOTTOM':
|
|
605
537
|
currentItem.value = {
|
|
606
538
|
type: currentItem.value.type,
|
|
@@ -614,7 +546,6 @@ const DrawCore = /*#__PURE__*/_react.default.forwardRef((_ref, ref) => {
|
|
|
614
546
|
}
|
|
615
547
|
};
|
|
616
548
|
break;
|
|
617
|
-
|
|
618
549
|
case 'LEFT':
|
|
619
550
|
currentItem.value = {
|
|
620
551
|
type: currentItem.value.type,
|
|
@@ -628,7 +559,6 @@ const DrawCore = /*#__PURE__*/_react.default.forwardRef((_ref, ref) => {
|
|
|
628
559
|
}
|
|
629
560
|
};
|
|
630
561
|
break;
|
|
631
|
-
|
|
632
562
|
case 'RIGHT':
|
|
633
563
|
currentItem.value = {
|
|
634
564
|
type: currentItem.value.type,
|
|
@@ -642,7 +572,6 @@ const DrawCore = /*#__PURE__*/_react.default.forwardRef((_ref, ref) => {
|
|
|
642
572
|
}
|
|
643
573
|
};
|
|
644
574
|
break;
|
|
645
|
-
|
|
646
575
|
case 'CENTER':
|
|
647
576
|
currentItem.value = {
|
|
648
577
|
type: currentItem.value.type,
|
|
@@ -670,18 +599,14 @@ const DrawCore = /*#__PURE__*/_react.default.forwardRef((_ref, ref) => {
|
|
|
670
599
|
}
|
|
671
600
|
};
|
|
672
601
|
}
|
|
673
|
-
|
|
674
602
|
break;
|
|
675
|
-
|
|
676
603
|
case 'rectangle':
|
|
677
604
|
if (((_initialItem$value4 = initialItem.value) === null || _initialItem$value4 === void 0 ? void 0 : _initialItem$value4.type) === currentItem.value.type) {
|
|
678
605
|
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
606
|
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
607
|
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
608
|
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
609
|
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
610
|
switch (zone) {
|
|
686
611
|
case 'TOP_LEFT':
|
|
687
612
|
currentItem.value = {
|
|
@@ -696,7 +621,6 @@ const DrawCore = /*#__PURE__*/_react.default.forwardRef((_ref, ref) => {
|
|
|
696
621
|
}
|
|
697
622
|
};
|
|
698
623
|
break;
|
|
699
|
-
|
|
700
624
|
case 'TOP_RIGHT':
|
|
701
625
|
currentItem.value = {
|
|
702
626
|
type: 'rectangle',
|
|
@@ -710,7 +634,6 @@ const DrawCore = /*#__PURE__*/_react.default.forwardRef((_ref, ref) => {
|
|
|
710
634
|
}
|
|
711
635
|
};
|
|
712
636
|
break;
|
|
713
|
-
|
|
714
637
|
case 'BOTTOM_LEFT':
|
|
715
638
|
currentItem.value = {
|
|
716
639
|
type: 'rectangle',
|
|
@@ -724,7 +647,6 @@ const DrawCore = /*#__PURE__*/_react.default.forwardRef((_ref, ref) => {
|
|
|
724
647
|
}
|
|
725
648
|
};
|
|
726
649
|
break;
|
|
727
|
-
|
|
728
650
|
case 'BOTTOM_RIGHT':
|
|
729
651
|
currentItem.value = {
|
|
730
652
|
type: 'rectangle',
|
|
@@ -738,7 +660,6 @@ const DrawCore = /*#__PURE__*/_react.default.forwardRef((_ref, ref) => {
|
|
|
738
660
|
}
|
|
739
661
|
};
|
|
740
662
|
break;
|
|
741
|
-
|
|
742
663
|
case 'CENTER':
|
|
743
664
|
currentItem.value = {
|
|
744
665
|
type: 'rectangle',
|
|
@@ -766,19 +687,15 @@ const DrawCore = /*#__PURE__*/_react.default.forwardRef((_ref, ref) => {
|
|
|
766
687
|
}
|
|
767
688
|
};
|
|
768
689
|
}
|
|
769
|
-
|
|
770
690
|
break;
|
|
771
|
-
|
|
772
691
|
case 'singleHead':
|
|
773
692
|
case 'doubleHead':
|
|
774
693
|
if (((_initialItem$value17 = initialItem.value) === null || _initialItem$value17 === void 0 ? void 0 : _initialItem$value17.type) === currentItem.value.type) {
|
|
775
694
|
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
695
|
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
696
|
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
697
|
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
698
|
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
699
|
switch (zone) {
|
|
783
700
|
case 'TOP':
|
|
784
701
|
currentItem.value = {
|
|
@@ -793,7 +710,6 @@ const DrawCore = /*#__PURE__*/_react.default.forwardRef((_ref, ref) => {
|
|
|
793
710
|
}
|
|
794
711
|
};
|
|
795
712
|
break;
|
|
796
|
-
|
|
797
713
|
case 'BOTTOM':
|
|
798
714
|
currentItem.value = {
|
|
799
715
|
type: currentItem.value.type,
|
|
@@ -807,7 +723,6 @@ const DrawCore = /*#__PURE__*/_react.default.forwardRef((_ref, ref) => {
|
|
|
807
723
|
}
|
|
808
724
|
};
|
|
809
725
|
break;
|
|
810
|
-
|
|
811
726
|
case 'CENTER':
|
|
812
727
|
currentItem.value = {
|
|
813
728
|
type: currentItem.value.type,
|
|
@@ -835,18 +750,14 @@ const DrawCore = /*#__PURE__*/_react.default.forwardRef((_ref, ref) => {
|
|
|
835
750
|
}
|
|
836
751
|
};
|
|
837
752
|
}
|
|
838
|
-
|
|
839
753
|
break;
|
|
840
|
-
|
|
841
754
|
case 'text':
|
|
842
755
|
if (((_initialItem$value30 = initialItem.value) === null || _initialItem$value30 === void 0 ? void 0 : _initialItem$value30.type) === currentItem.value.type) {
|
|
843
756
|
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
757
|
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
758
|
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
759
|
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
760
|
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
761
|
switch (zone) {
|
|
851
762
|
case 'LEFT':
|
|
852
763
|
currentItem.value = {
|
|
@@ -862,7 +773,6 @@ const DrawCore = /*#__PURE__*/_react.default.forwardRef((_ref, ref) => {
|
|
|
862
773
|
}
|
|
863
774
|
};
|
|
864
775
|
break;
|
|
865
|
-
|
|
866
776
|
case 'RIGHT':
|
|
867
777
|
currentItem.value = {
|
|
868
778
|
type: currentItem.value.type,
|
|
@@ -877,7 +787,6 @@ const DrawCore = /*#__PURE__*/_react.default.forwardRef((_ref, ref) => {
|
|
|
877
787
|
}
|
|
878
788
|
};
|
|
879
789
|
break;
|
|
880
|
-
|
|
881
790
|
case 'CENTER':
|
|
882
791
|
currentItem.value = {
|
|
883
792
|
type: currentItem.value.type,
|
|
@@ -907,27 +816,21 @@ const DrawCore = /*#__PURE__*/_react.default.forwardRef((_ref, ref) => {
|
|
|
907
816
|
}
|
|
908
817
|
};
|
|
909
818
|
}
|
|
910
|
-
|
|
911
819
|
}
|
|
912
820
|
},
|
|
913
821
|
onEnd: _event => {
|
|
914
822
|
var _currentItem$value5;
|
|
915
|
-
|
|
916
823
|
panPosition.value = (0, _reactNativeReanimated.withTiming)(0);
|
|
917
|
-
|
|
918
824
|
if (((_currentItem$value5 = currentItem.value) === null || _currentItem$value5 === void 0 ? void 0 : _currentItem$value5.type) === 'text') {
|
|
919
|
-
var _currentItem$value$te;
|
|
920
|
-
|
|
921
825
|
(0, _reactNativeReanimated.runOnJS)(textFocus)();
|
|
922
826
|
currentItem.value = {
|
|
923
827
|
type: currentItem.value.type,
|
|
924
828
|
strokeWidth: currentItem.value.strokeWidth,
|
|
925
829
|
color: currentItem.value.color,
|
|
926
830
|
data: currentItem.value.data,
|
|
927
|
-
text: currentItem.value.text !== DEFAULT_TEXT ?
|
|
831
|
+
text: currentItem.value.text !== DEFAULT_TEXT ? currentItem.value.text ?? '' : ''
|
|
928
832
|
};
|
|
929
833
|
}
|
|
930
|
-
|
|
931
834
|
(0, _reactNativeReanimated.runOnJS)(addScreenStates)(currentItem.value);
|
|
932
835
|
}
|
|
933
836
|
}, []);
|
|
@@ -942,15 +845,14 @@ const DrawCore = /*#__PURE__*/_react.default.forwardRef((_ref, ref) => {
|
|
|
942
845
|
const sudDidHide = _reactNative.Keyboard.addListener('keyboardDidHide', () => {
|
|
943
846
|
showTextInput.value = false;
|
|
944
847
|
});
|
|
945
|
-
|
|
946
848
|
const sudDidShow = _reactNative.Keyboard.addListener('keyboardDidShow', event => {
|
|
947
849
|
// avoid events triggered by InputAccessoryView
|
|
948
850
|
if (event.endCoordinates.height > 100) {
|
|
949
851
|
showTextInput.value = true;
|
|
950
852
|
}
|
|
951
|
-
});
|
|
952
|
-
|
|
853
|
+
});
|
|
953
854
|
|
|
855
|
+
// cleanup function
|
|
954
856
|
return () => {
|
|
955
857
|
sudDidShow.remove();
|
|
956
858
|
sudDidHide.remove();
|
|
@@ -978,12 +880,10 @@ const DrawCore = /*#__PURE__*/_react.default.forwardRef((_ref, ref) => {
|
|
|
978
880
|
};
|
|
979
881
|
}, _ref4 => {
|
|
980
882
|
var _currentItem$value6;
|
|
981
|
-
|
|
982
883
|
let {
|
|
983
884
|
strokeWidth: sw,
|
|
984
885
|
color: c
|
|
985
886
|
} = _ref4;
|
|
986
|
-
|
|
987
887
|
switch ((_currentItem$value6 = currentItem.value) === null || _currentItem$value6 === void 0 ? void 0 : _currentItem$value6.type) {
|
|
988
888
|
case 'singleHead':
|
|
989
889
|
currentItem.value = {
|
|
@@ -993,7 +893,6 @@ const DrawCore = /*#__PURE__*/_react.default.forwardRef((_ref, ref) => {
|
|
|
993
893
|
color: c
|
|
994
894
|
};
|
|
995
895
|
break;
|
|
996
|
-
|
|
997
896
|
case 'doubleHead':
|
|
998
897
|
currentItem.value = {
|
|
999
898
|
type: currentItem.value.type,
|
|
@@ -1002,7 +901,6 @@ const DrawCore = /*#__PURE__*/_react.default.forwardRef((_ref, ref) => {
|
|
|
1002
901
|
color: c
|
|
1003
902
|
};
|
|
1004
903
|
break;
|
|
1005
|
-
|
|
1006
904
|
case 'ellipse':
|
|
1007
905
|
currentItem.value = {
|
|
1008
906
|
type: currentItem.value.type,
|
|
@@ -1011,7 +909,6 @@ const DrawCore = /*#__PURE__*/_react.default.forwardRef((_ref, ref) => {
|
|
|
1011
909
|
color: c
|
|
1012
910
|
};
|
|
1013
911
|
break;
|
|
1014
|
-
|
|
1015
912
|
case 'rectangle':
|
|
1016
913
|
currentItem.value = {
|
|
1017
914
|
type: currentItem.value.type,
|
|
@@ -1020,7 +917,6 @@ const DrawCore = /*#__PURE__*/_react.default.forwardRef((_ref, ref) => {
|
|
|
1020
917
|
color: c
|
|
1021
918
|
};
|
|
1022
919
|
break;
|
|
1023
|
-
|
|
1024
920
|
case 'pen':
|
|
1025
921
|
currentItem.value = {
|
|
1026
922
|
type: currentItem.value.type,
|
|
@@ -1029,7 +925,6 @@ const DrawCore = /*#__PURE__*/_react.default.forwardRef((_ref, ref) => {
|
|
|
1029
925
|
color: c
|
|
1030
926
|
};
|
|
1031
927
|
break;
|
|
1032
|
-
|
|
1033
928
|
case 'text':
|
|
1034
929
|
currentItem.value = {
|
|
1035
930
|
type: currentItem.value.type,
|
|
@@ -1048,18 +943,13 @@ const DrawCore = /*#__PURE__*/_react.default.forwardRef((_ref, ref) => {
|
|
|
1048
943
|
color.value = item.color;
|
|
1049
944
|
currentItem.value = item;
|
|
1050
945
|
deleteDoneItem(index);
|
|
1051
|
-
|
|
1052
946
|
if (previousItem) {
|
|
1053
947
|
addDoneItem(previousItem);
|
|
1054
948
|
}
|
|
1055
|
-
|
|
1056
949
|
if (item.type === 'text') {
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
setTextVal((_item$text = item.text) !== null && _item$text !== void 0 ? _item$text : '');
|
|
950
|
+
setTextVal(item.text ?? '');
|
|
1060
951
|
} else {
|
|
1061
952
|
var _textInputRef$current2;
|
|
1062
|
-
|
|
1063
953
|
(_textInputRef$current2 = textInputRef.current) === null || _textInputRef$current2 === void 0 ? void 0 : _textInputRef$current2.blur();
|
|
1064
954
|
}
|
|
1065
955
|
}, [onSelectionChange, currentItem, strokeWidth, color, deleteDoneItem, addDoneItem]);
|
|
@@ -1073,7 +963,6 @@ const DrawCore = /*#__PURE__*/_react.default.forwardRef((_ref, ref) => {
|
|
|
1073
963
|
height: imageHeight
|
|
1074
964
|
});
|
|
1075
965
|
const ratioImageHeight = Math.round(imageHeight * drawRegion.width / imageWidth * 100) / 100;
|
|
1076
|
-
|
|
1077
966
|
if (ratioImageHeight < drawRegion.height) {
|
|
1078
967
|
setImageSize({
|
|
1079
968
|
width: drawRegion.width,
|
|
@@ -1091,7 +980,6 @@ const DrawCore = /*#__PURE__*/_react.default.forwardRef((_ref, ref) => {
|
|
|
1091
980
|
if (drawRegion && image) {
|
|
1092
981
|
if (typeof image === 'number') {
|
|
1093
982
|
const infos = _reactNative.Image.resolveAssetSource(image);
|
|
1094
|
-
|
|
1095
983
|
calculateSizes(infos.width, infos.height);
|
|
1096
984
|
} else if (image.uri) {
|
|
1097
985
|
_reactNative.Image.getSize(image.uri, (imageWidth, imageHeight) => {
|
|
@@ -1103,7 +991,9 @@ const DrawCore = /*#__PURE__*/_react.default.forwardRef((_ref, ref) => {
|
|
|
1103
991
|
return /*#__PURE__*/_react.default.createElement(_reactNative.View, {
|
|
1104
992
|
style: styles.container
|
|
1105
993
|
}, /*#__PURE__*/_react.default.createElement(_reactNative.View, {
|
|
1106
|
-
style: styles.drawZone,
|
|
994
|
+
style: [styles.drawZone, {
|
|
995
|
+
backgroundColor: backgroundColor ?? '#FFF'
|
|
996
|
+
}],
|
|
1107
997
|
onLayout: event => {
|
|
1108
998
|
setDrawRegion({
|
|
1109
999
|
height: event.nativeEvent.layout.height,
|
|
@@ -1177,7 +1067,6 @@ const DrawCore = /*#__PURE__*/_react.default.forwardRef((_ref, ref) => {
|
|
|
1177
1067
|
autoCorrect: false
|
|
1178
1068
|
})));
|
|
1179
1069
|
});
|
|
1180
|
-
|
|
1181
1070
|
var _default = DrawCore;
|
|
1182
1071
|
exports.default = _default;
|
|
1183
1072
|
//# sourceMappingURL=index.js.map
|