@nexara/nativeflow 0.1.1 → 0.1.2
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/lib/commonjs/components/Button/Button.js +50 -37
- package/lib/commonjs/components/Button/Button.js.map +1 -1
- package/lib/commonjs/components/CheckBox/CheckBox.js +39 -29
- package/lib/commonjs/components/CheckBox/CheckBox.js.map +1 -1
- package/lib/commonjs/components/Dialog/Dialog.js +52 -48
- package/lib/commonjs/components/Dialog/Dialog.js.map +1 -1
- package/lib/commonjs/components/Dialog/DialogBody.js +6 -8
- package/lib/commonjs/components/Dialog/DialogBody.js.map +1 -1
- package/lib/commonjs/components/Dialog/DialogDescription.js +4 -7
- package/lib/commonjs/components/Dialog/DialogDescription.js.map +1 -1
- package/lib/commonjs/components/Dialog/DialogFoot.js +13 -13
- package/lib/commonjs/components/Dialog/DialogFoot.js.map +1 -1
- package/lib/commonjs/components/Dialog/DialogHead.js +17 -16
- package/lib/commonjs/components/Dialog/DialogHead.js.map +1 -1
- package/lib/commonjs/components/Divider/Divider.js +5 -8
- package/lib/commonjs/components/Divider/Divider.js.map +1 -1
- package/lib/commonjs/components/Header/Header.js.map +1 -1
- package/lib/commonjs/components/Icon/Icon.js +9 -5
- package/lib/commonjs/components/Icon/Icon.js.map +1 -1
- package/lib/commonjs/components/Link/Link.js +13 -15
- package/lib/commonjs/components/Link/Link.js.map +1 -1
- package/lib/commonjs/components/Menu/Menu.js +51 -54
- package/lib/commonjs/components/Menu/Menu.js.map +1 -1
- package/lib/commonjs/components/Menu/MenuItem.js +0 -2
- package/lib/commonjs/components/Menu/MenuItem.js.map +1 -1
- package/lib/commonjs/components/Portal/Portal.js +1 -1
- package/lib/commonjs/components/Portal/Portal.js.map +1 -1
- package/lib/commonjs/components/Progress/Progress.js +25 -15
- package/lib/commonjs/components/Progress/Progress.js.map +1 -1
- package/lib/commonjs/components/Stack/HStack.js +9 -11
- package/lib/commonjs/components/Stack/HStack.js.map +1 -1
- package/lib/commonjs/components/Stack/VStack.js +4 -2
- package/lib/commonjs/components/Stack/VStack.js.map +1 -1
- package/lib/commonjs/components/StyledComponents/StyledText.js +12 -13
- package/lib/commonjs/components/StyledComponents/StyledText.js.map +1 -1
- package/lib/commonjs/components/StyledComponents/StyledView.js +14 -14
- package/lib/commonjs/components/StyledComponents/StyledView.js.map +1 -1
- package/lib/commonjs/components/Switch/Switch.js +2 -2
- package/lib/commonjs/components/Switch/Switch.js.map +1 -1
- package/lib/commonjs/components/UserInput/UserInput.js +29 -32
- package/lib/commonjs/components/UserInput/UserInput.js.map +1 -1
- package/lib/commonjs/helpers/LightenColorShades.js +18 -5
- package/lib/commonjs/helpers/LightenColorShades.js.map +1 -1
- package/lib/commonjs/helpers/ResponsiveCalculations.js +30 -4
- package/lib/commonjs/helpers/ResponsiveCalculations.js.map +1 -1
- package/lib/commonjs/helpers/index.js +16 -0
- package/lib/commonjs/helpers/index.js.map +1 -1
- package/lib/commonjs/index.js +5 -4
- package/lib/commonjs/index.js.map +2 -1
- package/lib/commonjs/themes/LightTheme.js +1 -3
- package/lib/commonjs/themes/LightTheme.js.map +1 -1
- package/lib/commonjs/types/index.js +11 -0
- package/lib/commonjs/types/index.js.map +1 -1
- package/lib/commonjs/types/progress.type.js +2 -0
- package/lib/commonjs/types/progress.type.js.map +1 -0
- package/lib/module/components/Button/Button.js +50 -37
- package/lib/module/components/Button/Button.js.map +1 -1
- package/lib/module/components/CheckBox/CheckBox.js +41 -31
- package/lib/module/components/CheckBox/CheckBox.js.map +1 -1
- package/lib/module/components/Dialog/Dialog.js +52 -48
- package/lib/module/components/Dialog/Dialog.js.map +1 -1
- package/lib/module/components/Dialog/DialogBody.js +7 -9
- package/lib/module/components/Dialog/DialogBody.js.map +1 -1
- package/lib/module/components/Dialog/DialogDescription.js +5 -8
- package/lib/module/components/Dialog/DialogDescription.js.map +1 -1
- package/lib/module/components/Dialog/DialogFoot.js +13 -13
- package/lib/module/components/Dialog/DialogFoot.js.map +1 -1
- package/lib/module/components/Dialog/DialogHead.js +17 -16
- package/lib/module/components/Dialog/DialogHead.js.map +1 -1
- package/lib/module/components/Divider/Divider.js +5 -8
- package/lib/module/components/Divider/Divider.js.map +1 -1
- package/lib/module/components/Header/Header.js.map +1 -1
- package/lib/module/components/Icon/Icon.js +7 -4
- package/lib/module/components/Icon/Icon.js.map +1 -1
- package/lib/module/components/Link/Link.js +14 -16
- package/lib/module/components/Link/Link.js.map +1 -1
- package/lib/module/components/Menu/Menu.js +51 -54
- package/lib/module/components/Menu/Menu.js.map +1 -1
- package/lib/module/components/Menu/MenuItem.js +0 -2
- package/lib/module/components/Menu/MenuItem.js.map +1 -1
- package/lib/module/components/Portal/Portal.js +1 -1
- package/lib/module/components/Portal/Portal.js.map +1 -1
- package/lib/module/components/Progress/Progress.js +26 -16
- package/lib/module/components/Progress/Progress.js.map +1 -1
- package/lib/module/components/Stack/HStack.js +10 -12
- package/lib/module/components/Stack/HStack.js.map +1 -1
- package/lib/module/components/Stack/VStack.js +4 -2
- package/lib/module/components/Stack/VStack.js.map +1 -1
- package/lib/module/components/StyledComponents/StyledText.js +13 -14
- package/lib/module/components/StyledComponents/StyledText.js.map +1 -1
- package/lib/module/components/StyledComponents/StyledView.js +15 -15
- package/lib/module/components/StyledComponents/StyledView.js.map +1 -1
- package/lib/module/components/Switch/Switch.js +2 -2
- package/lib/module/components/Switch/Switch.js.map +1 -1
- package/lib/module/components/UserInput/UserInput.js +30 -35
- package/lib/module/components/UserInput/UserInput.js.map +1 -1
- package/lib/module/helpers/LightenColorShades.js +18 -5
- package/lib/module/helpers/LightenColorShades.js.map +1 -1
- package/lib/module/helpers/ResponsiveCalculations.js +28 -3
- package/lib/module/helpers/ResponsiveCalculations.js.map +1 -1
- package/lib/module/helpers/index.js +1 -0
- package/lib/module/helpers/index.js.map +1 -1
- package/lib/module/index.js +2 -4
- package/lib/module/index.js.map +1 -2
- package/lib/module/themes/LightTheme.js +1 -2
- package/lib/module/themes/LightTheme.js.map +1 -1
- package/lib/module/types/index.js +1 -0
- package/lib/module/types/index.js.map +1 -1
- package/lib/module/types/progress.type.js +2 -0
- package/lib/module/types/progress.type.js.map +1 -0
- package/lib/typescript/commonjs/src/components/Button/Button.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/components/CheckBox/CheckBox.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/components/Dialog/Dialog.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/components/Dialog/DialogBody.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/components/Dialog/DialogFoot.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/components/Dialog/DialogHead.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/components/Divider/Divider.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/components/Header/Header.d.ts +1 -0
- package/lib/typescript/commonjs/src/components/Header/Header.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/components/Icon/Icon.d.ts +1 -0
- package/lib/typescript/commonjs/src/components/Icon/Icon.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/components/Link/Link.d.ts +4 -0
- package/lib/typescript/commonjs/src/components/Link/Link.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/components/Menu/Menu.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/components/Menu/MenuItem.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/components/Portal/Portal.d.ts +1 -1
- package/lib/typescript/commonjs/src/components/Portal/Portal.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/components/Progress/Progress.d.ts +1 -12
- package/lib/typescript/commonjs/src/components/Progress/Progress.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/components/Stack/HStack.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/components/Stack/VStack.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/components/StyledComponents/StyledText.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/components/StyledComponents/StyledView.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/components/UserInput/UserInput.d.ts +1 -34
- package/lib/typescript/commonjs/src/components/UserInput/UserInput.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/helpers/LightenColorShades.d.ts +1 -1
- package/lib/typescript/commonjs/src/helpers/LightenColorShades.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/helpers/ResponsiveCalculations.d.ts +1 -0
- package/lib/typescript/commonjs/src/helpers/ResponsiveCalculations.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/helpers/index.d.ts +1 -0
- package/lib/typescript/commonjs/src/helpers/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/themes/LightTheme.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/types/button.type.d.ts +1 -0
- package/lib/typescript/commonjs/src/types/button.type.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/types/dialog.type.d.ts +0 -2
- package/lib/typescript/commonjs/src/types/dialog.type.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/types/index.d.ts +1 -0
- package/lib/typescript/commonjs/src/types/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/types/progress.type.d.ts +13 -0
- package/lib/typescript/commonjs/src/types/progress.type.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/types/stack.type.d.ts +14 -3
- package/lib/typescript/commonjs/src/types/stack.type.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/types/styledComponents.type.d.ts +7 -1
- package/lib/typescript/commonjs/src/types/styledComponents.type.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/types/userInput.type.d.ts +6 -1
- package/lib/typescript/commonjs/src/types/userInput.type.d.ts.map +1 -1
- package/lib/typescript/module/src/components/Button/Button.d.ts.map +1 -1
- package/lib/typescript/module/src/components/CheckBox/CheckBox.d.ts.map +1 -1
- package/lib/typescript/module/src/components/Dialog/Dialog.d.ts.map +1 -1
- package/lib/typescript/module/src/components/Dialog/DialogBody.d.ts.map +1 -1
- package/lib/typescript/module/src/components/Dialog/DialogFoot.d.ts.map +1 -1
- package/lib/typescript/module/src/components/Dialog/DialogHead.d.ts.map +1 -1
- package/lib/typescript/module/src/components/Divider/Divider.d.ts.map +1 -1
- package/lib/typescript/module/src/components/Header/Header.d.ts +1 -0
- package/lib/typescript/module/src/components/Header/Header.d.ts.map +1 -1
- package/lib/typescript/module/src/components/Icon/Icon.d.ts +1 -0
- package/lib/typescript/module/src/components/Icon/Icon.d.ts.map +1 -1
- package/lib/typescript/module/src/components/Link/Link.d.ts +4 -0
- package/lib/typescript/module/src/components/Link/Link.d.ts.map +1 -1
- package/lib/typescript/module/src/components/Menu/Menu.d.ts.map +1 -1
- package/lib/typescript/module/src/components/Menu/MenuItem.d.ts.map +1 -1
- package/lib/typescript/module/src/components/Portal/Portal.d.ts +1 -1
- package/lib/typescript/module/src/components/Portal/Portal.d.ts.map +1 -1
- package/lib/typescript/module/src/components/Progress/Progress.d.ts +1 -12
- package/lib/typescript/module/src/components/Progress/Progress.d.ts.map +1 -1
- package/lib/typescript/module/src/components/Stack/HStack.d.ts.map +1 -1
- package/lib/typescript/module/src/components/Stack/VStack.d.ts.map +1 -1
- package/lib/typescript/module/src/components/StyledComponents/StyledText.d.ts.map +1 -1
- package/lib/typescript/module/src/components/StyledComponents/StyledView.d.ts.map +1 -1
- package/lib/typescript/module/src/components/UserInput/UserInput.d.ts +1 -34
- package/lib/typescript/module/src/components/UserInput/UserInput.d.ts.map +1 -1
- package/lib/typescript/module/src/helpers/LightenColorShades.d.ts +1 -1
- package/lib/typescript/module/src/helpers/LightenColorShades.d.ts.map +1 -1
- package/lib/typescript/module/src/helpers/ResponsiveCalculations.d.ts +1 -0
- package/lib/typescript/module/src/helpers/ResponsiveCalculations.d.ts.map +1 -1
- package/lib/typescript/module/src/helpers/index.d.ts +1 -0
- package/lib/typescript/module/src/helpers/index.d.ts.map +1 -1
- package/lib/typescript/module/src/themes/LightTheme.d.ts.map +1 -1
- package/lib/typescript/module/src/types/button.type.d.ts +1 -0
- package/lib/typescript/module/src/types/button.type.d.ts.map +1 -1
- package/lib/typescript/module/src/types/dialog.type.d.ts +0 -2
- package/lib/typescript/module/src/types/dialog.type.d.ts.map +1 -1
- package/lib/typescript/module/src/types/index.d.ts +1 -0
- package/lib/typescript/module/src/types/index.d.ts.map +1 -1
- package/lib/typescript/module/src/types/progress.type.d.ts +13 -0
- package/lib/typescript/module/src/types/progress.type.d.ts.map +1 -0
- package/lib/typescript/module/src/types/stack.type.d.ts +14 -3
- package/lib/typescript/module/src/types/stack.type.d.ts.map +1 -1
- package/lib/typescript/module/src/types/styledComponents.type.d.ts +7 -1
- package/lib/typescript/module/src/types/styledComponents.type.d.ts.map +1 -1
- package/lib/typescript/module/src/types/userInput.type.d.ts +6 -1
- package/lib/typescript/module/src/types/userInput.type.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/components/Button/Button.tsx +111 -76
- package/src/components/CheckBox/CheckBox.tsx +61 -49
- package/src/components/Dialog/Dialog.tsx +54 -51
- package/src/components/Dialog/DialogBody.tsx +7 -9
- package/src/components/Dialog/DialogDescription.tsx +9 -9
- package/src/components/Dialog/DialogFoot.tsx +15 -13
- package/src/components/Dialog/DialogHead.tsx +20 -17
- package/src/components/Divider/Divider.tsx +5 -9
- package/src/components/Header/Header.tsx +1 -0
- package/src/components/Icon/Icon.tsx +9 -4
- package/src/components/Link/Link.tsx +24 -7
- package/src/components/Menu/Menu.tsx +50 -50
- package/src/components/Menu/MenuItem.tsx +0 -2
- package/src/components/Portal/Portal.tsx +2 -2
- package/src/components/Progress/Progress.tsx +32 -35
- package/src/components/Stack/HStack.tsx +12 -12
- package/src/components/Stack/VStack.tsx +5 -2
- package/src/components/StyledComponents/StyledText.tsx +3 -5
- package/src/components/StyledComponents/StyledView.tsx +6 -2
- package/src/components/Switch/Switch.tsx +2 -2
- package/src/components/UserInput/UserInput.tsx +43 -37
- package/src/helpers/LightenColorShades.ts +26 -6
- package/src/helpers/ResponsiveCalculations.ts +28 -3
- package/src/helpers/index.ts +2 -1
- package/src/themes/LightTheme.ts +1 -2
- package/src/types/button.type.ts +1 -0
- package/src/types/dialog.type.ts +0 -3
- package/src/types/index.ts +2 -1
- package/src/types/progress.type.ts +16 -0
- package/src/types/stack.type.ts +16 -3
- package/src/types/styledComponents.type.ts +8 -1
- package/src/types/userInput.type.ts +7 -1
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import React, { useState, useRef, useCallback, useEffect, } from "react";
|
|
2
|
-
import { StyleSheet, Pressable, View, ScrollView } from "react-native";
|
|
2
|
+
import { StyleSheet, Pressable, View, ScrollView, Animated } from "react-native";
|
|
3
3
|
import { StyledView } from "../StyledComponents";
|
|
4
|
-
import Animated, { useAnimatedStyle, useSharedValue, withTiming } from "react-native-reanimated";
|
|
5
4
|
import Portal from "../Portal/Portal";
|
|
6
5
|
import { positionCalculations } from "./calculations";
|
|
7
6
|
import type { menuLayoutTypes, anchorLayoutTypes } from "./calculations";
|
|
@@ -19,20 +18,20 @@ const Menu: React.FC<MenuProps> = ({
|
|
|
19
18
|
style,
|
|
20
19
|
children
|
|
21
20
|
}) => {
|
|
22
|
-
|
|
23
21
|
const [isVisible, setIsVisible] = useState<boolean>(false);
|
|
24
22
|
const anchorLayoutRef = useRef<anchorLayoutTypes>({ pageY: 0, pageX: 0, height: 0, width: 0 });
|
|
25
23
|
const menuLayoutRef = useRef<menuLayoutTypes>({ height: 0, width: 0 });
|
|
26
24
|
const buttonRef = useRef<View | null>(null);
|
|
27
|
-
const
|
|
25
|
+
const animatedScaleRef = useRef(new Animated.Value(1)).current;
|
|
26
|
+
|
|
28
27
|
const positions = (useCallback(() => (positionCalculations(anchorLayoutRef.current, menuLayoutRef.current, placement)), [menuLayoutRef, anchorLayoutRef, placement]))();
|
|
29
28
|
|
|
30
29
|
useEffect(() => {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
}
|
|
30
|
+
Animated.timing(animatedScaleRef, {
|
|
31
|
+
toValue: (disableBuiltInState && isOpen) || isVisible ? 1 : 0,
|
|
32
|
+
duration: 150,
|
|
33
|
+
useNativeDriver: true,
|
|
34
|
+
}).start();
|
|
36
35
|
}, [isOpen, isVisible]);
|
|
37
36
|
|
|
38
37
|
const measureLayout = useCallback(() => {
|
|
@@ -63,14 +62,17 @@ const Menu: React.FC<MenuProps> = ({
|
|
|
63
62
|
|
|
64
63
|
const renderChildren = (useCallback(() => {
|
|
65
64
|
return (<ScrollView>
|
|
66
|
-
{React.Children?.toArray(children).map((
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
(
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
65
|
+
{React.Children?.toArray(children).map((child) => {
|
|
66
|
+
if (React.isValidElement<{ onPress: () => void; name: string; }>(child)) {
|
|
67
|
+
return React.cloneElement(child, {
|
|
68
|
+
onPress: () => {
|
|
69
|
+
(child)?.props?.onPress?.();
|
|
70
|
+
onSelect?.((child)?.props?.name);
|
|
71
|
+
onClose();
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
return null;
|
|
74
76
|
})}
|
|
75
77
|
</ScrollView>)
|
|
76
78
|
|
|
@@ -79,34 +81,15 @@ const Menu: React.FC<MenuProps> = ({
|
|
|
79
81
|
const scale: number = disableBuiltInState ? Number(isOpen) : Number(isVisible);
|
|
80
82
|
const pointerEvent = (isVisible && !disableBuiltInState) || (isOpen && disableBuiltInState) ? 'auto' : 'none';
|
|
81
83
|
|
|
82
|
-
const
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
backgroundColor: '#fff',
|
|
87
|
-
shadowOffset: {
|
|
88
|
-
width: 0,
|
|
89
|
-
height: 2,
|
|
90
|
-
},
|
|
91
|
-
shadowOpacity: 0.23,
|
|
92
|
-
shadowRadius: 2.62,
|
|
93
|
-
elevation: 4,
|
|
94
|
-
position: 'absolute',
|
|
95
|
-
left: positions.left,
|
|
96
|
-
top: positions.top,
|
|
97
|
-
borderRadius: 5,
|
|
98
|
-
maxHeight: 400,
|
|
99
|
-
minWidth: horizontalScale(150),
|
|
100
|
-
paddingVertical: verticalScale(5)
|
|
101
|
-
}
|
|
102
|
-
});
|
|
84
|
+
const dynamicStyles = {
|
|
85
|
+
left: positions.left,
|
|
86
|
+
top: positions.top,
|
|
87
|
+
};
|
|
103
88
|
|
|
104
|
-
const menuAnimatedStyle =
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
}
|
|
109
|
-
});
|
|
89
|
+
const menuAnimatedStyle = {
|
|
90
|
+
transform: [{ scale: animatedScaleRef }],
|
|
91
|
+
opacity: animatedScaleRef
|
|
92
|
+
};
|
|
110
93
|
|
|
111
94
|
return (<>
|
|
112
95
|
|
|
@@ -119,7 +102,7 @@ const Menu: React.FC<MenuProps> = ({
|
|
|
119
102
|
onPress={onClose}>
|
|
120
103
|
<Animated.View
|
|
121
104
|
onStartShouldSetResponder={() => true}
|
|
122
|
-
style={[STYLES.
|
|
105
|
+
style={[STYLES.MENU_CONT, dynamicStyles, menuAnimatedStyle, style]}
|
|
123
106
|
onLayout={({ nativeEvent: { layout: { height, width } } }) => menuLayoutRef.current = { width, height }}
|
|
124
107
|
>
|
|
125
108
|
{renderChildren}
|
|
@@ -127,13 +110,30 @@ const Menu: React.FC<MenuProps> = ({
|
|
|
127
110
|
</Pressable>
|
|
128
111
|
</Portal>
|
|
129
112
|
|
|
130
|
-
<StyledView alignItems='flex-start'>
|
|
131
|
-
<
|
|
132
|
-
{anchor && React.cloneElement(anchor, { onPress: onOpen })}
|
|
133
|
-
</View>
|
|
113
|
+
<StyledView alignItems='flex-start' ref={buttonRef} onLayout={measureLayout}>
|
|
114
|
+
{anchor && React.isValidElement<{ onPress: () => void }>(anchor) && React.cloneElement(anchor, { onPress: onOpen })}
|
|
134
115
|
</StyledView>
|
|
135
116
|
|
|
136
117
|
</>)
|
|
137
118
|
}
|
|
138
119
|
export default Menu;
|
|
139
|
-
export type { MenuProps };
|
|
120
|
+
export type { MenuProps };
|
|
121
|
+
|
|
122
|
+
const STYLES = StyleSheet.create({
|
|
123
|
+
MENU_CONT: {
|
|
124
|
+
shadowColor: "#000",
|
|
125
|
+
backgroundColor: '#fff',
|
|
126
|
+
shadowOffset: {
|
|
127
|
+
width: 0,
|
|
128
|
+
height: 2,
|
|
129
|
+
},
|
|
130
|
+
shadowOpacity: 0.23,
|
|
131
|
+
shadowRadius: 2.62,
|
|
132
|
+
elevation: 4,
|
|
133
|
+
position: 'absolute',
|
|
134
|
+
borderRadius: 5,
|
|
135
|
+
maxHeight: 400,
|
|
136
|
+
minWidth: horizontalScale(150),
|
|
137
|
+
paddingVertical: verticalScale(5)
|
|
138
|
+
}
|
|
139
|
+
});
|
|
@@ -5,8 +5,6 @@ import { horizontalScale, moderateScale, verticalScale } from "../../helpers/Res
|
|
|
5
5
|
import type { MenuItemProps } from "../../types";
|
|
6
6
|
|
|
7
7
|
const MenuItem: React.FC<MenuItemProps> = ({
|
|
8
|
-
// paddingV = 12,
|
|
9
|
-
// paddingH = 12,
|
|
10
8
|
paddingV = 11,
|
|
11
9
|
paddingH = 17,
|
|
12
10
|
gap = 12,
|
|
@@ -3,13 +3,13 @@ import PortalContext from "./PortalContext";
|
|
|
3
3
|
|
|
4
4
|
interface PortalProps {
|
|
5
5
|
children: React.ReactNode,
|
|
6
|
-
name
|
|
6
|
+
name?: string
|
|
7
7
|
}
|
|
8
8
|
const Portal: React.FC<PortalProps> = ({ children, name }) => {
|
|
9
9
|
const { addComponent, removeComponent } = useContext(PortalContext);
|
|
10
10
|
|
|
11
11
|
useEffect(() => {
|
|
12
|
-
const uniqueId = name ?? Math.random() * 50
|
|
12
|
+
const uniqueId = name ?? `${Math.random() * 50}`;
|
|
13
13
|
addComponent({ name: uniqueId, component: children });
|
|
14
14
|
return () => removeComponent(uniqueId);
|
|
15
15
|
}, [children, name]);
|
|
@@ -1,33 +1,16 @@
|
|
|
1
|
-
import React, { useEffect, useRef } from 'react';
|
|
1
|
+
import React, { useEffect, useMemo, useRef } from 'react';
|
|
2
2
|
import { Animated, StyleSheet } from "react-native";
|
|
3
3
|
import { moderateScale, verticalScale, } from "../../helpers/ResponsiveCalculations";
|
|
4
4
|
import { StyledView } from '../StyledComponents';
|
|
5
5
|
import { useTheme } from '../../hooks';
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
type ProgressProps = {
|
|
9
|
-
/** Current progress value (0-100) */
|
|
10
|
-
value?: number;
|
|
11
|
-
|
|
12
|
-
/** Thickness of the progress bar */
|
|
13
|
-
thickness?: number;
|
|
14
|
-
|
|
15
|
-
/** Border radius of the progress bar */
|
|
16
|
-
br?: number;
|
|
17
|
-
|
|
18
|
-
/** Background color of the track (unfilled part) */
|
|
19
|
-
trackColor?: string;
|
|
20
|
-
|
|
21
|
-
/** Color of the progress (filled part) */
|
|
22
|
-
color?: string;
|
|
23
|
-
}
|
|
6
|
+
import type { ProgressProps } from '../../types';
|
|
24
7
|
|
|
25
8
|
const Progress: React.FC<ProgressProps> = ({
|
|
26
9
|
value = 50,
|
|
27
10
|
thickness = 5,
|
|
28
11
|
br = 100,
|
|
29
12
|
trackColor = '#E8E8E8',
|
|
30
|
-
|
|
13
|
+
progressColor,
|
|
31
14
|
}) => {
|
|
32
15
|
|
|
33
16
|
const animatedWidth = useRef(new Animated.Value(value)).current;
|
|
@@ -35,35 +18,49 @@ const Progress: React.FC<ProgressProps> = ({
|
|
|
35
18
|
|
|
36
19
|
useEffect(() => {
|
|
37
20
|
Animated.timing(animatedWidth, {
|
|
38
|
-
toValue: value,
|
|
21
|
+
toValue: value / 100,
|
|
39
22
|
duration: 1000,
|
|
40
|
-
useNativeDriver:
|
|
23
|
+
useNativeDriver: true,
|
|
41
24
|
}).start();
|
|
42
25
|
}, [value]);
|
|
43
26
|
|
|
44
|
-
const
|
|
27
|
+
const dynamicStyles = useMemo(() => ({
|
|
45
28
|
TRACK: {
|
|
46
29
|
backgroundColor: trackColor,
|
|
47
30
|
borderRadius: moderateScale(br),
|
|
48
|
-
|
|
31
|
+
height: verticalScale(thickness),
|
|
49
32
|
},
|
|
50
33
|
TRACK_ITEM: {
|
|
51
|
-
backgroundColor:
|
|
52
|
-
|
|
53
|
-
borderRadius: moderateScale(br)
|
|
34
|
+
backgroundColor: progressColor ?? theme?.colors.primary,
|
|
35
|
+
borderRadius: moderateScale(br),
|
|
54
36
|
}
|
|
55
|
-
});
|
|
37
|
+
}), [br, trackColor, thickness, progressColor, theme]);
|
|
38
|
+
|
|
39
|
+
const animatedViewStyle = {
|
|
40
|
+
transform: [{ scaleX: animatedWidth }],
|
|
41
|
+
transformOrigin: 'left'
|
|
42
|
+
}
|
|
56
43
|
|
|
57
44
|
return (<>
|
|
58
|
-
<StyledView
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
}]} />
|
|
45
|
+
<StyledView
|
|
46
|
+
style={[STYLES.TRACK, dynamicStyles.TRACK]}
|
|
47
|
+
>
|
|
48
|
+
<Animated.View
|
|
49
|
+
style={[STYLES.TRACK_ITEM, dynamicStyles.TRACK_ITEM, animatedViewStyle]}
|
|
50
|
+
/>
|
|
65
51
|
</StyledView>
|
|
66
52
|
</>);
|
|
67
53
|
};
|
|
68
54
|
export default Progress;
|
|
69
55
|
export type { ProgressProps };
|
|
56
|
+
|
|
57
|
+
const STYLES = StyleSheet.create({
|
|
58
|
+
TRACK: {
|
|
59
|
+
overflow: 'hidden',
|
|
60
|
+
width: '100%',
|
|
61
|
+
},
|
|
62
|
+
TRACK_ITEM: {
|
|
63
|
+
width: "100%",
|
|
64
|
+
height: '100%'
|
|
65
|
+
}
|
|
66
|
+
});
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import React, { useMemo } from "react";
|
|
2
|
-
import {
|
|
2
|
+
import { View } from "react-native";
|
|
3
3
|
import { horizontalScale } from "../../helpers/ResponsiveCalculations";
|
|
4
|
+
import type { ViewStyle } from 'react-native';
|
|
4
5
|
import type { HStackProps } from "../../types";
|
|
5
6
|
|
|
6
7
|
const HStack: React.FC<HStackProps> = ({
|
|
@@ -8,26 +9,25 @@ const HStack: React.FC<HStackProps> = ({
|
|
|
8
9
|
align = 'center',
|
|
9
10
|
fWrap = 'wrap',
|
|
10
11
|
gap = 10,
|
|
11
|
-
|
|
12
|
+
style,
|
|
12
13
|
children,
|
|
14
|
+
ref,
|
|
13
15
|
...rest
|
|
14
16
|
}) => {
|
|
15
17
|
const calculatedGap: number = useMemo(() => horizontalScale(gap), [gap]);
|
|
16
|
-
|
|
18
|
+
|
|
19
|
+
const viewProps: ViewStyle = {
|
|
17
20
|
gap: calculatedGap,
|
|
21
|
+
flexDirection: 'row',
|
|
22
|
+
justifyContent: justify,
|
|
23
|
+
alignItems: align,
|
|
24
|
+
flexWrap: fWrap,
|
|
18
25
|
};
|
|
19
|
-
const STYLES = StyleSheet.create({
|
|
20
|
-
HSTACK: {
|
|
21
|
-
flexDirection: 'row',
|
|
22
|
-
justifyContent: justify,
|
|
23
|
-
alignItems: align,
|
|
24
|
-
flexWrap: fWrap,
|
|
25
|
-
}
|
|
26
|
-
});
|
|
27
26
|
|
|
28
27
|
return (<>
|
|
29
28
|
<View
|
|
30
|
-
style={[viewProps,
|
|
29
|
+
style={[viewProps, style]}
|
|
30
|
+
ref={ref}
|
|
31
31
|
{...rest}
|
|
32
32
|
>
|
|
33
33
|
{children}
|
|
@@ -7,11 +7,13 @@ const VStack: React.FC<VStackProps> = ({
|
|
|
7
7
|
children,
|
|
8
8
|
align,
|
|
9
9
|
gap = 10,
|
|
10
|
-
|
|
10
|
+
style,
|
|
11
|
+
ref,
|
|
11
12
|
...rest
|
|
12
13
|
}) => {
|
|
13
14
|
|
|
14
15
|
const calculatedGap: number = useMemo(() => horizontalScale(gap), [gap]);
|
|
16
|
+
|
|
15
17
|
const viewProps = {
|
|
16
18
|
flexDirection: 'column',
|
|
17
19
|
alignItems: align,
|
|
@@ -20,7 +22,8 @@ const VStack: React.FC<VStackProps> = ({
|
|
|
20
22
|
return (<>
|
|
21
23
|
<View
|
|
22
24
|
{...viewProps}
|
|
23
|
-
style={
|
|
25
|
+
style={style}
|
|
26
|
+
ref={ref}
|
|
24
27
|
{...rest}
|
|
25
28
|
>
|
|
26
29
|
{children}
|
|
@@ -18,12 +18,10 @@ const StyledText: React.FC<StyledTextProps> = ({
|
|
|
18
18
|
secondary,
|
|
19
19
|
...props
|
|
20
20
|
}) => {
|
|
21
|
-
|
|
22
21
|
const { colors, typography: { variantSizes } }: any = useTheme();
|
|
23
|
-
|
|
24
|
-
return (<>
|
|
22
|
+
return (
|
|
25
23
|
<Text
|
|
26
|
-
allowFontScaling={false}
|
|
24
|
+
// allowFontScaling={false}
|
|
27
25
|
style={[{
|
|
28
26
|
fontSize: responsiveFontSize(fs ?? variantSizes[variant]),
|
|
29
27
|
fontFamily: ff ?? '',
|
|
@@ -37,7 +35,7 @@ const StyledText: React.FC<StyledTextProps> = ({
|
|
|
37
35
|
>
|
|
38
36
|
{children}
|
|
39
37
|
</Text>
|
|
40
|
-
|
|
38
|
+
);
|
|
41
39
|
};
|
|
42
40
|
|
|
43
41
|
export default StyledText;
|
|
@@ -15,10 +15,13 @@ const StyledView: React.FC<StyledViewProps> = ({
|
|
|
15
15
|
w,
|
|
16
16
|
children,
|
|
17
17
|
style,
|
|
18
|
+
ref,
|
|
18
19
|
...rest
|
|
19
20
|
}) => {
|
|
21
|
+
|
|
20
22
|
const theme = useTheme(themeBg);
|
|
21
|
-
|
|
23
|
+
|
|
24
|
+
return (
|
|
22
25
|
<View
|
|
23
26
|
style={[{
|
|
24
27
|
flex: f,
|
|
@@ -31,11 +34,12 @@ const StyledView: React.FC<StyledViewProps> = ({
|
|
|
31
34
|
},
|
|
32
35
|
style
|
|
33
36
|
]}
|
|
37
|
+
ref={ref}
|
|
34
38
|
{...rest}
|
|
35
39
|
>
|
|
36
40
|
{children}
|
|
37
41
|
</View>
|
|
38
|
-
|
|
42
|
+
);
|
|
39
43
|
};
|
|
40
44
|
|
|
41
45
|
export default StyledView;
|
|
@@ -17,12 +17,12 @@ const Switch: React.FC<SwitchProps> = ({
|
|
|
17
17
|
}) => {
|
|
18
18
|
|
|
19
19
|
const theme: any = useTheme();
|
|
20
|
-
const switchColor = disabled ? '#808080' : color ?? theme.colors.
|
|
20
|
+
const switchColor = disabled ? '#808080' : color ?? theme.colors.primary;
|
|
21
21
|
|
|
22
22
|
return (<>
|
|
23
23
|
<NativeSwitch
|
|
24
24
|
value={checked}
|
|
25
|
-
trackColor={{ true: LightenColorShades(activeTrackColor ?? switchColor,
|
|
25
|
+
trackColor={{ true: LightenColorShades(activeTrackColor ?? switchColor, 50), false: LightenColorShades(inactiveTrackColor, 60) }}
|
|
26
26
|
thumbColor={switchColor}
|
|
27
27
|
onValueChange={onChange}
|
|
28
28
|
style={{ transform: [{ scaleX: moderateScale(size) }, { scaleY: moderateScale(size) }] }}
|
|
@@ -1,12 +1,13 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { TextInput, StyleSheet } from 'react-native';
|
|
1
|
+
import { useMemo } from 'react';
|
|
2
|
+
import { TextInput, StyleSheet, type ViewStyle } from 'react-native';
|
|
3
|
+
import type { TextStyle } from 'react-native';
|
|
3
4
|
import { responsiveFontSize, verticalScale, horizontalScale } from '../../helpers/ResponsiveCalculations';
|
|
4
5
|
import { useTheme } from '../../hooks';
|
|
5
6
|
import { StyledText, StyledView } from '../StyledComponents';
|
|
6
7
|
import type { UserInputProps } from '../../types';
|
|
7
8
|
import generateColors from './generateColors';
|
|
8
9
|
|
|
9
|
-
const UserInput
|
|
10
|
+
const UserInput: React.FC<UserInputProps> = ({
|
|
10
11
|
variant = 'standard',
|
|
11
12
|
label,
|
|
12
13
|
bg,
|
|
@@ -32,8 +33,9 @@ const UserInput = forwardRef<TextInput, UserInputProps>(({
|
|
|
32
33
|
renderLeftIcon,
|
|
33
34
|
renderRightIcon,
|
|
34
35
|
styles,
|
|
36
|
+
ref,
|
|
35
37
|
...props
|
|
36
|
-
}
|
|
38
|
+
}) => {
|
|
37
39
|
|
|
38
40
|
const theme: any = useTheme();
|
|
39
41
|
|
|
@@ -43,50 +45,44 @@ const UserInput = forwardRef<TextInput, UserInputProps>(({
|
|
|
43
45
|
computedLabelColor
|
|
44
46
|
} = useMemo(() => generateColors(theme, isError, cursorColor, placeholderColor, labelColor), [theme, isError, cursorColor, placeholderColor, labelColor]);
|
|
45
47
|
|
|
46
|
-
const
|
|
48
|
+
const dynamicStyles = {
|
|
47
49
|
INPUT_CONT: {
|
|
48
|
-
|
|
49
|
-
alignItems: multiline ? 'flex-start' : 'center',
|
|
50
|
+
alignItems: multiline ? 'flex-start' : 'center' as ViewStyle['alignItems'],
|
|
50
51
|
backgroundColor: disabled ? theme.colors.disable : bg ?? theme.colors.inputBgColor,
|
|
51
52
|
borderColor: isError ? theme.colors.error : strokeColor ?? theme.colors.outline,
|
|
52
53
|
borderWidth: variant === 'standard' ? 0 : stroke,
|
|
53
54
|
borderBottomWidth: stroke,
|
|
54
|
-
paddingHorizontal: horizontalScale(14),
|
|
55
55
|
borderRadius: verticalScale(br),
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
paddingVertical: multiline ? horizontalScale(10) : 'auto',
|
|
56
|
+
height: multiline ? undefined : verticalScale(48),
|
|
57
|
+
paddingVertical: multiline ? horizontalScale(10) : undefined,
|
|
59
58
|
},
|
|
60
59
|
INPUT: {
|
|
61
60
|
color: disabled ? theme.colors.textDisable : isError ? theme.colors.error : inputTextColor ?? theme.colors.textPrimary,
|
|
62
61
|
fontSize: responsiveFontSize(inputFs),
|
|
63
|
-
textAlignVertical: multiline ? 'top' : 'center',
|
|
64
|
-
minHeight: multiline ? 100 :
|
|
65
|
-
maxHeight: multiline ? 150 :
|
|
66
|
-
padding: 0,
|
|
67
|
-
flex: 1,
|
|
62
|
+
textAlignVertical: (multiline ? 'top' : 'center') as TextStyle['textAlignVertical'],
|
|
63
|
+
minHeight: multiline ? 100 : undefined,
|
|
64
|
+
maxHeight: multiline ? 150 : undefined,
|
|
68
65
|
},
|
|
69
66
|
ERROR_HELPER_TEXT: {
|
|
70
67
|
color: theme.colors.error,
|
|
71
|
-
paddingHorizontal: 5
|
|
72
68
|
}
|
|
73
|
-
}
|
|
69
|
+
};
|
|
74
70
|
|
|
75
71
|
return (<>
|
|
76
|
-
<StyledView gap={verticalScale(5)} style={styles?.mainContainer}>
|
|
72
|
+
<StyledView gap={verticalScale(5)} style={styles?.mainContainer} w='100%'>
|
|
77
73
|
{
|
|
78
74
|
label &&
|
|
79
75
|
<StyledText variant={textVariant?.label} fs={labelFs} color={computedLabelColor} style={styles?.label}>{label}</StyledText>
|
|
80
76
|
}
|
|
81
77
|
<StyledView
|
|
82
|
-
style={[STYLES.INPUT_CONT, styles?.inputContainer]}
|
|
78
|
+
style={[STYLES.INPUT_CONT, dynamicStyles.INPUT_CONT, styles?.inputContainer]}
|
|
83
79
|
>
|
|
84
80
|
{
|
|
85
81
|
renderLeftIcon
|
|
86
82
|
}
|
|
87
83
|
<TextInput
|
|
88
84
|
ref={ref}
|
|
89
|
-
style={[STYLES.INPUT, styles?.input]}
|
|
85
|
+
style={[STYLES.INPUT, dynamicStyles.INPUT, styles?.input]}
|
|
90
86
|
placeholder={placeholder}
|
|
91
87
|
placeholderTextColor={computedPlaceholderColor}
|
|
92
88
|
editable={!disabled}
|
|
@@ -100,25 +96,35 @@ const UserInput = forwardRef<TextInput, UserInputProps>(({
|
|
|
100
96
|
</StyledView>
|
|
101
97
|
{
|
|
102
98
|
(isError && helperText) &&
|
|
103
|
-
<StyledText
|
|
99
|
+
<StyledText
|
|
100
|
+
variant={textVariant?.helperText}
|
|
101
|
+
fs={helperTextFS}
|
|
102
|
+
style={[
|
|
103
|
+
STYLES.ERROR_HELPER_TEXT,
|
|
104
|
+
dynamicStyles.ERROR_HELPER_TEXT,
|
|
105
|
+
styles?.helperText
|
|
106
|
+
]}
|
|
107
|
+
>
|
|
108
|
+
{helperText}
|
|
109
|
+
</StyledText>
|
|
104
110
|
}
|
|
105
111
|
</StyledView>
|
|
106
112
|
</>)
|
|
107
|
-
}
|
|
113
|
+
};
|
|
108
114
|
export default UserInput;
|
|
109
115
|
export type { UserInputProps };
|
|
110
116
|
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
117
|
+
const STYLES = StyleSheet.create({
|
|
118
|
+
INPUT_CONT: {
|
|
119
|
+
flexDirection: 'row',
|
|
120
|
+
paddingHorizontal: horizontalScale(14),
|
|
121
|
+
gap: horizontalScale(10),
|
|
122
|
+
},
|
|
123
|
+
INPUT: {
|
|
124
|
+
padding: 0,
|
|
125
|
+
flex: 1,
|
|
126
|
+
},
|
|
127
|
+
ERROR_HELPER_TEXT: {
|
|
128
|
+
paddingHorizontal: 5
|
|
129
|
+
}
|
|
130
|
+
});
|
|
@@ -1,7 +1,27 @@
|
|
|
1
|
-
const LightenColorShades = (
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
const LightenColorShades = (color: string, amount: number): string => {
|
|
2
|
+
if (color.startsWith("#")) {
|
|
3
|
+
color = color.slice(1);
|
|
4
|
+
}
|
|
5
|
+
if (color.length === 3) {
|
|
6
|
+
color = color.split("").map(c => c + c).join("");
|
|
7
|
+
}
|
|
8
|
+
if (color.length !== 6) {
|
|
9
|
+
throw new Error("Invalid HEX color.");
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
const getValidColorValue = (start: number): number => {
|
|
13
|
+
const value = parseInt(color.slice(start, start + 2), 16);
|
|
14
|
+
return Number.isNaN(value) ? 0 : Math.min(255, Math.max(0, value + amount));
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
const r: number = getValidColorValue(0);
|
|
18
|
+
const g: number = getValidColorValue(2);
|
|
19
|
+
const b: number = getValidColorValue(4);
|
|
20
|
+
|
|
21
|
+
return `#${((1 << 24) + (r << 16) + (g << 8) + b)
|
|
22
|
+
.toString(16)
|
|
23
|
+
.slice(1)
|
|
24
|
+
.toUpperCase()}`;
|
|
25
|
+
};
|
|
26
|
+
|
|
7
27
|
export default LightenColorShades;
|
|
@@ -13,7 +13,11 @@ const guidelineBaseWidth = 350;
|
|
|
13
13
|
const guidelineBaseHeight = 680;
|
|
14
14
|
const [shortDimension, longDimension] = SCREEN_WIDTH < SCREEN_HEIGHT ? [SCREEN_WIDTH, SCREEN_HEIGHT] : [SCREEN_HEIGHT, SCREEN_WIDTH];
|
|
15
15
|
|
|
16
|
+
const scalingCache = new Map<'hScale' | 'vScale' | 'fs', object>();
|
|
16
17
|
|
|
18
|
+
export const fun = () => {
|
|
19
|
+
return scalingCache
|
|
20
|
+
}
|
|
17
21
|
const checkIsPhone = (size: number): number => {
|
|
18
22
|
if (SCREEN_WIDTH <= 430 && SCREEN_WIDTH >= 375) {
|
|
19
23
|
return size;
|
|
@@ -24,11 +28,18 @@ export const horizontalScale = (size: number): number => {
|
|
|
24
28
|
if (checkIsPhone(size)) {
|
|
25
29
|
return size;
|
|
26
30
|
}
|
|
31
|
+
const hScaleCache: any = scalingCache.get('hScale') || {};
|
|
32
|
+
if (hScaleCache?.[size]) {
|
|
33
|
+
return hScaleCache?.[size];
|
|
34
|
+
}
|
|
27
35
|
const slowDownRate = SCREEN_WIDTH < 375 ? 2 : 0.40;
|
|
28
36
|
let scale = (shortDimension / guidelineBaseHeight);
|
|
29
37
|
scale = 1 + (scale - 1) * slowDownRate;
|
|
30
38
|
let adjustedSize = size * Math.max(scale, 0.80);
|
|
31
|
-
|
|
39
|
+
const finalSize = Math.floor(PixelRatio.roundToNearestPixel(adjustedSize));
|
|
40
|
+
hScaleCache[size] = finalSize;
|
|
41
|
+
scalingCache.set('hScale', hScaleCache)
|
|
42
|
+
return finalSize;
|
|
32
43
|
}
|
|
33
44
|
|
|
34
45
|
|
|
@@ -36,11 +47,18 @@ export const verticalScale = (size: number): number => {
|
|
|
36
47
|
if (checkIsPhone(size)) {
|
|
37
48
|
return size;
|
|
38
49
|
}
|
|
50
|
+
const vScaleCache: any = scalingCache.get('vScale') || {};
|
|
51
|
+
if (vScaleCache?.[size]) {
|
|
52
|
+
return vScaleCache?.[size];
|
|
53
|
+
}
|
|
39
54
|
const slowDownRate = SCREEN_WIDTH < 375 ? 2 : 0.40;
|
|
40
55
|
let scale = (longDimension / guidelineBaseHeight);
|
|
41
56
|
scale = 1 + (scale - 1) * slowDownRate;
|
|
42
57
|
let adjustedSize = size * Math.max(scale, 0.80);
|
|
43
|
-
|
|
58
|
+
const finalSize = Math.floor(PixelRatio.roundToNearestPixel(adjustedSize));
|
|
59
|
+
vScaleCache[size] = finalSize;
|
|
60
|
+
scalingCache.set('vScale', vScaleCache)
|
|
61
|
+
return finalSize;
|
|
44
62
|
}
|
|
45
63
|
|
|
46
64
|
|
|
@@ -63,13 +81,20 @@ export const responsiveFontSize = (fontSize: number): number => {
|
|
|
63
81
|
if (checkIsPhone(fontSize)) {
|
|
64
82
|
return fontSize;
|
|
65
83
|
}
|
|
84
|
+
const fsCache: any = scalingCache.get('fs') || {};
|
|
85
|
+
if (fsCache?.[fontSize]) {
|
|
86
|
+
return fsCache?.[fontSize];
|
|
87
|
+
}
|
|
66
88
|
const slowDownRate = SCREEN_WIDTH < 375 ? 2 : 0.20
|
|
67
89
|
const screenDiagonal = Math.sqrt(SCREEN_WIDTH ** 2 + SCREEN_HEIGHT ** 2);
|
|
68
90
|
const baseScreenDiagonal = Math.sqrt(360 ** 2 + 640 ** 2);
|
|
69
91
|
let scale = screenDiagonal / baseScreenDiagonal;
|
|
70
92
|
scale = 1 + (scale - 1) * slowDownRate;
|
|
71
93
|
let adjustedFontSize = fontSize * Math.max(scale, 0.85);
|
|
72
|
-
|
|
94
|
+
const finalSize = Math.floor(PixelRatio.roundToNearestPixel(adjustedFontSize));
|
|
95
|
+
fsCache[fontSize] = finalSize;
|
|
96
|
+
scalingCache.set('vScale', fsCache)
|
|
97
|
+
return finalSize;
|
|
73
98
|
};
|
|
74
99
|
|
|
75
100
|
|