@archireport/react-native-svg-draw 3.1.2 → 3.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +1 -1
- package/README.md +9 -2
- package/lib/commonjs/components/DrawCore/CurrentAnimatedItem.js +159 -148
- package/lib/commonjs/components/DrawCore/CurrentAnimatedItem.js.map +1 -1
- package/lib/commonjs/components/DrawCore/CurrentAnimatedText.js +18 -17
- package/lib/commonjs/components/DrawCore/CurrentAnimatedText.js.map +1 -1
- package/lib/commonjs/components/DrawCore/DrawPad.js +2 -2
- package/lib/commonjs/components/DrawCore/DrawPad.js.map +1 -1
- package/lib/commonjs/components/DrawCore/index.js +54 -14
- package/lib/commonjs/components/DrawCore/index.js.map +1 -1
- package/lib/commonjs/components/DrawCore/useDrawHook.js +1 -3
- package/lib/commonjs/components/DrawCore/useDrawHook.js.map +1 -1
- package/lib/commonjs/components/DrawWithOptions/index.js +6 -2
- package/lib/commonjs/components/DrawWithOptions/index.js.map +1 -1
- package/lib/commonjs/components/Slider/ColorSlider.js +18 -30
- package/lib/commonjs/components/Slider/ColorSlider.js.map +1 -1
- package/lib/commonjs/components/Slider/Sliders.js +1 -1
- package/lib/commonjs/components/Slider/Sliders.js.map +1 -1
- package/lib/commonjs/components/Slider/StrokeSlider.js +11 -23
- package/lib/commonjs/components/Slider/StrokeSlider.js.map +1 -1
- package/lib/module/components/DrawCore/CurrentAnimatedItem.js +158 -148
- package/lib/module/components/DrawCore/CurrentAnimatedItem.js.map +1 -1
- package/lib/module/components/DrawCore/CurrentAnimatedText.js +19 -18
- package/lib/module/components/DrawCore/CurrentAnimatedText.js.map +1 -1
- package/lib/module/components/DrawCore/DrawPad.js +2 -2
- package/lib/module/components/DrawCore/DrawPad.js.map +1 -1
- package/lib/module/components/DrawCore/index.js +54 -14
- package/lib/module/components/DrawCore/index.js.map +1 -1
- package/lib/module/components/DrawCore/useDrawHook.js +1 -3
- package/lib/module/components/DrawCore/useDrawHook.js.map +1 -1
- package/lib/module/components/DrawWithOptions/index.js +6 -2
- package/lib/module/components/DrawWithOptions/index.js.map +1 -1
- package/lib/module/components/Slider/ColorSlider.js +20 -32
- package/lib/module/components/Slider/ColorSlider.js.map +1 -1
- package/lib/module/components/Slider/Sliders.js +1 -1
- package/lib/module/components/Slider/Sliders.js.map +1 -1
- package/lib/module/components/Slider/StrokeSlider.js +13 -25
- package/lib/module/components/Slider/StrokeSlider.js.map +1 -1
- package/lib/typescript/components/DrawCore/CurrentAnimatedItem.d.ts +1 -0
- package/lib/typescript/components/DrawCore/CurrentAnimatedItem.d.ts.map +1 -1
- package/lib/typescript/components/DrawCore/CurrentAnimatedText.d.ts.map +1 -1
- package/lib/typescript/components/DrawCore/DrawPad.d.ts.map +1 -1
- package/lib/typescript/components/DrawCore/index.d.ts.map +1 -1
- package/lib/typescript/components/DrawCore/useDrawHook.d.ts.map +1 -1
- package/lib/typescript/components/DrawWithOptions/index.d.ts +3 -4
- package/lib/typescript/components/DrawWithOptions/index.d.ts.map +1 -1
- package/lib/typescript/components/Slider/ColorSlider.d.ts +2 -3
- package/lib/typescript/components/Slider/ColorSlider.d.ts.map +1 -1
- package/lib/typescript/components/Slider/Sliders.d.ts +2 -3
- package/lib/typescript/components/Slider/Sliders.d.ts.map +1 -1
- package/lib/typescript/components/Slider/StrokeSlider.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/components/DrawCore/CurrentAnimatedItem.tsx +285 -333
- package/src/components/DrawCore/CurrentAnimatedText.tsx +14 -11
- package/src/components/DrawCore/DrawPad.tsx +4 -1
- package/src/components/DrawCore/index.tsx +77 -25
- package/src/components/DrawCore/useDrawHook.tsx +1 -2
- package/src/components/DrawWithOptions/index.tsx +12 -4
- package/src/components/Slider/ColorSlider.tsx +42 -50
- package/src/components/Slider/Sliders.tsx +4 -4
- package/src/components/Slider/StrokeSlider.tsx +24 -33
- package/src/types.d.ts +5 -0
|
@@ -31,6 +31,7 @@ const ColorSlider = _ref => {
|
|
|
31
31
|
color
|
|
32
32
|
} = (0, _useDrawHook.default)();
|
|
33
33
|
const sliderWidth = (0, _reactNativeReanimated.useSharedValue)(0);
|
|
34
|
+
const gestureStartX = (0, _reactNativeReanimated.useSharedValue)(0);
|
|
34
35
|
const position = (0, _reactNativeReanimated.useDerivedValue)(() => {
|
|
35
36
|
const hslRegExp = new RegExp(/hsl\(([\d.]+),\s*(\d+)%,\s*([\d.]+)%\)/);
|
|
36
37
|
const res = hslRegExp.exec(color.value);
|
|
@@ -43,51 +44,38 @@ const ColorSlider = _ref => {
|
|
|
43
44
|
return sliderWidth.value - sliderWidth.value * 0.1 / 50 * lum;
|
|
44
45
|
}
|
|
45
46
|
return Math.min(sliderWidth.value, Math.max(0, sliderWidth.value * 0.1 + tint * ((sliderWidth.value - sliderWidth.value * 0.2) / 360)));
|
|
46
|
-
}
|
|
47
|
+
});
|
|
47
48
|
const wrapperOnColorChange = () => {
|
|
48
49
|
onColorStrokeChange();
|
|
49
50
|
};
|
|
50
|
-
const
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
} = _ref3;
|
|
61
|
-
let {
|
|
62
|
-
startX
|
|
63
|
-
} = _ref4;
|
|
64
|
-
const slidePos = Math.min(sliderWidth.value, startX + translationX);
|
|
65
|
-
if (slidePos < 0.1 * sliderWidth.value) {
|
|
66
|
-
color.value = `hsl(0, 100%, ${Math.min(100, 100 - slidePos / (0.1 * sliderWidth.value) * 50).toFixed(10)}%)`;
|
|
67
|
-
} else if (slidePos > 0.9 * sliderWidth.value) {
|
|
68
|
-
color.value = `hsl(0, 100%, ${Math.max(50 - (slidePos - 0.9 * sliderWidth.value) / (0.1 * sliderWidth.value) * 50, 0).toFixed(10)}%)`;
|
|
69
|
-
} else {
|
|
70
|
-
color.value = `hsl(${(slidePos - sliderWidth.value * 0.1) / (sliderWidth.value - sliderWidth.value * 0.2) * 360}, 100%, 50%)`;
|
|
71
|
-
}
|
|
72
|
-
},
|
|
73
|
-
onEnd: () => {
|
|
74
|
-
(0, _reactNativeReanimated.runOnJS)(wrapperOnColorChange)();
|
|
51
|
+
const panGesture = _reactNativeGestureHandler.Gesture.Pan().onStart(event => {
|
|
52
|
+
gestureStartX.value = event.x;
|
|
53
|
+
}).onUpdate(event => {
|
|
54
|
+
const slidePos = Math.min(sliderWidth.value, gestureStartX.value + event.translationX);
|
|
55
|
+
if (slidePos < 0.1 * sliderWidth.value) {
|
|
56
|
+
color.value = `hsl(0, 100%, ${Math.min(100, 100 - slidePos / (0.1 * sliderWidth.value) * 50).toFixed(10)}%)`;
|
|
57
|
+
} else if (slidePos > 0.9 * sliderWidth.value) {
|
|
58
|
+
color.value = `hsl(0, 100%, ${Math.max(50 - (slidePos - 0.9 * sliderWidth.value) / (0.1 * sliderWidth.value) * 50, 0).toFixed(10)}%)`;
|
|
59
|
+
} else {
|
|
60
|
+
color.value = `hsl(${(slidePos - sliderWidth.value * 0.1) / (sliderWidth.value - sliderWidth.value * 0.2) * 360}, 100%, 50%)`;
|
|
75
61
|
}
|
|
76
|
-
}
|
|
62
|
+
}).onEnd(() => {
|
|
63
|
+
(0, _reactNativeReanimated.runOnJS)(wrapperOnColorChange)();
|
|
64
|
+
});
|
|
77
65
|
const style = (0, _reactNativeReanimated.useAnimatedStyle)(() => {
|
|
78
66
|
return {
|
|
79
67
|
transform: [{
|
|
80
68
|
translateX: position.value - _sliderStyle.TRACK_R
|
|
81
69
|
}]
|
|
82
70
|
};
|
|
83
|
-
}
|
|
71
|
+
});
|
|
84
72
|
const onLayout = (0, _react.useCallback)(event => {
|
|
85
73
|
sliderWidth.value = event.nativeEvent.layout.width;
|
|
86
74
|
}, [sliderWidth]);
|
|
87
75
|
return /*#__PURE__*/_react.default.createElement(_reactNative.View, {
|
|
88
76
|
style: _sliderStyle.sliderStyle.container
|
|
89
|
-
}, /*#__PURE__*/_react.default.createElement(_reactNativeGestureHandler.
|
|
90
|
-
|
|
77
|
+
}, /*#__PURE__*/_react.default.createElement(_reactNativeGestureHandler.GestureDetector, {
|
|
78
|
+
gesture: panGesture
|
|
91
79
|
}, /*#__PURE__*/_react.default.createElement(_reactNativeReanimated.default.View, {
|
|
92
80
|
style: _sliderStyle.sliderStyle.container
|
|
93
81
|
}, /*#__PURE__*/_react.default.createElement(LinearGradient, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["gradientColors","gradientStart","x","y","gradientEnd","ColorSlider","linearGradient","LinearGradient","onColorStrokeChange","color","useDrawHook","sliderWidth","useSharedValue","position","useDerivedValue","hslRegExp","RegExp","res","exec","value","lum","parseFloat","tint","Math","min","max","wrapperOnColorChange","
|
|
1
|
+
{"version":3,"names":["gradientColors","gradientStart","x","y","gradientEnd","ColorSlider","linearGradient","LinearGradient","onColorStrokeChange","color","useDrawHook","sliderWidth","useSharedValue","gestureStartX","position","useDerivedValue","hslRegExp","RegExp","res","exec","value","lum","parseFloat","tint","Math","min","max","wrapperOnColorChange","panGesture","Gesture","Pan","onStart","event","onUpdate","slidePos","translationX","toFixed","onEnd","runOnJS","style","useAnimatedStyle","transform","translateX","TRACK_R","onLayout","useCallback","nativeEvent","layout","width","sliderStyle","container","track","thumb"],"sourceRoot":"../../../../src","sources":["components/Slider/ColorSlider.tsx"],"mappings":";;;;;;AAAA;AACA;AACA;AAEA;AACA;AAOA;AAAkD;AAAA;AAAA;AAElD,MAAMA,cAAc,GAAG,CACrB,wBAAwB,EACxB,uBAAuB,EACvB,wBAAwB,EACxB,wBAAwB,EACxB,yBAAyB,EACzB,yBAAyB,EACzB,yBAAyB,EACzB,yBAAyB,EACzB,yBAAyB,EACzB,yBAAyB,EACzB,yBAAyB,CAC1B;AAED,MAAMC,aAAa,GAAG;EAAEC,CAAC,EAAE,CAAC;EAAEC,CAAC,EAAE;AAAE,CAAC;AACpC,MAAMC,WAAW,GAAG;EAAEF,CAAC,EAAE,CAAC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EAAE;EACjC,CAAC,CAAC;EAEJ,MAAMY,KAAK,GAAG,IAAAC,uCAAgB,EAAC,MAAM;IACnC,OAAO;MACLC,SAAS,EAAE,CAAC;QAAEC,UAAU,EAAE5B,QAAQ,CAACM,KAAK,GAAGuB;MAAQ,CAAC;IACtD,CAAC;EACH,CAAC,CAAC;EAEF,MAAMC,QAAQ,GAAG,IAAAC,kBAAW,EACzBb,KAAwB,IAAK;IAC5BrB,WAAW,CAACS,KAAK,GAAGY,KAAK,CAACc,WAAW,CAACC,MAAM,CAACC,KAAK;EACpD,CAAC,EACD,CAACrC,WAAW,CAAC,CACd;EAED,oBACE,6BAAC,iBAAI;IAAC,KAAK,EAAEsC,wBAAW,CAACC;EAAU,gBACjC,6BAAC,0CAAe;IAAC,OAAO,EAAEtB;EAAW,gBACnC,6BAAC,8BAAQ,CAAC,IAAI;IAAC,KAAK,EAAEqB,wBAAW,CAACC;EAAU,gBAC1C,6BAAC,cAAc;IACb,KAAK,EAAEjD,aAAc;IACrB,GAAG,EAAEG,WAAY;IACjB,MAAM,EAAEJ,cAAe;IACvB,QAAQ,EAAE4C,QAAS;IACnB,KAAK,EAAEK,wBAAW,CAACE;EAAM,EACzB,eACF,6BAAC,8BAAQ,CAAC,IAAI;IAAC,KAAK,EAAE,CAACF,wBAAW,CAACG,KAAK,EAAEb,KAAK;EAAE,EAAG,CACtC,CACA,CACb;AAEX,CAAC;AAAC,eAEalC,WAAW;AAAA"}
|
|
@@ -65,7 +65,7 @@ const Sliders = _ref => {
|
|
|
65
65
|
borderWidth: strokeWidth.value,
|
|
66
66
|
borderColor: color.value
|
|
67
67
|
};
|
|
68
|
-
}
|
|
68
|
+
});
|
|
69
69
|
return /*#__PURE__*/_react.default.createElement(_reactNative.View, {
|
|
70
70
|
style: styles.strokeContainer
|
|
71
71
|
}, /*#__PURE__*/_react.default.createElement(_reactNative.View, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["styles","StyleSheet","create","strokeContainer","flexDirection","marginTop","borderColor","borderRadius","height","borderWidth","marginHorizontal","maxWidth","alignSelf","strokeWrapper","flex","justifyContent","currentColorContainer","alignContent","padding","currentColor","width","colorContainer","Sliders","linearGradient","strokeWidth","color","useDrawHook","styleStrokeColor","useAnimatedStyle","value"],"sourceRoot":"../../../../src","sources":["components/Slider/Sliders.tsx"],"mappings":";;;;;;AAAA;AACA;AACA;AACA;AACA;AAEA;AAAkD;AAAA;AAAA;AAGlD,MAAMA,MAAM,GAAGC,uBAAU,CAACC,MAAM,CAAC;EAC/BC,eAAe,EAAE;IACfC,aAAa,EAAE,KAAK;IACpBC,SAAS,EAAE,EAAE;IACbC,WAAW,EAAE,MAAM;IACnBC,YAAY,EAAE,EAAE;IAChBC,MAAM,EAAE,EAAE;IACVC,WAAW,EAAE,CAAC;IACdC,gBAAgB,EAAE,EAAE;IACpBC,QAAQ,EAAE,GAAG;IACbC,SAAS,EAAE;EACb,CAAC;EACDC,aAAa,EAAE;IACbC,IAAI,EAAE,CAAC;IACPN,MAAM,EAAE,EAAE;IACVE,gBAAgB,EAAE,EAAE;IACpBK,cAAc,EAAE;EAClB,CAAC;EACDC,qBAAqB,EAAE;IACrBT,YAAY,EAAE,EAAE;IAChBE,WAAW,EAAE,CAAC;IACdH,WAAW,EAAE,SAAS;IACtBS,cAAc,EAAE,QAAQ;IACxBE,YAAY,EAAE,QAAQ;IACtBL,SAAS,EAAE,QAAQ;IACnBM,OAAO,EAAE;EACX,CAAC;EACDC,YAAY,EAAE;IAAEC,KAAK,EAAE,EAAE;IAAEZ,MAAM,EAAE,EAAE;IAAED,YAAY,EAAE;EAAG,CAAC;EACzDc,cAAc,EAAE;IACdP,IAAI,EAAE,CAAC;IACPN,MAAM,EAAE,EAAE;IACVE,gBAAgB,EAAE,EAAE;IACpBK,cAAc,EAAE;EAClB;AACF,CAAC,CAAC;AAEF,MAAMO,OAAO,GAAG,QAIV;EAAA,IAJW;IACfC;EAGF,CAAC;EACC,MAAM;IAAEC,WAAW;IAAEC;EAAM,CAAC,GAAG,IAAAC,oBAAW,GAAE;EAE5C,MAAMC,gBAAgB,GAAG,IAAAC,uCAAgB,EAAC,MAAM;IAC9C,OAAO;MACLnB,WAAW,EAAEe,WAAW,CAAEK,KAAK;MAC/BvB,WAAW,EAAEmB,KAAK,CAAEI;IACtB,CAAC;EACH,CAAC,
|
|
1
|
+
{"version":3,"names":["styles","StyleSheet","create","strokeContainer","flexDirection","marginTop","borderColor","borderRadius","height","borderWidth","marginHorizontal","maxWidth","alignSelf","strokeWrapper","flex","justifyContent","currentColorContainer","alignContent","padding","currentColor","width","colorContainer","Sliders","linearGradient","strokeWidth","color","useDrawHook","styleStrokeColor","useAnimatedStyle","value"],"sourceRoot":"../../../../src","sources":["components/Slider/Sliders.tsx"],"mappings":";;;;;;AAAA;AACA;AACA;AACA;AACA;AAEA;AAAkD;AAAA;AAAA;AAGlD,MAAMA,MAAM,GAAGC,uBAAU,CAACC,MAAM,CAAC;EAC/BC,eAAe,EAAE;IACfC,aAAa,EAAE,KAAK;IACpBC,SAAS,EAAE,EAAE;IACbC,WAAW,EAAE,MAAM;IACnBC,YAAY,EAAE,EAAE;IAChBC,MAAM,EAAE,EAAE;IACVC,WAAW,EAAE,CAAC;IACdC,gBAAgB,EAAE,EAAE;IACpBC,QAAQ,EAAE,GAAG;IACbC,SAAS,EAAE;EACb,CAAC;EACDC,aAAa,EAAE;IACbC,IAAI,EAAE,CAAC;IACPN,MAAM,EAAE,EAAE;IACVE,gBAAgB,EAAE,EAAE;IACpBK,cAAc,EAAE;EAClB,CAAC;EACDC,qBAAqB,EAAE;IACrBT,YAAY,EAAE,EAAE;IAChBE,WAAW,EAAE,CAAC;IACdH,WAAW,EAAE,SAAS;IACtBS,cAAc,EAAE,QAAQ;IACxBE,YAAY,EAAE,QAAQ;IACtBL,SAAS,EAAE,QAAQ;IACnBM,OAAO,EAAE;EACX,CAAC;EACDC,YAAY,EAAE;IAAEC,KAAK,EAAE,EAAE;IAAEZ,MAAM,EAAE,EAAE;IAAED,YAAY,EAAE;EAAG,CAAC;EACzDc,cAAc,EAAE;IACdP,IAAI,EAAE,CAAC;IACPN,MAAM,EAAE,EAAE;IACVE,gBAAgB,EAAE,EAAE;IACpBK,cAAc,EAAE;EAClB;AACF,CAAC,CAAC;AAEF,MAAMO,OAAO,GAAG,QAIV;EAAA,IAJW;IACfC;EAGF,CAAC;EACC,MAAM;IAAEC,WAAW;IAAEC;EAAM,CAAC,GAAG,IAAAC,oBAAW,GAAE;EAE5C,MAAMC,gBAAgB,GAAG,IAAAC,uCAAgB,EAAC,MAAM;IAC9C,OAAO;MACLnB,WAAW,EAAEe,WAAW,CAAEK,KAAK;MAC/BvB,WAAW,EAAEmB,KAAK,CAAEI;IACtB,CAAC;EACH,CAAC,CAAC;EAEF,oBACE,6BAAC,iBAAI;IAAC,KAAK,EAAE7B,MAAM,CAACG;EAAgB,gBAClC,6BAAC,iBAAI;IAAC,KAAK,EAAEH,MAAM,CAACa;EAAc,gBAChC,6BAAC,qBAAY;IAAC,QAAQ,EAAE,CAAE;IAAC,QAAQ,EAAE;EAAG,EAAG,CACtC,eACP,6BAAC,iBAAI;IAAC,KAAK,EAAEb,MAAM,CAACgB;EAAsB,gBACxC,6BAAC,8BAAQ,CAAC,IAAI;IAAC,KAAK,EAAE,CAAChB,MAAM,CAACmB,YAAY,EAAEQ,gBAAgB;EAAE,EAAG,CAC5D,eACP,6BAAC,iBAAI;IAAC,KAAK,EAAE3B,MAAM,CAACqB;EAAe,gBACjC,6BAAC,oBAAW;IAAC,cAAc,EAAEE;EAAe,EAAG,CAC1C,CACF;AAEX,CAAC;AAAC,eAEaD,OAAO;AAAA"}
|
|
@@ -34,43 +34,31 @@ const StrokeSlider = _ref => {
|
|
|
34
34
|
strokeWidth
|
|
35
35
|
} = (0, _useDrawHook.default)();
|
|
36
36
|
const sliderWidth = (0, _reactNativeReanimated.useSharedValue)(0);
|
|
37
|
+
const gestureStartX = (0, _reactNativeReanimated.useSharedValue)(0);
|
|
37
38
|
const position = (0, _reactNativeReanimated.useDerivedValue)(() => {
|
|
38
39
|
return sliderWidth.value / (maxValue - minValue) * (strokeWidth.value - minValue);
|
|
39
40
|
});
|
|
40
41
|
const wrapperOnColorStrokeChange = () => {
|
|
41
42
|
onColorStrokeChange();
|
|
42
43
|
};
|
|
43
|
-
const
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
onActive: (_ref3, _ref4) => {
|
|
51
|
-
let {
|
|
52
|
-
translationX
|
|
53
|
-
} = _ref3;
|
|
54
|
-
let {
|
|
55
|
-
startX
|
|
56
|
-
} = _ref4;
|
|
57
|
-
strokeWidth.value = Math.min(maxValue, Math.max(minValue, (startX + translationX) / sliderWidth.value * (maxValue - minValue) + minValue));
|
|
58
|
-
},
|
|
59
|
-
onEnd: () => {
|
|
60
|
-
(0, _reactNativeReanimated.runOnJS)(wrapperOnColorStrokeChange)();
|
|
61
|
-
}
|
|
62
|
-
}, []);
|
|
44
|
+
const panGesture = _reactNativeGestureHandler.Gesture.Pan().onStart(event => {
|
|
45
|
+
gestureStartX.value = event.x;
|
|
46
|
+
}).onUpdate(event => {
|
|
47
|
+
strokeWidth.value = Math.min(maxValue, Math.max(minValue, (gestureStartX.value + event.translationX) / sliderWidth.value * (maxValue - minValue) + minValue));
|
|
48
|
+
}).onEnd(() => {
|
|
49
|
+
(0, _reactNativeReanimated.runOnJS)(wrapperOnColorStrokeChange)();
|
|
50
|
+
});
|
|
63
51
|
const style = (0, _reactNativeReanimated.useAnimatedStyle)(() => {
|
|
64
52
|
return {
|
|
65
53
|
transform: [{
|
|
66
54
|
translateX: position.value - _sliderStyle.TRACK_R
|
|
67
55
|
}]
|
|
68
56
|
};
|
|
69
|
-
}
|
|
57
|
+
});
|
|
70
58
|
return /*#__PURE__*/_react.default.createElement(_reactNative.View, {
|
|
71
59
|
style: _sliderStyle.sliderStyle.container
|
|
72
|
-
}, /*#__PURE__*/_react.default.createElement(_reactNativeGestureHandler.
|
|
73
|
-
|
|
60
|
+
}, /*#__PURE__*/_react.default.createElement(_reactNativeGestureHandler.GestureDetector, {
|
|
61
|
+
gesture: panGesture
|
|
74
62
|
}, /*#__PURE__*/_react.default.createElement(_reactNativeReanimated.default.View, {
|
|
75
63
|
style: _sliderStyle.sliderStyle.container
|
|
76
64
|
}, /*#__PURE__*/_react.default.createElement(_reactNative.View, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["styles","StyleSheet","create","container","height","width","justifyContent","sliderBackground","maxHeight","StrokeSlider","minValue","maxValue","onColorStrokeChange","strokeWidth","useDrawHook","sliderWidth","useSharedValue","position","useDerivedValue","value","wrapperOnColorStrokeChange","
|
|
1
|
+
{"version":3,"names":["styles","StyleSheet","create","container","height","width","justifyContent","sliderBackground","maxHeight","StrokeSlider","minValue","maxValue","onColorStrokeChange","strokeWidth","useDrawHook","sliderWidth","useSharedValue","gestureStartX","position","useDerivedValue","value","wrapperOnColorStrokeChange","panGesture","Gesture","Pan","onStart","event","x","onUpdate","Math","min","max","translationX","onEnd","runOnJS","style","useAnimatedStyle","transform","translateX","TRACK_R","sliderStyle","nativeEvent","layout","thumb"],"sourceRoot":"../../../../src","sources":["components/Slider/StrokeSlider.tsx"],"mappings":";;;;;;AAAA;AACA;AACA;AAMA;AACA;AACA;AACA;AAAqD;AAAA;AAAA;AAGrD,MAAMA,MAAM,GAAGC,uBAAU,CAACC,MAAM,CAAC;EAC/BC,SAAS,EAAE;IACTC,MAAM,EAAE,EAAE;IACVC,KAAK,EAAE,MAAM;IACbC,cAAc,EAAE;EAClB,CAAC;EACDC,gBAAgB,EAAE;IAChBC,SAAS,EAAE;EACb;AACF,CAAC,CAAC;AAEF,MAAMC,YAAY,GAAG,QAMf;EAAA,IANgB;IACpBC,QAAQ;IACRC;EAIF,CAAC;EACC,MAAM;IAAEC,mBAAmB;IAAEC;EAAY,CAAC,GAAG,IAAAC,oBAAW,GAAE;E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,IAAI;IAAC,KAAK,EAAEkB,wBAAW,CAACrC;EAAU,gBAC1C,6BAAC,iBAAI;IACH,QAAQ,EAAGuB,KAAK,IAAK;MACnBX,WAAW,CAACK,KAAK,GAAGM,KAAK,CAACe,WAAW,CAACC,MAAM,CAACrC,KAAK;IACpD,CAAE;IACF,KAAK,EAAEL,MAAM,CAACG;EAAU,gBAExB,6BAAC,kBAAS;IACR,KAAK,EAAC,MAAM;IACZ,mBAAmB,EAAC,MAAM;IAC1B,KAAK,EAAEH,MAAM,CAACO;EAAiB,EAC/B,CACG,eACP,6BAAC,8BAAQ,CAAC,IAAI;IAAC,KAAK,EAAE,CAACiC,wBAAW,CAACG,KAAK,EAAER,KAAK;EAAE,EAAG,CACtC,CACA,CACb;AAEX,CAAC;AAAC,eACa1B,YAAY;AAAA"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import Animated, {
|
|
1
|
+
import React, { useState } from 'react';
|
|
2
|
+
import Animated, { runOnJS, useAnimatedProps, useAnimatedReaction, useAnimatedStyle } from 'react-native-reanimated';
|
|
3
3
|
import { Path, Ellipse, Rect, Line, G } from 'react-native-svg';
|
|
4
4
|
import { TextInput } from 'react-native';
|
|
5
5
|
import useDrawHook from './useDrawHook';
|
|
@@ -13,8 +13,6 @@ const AnimatedLine = Animated.createAnimatedComponent(Line);
|
|
|
13
13
|
|
|
14
14
|
//const AnimatedText = Animated.createAnimatedComponent(Text);
|
|
15
15
|
|
|
16
|
-
const AnimatedTextInput = Animated.createAnimatedComponent(TextInput);
|
|
17
|
-
|
|
18
16
|
// properties of a line
|
|
19
17
|
const line = (pointA, pointB) => {
|
|
20
18
|
'worklet';
|
|
@@ -71,7 +69,18 @@ const bezierCommand = (point, i, a) => {
|
|
|
71
69
|
export const pointsToPath = points => {
|
|
72
70
|
'worklet';
|
|
73
71
|
|
|
74
|
-
|
|
72
|
+
if (points.length === 0) {
|
|
73
|
+
return '';
|
|
74
|
+
}
|
|
75
|
+
let path = '';
|
|
76
|
+
for (let index = 0; index < points.length; index += 1) {
|
|
77
|
+
const point = points[index];
|
|
78
|
+
if (!point) {
|
|
79
|
+
continue;
|
|
80
|
+
}
|
|
81
|
+
path = index === 0 ? `M ${point.x},${point.y}` : `${path} ${bezierCommand(point, index, points)}`;
|
|
82
|
+
}
|
|
83
|
+
return path;
|
|
75
84
|
};
|
|
76
85
|
function hue2rgb(p, q, t) {
|
|
77
86
|
'worklet';
|
|
@@ -115,25 +124,9 @@ export function hslToRgb(col) {
|
|
|
115
124
|
}
|
|
116
125
|
return `rgb(${Math.round(r * 255)}, ${Math.round(g * 255)}, ${Math.round(b * 255)})`;
|
|
117
126
|
}
|
|
118
|
-
const propAdapter = createAnimatedPropAdapter(props => {
|
|
119
|
-
if (Object.keys(props).includes('fill') && (typeof props.fill === 'string' || typeof props.fill === 'number')) {
|
|
120
|
-
props.fill = {
|
|
121
|
-
type: 0,
|
|
122
|
-
payload: processColor(props.fill)
|
|
123
|
-
};
|
|
124
|
-
}
|
|
125
|
-
if (Object.keys(props).includes('stroke') && (typeof props.stroke === 'string' || typeof props.stroke === 'number')) {
|
|
126
|
-
props.stroke = {
|
|
127
|
-
type: 0,
|
|
128
|
-
payload: processColor(props.stroke)
|
|
129
|
-
};
|
|
130
|
-
}
|
|
131
|
-
}, ['fill', 'stroke']);
|
|
132
127
|
export default function CurrentAnimatedItem() {
|
|
133
|
-
var _currentItem$value30, _currentItem$value31, _currentItem$value32, _currentItem$value33, _currentItem$value34, _currentItem$value36, _currentItem$value37, _currentItem$value38;
|
|
134
128
|
const {
|
|
135
|
-
currentItem
|
|
136
|
-
doubleArrowTextInput
|
|
129
|
+
currentItem
|
|
137
130
|
} = useDrawHook();
|
|
138
131
|
const getTextLength = () => {
|
|
139
132
|
'worklet';
|
|
@@ -144,7 +137,9 @@ export default function CurrentAnimatedItem() {
|
|
|
144
137
|
return textLength;
|
|
145
138
|
};
|
|
146
139
|
const ellipseAnimatedProps = useAnimatedProps(() => {
|
|
147
|
-
|
|
140
|
+
'worklet';
|
|
141
|
+
|
|
142
|
+
var _currentItem$value3, _currentItem$value4, _currentItem$value5, _currentItem$value6;
|
|
148
143
|
const coordinates = ((_currentItem$value3 = currentItem.value) === null || _currentItem$value3 === void 0 ? void 0 : _currentItem$value3.type) === 'ellipse' ? currentItem.value.data : {
|
|
149
144
|
cx: -10,
|
|
150
145
|
cy: -10,
|
|
@@ -157,15 +152,17 @@ export default function CurrentAnimatedItem() {
|
|
|
157
152
|
rx: coordinates.rx,
|
|
158
153
|
ry: coordinates.ry,
|
|
159
154
|
fill: 'transparent',
|
|
160
|
-
|
|
161
|
-
opacity: ((_currentItem$
|
|
162
|
-
strokeWidth: ((_currentItem$
|
|
155
|
+
stroke: hslToRgb(((_currentItem$value4 = currentItem.value) === null || _currentItem$value4 === void 0 ? void 0 : _currentItem$value4.color) || 'hsl(0, 0%, 0%)'),
|
|
156
|
+
opacity: ((_currentItem$value5 = currentItem.value) === null || _currentItem$value5 === void 0 ? void 0 : _currentItem$value5.type) === 'ellipse' ? 1 : 0,
|
|
157
|
+
strokeWidth: ((_currentItem$value6 = currentItem.value) === null || _currentItem$value6 === void 0 ? void 0 : _currentItem$value6.type) === 'ellipse' ? currentItem.value.strokeWidth : 0,
|
|
163
158
|
marker: 'url(#selection)'
|
|
164
159
|
};
|
|
165
|
-
}
|
|
160
|
+
});
|
|
166
161
|
const singleHeadAnimatedProps = useAnimatedProps(() => {
|
|
167
|
-
|
|
168
|
-
|
|
162
|
+
'worklet';
|
|
163
|
+
|
|
164
|
+
var _currentItem$value7, _currentItem$value8, _currentItem$value9, _currentItem$value10;
|
|
165
|
+
const coordinates = ((_currentItem$value7 = currentItem.value) === null || _currentItem$value7 === void 0 ? void 0 : _currentItem$value7.type) === 'singleHead' ? currentItem.value.data : {
|
|
169
166
|
x1: -10,
|
|
170
167
|
y1: -10,
|
|
171
168
|
x2: -10,
|
|
@@ -177,15 +174,17 @@ export default function CurrentAnimatedItem() {
|
|
|
177
174
|
x2: coordinates.x2,
|
|
178
175
|
y2: coordinates.y2,
|
|
179
176
|
fill: 'transparent',
|
|
180
|
-
|
|
181
|
-
opacity: ((_currentItem$
|
|
182
|
-
strokeWidth: ((_currentItem$
|
|
177
|
+
stroke: hslToRgb(((_currentItem$value8 = currentItem.value) === null || _currentItem$value8 === void 0 ? void 0 : _currentItem$value8.color) || 'hsl(0, 0%, 0%)'),
|
|
178
|
+
opacity: ((_currentItem$value9 = currentItem.value) === null || _currentItem$value9 === void 0 ? void 0 : _currentItem$value9.type) === 'singleHead' ? 1 : 0,
|
|
179
|
+
strokeWidth: ((_currentItem$value10 = currentItem.value) === null || _currentItem$value10 === void 0 ? void 0 : _currentItem$value10.type) === 'singleHead' ? currentItem.value.strokeWidth : 0,
|
|
183
180
|
markerEnd: 'arrowhead'
|
|
184
181
|
};
|
|
185
|
-
}
|
|
182
|
+
});
|
|
186
183
|
const doubleHeadAnimatedProps = useAnimatedProps(() => {
|
|
187
|
-
|
|
188
|
-
|
|
184
|
+
'worklet';
|
|
185
|
+
|
|
186
|
+
var _currentItem$value11, _currentItem$value12, _currentItem$value13, _currentItem$value14;
|
|
187
|
+
const coordinates = ((_currentItem$value11 = currentItem.value) === null || _currentItem$value11 === void 0 ? void 0 : _currentItem$value11.type) === 'doubleHead' ? currentItem.value.data : {
|
|
189
188
|
x1: -10,
|
|
190
189
|
y1: -10,
|
|
191
190
|
x2: -10,
|
|
@@ -197,13 +196,13 @@ export default function CurrentAnimatedItem() {
|
|
|
197
196
|
x2: coordinates.x2,
|
|
198
197
|
y2: coordinates.y2,
|
|
199
198
|
fill: 'transparent',
|
|
200
|
-
|
|
201
|
-
opacity: ((_currentItem$
|
|
202
|
-
strokeWidth: ((_currentItem$
|
|
199
|
+
stroke: hslToRgb(((_currentItem$value12 = currentItem.value) === null || _currentItem$value12 === void 0 ? void 0 : _currentItem$value12.color) || 'hsl(0, 0%, 0%)'),
|
|
200
|
+
opacity: ((_currentItem$value13 = currentItem.value) === null || _currentItem$value13 === void 0 ? void 0 : _currentItem$value13.type) === 'doubleHead' ? 1 : 0,
|
|
201
|
+
strokeWidth: ((_currentItem$value14 = currentItem.value) === null || _currentItem$value14 === void 0 ? void 0 : _currentItem$value14.type) === 'doubleHead' ? currentItem.value.strokeWidth : 0,
|
|
203
202
|
markerStart: 'side',
|
|
204
203
|
markerEnd: 'side'
|
|
205
204
|
};
|
|
206
|
-
}
|
|
205
|
+
});
|
|
207
206
|
const distance = (x1, y1, x2, y2) => {
|
|
208
207
|
'worklet';
|
|
209
208
|
|
|
@@ -275,9 +274,11 @@ export default function CurrentAnimatedItem() {
|
|
|
275
274
|
return [newX1, newY1, newX2, newY2];
|
|
276
275
|
};
|
|
277
276
|
const doubleArrowsAnimatedPropsFirst = useAnimatedProps(() => {
|
|
278
|
-
|
|
277
|
+
'worklet';
|
|
278
|
+
|
|
279
|
+
var _currentItem$value15, _currentItem$value16, _currentItem$value17, _currentItem$value18;
|
|
279
280
|
let x1, y1, x2, y2;
|
|
280
|
-
if (((_currentItem$
|
|
281
|
+
if (((_currentItem$value15 = currentItem.value) === null || _currentItem$value15 === void 0 ? void 0 : _currentItem$value15.type) !== 'doubleArrows') {
|
|
281
282
|
x1 = -10;
|
|
282
283
|
y1 = -10;
|
|
283
284
|
x2 = -10;
|
|
@@ -300,16 +301,18 @@ export default function CurrentAnimatedItem() {
|
|
|
300
301
|
x2,
|
|
301
302
|
y2,
|
|
302
303
|
fill: 'transparent',
|
|
303
|
-
|
|
304
|
-
opacity: ((_currentItem$
|
|
305
|
-
strokeWidth: ((_currentItem$
|
|
304
|
+
stroke: hslToRgb(((_currentItem$value16 = currentItem.value) === null || _currentItem$value16 === void 0 ? void 0 : _currentItem$value16.color) || 'hsl(0, 0%, 0%)'),
|
|
305
|
+
opacity: ((_currentItem$value17 = currentItem.value) === null || _currentItem$value17 === void 0 ? void 0 : _currentItem$value17.type) === 'doubleArrows' ? 1 : 0,
|
|
306
|
+
strokeWidth: ((_currentItem$value18 = currentItem.value) === null || _currentItem$value18 === void 0 ? void 0 : _currentItem$value18.type) === 'doubleArrows' ? currentItem.value.strokeWidth : 0,
|
|
306
307
|
markerStart: 'arrowheadStart'
|
|
307
308
|
};
|
|
308
|
-
}
|
|
309
|
+
});
|
|
309
310
|
const doubleArrowsAnimatedPropsLast = useAnimatedProps(() => {
|
|
310
|
-
|
|
311
|
+
'worklet';
|
|
312
|
+
|
|
313
|
+
var _currentItem$value19, _currentItem$value20, _currentItem$value21, _currentItem$value22;
|
|
311
314
|
let x1, y1, x2, y2;
|
|
312
|
-
if (((_currentItem$
|
|
315
|
+
if (((_currentItem$value19 = currentItem.value) === null || _currentItem$value19 === void 0 ? void 0 : _currentItem$value19.type) !== 'doubleArrows') {
|
|
313
316
|
x1 = -10;
|
|
314
317
|
y1 = -10;
|
|
315
318
|
x2 = -10;
|
|
@@ -332,12 +335,95 @@ export default function CurrentAnimatedItem() {
|
|
|
332
335
|
x2,
|
|
333
336
|
y2,
|
|
334
337
|
fill: 'transparent',
|
|
335
|
-
|
|
336
|
-
opacity: ((_currentItem$
|
|
337
|
-
strokeWidth: ((_currentItem$
|
|
338
|
+
stroke: hslToRgb(((_currentItem$value20 = currentItem.value) === null || _currentItem$value20 === void 0 ? void 0 : _currentItem$value20.color) || 'hsl(0, 0%, 0%)'),
|
|
339
|
+
opacity: ((_currentItem$value21 = currentItem.value) === null || _currentItem$value21 === void 0 ? void 0 : _currentItem$value21.type) === 'doubleArrows' ? 1 : 0,
|
|
340
|
+
strokeWidth: ((_currentItem$value22 = currentItem.value) === null || _currentItem$value22 === void 0 ? void 0 : _currentItem$value22.type) === 'doubleArrows' ? currentItem.value.strokeWidth : 0,
|
|
338
341
|
markerEnd: 'arrowhead'
|
|
339
342
|
};
|
|
340
|
-
}
|
|
343
|
+
});
|
|
344
|
+
const rectangleAnimatedProps = useAnimatedProps(() => {
|
|
345
|
+
'worklet';
|
|
346
|
+
|
|
347
|
+
var _currentItem$value23, _currentItem$value24, _currentItem$value25, _currentItem$value26;
|
|
348
|
+
const coordinates = ((_currentItem$value23 = currentItem.value) === null || _currentItem$value23 === void 0 ? void 0 : _currentItem$value23.type) === 'rectangle' ? currentItem.value.data : {
|
|
349
|
+
x: -10,
|
|
350
|
+
y: -10,
|
|
351
|
+
width: 0,
|
|
352
|
+
height: 0
|
|
353
|
+
};
|
|
354
|
+
return {
|
|
355
|
+
x: coordinates.x,
|
|
356
|
+
y: coordinates.y,
|
|
357
|
+
width: coordinates.width,
|
|
358
|
+
height: coordinates.height,
|
|
359
|
+
fill: 'transparent',
|
|
360
|
+
stroke: hslToRgb(((_currentItem$value24 = currentItem.value) === null || _currentItem$value24 === void 0 ? void 0 : _currentItem$value24.color) || 'hsl(0, 0%, 0%)'),
|
|
361
|
+
opacity: ((_currentItem$value25 = currentItem.value) === null || _currentItem$value25 === void 0 ? void 0 : _currentItem$value25.type) === 'rectangle' ? 1 : 0,
|
|
362
|
+
strokeWidth: ((_currentItem$value26 = currentItem.value) === null || _currentItem$value26 === void 0 ? void 0 : _currentItem$value26.type) === 'rectangle' ? currentItem.value.strokeWidth : 0,
|
|
363
|
+
marker: 'url(#selection)'
|
|
364
|
+
};
|
|
365
|
+
});
|
|
366
|
+
const penAnimatedProps = useAnimatedProps(() => {
|
|
367
|
+
'worklet';
|
|
368
|
+
|
|
369
|
+
var _currentItem$value27, _currentItem$value28, _currentItem$value29, _currentItem$value30;
|
|
370
|
+
const d = pointsToPath(((_currentItem$value27 = currentItem.value) === null || _currentItem$value27 === void 0 ? void 0 : _currentItem$value27.type) === 'pen' ? currentItem.value.data : [{
|
|
371
|
+
x: -10,
|
|
372
|
+
y: -10
|
|
373
|
+
}]);
|
|
374
|
+
return {
|
|
375
|
+
d: d,
|
|
376
|
+
opacity: ((_currentItem$value28 = currentItem.value) === null || _currentItem$value28 === void 0 ? void 0 : _currentItem$value28.type) === 'pen' ? 1 : 0,
|
|
377
|
+
stroke: hslToRgb(((_currentItem$value29 = currentItem.value) === null || _currentItem$value29 === void 0 ? void 0 : _currentItem$value29.color) || 'hsl(0, 0%, 0%)'),
|
|
378
|
+
strokeWidth: ((_currentItem$value30 = currentItem.value) === null || _currentItem$value30 === void 0 ? void 0 : _currentItem$value30.type) === 'pen' ? currentItem.value.strokeWidth : 0,
|
|
379
|
+
fill: 'transparent',
|
|
380
|
+
markerStart: 'selection',
|
|
381
|
+
markerEnd: 'selection'
|
|
382
|
+
};
|
|
383
|
+
});
|
|
384
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(AnimatedEllipse, {
|
|
385
|
+
animatedProps: ellipseAnimatedProps
|
|
386
|
+
}), /*#__PURE__*/React.createElement(G, {
|
|
387
|
+
markerStart: "url(#selection)",
|
|
388
|
+
markerEnd: "url(#selection)"
|
|
389
|
+
}, /*#__PURE__*/React.createElement(AnimatedLine, {
|
|
390
|
+
animatedProps: singleHeadAnimatedProps
|
|
391
|
+
})), /*#__PURE__*/React.createElement(G, {
|
|
392
|
+
markerStart: "url(#selection)",
|
|
393
|
+
markerEnd: "url(#selection)"
|
|
394
|
+
}, /*#__PURE__*/React.createElement(AnimatedLine, {
|
|
395
|
+
animatedProps: doubleHeadAnimatedProps
|
|
396
|
+
})), /*#__PURE__*/React.createElement(G, {
|
|
397
|
+
markerStart: "url(#selection)",
|
|
398
|
+
markerEnd: "url(#selection)"
|
|
399
|
+
}, /*#__PURE__*/React.createElement(AnimatedLine, {
|
|
400
|
+
animatedProps: doubleArrowsAnimatedPropsFirst
|
|
401
|
+
}), /*#__PURE__*/React.createElement(AnimatedLine, {
|
|
402
|
+
animatedProps: doubleArrowsAnimatedPropsLast
|
|
403
|
+
})), /*#__PURE__*/React.createElement(AnimatedRectangle, {
|
|
404
|
+
animatedProps: rectangleAnimatedProps
|
|
405
|
+
}), /*#__PURE__*/React.createElement(AnimatedPath, {
|
|
406
|
+
animatedProps: penAnimatedProps
|
|
407
|
+
}));
|
|
408
|
+
}
|
|
409
|
+
export function DoubleArrowsTextInput() {
|
|
410
|
+
const {
|
|
411
|
+
currentItem,
|
|
412
|
+
doubleArrowTextInput
|
|
413
|
+
} = useDrawHook();
|
|
414
|
+
const getTextLength = () => {
|
|
415
|
+
'worklet';
|
|
416
|
+
|
|
417
|
+
var _currentItem$value31, _currentItem$value32;
|
|
418
|
+
const text = ((_currentItem$value31 = currentItem.value) === null || _currentItem$value31 === void 0 ? void 0 : _currentItem$value31.type) === 'doubleArrows' ? (_currentItem$value32 = currentItem.value) === null || _currentItem$value32 === void 0 ? void 0 : _currentItem$value32.text : '';
|
|
419
|
+
const textLength = text && text.length > 5 ? text.length * 10 : 50;
|
|
420
|
+
return textLength;
|
|
421
|
+
};
|
|
422
|
+
const distance = (x1, y1, x2, y2) => {
|
|
423
|
+
'worklet';
|
|
424
|
+
|
|
425
|
+
return Math.sqrt((x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1));
|
|
426
|
+
};
|
|
341
427
|
const getTextValues = _ref3 => {
|
|
342
428
|
'worklet';
|
|
343
429
|
|
|
@@ -367,12 +453,12 @@ export default function CurrentAnimatedItem() {
|
|
|
367
453
|
}
|
|
368
454
|
return [newX, newY, angle];
|
|
369
455
|
};
|
|
370
|
-
const
|
|
371
|
-
var _currentItem$
|
|
456
|
+
const containerStyle = useAnimatedStyle(() => {
|
|
457
|
+
var _currentItem$value33;
|
|
372
458
|
let x = 0,
|
|
373
459
|
y = 0,
|
|
374
460
|
angle = 0;
|
|
375
|
-
if (((_currentItem$
|
|
461
|
+
if (((_currentItem$value33 = currentItem.value) === null || _currentItem$value33 === void 0 ? void 0 : _currentItem$value33.type) !== 'doubleArrows') {
|
|
376
462
|
x = -50;
|
|
377
463
|
y = -50;
|
|
378
464
|
angle = 0;
|
|
@@ -386,120 +472,44 @@ export default function CurrentAnimatedItem() {
|
|
|
386
472
|
});
|
|
387
473
|
}
|
|
388
474
|
return {
|
|
475
|
+
position: 'absolute',
|
|
389
476
|
top: y - 25,
|
|
390
477
|
left: x - getTextLength() / 2,
|
|
391
|
-
fontSize: 10 + (((_currentItem$value19 = currentItem.value) === null || _currentItem$value19 === void 0 ? void 0 : _currentItem$value19.strokeWidth) ?? 0) * 2,
|
|
392
|
-
color: (_currentItem$value20 = currentItem.value) !== null && _currentItem$value20 !== void 0 && _currentItem$value20.color ? hslToRgb((_currentItem$value21 = currentItem.value) === null || _currentItem$value21 === void 0 ? void 0 : _currentItem$value21.color) : 'white',
|
|
393
478
|
transform: [{
|
|
394
479
|
rotateZ: `${angle}deg`
|
|
395
480
|
}],
|
|
396
|
-
//backgroundColor: 'red',
|
|
397
481
|
width: getTextLength(),
|
|
398
482
|
height: 50
|
|
399
483
|
};
|
|
400
|
-
}
|
|
401
|
-
const
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
height: 0
|
|
408
|
-
};
|
|
409
|
-
return {
|
|
410
|
-
x: coordinates.x,
|
|
411
|
-
y: coordinates.y,
|
|
412
|
-
width: coordinates.width,
|
|
413
|
-
height: coordinates.height,
|
|
414
|
-
fill: 'transparent',
|
|
415
|
-
//stroke: hslToRgb(currentItem.value?.color || 'hsl(0, 0%, 0%)'),
|
|
416
|
-
opacity: ((_currentItem$value23 = currentItem.value) === null || _currentItem$value23 === void 0 ? void 0 : _currentItem$value23.type) === 'rectangle' ? 1 : 0,
|
|
417
|
-
strokeWidth: ((_currentItem$value24 = currentItem.value) === null || _currentItem$value24 === void 0 ? void 0 : _currentItem$value24.type) === 'rectangle' ? currentItem.value.strokeWidth : 0,
|
|
418
|
-
marker: 'url(#selection)'
|
|
419
|
-
};
|
|
420
|
-
}, null, propAdapter);
|
|
421
|
-
const penAnimatedProps = useAnimatedProps(() => {
|
|
422
|
-
var _currentItem$value25, _currentItem$value26, _currentItem$value27;
|
|
423
|
-
const d = pointsToPath(((_currentItem$value25 = currentItem.value) === null || _currentItem$value25 === void 0 ? void 0 : _currentItem$value25.type) === 'pen' ? currentItem.value.data : [{
|
|
424
|
-
x: -10,
|
|
425
|
-
y: -10
|
|
426
|
-
}]);
|
|
484
|
+
});
|
|
485
|
+
const [textStyle, setTextStyle] = useState({
|
|
486
|
+
fontSize: 12,
|
|
487
|
+
color: 'white'
|
|
488
|
+
});
|
|
489
|
+
useAnimatedReaction(() => {
|
|
490
|
+
var _currentItem$value34, _currentItem$value35, _currentItem$value36;
|
|
427
491
|
return {
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
opacity: ((_currentItem$value26 = currentItem.value) === null || _currentItem$value26 === void 0 ? void 0 : _currentItem$value26.type) === 'pen' ? 1 : 0,
|
|
431
|
-
//stroke: currentItem.value?.color || "black",
|
|
432
|
-
strokeWidth: ((_currentItem$value27 = currentItem.value) === null || _currentItem$value27 === void 0 ? void 0 : _currentItem$value27.type) === 'pen' ? currentItem.value.strokeWidth : 0,
|
|
433
|
-
fill: 'transparent',
|
|
434
|
-
markerStart: 'selection',
|
|
435
|
-
markerEnd: 'selection'
|
|
492
|
+
fontSize: 10 + (((_currentItem$value34 = currentItem.value) === null || _currentItem$value34 === void 0 ? void 0 : _currentItem$value34.strokeWidth) ?? 0) * 2,
|
|
493
|
+
color: (_currentItem$value35 = currentItem.value) !== null && _currentItem$value35 !== void 0 && _currentItem$value35.color ? hslToRgb((_currentItem$value36 = currentItem.value) === null || _currentItem$value36 === void 0 ? void 0 : _currentItem$value36.color) : 'white'
|
|
436
494
|
};
|
|
437
|
-
}, null, propAdapter);
|
|
438
|
-
const updateText = value => {
|
|
439
|
-
if (!(doubleArrowTextInput !== null && doubleArrowTextInput !== void 0 && doubleArrowTextInput.current)) return;
|
|
440
|
-
doubleArrowTextInput.current.setNativeProps({
|
|
441
|
-
text: value
|
|
442
|
-
});
|
|
443
|
-
};
|
|
444
|
-
useAnimatedReaction(() => {
|
|
445
|
-
var _currentItem$value28, _currentItem$value29;
|
|
446
|
-
return ((_currentItem$value28 = currentItem.value) === null || _currentItem$value28 === void 0 ? void 0 : _currentItem$value28.type) === 'doubleArrows' ? ((_currentItem$value29 = currentItem.value) === null || _currentItem$value29 === void 0 ? void 0 : _currentItem$value29.text) || '' : '';
|
|
447
495
|
}, value => {
|
|
448
|
-
|
|
449
|
-
}
|
|
450
|
-
return /*#__PURE__*/React.createElement(
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
}), /*#__PURE__*/React.createElement(G, {
|
|
454
|
-
markerStart: "url(#selection)",
|
|
455
|
-
markerEnd: "url(#selection)"
|
|
456
|
-
}, /*#__PURE__*/React.createElement(AnimatedLine, {
|
|
457
|
-
animatedProps: singleHeadAnimatedProps,
|
|
458
|
-
stroke: ((_currentItem$value31 = currentItem.value) === null || _currentItem$value31 === void 0 ? void 0 : _currentItem$value31.color) || 'black'
|
|
459
|
-
})), /*#__PURE__*/React.createElement(G, {
|
|
460
|
-
markerStart: "url(#selection)",
|
|
461
|
-
markerEnd: "url(#selection)"
|
|
462
|
-
}, /*#__PURE__*/React.createElement(AnimatedLine, {
|
|
463
|
-
animatedProps: doubleHeadAnimatedProps,
|
|
464
|
-
stroke: ((_currentItem$value32 = currentItem.value) === null || _currentItem$value32 === void 0 ? void 0 : _currentItem$value32.color) || 'black'
|
|
465
|
-
})), /*#__PURE__*/React.createElement(G, {
|
|
466
|
-
markerStart: "url(#selection)",
|
|
467
|
-
markerEnd: "url(#selection)"
|
|
468
|
-
}, /*#__PURE__*/React.createElement(AnimatedLine, {
|
|
469
|
-
animatedProps: doubleArrowsAnimatedPropsFirst,
|
|
470
|
-
stroke: ((_currentItem$value33 = currentItem.value) === null || _currentItem$value33 === void 0 ? void 0 : _currentItem$value33.color) || 'black'
|
|
471
|
-
}), /*#__PURE__*/React.createElement(AnimatedTextInput, {
|
|
472
|
-
animatedProps: {
|
|
473
|
-
...doubleArrowsAnimatedPropsText // Type cast to bypass the type error
|
|
474
|
-
// Ensure other relevant props if needed
|
|
475
|
-
},
|
|
476
|
-
|
|
477
|
-
value: ((_currentItem$value34 = currentItem.value) === null || _currentItem$value34 === void 0 ? void 0 : _currentItem$value34.type) === 'doubleArrows' ? currentItem.value.text : '',
|
|
496
|
+
runOnJS(setTextStyle)(value);
|
|
497
|
+
});
|
|
498
|
+
return /*#__PURE__*/React.createElement(Animated.View, {
|
|
499
|
+
style: containerStyle
|
|
500
|
+
}, /*#__PURE__*/React.createElement(TextInput, {
|
|
478
501
|
ref: doubleArrowTextInput,
|
|
479
502
|
underlineColorAndroid: 'transparent',
|
|
480
503
|
onChangeText: text => {
|
|
481
|
-
var _currentItem$
|
|
482
|
-
if (((_currentItem$
|
|
504
|
+
var _currentItem$value37;
|
|
505
|
+
if (((_currentItem$value37 = currentItem.value) === null || _currentItem$value37 === void 0 ? void 0 : _currentItem$value37.type) === 'doubleArrows') {
|
|
483
506
|
currentItem.value = {
|
|
484
507
|
...currentItem.value,
|
|
485
508
|
text
|
|
486
509
|
};
|
|
487
510
|
}
|
|
488
511
|
},
|
|
489
|
-
style:
|
|
490
|
-
color: 'black',
|
|
491
|
-
fontSize: 24,
|
|
492
|
-
position: 'absolute'
|
|
493
|
-
}
|
|
494
|
-
}), /*#__PURE__*/React.createElement(AnimatedLine, {
|
|
495
|
-
animatedProps: doubleArrowsAnimatedPropsLast,
|
|
496
|
-
stroke: ((_currentItem$value36 = currentItem.value) === null || _currentItem$value36 === void 0 ? void 0 : _currentItem$value36.color) || 'black'
|
|
497
|
-
})), /*#__PURE__*/React.createElement(AnimatedRectangle, {
|
|
498
|
-
animatedProps: rectangleAnimatedProps,
|
|
499
|
-
stroke: ((_currentItem$value37 = currentItem.value) === null || _currentItem$value37 === void 0 ? void 0 : _currentItem$value37.color) || 'black'
|
|
500
|
-
}), /*#__PURE__*/React.createElement(AnimatedPath, {
|
|
501
|
-
animatedProps: penAnimatedProps,
|
|
502
|
-
stroke: ((_currentItem$value38 = currentItem.value) === null || _currentItem$value38 === void 0 ? void 0 : _currentItem$value38.color) || 'black'
|
|
512
|
+
style: textStyle
|
|
503
513
|
}));
|
|
504
514
|
}
|
|
505
515
|
//# sourceMappingURL=CurrentAnimatedItem.js.map
|