@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
|
-
import React, { useEffect, useState } from "react";
|
|
2
|
-
import { StyleSheet, TouchableWithoutFeedback } from "react-native";
|
|
1
|
+
import React, { useEffect, useRef, useState } from "react";
|
|
2
|
+
import { StyleSheet, TouchableWithoutFeedback, Animated, type ViewStyle } from "react-native";
|
|
3
3
|
import { StyledText, StyledView } from "../StyledComponents";
|
|
4
|
-
import Animated, { useAnimatedStyle, useSharedValue, withSpring } from "react-native-reanimated";
|
|
5
4
|
import { useTheme } from "../../hooks";
|
|
6
5
|
import { horizontalScale, verticalScale } from "../../helpers/ResponsiveCalculations";
|
|
7
6
|
import { Check } from "../../assets/svg";
|
|
@@ -33,36 +32,33 @@ const CheckBox: React.FC<CheckBoxProps> = ({
|
|
|
33
32
|
setIsCheckboxChecked(defaultValue);
|
|
34
33
|
}, [defaultValue]);
|
|
35
34
|
|
|
36
|
-
const scaleVal =
|
|
35
|
+
const scaleVal = useRef(new Animated.Value(1)).current;
|
|
37
36
|
const { colors }: any = useTheme();
|
|
38
37
|
activeBgColor = disabled ? colors.disable : activeBgColor ?? colors.primary;
|
|
39
38
|
iconSize = iconSize ?? size / 1.5;
|
|
40
39
|
const bgColor = (!disableBuiltInState && isCheckboxChecked) || (disableBuiltInState && isChecked) ? activeBgColor : inActiveBgColor;
|
|
40
|
+
const textColor = disabled ? colors.textDisable : colors.textPrimary;
|
|
41
41
|
|
|
42
|
-
const
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
CHECKBOX_PARENT_CONT: {
|
|
50
|
-
height: verticalScale(size),
|
|
51
|
-
width: verticalScale(size),
|
|
52
|
-
borderWidth: 0.8,
|
|
53
|
-
borderColor: disabled ? colors.disable : activeBgColor,
|
|
54
|
-
alignItems: 'center',
|
|
55
|
-
justifyContent: 'center',
|
|
56
|
-
borderRadius: variant === 'square' ? 5 : verticalScale(size),
|
|
57
|
-
padding: verticalScale(7),
|
|
58
|
-
backgroundColor: bgColor,
|
|
59
|
-
}
|
|
60
|
-
});
|
|
42
|
+
const dynamicMainContStyles: ViewStyle = {
|
|
43
|
+
height: verticalScale(size),
|
|
44
|
+
width: verticalScale(size),
|
|
45
|
+
borderColor: disabled ? colors.disable : activeBgColor,
|
|
46
|
+
borderRadius: variant === 'square' ? 5 : verticalScale(size),
|
|
47
|
+
backgroundColor: bgColor
|
|
48
|
+
};
|
|
61
49
|
|
|
62
|
-
const animatedStyle =
|
|
63
|
-
transform: [{ scale: scaleVal
|
|
64
|
-
}
|
|
50
|
+
const animatedStyle = {
|
|
51
|
+
transform: [{ scale: scaleVal }]
|
|
52
|
+
};
|
|
65
53
|
|
|
54
|
+
const animateScale = (toValue: number) => {
|
|
55
|
+
Animated.spring(scaleVal, {
|
|
56
|
+
toValue,
|
|
57
|
+
speed: 20,
|
|
58
|
+
bounciness: 8,
|
|
59
|
+
useNativeDriver: true,
|
|
60
|
+
}).start();
|
|
61
|
+
};
|
|
66
62
|
const onUserClick = () => {
|
|
67
63
|
if (!disableBuiltInState) {
|
|
68
64
|
onPress?.(!isCheckboxChecked);
|
|
@@ -71,32 +67,48 @@ const CheckBox: React.FC<CheckBoxProps> = ({
|
|
|
71
67
|
onPress?.(!isChecked);
|
|
72
68
|
}
|
|
73
69
|
};
|
|
74
|
-
return (
|
|
75
|
-
<
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
70
|
+
return (
|
|
71
|
+
<StyledView>
|
|
72
|
+
<TouchableWithoutFeedback
|
|
73
|
+
onPressIn={() => animateScale(0.8)}
|
|
74
|
+
onPressOut={() => animateScale(1)}
|
|
75
|
+
onPress={onUserClick}
|
|
76
|
+
disabled={disabled}
|
|
77
|
+
>
|
|
78
|
+
<StyledView style={[STYLES.CONTAINER, containerStyle]}>
|
|
82
79
|
|
|
83
|
-
|
|
80
|
+
<Animated.View style={[STYLES.CHECKBOX_PARENT_CONT, dynamicMainContStyles, checkBoxStyle, animatedStyle]}>
|
|
81
|
+
{
|
|
82
|
+
(disableBuiltInState ? isChecked : isCheckboxChecked) &&
|
|
83
|
+
<Check
|
|
84
|
+
color={iconColor ?? colors.iconSecondary}
|
|
85
|
+
size={verticalScale(iconSize)}
|
|
86
|
+
/>
|
|
87
|
+
}
|
|
88
|
+
</Animated.View>
|
|
84
89
|
{
|
|
85
|
-
|
|
86
|
-
<
|
|
87
|
-
color={iconColor ?? colors.iconSecondary}
|
|
88
|
-
size={verticalScale(iconSize)}
|
|
89
|
-
/>
|
|
90
|
+
text &&
|
|
91
|
+
<StyledText style={textStyle} fs={fs} color={textColor} variant={textVariant} primary>{text}</StyledText>
|
|
90
92
|
}
|
|
91
|
-
</Animated.View>
|
|
92
|
-
{
|
|
93
|
-
text &&
|
|
94
|
-
<StyledText style={textStyle} fs={fs} variant={textVariant} primary>{text}</StyledText>
|
|
95
|
-
}
|
|
96
93
|
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
94
|
+
</StyledView>
|
|
95
|
+
</TouchableWithoutFeedback>
|
|
96
|
+
</StyledView>
|
|
97
|
+
)
|
|
100
98
|
}
|
|
101
99
|
export default CheckBox;
|
|
102
|
-
export type { CheckBoxProps };
|
|
100
|
+
export type { CheckBoxProps };
|
|
101
|
+
|
|
102
|
+
const STYLES = StyleSheet.create({
|
|
103
|
+
CONTAINER: {
|
|
104
|
+
flexDirection: 'row',
|
|
105
|
+
gap: horizontalScale(10),
|
|
106
|
+
alignItems: 'center',
|
|
107
|
+
},
|
|
108
|
+
CHECKBOX_PARENT_CONT: {
|
|
109
|
+
borderWidth: 0.8,
|
|
110
|
+
alignItems: 'center',
|
|
111
|
+
justifyContent: 'center',
|
|
112
|
+
padding: verticalScale(7)
|
|
113
|
+
}
|
|
114
|
+
});
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import React, { cloneElement, forwardRef, useEffect, useImperativeHandle, useState } from 'react';
|
|
1
|
+
import React, { cloneElement, forwardRef, useEffect, useImperativeHandle, useRef, useState } from 'react';
|
|
2
2
|
import type { ReactElement } from "react";
|
|
3
|
-
import { Keyboard, BackHandler } from 'react-native';
|
|
4
|
-
import
|
|
3
|
+
import { Keyboard, BackHandler, StyleSheet, Animated } from 'react-native';
|
|
4
|
+
import type { ViewStyle } from 'react-native';
|
|
5
5
|
import { dialogSizes } from '../../constants';
|
|
6
6
|
import Portal from '../Portal/Portal';
|
|
7
7
|
import type { DialogProps, DialogRefProps } from '../../types';
|
|
@@ -9,36 +9,35 @@ import type { DialogProps, DialogRefProps } from '../../types';
|
|
|
9
9
|
|
|
10
10
|
const Dialog = forwardRef<DialogRefProps, DialogProps>(({
|
|
11
11
|
variant = 'default',
|
|
12
|
-
// isVisible = false,
|
|
13
12
|
size = 'lg',
|
|
14
13
|
fullScreen,
|
|
15
14
|
backdropColor = 'rgba(0, 0, 0, 0.5)',
|
|
16
|
-
animationDuration = 800,
|
|
15
|
+
// animationDuration = 800,
|
|
17
16
|
onClose,
|
|
18
17
|
children,
|
|
19
18
|
}, ref) => {
|
|
20
19
|
|
|
21
20
|
const [dialogVisible, setDialogVisible] = useState(false);
|
|
22
|
-
const scale =
|
|
23
|
-
const opacity =
|
|
21
|
+
const scale = useRef(new Animated.Value(0.9)).current;
|
|
22
|
+
const opacity = useRef(new Animated.Value(0)).current;
|
|
24
23
|
|
|
25
24
|
useEffect(() => {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
);
|
|
25
|
+
Animated.timing(opacity, {
|
|
26
|
+
toValue: dialogVisible ? 1 : 0,
|
|
27
|
+
duration: 300,
|
|
28
|
+
useNativeDriver: true,
|
|
29
|
+
}).start();
|
|
30
|
+
Animated.spring(scale, {
|
|
31
|
+
toValue: dialogVisible ? 1 : 0.9,
|
|
32
|
+
damping: 10,
|
|
33
|
+
stiffness: 90,
|
|
34
|
+
useNativeDriver: true,
|
|
35
|
+
}).start();
|
|
37
36
|
}, [dialogVisible]);
|
|
38
37
|
|
|
39
38
|
useEffect(() => {
|
|
40
|
-
BackHandler.addEventListener('hardwareBackPress', hardwareBackPress)
|
|
41
|
-
return () =>
|
|
39
|
+
const handler = BackHandler.addEventListener('hardwareBackPress', hardwareBackPress);
|
|
40
|
+
return () => handler.remove();
|
|
42
41
|
}, [dialogVisible]);
|
|
43
42
|
|
|
44
43
|
const hardwareBackPress = () => {
|
|
@@ -51,34 +50,20 @@ const Dialog = forwardRef<DialogRefProps, DialogProps>(({
|
|
|
51
50
|
close: () => setDialogVisible(false)
|
|
52
51
|
}));
|
|
53
52
|
|
|
54
|
-
const
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
return {
|
|
69
|
-
backgroundColor: '#fff',
|
|
70
|
-
borderRadius: 5,
|
|
71
|
-
width: `${dialogSizes[size]}%`,
|
|
72
|
-
borderWidth: 1,
|
|
73
|
-
borderColor: '#d4d4d4',
|
|
74
|
-
minHeight: fullScreen ? '100%' : 'auto',
|
|
75
|
-
maxHeight: fullScreen ? '100%' : '80%',
|
|
76
|
-
opacity: opacity.value,
|
|
77
|
-
transform: [{
|
|
78
|
-
scale: scale.value
|
|
79
|
-
}],
|
|
80
|
-
}
|
|
81
|
-
});
|
|
53
|
+
const backdropAnimatedStyles = {
|
|
54
|
+
opacity: opacity,
|
|
55
|
+
backgroundColor: backdropColor,
|
|
56
|
+
};
|
|
57
|
+
const modalContAnimatedStyles = {
|
|
58
|
+
transform: [{ scale }],
|
|
59
|
+
opacity: opacity,
|
|
60
|
+
};
|
|
61
|
+
const dynamicModalContStyles: ViewStyle = {
|
|
62
|
+
minHeight: fullScreen ? '100%' : 'auto',
|
|
63
|
+
maxHeight: fullScreen ? '100%' : '80%',
|
|
64
|
+
width: `${dialogSizes[size]}%`,
|
|
65
|
+
};
|
|
66
|
+
|
|
82
67
|
const renderChildrenWithVariant = () => {
|
|
83
68
|
return React.Children.map(children, (child) => {
|
|
84
69
|
if (React.isValidElement(child)) {
|
|
@@ -98,12 +83,12 @@ const Dialog = forwardRef<DialogRefProps, DialogProps>(({
|
|
|
98
83
|
return (<>
|
|
99
84
|
<Portal name='dialog'>
|
|
100
85
|
<Animated.View
|
|
101
|
-
style={
|
|
86
|
+
style={[STYLES.BACKDROP_CONT, backdropAnimatedStyles]}
|
|
102
87
|
pointerEvents={dialogVisible ? 'auto' : 'none'}
|
|
103
88
|
onStartShouldSetResponder={handleStartShouldSetResponder}
|
|
104
89
|
>
|
|
105
90
|
<Animated.View
|
|
106
|
-
style={
|
|
91
|
+
style={[STYLES.MODAL_CONT, dynamicModalContStyles, modalContAnimatedStyles]}
|
|
107
92
|
onStartShouldSetResponder={() => true}
|
|
108
93
|
>
|
|
109
94
|
{renderChildrenWithVariant()}
|
|
@@ -113,4 +98,22 @@ const Dialog = forwardRef<DialogRefProps, DialogProps>(({
|
|
|
113
98
|
</>);
|
|
114
99
|
});
|
|
115
100
|
export default Dialog;
|
|
116
|
-
export type { DialogProps };
|
|
101
|
+
export type { DialogProps };
|
|
102
|
+
|
|
103
|
+
const STYLES = StyleSheet.create({
|
|
104
|
+
BACKDROP_CONT: {
|
|
105
|
+
position: 'absolute',
|
|
106
|
+
top: 0,
|
|
107
|
+
bottom: 0,
|
|
108
|
+
left: 0,
|
|
109
|
+
right: 0,
|
|
110
|
+
justifyContent: 'center',
|
|
111
|
+
alignItems: 'center',
|
|
112
|
+
},
|
|
113
|
+
MODAL_CONT: {
|
|
114
|
+
backgroundColor: '#fff',
|
|
115
|
+
borderRadius: 5,
|
|
116
|
+
borderWidth: 1,
|
|
117
|
+
borderColor: '#d4d4d4'
|
|
118
|
+
}
|
|
119
|
+
});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { View,
|
|
2
|
+
import { View, ScrollView } from 'react-native';
|
|
3
3
|
import { moderateScale } from '../../helpers/ResponsiveCalculations';
|
|
4
4
|
import type { DialogBodyProps } from '../../types';
|
|
5
5
|
|
|
@@ -14,17 +14,15 @@ const DialogBody: React.FC<props> = ({
|
|
|
14
14
|
containerStyle,
|
|
15
15
|
children,
|
|
16
16
|
}) => {
|
|
17
|
-
const
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
},
|
|
23
|
-
});
|
|
17
|
+
const style = {
|
|
18
|
+
paddingVertical: variant == 'default' ? moderateScale(16) : 0,
|
|
19
|
+
paddingHorizontal: moderateScale(variant == 'default' ? 16 : 25),
|
|
20
|
+
gap: 20,
|
|
21
|
+
};
|
|
24
22
|
return (<>
|
|
25
23
|
|
|
26
24
|
<ScrollView scrollEnabled={scrollEnable}>
|
|
27
|
-
<View style={[
|
|
25
|
+
<View style={[style, containerStyle]} pointerEvents='box-none'>
|
|
28
26
|
{children}
|
|
29
27
|
</View>
|
|
30
28
|
</ScrollView>
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { View
|
|
2
|
+
import { View } from 'react-native';
|
|
3
3
|
import { moderateVerticalScale } from '../../helpers/ResponsiveCalculations';
|
|
4
4
|
import { StyledText } from '../StyledComponents';
|
|
5
5
|
import type { DialogDescriptionProps } from '../../types';
|
|
@@ -11,16 +11,16 @@ const DialogDescription: React.FC<DialogDescriptionProps> = ({
|
|
|
11
11
|
textStyle,
|
|
12
12
|
children,
|
|
13
13
|
}) => {
|
|
14
|
-
const STYLES = StyleSheet.create({
|
|
15
|
-
TEXT: {
|
|
16
|
-
color: '#a1a1aa',
|
|
17
|
-
lineHeight: moderateVerticalScale(13)
|
|
18
|
-
}
|
|
19
|
-
});
|
|
20
14
|
return (<>
|
|
21
|
-
|
|
22
15
|
<View style={containerStyle}>
|
|
23
|
-
<StyledText
|
|
16
|
+
<StyledText
|
|
17
|
+
style={[{ lineHeight: moderateVerticalScale(13) }, textStyle]}
|
|
18
|
+
color='#a1a1aa'
|
|
19
|
+
variant={textVariant}
|
|
20
|
+
fs={fs}
|
|
21
|
+
>
|
|
22
|
+
{children}
|
|
23
|
+
</StyledText>
|
|
24
24
|
</View>
|
|
25
25
|
</>);
|
|
26
26
|
}
|
|
@@ -14,22 +14,24 @@ const DialogFoot: React.FC<props> = ({
|
|
|
14
14
|
containerStyle,
|
|
15
15
|
children
|
|
16
16
|
}) => {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
padding: moderateScale(variant === 'default' ? 16 : 20),
|
|
23
|
-
paddingHorizontal: moderateScale(variant === 'default' ? 16 : 25),
|
|
24
|
-
justifyContent: 'flex-end',
|
|
25
|
-
gap: moderateScale(15)
|
|
26
|
-
},
|
|
27
|
-
});
|
|
17
|
+
const dynamicStyles = {
|
|
18
|
+
borderTopWidth: variant === 'default' ? 0.7 : 0,
|
|
19
|
+
padding: moderateScale(variant === 'default' ? 16 : 20),
|
|
20
|
+
paddingHorizontal: moderateScale(variant === 'default' ? 16 : 25),
|
|
21
|
+
};
|
|
28
22
|
return (<>
|
|
29
|
-
<Stack.H
|
|
23
|
+
<Stack.H style={[STYLES.CONTAINER, dynamicStyles, containerStyle]}>
|
|
30
24
|
{children}
|
|
31
25
|
</Stack.H>
|
|
32
26
|
</>);
|
|
33
27
|
}
|
|
34
28
|
export default DialogFoot;
|
|
35
|
-
export type { DialogFootProps };
|
|
29
|
+
export type { DialogFootProps };
|
|
30
|
+
|
|
31
|
+
const STYLES = StyleSheet.create({
|
|
32
|
+
CONTAINER: {
|
|
33
|
+
borderColor: '#d4d4d4',
|
|
34
|
+
justifyContent: 'flex-end',
|
|
35
|
+
gap: moderateScale(15)
|
|
36
|
+
},
|
|
37
|
+
});
|
|
@@ -19,24 +19,13 @@ const DialogHead: React.FC<props> = ({
|
|
|
19
19
|
textStyle,
|
|
20
20
|
children
|
|
21
21
|
}) => {
|
|
22
|
-
const
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
padding: moderateScale(variant === 'default' ? 16 : 25),
|
|
27
|
-
paddingBottom: moderateScale(16),
|
|
28
|
-
justifyContent: 'space-between',
|
|
29
|
-
flexDirection: 'row',
|
|
30
|
-
},
|
|
31
|
-
HEADER_TEXT: {
|
|
32
|
-
// fontSize: responsiveFontSize(15),
|
|
33
|
-
fontWeight: 'bold',
|
|
34
|
-
color: '#000',
|
|
35
|
-
}
|
|
36
|
-
});
|
|
22
|
+
const dynamicStyles = {
|
|
23
|
+
borderBottomWidth: variant == 'default' ? 0.7 : 0,
|
|
24
|
+
padding: moderateScale(variant === 'default' ? 16 : 25),
|
|
25
|
+
};
|
|
37
26
|
return (<>
|
|
38
27
|
|
|
39
|
-
<View style={[STYLES.CONTAINER, containerStyle]}>
|
|
28
|
+
<View style={[STYLES.CONTAINER, dynamicStyles, containerStyle]}>
|
|
40
29
|
<View>
|
|
41
30
|
<StyledText style={[STYLES.HEADER_TEXT, textStyle]} fs={fs} variant={textVariant}>{title}</StyledText>
|
|
42
31
|
{children}
|
|
@@ -48,4 +37,18 @@ const DialogHead: React.FC<props> = ({
|
|
|
48
37
|
</>);
|
|
49
38
|
}
|
|
50
39
|
export default DialogHead;
|
|
51
|
-
export type { DialogHeadProps };
|
|
40
|
+
export type { DialogHeadProps };
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
const STYLES = StyleSheet.create({
|
|
44
|
+
CONTAINER: {
|
|
45
|
+
borderColor: '#d4d4d4',
|
|
46
|
+
paddingBottom: moderateScale(16),
|
|
47
|
+
justifyContent: 'space-between',
|
|
48
|
+
flexDirection: 'row',
|
|
49
|
+
},
|
|
50
|
+
HEADER_TEXT: {
|
|
51
|
+
fontWeight: 'bold',
|
|
52
|
+
color: '#000',
|
|
53
|
+
}
|
|
54
|
+
});
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { StyleSheet } from "react-native";
|
|
3
2
|
import type { ViewStyle, StyleProp } from "react-native";
|
|
4
3
|
import { StyledView } from '../StyledComponents';
|
|
5
4
|
import { useTheme } from '../../hooks';
|
|
@@ -20,15 +19,12 @@ const Divider: React.FC<DividerProps> = ({
|
|
|
20
19
|
|
|
21
20
|
const theme = useTheme();
|
|
22
21
|
|
|
23
|
-
const
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
}
|
|
28
|
-
});
|
|
29
|
-
|
|
22
|
+
const dynamicStyles = {
|
|
23
|
+
borderWidth: thickness,
|
|
24
|
+
borderColor: color ?? theme?.colors.dividerColor
|
|
25
|
+
};
|
|
30
26
|
return (<>
|
|
31
|
-
<StyledView style={[
|
|
27
|
+
<StyledView style={[dynamicStyles, style]} />
|
|
32
28
|
</>);
|
|
33
29
|
};
|
|
34
30
|
export default Divider;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import type { JSX } from 'react';
|
|
2
3
|
import { View, StyleSheet, TouchableOpacity } from 'react-native';
|
|
3
4
|
import { moderateScale, moderateVerticalScale, responsiveFontSize } from '../../helpers/ResponsiveCalculations';
|
|
4
5
|
import { StyledText } from '../StyledComponents';
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import React from "react";
|
|
1
|
+
import React, { useMemo } from "react";
|
|
2
|
+
import type { JSX } from 'react';
|
|
2
3
|
import { verticalScale } from "../../helpers/ResponsiveCalculations";
|
|
3
4
|
import { useTheme } from "../../hooks";
|
|
4
5
|
|
|
@@ -14,14 +15,18 @@ const Icon: React.FC<IconProps> = ({
|
|
|
14
15
|
}) => {
|
|
15
16
|
const theme = useTheme(!color && !renderIcon?.props.color);
|
|
16
17
|
|
|
17
|
-
|
|
18
|
-
|
|
18
|
+
const renderCallBackIcon = useMemo(() => {
|
|
19
|
+
return React.cloneElement(renderIcon as React.ReactElement<any>,
|
|
19
20
|
{
|
|
20
21
|
...renderIcon?.props,
|
|
21
22
|
size: verticalScale(renderIcon?.props?.size ?? 15),
|
|
22
23
|
color: color ?? (renderIcon?.props.color ?? theme?.colors.iconPrimary)
|
|
23
24
|
}
|
|
24
|
-
)
|
|
25
|
+
)
|
|
26
|
+
}, [color, theme]);
|
|
27
|
+
|
|
28
|
+
return (<>
|
|
29
|
+
{renderCallBackIcon}
|
|
25
30
|
</>)
|
|
26
31
|
}
|
|
27
32
|
export default Icon;
|
|
@@ -1,31 +1,48 @@
|
|
|
1
1
|
import type React from "react";
|
|
2
2
|
import { StyledText } from "../StyledComponents";
|
|
3
|
-
import { Linking, TouchableOpacity } from "react-native";
|
|
3
|
+
import { Linking, StyleSheet, TouchableOpacity, type TextStyle } from "react-native";
|
|
4
4
|
import { useCallback } from "react";
|
|
5
|
+
import type { TypographyVariant } from "../../types";
|
|
5
6
|
|
|
6
7
|
|
|
7
8
|
type props = {
|
|
8
9
|
title: string;
|
|
9
10
|
href: string;
|
|
11
|
+
textVariant?: TypographyVariant;
|
|
12
|
+
style?: TextStyle
|
|
10
13
|
}
|
|
11
14
|
|
|
12
15
|
const Link: React.FC<props> = ({
|
|
13
16
|
title = '',
|
|
14
|
-
href
|
|
17
|
+
href,
|
|
18
|
+
textVariant = 'h5',
|
|
19
|
+
style
|
|
15
20
|
}) => {
|
|
16
21
|
const onUserPress = useCallback(async () => {
|
|
17
22
|
const supported = await Linking.canOpenURL(href);
|
|
18
23
|
if (supported) {
|
|
19
24
|
await Linking.openURL(href);
|
|
20
25
|
}
|
|
21
|
-
}, []);
|
|
26
|
+
}, [href]);
|
|
22
27
|
return (<>
|
|
23
28
|
<TouchableOpacity onPress={onUserPress}>
|
|
24
|
-
<StyledText
|
|
25
|
-
|
|
26
|
-
|
|
29
|
+
<StyledText
|
|
30
|
+
variant={textVariant}
|
|
31
|
+
color='#0000FF'
|
|
32
|
+
style={[STYLES.TEXT, style]}
|
|
33
|
+
>
|
|
34
|
+
{title}
|
|
35
|
+
</StyledText>
|
|
27
36
|
</TouchableOpacity>
|
|
28
37
|
</>)
|
|
29
38
|
}
|
|
30
39
|
|
|
31
|
-
export default Link;
|
|
40
|
+
export default Link;
|
|
41
|
+
|
|
42
|
+
const STYLES = StyleSheet.create({
|
|
43
|
+
TEXT: {
|
|
44
|
+
borderBottomColor: '#0000FF',
|
|
45
|
+
borderBottomWidth: 0.8,
|
|
46
|
+
alignSelf: 'flex-start',
|
|
47
|
+
}
|
|
48
|
+
});
|