@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.
Files changed (235) hide show
  1. package/lib/commonjs/components/Button/Button.js +50 -37
  2. package/lib/commonjs/components/Button/Button.js.map +1 -1
  3. package/lib/commonjs/components/CheckBox/CheckBox.js +39 -29
  4. package/lib/commonjs/components/CheckBox/CheckBox.js.map +1 -1
  5. package/lib/commonjs/components/Dialog/Dialog.js +52 -48
  6. package/lib/commonjs/components/Dialog/Dialog.js.map +1 -1
  7. package/lib/commonjs/components/Dialog/DialogBody.js +6 -8
  8. package/lib/commonjs/components/Dialog/DialogBody.js.map +1 -1
  9. package/lib/commonjs/components/Dialog/DialogDescription.js +4 -7
  10. package/lib/commonjs/components/Dialog/DialogDescription.js.map +1 -1
  11. package/lib/commonjs/components/Dialog/DialogFoot.js +13 -13
  12. package/lib/commonjs/components/Dialog/DialogFoot.js.map +1 -1
  13. package/lib/commonjs/components/Dialog/DialogHead.js +17 -16
  14. package/lib/commonjs/components/Dialog/DialogHead.js.map +1 -1
  15. package/lib/commonjs/components/Divider/Divider.js +5 -8
  16. package/lib/commonjs/components/Divider/Divider.js.map +1 -1
  17. package/lib/commonjs/components/Header/Header.js.map +1 -1
  18. package/lib/commonjs/components/Icon/Icon.js +9 -5
  19. package/lib/commonjs/components/Icon/Icon.js.map +1 -1
  20. package/lib/commonjs/components/Link/Link.js +13 -15
  21. package/lib/commonjs/components/Link/Link.js.map +1 -1
  22. package/lib/commonjs/components/Menu/Menu.js +51 -54
  23. package/lib/commonjs/components/Menu/Menu.js.map +1 -1
  24. package/lib/commonjs/components/Menu/MenuItem.js +0 -2
  25. package/lib/commonjs/components/Menu/MenuItem.js.map +1 -1
  26. package/lib/commonjs/components/Portal/Portal.js +1 -1
  27. package/lib/commonjs/components/Portal/Portal.js.map +1 -1
  28. package/lib/commonjs/components/Progress/Progress.js +25 -15
  29. package/lib/commonjs/components/Progress/Progress.js.map +1 -1
  30. package/lib/commonjs/components/Stack/HStack.js +9 -11
  31. package/lib/commonjs/components/Stack/HStack.js.map +1 -1
  32. package/lib/commonjs/components/Stack/VStack.js +4 -2
  33. package/lib/commonjs/components/Stack/VStack.js.map +1 -1
  34. package/lib/commonjs/components/StyledComponents/StyledText.js +12 -13
  35. package/lib/commonjs/components/StyledComponents/StyledText.js.map +1 -1
  36. package/lib/commonjs/components/StyledComponents/StyledView.js +14 -14
  37. package/lib/commonjs/components/StyledComponents/StyledView.js.map +1 -1
  38. package/lib/commonjs/components/Switch/Switch.js +2 -2
  39. package/lib/commonjs/components/Switch/Switch.js.map +1 -1
  40. package/lib/commonjs/components/UserInput/UserInput.js +29 -32
  41. package/lib/commonjs/components/UserInput/UserInput.js.map +1 -1
  42. package/lib/commonjs/helpers/LightenColorShades.js +18 -5
  43. package/lib/commonjs/helpers/LightenColorShades.js.map +1 -1
  44. package/lib/commonjs/helpers/ResponsiveCalculations.js +30 -4
  45. package/lib/commonjs/helpers/ResponsiveCalculations.js.map +1 -1
  46. package/lib/commonjs/helpers/index.js +16 -0
  47. package/lib/commonjs/helpers/index.js.map +1 -1
  48. package/lib/commonjs/index.js +5 -4
  49. package/lib/commonjs/index.js.map +2 -1
  50. package/lib/commonjs/themes/LightTheme.js +1 -3
  51. package/lib/commonjs/themes/LightTheme.js.map +1 -1
  52. package/lib/commonjs/types/index.js +11 -0
  53. package/lib/commonjs/types/index.js.map +1 -1
  54. package/lib/commonjs/types/progress.type.js +2 -0
  55. package/lib/commonjs/types/progress.type.js.map +1 -0
  56. package/lib/module/components/Button/Button.js +50 -37
  57. package/lib/module/components/Button/Button.js.map +1 -1
  58. package/lib/module/components/CheckBox/CheckBox.js +41 -31
  59. package/lib/module/components/CheckBox/CheckBox.js.map +1 -1
  60. package/lib/module/components/Dialog/Dialog.js +52 -48
  61. package/lib/module/components/Dialog/Dialog.js.map +1 -1
  62. package/lib/module/components/Dialog/DialogBody.js +7 -9
  63. package/lib/module/components/Dialog/DialogBody.js.map +1 -1
  64. package/lib/module/components/Dialog/DialogDescription.js +5 -8
  65. package/lib/module/components/Dialog/DialogDescription.js.map +1 -1
  66. package/lib/module/components/Dialog/DialogFoot.js +13 -13
  67. package/lib/module/components/Dialog/DialogFoot.js.map +1 -1
  68. package/lib/module/components/Dialog/DialogHead.js +17 -16
  69. package/lib/module/components/Dialog/DialogHead.js.map +1 -1
  70. package/lib/module/components/Divider/Divider.js +5 -8
  71. package/lib/module/components/Divider/Divider.js.map +1 -1
  72. package/lib/module/components/Header/Header.js.map +1 -1
  73. package/lib/module/components/Icon/Icon.js +7 -4
  74. package/lib/module/components/Icon/Icon.js.map +1 -1
  75. package/lib/module/components/Link/Link.js +14 -16
  76. package/lib/module/components/Link/Link.js.map +1 -1
  77. package/lib/module/components/Menu/Menu.js +51 -54
  78. package/lib/module/components/Menu/Menu.js.map +1 -1
  79. package/lib/module/components/Menu/MenuItem.js +0 -2
  80. package/lib/module/components/Menu/MenuItem.js.map +1 -1
  81. package/lib/module/components/Portal/Portal.js +1 -1
  82. package/lib/module/components/Portal/Portal.js.map +1 -1
  83. package/lib/module/components/Progress/Progress.js +26 -16
  84. package/lib/module/components/Progress/Progress.js.map +1 -1
  85. package/lib/module/components/Stack/HStack.js +10 -12
  86. package/lib/module/components/Stack/HStack.js.map +1 -1
  87. package/lib/module/components/Stack/VStack.js +4 -2
  88. package/lib/module/components/Stack/VStack.js.map +1 -1
  89. package/lib/module/components/StyledComponents/StyledText.js +13 -14
  90. package/lib/module/components/StyledComponents/StyledText.js.map +1 -1
  91. package/lib/module/components/StyledComponents/StyledView.js +15 -15
  92. package/lib/module/components/StyledComponents/StyledView.js.map +1 -1
  93. package/lib/module/components/Switch/Switch.js +2 -2
  94. package/lib/module/components/Switch/Switch.js.map +1 -1
  95. package/lib/module/components/UserInput/UserInput.js +30 -35
  96. package/lib/module/components/UserInput/UserInput.js.map +1 -1
  97. package/lib/module/helpers/LightenColorShades.js +18 -5
  98. package/lib/module/helpers/LightenColorShades.js.map +1 -1
  99. package/lib/module/helpers/ResponsiveCalculations.js +28 -3
  100. package/lib/module/helpers/ResponsiveCalculations.js.map +1 -1
  101. package/lib/module/helpers/index.js +1 -0
  102. package/lib/module/helpers/index.js.map +1 -1
  103. package/lib/module/index.js +2 -4
  104. package/lib/module/index.js.map +1 -2
  105. package/lib/module/themes/LightTheme.js +1 -2
  106. package/lib/module/themes/LightTheme.js.map +1 -1
  107. package/lib/module/types/index.js +1 -0
  108. package/lib/module/types/index.js.map +1 -1
  109. package/lib/module/types/progress.type.js +2 -0
  110. package/lib/module/types/progress.type.js.map +1 -0
  111. package/lib/typescript/commonjs/src/components/Button/Button.d.ts.map +1 -1
  112. package/lib/typescript/commonjs/src/components/CheckBox/CheckBox.d.ts.map +1 -1
  113. package/lib/typescript/commonjs/src/components/Dialog/Dialog.d.ts.map +1 -1
  114. package/lib/typescript/commonjs/src/components/Dialog/DialogBody.d.ts.map +1 -1
  115. package/lib/typescript/commonjs/src/components/Dialog/DialogFoot.d.ts.map +1 -1
  116. package/lib/typescript/commonjs/src/components/Dialog/DialogHead.d.ts.map +1 -1
  117. package/lib/typescript/commonjs/src/components/Divider/Divider.d.ts.map +1 -1
  118. package/lib/typescript/commonjs/src/components/Header/Header.d.ts +1 -0
  119. package/lib/typescript/commonjs/src/components/Header/Header.d.ts.map +1 -1
  120. package/lib/typescript/commonjs/src/components/Icon/Icon.d.ts +1 -0
  121. package/lib/typescript/commonjs/src/components/Icon/Icon.d.ts.map +1 -1
  122. package/lib/typescript/commonjs/src/components/Link/Link.d.ts +4 -0
  123. package/lib/typescript/commonjs/src/components/Link/Link.d.ts.map +1 -1
  124. package/lib/typescript/commonjs/src/components/Menu/Menu.d.ts.map +1 -1
  125. package/lib/typescript/commonjs/src/components/Menu/MenuItem.d.ts.map +1 -1
  126. package/lib/typescript/commonjs/src/components/Portal/Portal.d.ts +1 -1
  127. package/lib/typescript/commonjs/src/components/Portal/Portal.d.ts.map +1 -1
  128. package/lib/typescript/commonjs/src/components/Progress/Progress.d.ts +1 -12
  129. package/lib/typescript/commonjs/src/components/Progress/Progress.d.ts.map +1 -1
  130. package/lib/typescript/commonjs/src/components/Stack/HStack.d.ts.map +1 -1
  131. package/lib/typescript/commonjs/src/components/Stack/VStack.d.ts.map +1 -1
  132. package/lib/typescript/commonjs/src/components/StyledComponents/StyledText.d.ts.map +1 -1
  133. package/lib/typescript/commonjs/src/components/StyledComponents/StyledView.d.ts.map +1 -1
  134. package/lib/typescript/commonjs/src/components/UserInput/UserInput.d.ts +1 -34
  135. package/lib/typescript/commonjs/src/components/UserInput/UserInput.d.ts.map +1 -1
  136. package/lib/typescript/commonjs/src/helpers/LightenColorShades.d.ts +1 -1
  137. package/lib/typescript/commonjs/src/helpers/LightenColorShades.d.ts.map +1 -1
  138. package/lib/typescript/commonjs/src/helpers/ResponsiveCalculations.d.ts +1 -0
  139. package/lib/typescript/commonjs/src/helpers/ResponsiveCalculations.d.ts.map +1 -1
  140. package/lib/typescript/commonjs/src/helpers/index.d.ts +1 -0
  141. package/lib/typescript/commonjs/src/helpers/index.d.ts.map +1 -1
  142. package/lib/typescript/commonjs/src/themes/LightTheme.d.ts.map +1 -1
  143. package/lib/typescript/commonjs/src/types/button.type.d.ts +1 -0
  144. package/lib/typescript/commonjs/src/types/button.type.d.ts.map +1 -1
  145. package/lib/typescript/commonjs/src/types/dialog.type.d.ts +0 -2
  146. package/lib/typescript/commonjs/src/types/dialog.type.d.ts.map +1 -1
  147. package/lib/typescript/commonjs/src/types/index.d.ts +1 -0
  148. package/lib/typescript/commonjs/src/types/index.d.ts.map +1 -1
  149. package/lib/typescript/commonjs/src/types/progress.type.d.ts +13 -0
  150. package/lib/typescript/commonjs/src/types/progress.type.d.ts.map +1 -0
  151. package/lib/typescript/commonjs/src/types/stack.type.d.ts +14 -3
  152. package/lib/typescript/commonjs/src/types/stack.type.d.ts.map +1 -1
  153. package/lib/typescript/commonjs/src/types/styledComponents.type.d.ts +7 -1
  154. package/lib/typescript/commonjs/src/types/styledComponents.type.d.ts.map +1 -1
  155. package/lib/typescript/commonjs/src/types/userInput.type.d.ts +6 -1
  156. package/lib/typescript/commonjs/src/types/userInput.type.d.ts.map +1 -1
  157. package/lib/typescript/module/src/components/Button/Button.d.ts.map +1 -1
  158. package/lib/typescript/module/src/components/CheckBox/CheckBox.d.ts.map +1 -1
  159. package/lib/typescript/module/src/components/Dialog/Dialog.d.ts.map +1 -1
  160. package/lib/typescript/module/src/components/Dialog/DialogBody.d.ts.map +1 -1
  161. package/lib/typescript/module/src/components/Dialog/DialogFoot.d.ts.map +1 -1
  162. package/lib/typescript/module/src/components/Dialog/DialogHead.d.ts.map +1 -1
  163. package/lib/typescript/module/src/components/Divider/Divider.d.ts.map +1 -1
  164. package/lib/typescript/module/src/components/Header/Header.d.ts +1 -0
  165. package/lib/typescript/module/src/components/Header/Header.d.ts.map +1 -1
  166. package/lib/typescript/module/src/components/Icon/Icon.d.ts +1 -0
  167. package/lib/typescript/module/src/components/Icon/Icon.d.ts.map +1 -1
  168. package/lib/typescript/module/src/components/Link/Link.d.ts +4 -0
  169. package/lib/typescript/module/src/components/Link/Link.d.ts.map +1 -1
  170. package/lib/typescript/module/src/components/Menu/Menu.d.ts.map +1 -1
  171. package/lib/typescript/module/src/components/Menu/MenuItem.d.ts.map +1 -1
  172. package/lib/typescript/module/src/components/Portal/Portal.d.ts +1 -1
  173. package/lib/typescript/module/src/components/Portal/Portal.d.ts.map +1 -1
  174. package/lib/typescript/module/src/components/Progress/Progress.d.ts +1 -12
  175. package/lib/typescript/module/src/components/Progress/Progress.d.ts.map +1 -1
  176. package/lib/typescript/module/src/components/Stack/HStack.d.ts.map +1 -1
  177. package/lib/typescript/module/src/components/Stack/VStack.d.ts.map +1 -1
  178. package/lib/typescript/module/src/components/StyledComponents/StyledText.d.ts.map +1 -1
  179. package/lib/typescript/module/src/components/StyledComponents/StyledView.d.ts.map +1 -1
  180. package/lib/typescript/module/src/components/UserInput/UserInput.d.ts +1 -34
  181. package/lib/typescript/module/src/components/UserInput/UserInput.d.ts.map +1 -1
  182. package/lib/typescript/module/src/helpers/LightenColorShades.d.ts +1 -1
  183. package/lib/typescript/module/src/helpers/LightenColorShades.d.ts.map +1 -1
  184. package/lib/typescript/module/src/helpers/ResponsiveCalculations.d.ts +1 -0
  185. package/lib/typescript/module/src/helpers/ResponsiveCalculations.d.ts.map +1 -1
  186. package/lib/typescript/module/src/helpers/index.d.ts +1 -0
  187. package/lib/typescript/module/src/helpers/index.d.ts.map +1 -1
  188. package/lib/typescript/module/src/themes/LightTheme.d.ts.map +1 -1
  189. package/lib/typescript/module/src/types/button.type.d.ts +1 -0
  190. package/lib/typescript/module/src/types/button.type.d.ts.map +1 -1
  191. package/lib/typescript/module/src/types/dialog.type.d.ts +0 -2
  192. package/lib/typescript/module/src/types/dialog.type.d.ts.map +1 -1
  193. package/lib/typescript/module/src/types/index.d.ts +1 -0
  194. package/lib/typescript/module/src/types/index.d.ts.map +1 -1
  195. package/lib/typescript/module/src/types/progress.type.d.ts +13 -0
  196. package/lib/typescript/module/src/types/progress.type.d.ts.map +1 -0
  197. package/lib/typescript/module/src/types/stack.type.d.ts +14 -3
  198. package/lib/typescript/module/src/types/stack.type.d.ts.map +1 -1
  199. package/lib/typescript/module/src/types/styledComponents.type.d.ts +7 -1
  200. package/lib/typescript/module/src/types/styledComponents.type.d.ts.map +1 -1
  201. package/lib/typescript/module/src/types/userInput.type.d.ts +6 -1
  202. package/lib/typescript/module/src/types/userInput.type.d.ts.map +1 -1
  203. package/package.json +2 -2
  204. package/src/components/Button/Button.tsx +111 -76
  205. package/src/components/CheckBox/CheckBox.tsx +61 -49
  206. package/src/components/Dialog/Dialog.tsx +54 -51
  207. package/src/components/Dialog/DialogBody.tsx +7 -9
  208. package/src/components/Dialog/DialogDescription.tsx +9 -9
  209. package/src/components/Dialog/DialogFoot.tsx +15 -13
  210. package/src/components/Dialog/DialogHead.tsx +20 -17
  211. package/src/components/Divider/Divider.tsx +5 -9
  212. package/src/components/Header/Header.tsx +1 -0
  213. package/src/components/Icon/Icon.tsx +9 -4
  214. package/src/components/Link/Link.tsx +24 -7
  215. package/src/components/Menu/Menu.tsx +50 -50
  216. package/src/components/Menu/MenuItem.tsx +0 -2
  217. package/src/components/Portal/Portal.tsx +2 -2
  218. package/src/components/Progress/Progress.tsx +32 -35
  219. package/src/components/Stack/HStack.tsx +12 -12
  220. package/src/components/Stack/VStack.tsx +5 -2
  221. package/src/components/StyledComponents/StyledText.tsx +3 -5
  222. package/src/components/StyledComponents/StyledView.tsx +6 -2
  223. package/src/components/Switch/Switch.tsx +2 -2
  224. package/src/components/UserInput/UserInput.tsx +43 -37
  225. package/src/helpers/LightenColorShades.ts +26 -6
  226. package/src/helpers/ResponsiveCalculations.ts +28 -3
  227. package/src/helpers/index.ts +2 -1
  228. package/src/themes/LightTheme.ts +1 -2
  229. package/src/types/button.type.ts +1 -0
  230. package/src/types/dialog.type.ts +0 -3
  231. package/src/types/index.ts +2 -1
  232. package/src/types/progress.type.ts +16 -0
  233. package/src/types/stack.type.ts +16 -3
  234. package/src/types/styledComponents.type.ts +8 -1
  235. 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 = useSharedValue(1);
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 STYLES = StyleSheet.create({
43
- CONTAINER: {
44
- flexDirection: 'row',
45
- gap: horizontalScale(10),
46
- alignItems: 'center',
47
- alignSelf: 'flex-start',
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 = useAnimatedStyle(() => ({
63
- transform: [{ scale: scaleVal.value }]
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
- <TouchableWithoutFeedback
76
- onPressIn={() => scaleVal.value = withSpring(0.8)}
77
- onPressOut={() => scaleVal.value = withSpring(1)}
78
- onPress={onUserClick}
79
- disabled={disabled}
80
- >
81
- <StyledView style={[STYLES.CONTAINER, containerStyle]}>
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
- <Animated.View style={[STYLES.CHECKBOX_PARENT_CONT, checkBoxStyle, animatedStyle]}>
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
- (disableBuiltInState ? isChecked : isCheckboxChecked) &&
86
- <Check
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
- </StyledView>
98
- </TouchableWithoutFeedback>
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 Animated, { useSharedValue, useAnimatedStyle, withTiming, withSpring } from 'react-native-reanimated';
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 = useSharedValue(0.8);
23
- const opacity = useSharedValue(0);
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
- opacity.value = withTiming(dialogVisible ? 1 : 0);
27
- scale.value = withSpring(dialogVisible ? 1 : 0.8,
28
- {
29
- duration: animationDuration,
30
- dampingRatio: 0.6,
31
- stiffness: 36,
32
- overshootClamping: false,
33
- restDisplacementThreshold: 0.01,
34
- restSpeedThreshold: 0.01,
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 () => BackHandler.removeEventListener('hardwareBackPress', hardwareBackPress);
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 backdropAnimatedStyle = useAnimatedStyle(() => {
55
- return {
56
- position: 'absolute',
57
- top: 0,
58
- bottom: 0,
59
- left: 0,
60
- right: 0,
61
- backgroundColor: backdropColor,
62
- justifyContent: 'center',
63
- alignItems: 'center',
64
- opacity: opacity.value
65
- }
66
- });
67
- const modalContAnimatedStyle = useAnimatedStyle(() => {
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={backdropAnimatedStyle}
86
+ style={[STYLES.BACKDROP_CONT, backdropAnimatedStyles]}
102
87
  pointerEvents={dialogVisible ? 'auto' : 'none'}
103
88
  onStartShouldSetResponder={handleStartShouldSetResponder}
104
89
  >
105
90
  <Animated.View
106
- style={modalContAnimatedStyle}
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, StyleSheet, ScrollView } from 'react-native';
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 STYLES = StyleSheet.create({
18
- CONTAINER: {
19
- paddingVertical: variant == 'default' ? moderateScale(16) : 0,
20
- paddingHorizontal: moderateScale(variant == 'default' ? 16 : 25),
21
- gap: 20,
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={[STYLES.CONTAINER, containerStyle]} pointerEvents='box-none'>
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, StyleSheet } from 'react-native';
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 style={[STYLES.TEXT, textStyle]} variant={textVariant} fs={fs}>{children}</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
- const STYLES = StyleSheet.create({
19
- CONTAINER: {
20
- borderTopWidth: variant === 'default' ? 0.7 : 0,
21
- borderColor: '#d4d4d4',
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 justify='flex-end' gap={moderateScale(15)} containerStyle={[STYLES.CONTAINER, containerStyle]}>
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 STYLES = StyleSheet.create({
23
- CONTAINER: {
24
- borderBottomWidth: variant == 'default' ? 0.7 : 0,
25
- borderColor: '#d4d4d4',
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 STYLES = StyleSheet.create({
24
- CONTAINER: {
25
- borderWidth: thickness,
26
- borderColor: color ?? theme?.colors.dividerColor
27
- }
28
- });
29
-
22
+ const dynamicStyles = {
23
+ borderWidth: thickness,
24
+ borderColor: color ?? theme?.colors.dividerColor
25
+ };
30
26
  return (<>
31
- <StyledView style={[STYLES.CONTAINER, 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
- return (<>
18
- {React.cloneElement(renderIcon as React.ReactElement<any>,
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 variant='h5' color='#0000FF'
25
- style={{ includeFontPadding: false, alignItems: 'baseline', borderBottomColor: '#0000FF', borderBottomWidth: 1, alignSelf: 'flex-start', padding: 0, margin: 0, lineHeight: undefined, flexShrink: 1, textAlignVertical: 'bottom', }}
26
- >{title}</StyledText>
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
+ });