@nexara/nativeflow 0.1.8 → 0.1.10

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 (291) hide show
  1. package/lib/commonjs/assets/svg/Check.js.map +1 -1
  2. package/lib/commonjs/assets/svg/X.js.map +1 -1
  3. package/lib/commonjs/assets/svg/index.js.map +1 -1
  4. package/lib/commonjs/components/Avatar/AvatarImage.js.map +1 -1
  5. package/lib/commonjs/components/Avatar/AvatarText.js.map +1 -1
  6. package/lib/commonjs/components/Avatar/index.js.map +1 -1
  7. package/lib/commonjs/components/Button/Button.js +9 -4
  8. package/lib/commonjs/components/Button/Button.js.map +1 -1
  9. package/lib/commonjs/components/Button/utils.js +17 -10
  10. package/lib/commonjs/components/Button/utils.js.map +1 -1
  11. package/lib/commonjs/components/CheckBox/CheckBox.js.map +1 -1
  12. package/lib/commonjs/components/Chip/Chip.js.map +1 -1
  13. package/lib/commonjs/components/Chip/utils.js.map +1 -1
  14. package/lib/commonjs/components/Dialog/Dialog.js.map +1 -1
  15. package/lib/commonjs/components/Dialog/DialogBody.js.map +1 -1
  16. package/lib/commonjs/components/Dialog/DialogDescription.js.map +1 -1
  17. package/lib/commonjs/components/Dialog/DialogFoot.js.map +1 -1
  18. package/lib/commonjs/components/Dialog/DialogHead.js.map +1 -1
  19. package/lib/commonjs/components/Dialog/index.js.map +1 -1
  20. package/lib/commonjs/components/Divider/Divider.js.map +1 -1
  21. package/lib/commonjs/components/Grid/Grid.js.map +1 -1
  22. package/lib/commonjs/components/Icon/Icon.js.map +1 -1
  23. package/lib/commonjs/components/IconButton/IconButton.js.map +1 -1
  24. package/lib/commonjs/components/Link/Link.js.map +1 -1
  25. package/lib/commonjs/components/Menu/Menu.js.map +1 -1
  26. package/lib/commonjs/components/Menu/MenuItem.js.map +1 -1
  27. package/lib/commonjs/components/Menu/MenuItemLabel.js.map +1 -1
  28. package/lib/commonjs/components/Menu/calculations.js.map +1 -1
  29. package/lib/commonjs/components/Menu/index.js.map +1 -1
  30. package/lib/commonjs/components/Portal/Portal.js.map +1 -1
  31. package/lib/commonjs/components/Portal/PortalContext.js.map +1 -1
  32. package/lib/commonjs/components/Portal/PortalProvider.js.map +1 -1
  33. package/lib/commonjs/components/Progress/Progress.js.map +1 -1
  34. package/lib/commonjs/components/Provider/ContextManager.js.map +1 -1
  35. package/lib/commonjs/components/Provider/NativeProvider.js.map +1 -1
  36. package/lib/commonjs/components/Radio/RadioGroup.js.map +1 -1
  37. package/lib/commonjs/components/Radio/RadioItem.js.map +1 -1
  38. package/lib/commonjs/components/Radio/index.js.map +1 -1
  39. package/lib/commonjs/components/Slider/Slider.js.map +1 -1
  40. package/lib/commonjs/components/Stack/HStack.js.map +1 -1
  41. package/lib/commonjs/components/Stack/VStack.js.map +1 -1
  42. package/lib/commonjs/components/Stack/index.js.map +1 -1
  43. package/lib/commonjs/components/StyledComponents/StyledText.js +3 -1
  44. package/lib/commonjs/components/StyledComponents/StyledText.js.map +1 -1
  45. package/lib/commonjs/components/StyledComponents/StyledView.js.map +1 -1
  46. package/lib/commonjs/components/StyledComponents/index.js.map +1 -1
  47. package/lib/commonjs/components/Surface/Surface.js +3 -3
  48. package/lib/commonjs/components/Surface/Surface.js.map +1 -1
  49. package/lib/commonjs/components/Switch/Switch.js.map +1 -1
  50. package/lib/commonjs/components/TouchableRipple/TouchableRipple.js.map +1 -1
  51. package/lib/commonjs/components/UserInput/UserInput.js.map +1 -1
  52. package/lib/commonjs/components/UserInput/UserInputV2.js.map +1 -1
  53. package/lib/commonjs/components/UserInput/generateColors.js.map +1 -1
  54. package/lib/commonjs/constants/breakPoints.js.map +1 -1
  55. package/lib/commonjs/constants/dialogSizes.js.map +1 -1
  56. package/lib/commonjs/constants/index.js.map +1 -1
  57. package/lib/commonjs/constants/theme.js.map +1 -1
  58. package/lib/commonjs/constants/typographySizes.js.map +1 -1
  59. package/lib/commonjs/helpers/CalculateGridSize.js +1 -1
  60. package/lib/commonjs/helpers/CalculateGridSize.js.map +1 -1
  61. package/lib/commonjs/helpers/DeviceSizeCategory.js.map +1 -1
  62. package/lib/commonjs/helpers/ResponsiveCalculations.js +4 -1
  63. package/lib/commonjs/helpers/ResponsiveCalculations.js.map +1 -1
  64. package/lib/commonjs/helpers/index.js.map +1 -1
  65. package/lib/commonjs/hooks/index.js.map +1 -1
  66. package/lib/commonjs/hooks/useColorScheme.js.map +1 -1
  67. package/lib/commonjs/hooks/useConditionalWindowDimension.js.map +1 -1
  68. package/lib/commonjs/hooks/useScalingMode.js.map +1 -1
  69. package/lib/commonjs/hooks/useTheme.js.map +1 -1
  70. package/lib/commonjs/index.d.js.map +1 -1
  71. package/lib/commonjs/index.js.map +1 -1
  72. package/lib/commonjs/themes/DarkTheme.js.map +1 -1
  73. package/lib/commonjs/themes/LightTheme.js.map +1 -1
  74. package/lib/commonjs/themes/index.js.map +1 -1
  75. package/lib/commonjs/types/avatar.type.js.map +1 -1
  76. package/lib/commonjs/types/button.type.js.map +1 -1
  77. package/lib/commonjs/types/checkbox.type.js.map +1 -1
  78. package/lib/commonjs/types/chip.type.js.map +1 -1
  79. package/lib/commonjs/types/common.type.js.map +1 -1
  80. package/lib/commonjs/types/dialog.type.js.map +1 -1
  81. package/lib/commonjs/types/divider.type.js.map +1 -1
  82. package/lib/commonjs/types/grid.type.js.map +1 -1
  83. package/lib/commonjs/types/index.js.map +1 -1
  84. package/lib/commonjs/types/link.type.js.map +1 -1
  85. package/lib/commonjs/types/menu.type.js.map +1 -1
  86. package/lib/commonjs/types/progress.type.js.map +1 -1
  87. package/lib/commonjs/types/radio.type.js.map +1 -1
  88. package/lib/commonjs/types/stack.type.js.map +1 -1
  89. package/lib/commonjs/types/styledComponents.type.js.map +1 -1
  90. package/lib/commonjs/types/surface.type.js.map +1 -1
  91. package/lib/commonjs/types/switch.type.js.map +1 -1
  92. package/lib/commonjs/types/userInput.type.js.map +1 -1
  93. package/lib/commonjs/utils/index.js.map +1 -1
  94. package/lib/module/assets/svg/Check.js.map +1 -1
  95. package/lib/module/assets/svg/X.js.map +1 -1
  96. package/lib/module/assets/svg/index.js.map +1 -1
  97. package/lib/module/components/Avatar/AvatarImage.js.map +1 -1
  98. package/lib/module/components/Avatar/AvatarText.js.map +1 -1
  99. package/lib/module/components/Avatar/index.js.map +1 -1
  100. package/lib/module/components/Button/Button.js +10 -5
  101. package/lib/module/components/Button/Button.js.map +1 -1
  102. package/lib/module/components/Button/utils.js +17 -10
  103. package/lib/module/components/Button/utils.js.map +1 -1
  104. package/lib/module/components/CheckBox/CheckBox.js.map +1 -1
  105. package/lib/module/components/Chip/Chip.js.map +1 -1
  106. package/lib/module/components/Chip/utils.js.map +1 -1
  107. package/lib/module/components/Dialog/Dialog.js.map +1 -1
  108. package/lib/module/components/Dialog/DialogBody.js.map +1 -1
  109. package/lib/module/components/Dialog/DialogDescription.js.map +1 -1
  110. package/lib/module/components/Dialog/DialogFoot.js.map +1 -1
  111. package/lib/module/components/Dialog/DialogHead.js.map +1 -1
  112. package/lib/module/components/Dialog/index.js.map +1 -1
  113. package/lib/module/components/Divider/Divider.js.map +1 -1
  114. package/lib/module/components/Grid/Grid.js.map +1 -1
  115. package/lib/module/components/Icon/Icon.js.map +1 -1
  116. package/lib/module/components/IconButton/IconButton.js.map +1 -1
  117. package/lib/module/components/Link/Link.js.map +1 -1
  118. package/lib/module/components/Menu/Menu.js.map +1 -1
  119. package/lib/module/components/Menu/MenuItem.js.map +1 -1
  120. package/lib/module/components/Menu/MenuItemLabel.js.map +1 -1
  121. package/lib/module/components/Menu/calculations.js.map +1 -1
  122. package/lib/module/components/Menu/index.js.map +1 -1
  123. package/lib/module/components/Portal/Portal.js.map +1 -1
  124. package/lib/module/components/Portal/PortalContext.js.map +1 -1
  125. package/lib/module/components/Portal/PortalProvider.js.map +1 -1
  126. package/lib/module/components/Progress/Progress.js.map +1 -1
  127. package/lib/module/components/Provider/ContextManager.js.map +1 -1
  128. package/lib/module/components/Provider/NativeProvider.js.map +1 -1
  129. package/lib/module/components/Radio/RadioGroup.js.map +1 -1
  130. package/lib/module/components/Radio/RadioItem.js.map +1 -1
  131. package/lib/module/components/Radio/index.js.map +1 -1
  132. package/lib/module/components/Slider/Slider.js.map +1 -1
  133. package/lib/module/components/Stack/HStack.js.map +1 -1
  134. package/lib/module/components/Stack/VStack.js.map +1 -1
  135. package/lib/module/components/Stack/index.js.map +1 -1
  136. package/lib/module/components/StyledComponents/StyledText.js +3 -1
  137. package/lib/module/components/StyledComponents/StyledText.js.map +1 -1
  138. package/lib/module/components/StyledComponents/StyledView.js.map +1 -1
  139. package/lib/module/components/StyledComponents/index.js.map +1 -1
  140. package/lib/module/components/Surface/Surface.js +3 -3
  141. package/lib/module/components/Surface/Surface.js.map +1 -1
  142. package/lib/module/components/Switch/Switch.js.map +1 -1
  143. package/lib/module/components/TouchableRipple/TouchableRipple.js.map +1 -1
  144. package/lib/module/components/UserInput/UserInput.js.map +1 -1
  145. package/lib/module/components/UserInput/UserInputV2.js.map +1 -1
  146. package/lib/module/components/UserInput/generateColors.js.map +1 -1
  147. package/lib/module/constants/breakPoints.js.map +1 -1
  148. package/lib/module/constants/dialogSizes.js.map +1 -1
  149. package/lib/module/constants/index.js.map +1 -1
  150. package/lib/module/constants/theme.js.map +1 -1
  151. package/lib/module/constants/typographySizes.js.map +1 -1
  152. package/lib/module/helpers/CalculateGridSize.js +1 -1
  153. package/lib/module/helpers/CalculateGridSize.js.map +1 -1
  154. package/lib/module/helpers/DeviceSizeCategory.js.map +1 -1
  155. package/lib/module/helpers/ResponsiveCalculations.js +4 -1
  156. package/lib/module/helpers/ResponsiveCalculations.js.map +1 -1
  157. package/lib/module/helpers/index.js.map +1 -1
  158. package/lib/module/hooks/index.js.map +1 -1
  159. package/lib/module/hooks/useColorScheme.js.map +1 -1
  160. package/lib/module/hooks/useConditionalWindowDimension.js.map +1 -1
  161. package/lib/module/hooks/useScalingMode.js.map +1 -1
  162. package/lib/module/hooks/useTheme.js.map +1 -1
  163. package/lib/module/index.d.js.map +1 -1
  164. package/lib/module/index.js.map +1 -1
  165. package/lib/module/themes/DarkTheme.js.map +1 -1
  166. package/lib/module/themes/LightTheme.js.map +1 -1
  167. package/lib/module/themes/index.js.map +1 -1
  168. package/lib/module/types/avatar.type.js.map +1 -1
  169. package/lib/module/types/button.type.js.map +1 -1
  170. package/lib/module/types/checkbox.type.js.map +1 -1
  171. package/lib/module/types/chip.type.js.map +1 -1
  172. package/lib/module/types/common.type.js.map +1 -1
  173. package/lib/module/types/dialog.type.js.map +1 -1
  174. package/lib/module/types/divider.type.js.map +1 -1
  175. package/lib/module/types/grid.type.js.map +1 -1
  176. package/lib/module/types/index.js.map +1 -1
  177. package/lib/module/types/link.type.js.map +1 -1
  178. package/lib/module/types/menu.type.js.map +1 -1
  179. package/lib/module/types/progress.type.js.map +1 -1
  180. package/lib/module/types/radio.type.js.map +1 -1
  181. package/lib/module/types/stack.type.js.map +1 -1
  182. package/lib/module/types/styledComponents.type.js.map +1 -1
  183. package/lib/module/types/surface.type.js.map +1 -1
  184. package/lib/module/types/switch.type.js.map +1 -1
  185. package/lib/module/types/userInput.type.js.map +1 -1
  186. package/lib/module/utils/index.js.map +1 -1
  187. package/lib/typescript/commonjs/src/components/Button/Button.d.ts.map +1 -1
  188. package/lib/typescript/commonjs/src/components/Button/utils.d.ts +2 -1
  189. package/lib/typescript/commonjs/src/components/Button/utils.d.ts.map +1 -1
  190. package/lib/typescript/commonjs/src/components/UserInput/UserInput.d.ts.map +1 -1
  191. package/lib/typescript/commonjs/src/helpers/ResponsiveCalculations.d.ts.map +1 -1
  192. package/lib/typescript/commonjs/src/types/button.type.d.ts +2 -0
  193. package/lib/typescript/commonjs/src/types/button.type.d.ts.map +1 -1
  194. package/lib/typescript/commonjs/src/types/surface.type.d.ts +1 -1
  195. package/lib/typescript/commonjs/src/types/surface.type.d.ts.map +1 -1
  196. package/lib/typescript/module/src/components/Button/Button.d.ts.map +1 -1
  197. package/lib/typescript/module/src/components/Button/utils.d.ts +2 -1
  198. package/lib/typescript/module/src/components/Button/utils.d.ts.map +1 -1
  199. package/lib/typescript/module/src/components/UserInput/UserInput.d.ts.map +1 -1
  200. package/lib/typescript/module/src/helpers/ResponsiveCalculations.d.ts.map +1 -1
  201. package/lib/typescript/module/src/types/button.type.d.ts +2 -0
  202. package/lib/typescript/module/src/types/button.type.d.ts.map +1 -1
  203. package/lib/typescript/module/src/types/surface.type.d.ts +1 -1
  204. package/lib/typescript/module/src/types/surface.type.d.ts.map +1 -1
  205. package/package.json +2 -2
  206. package/src/assets/svg/Check.tsx +16 -16
  207. package/src/assets/svg/X.tsx +15 -15
  208. package/src/assets/svg/index.ts +1 -1
  209. package/src/components/Avatar/AvatarImage.tsx +33 -33
  210. package/src/components/Avatar/AvatarText.tsx +34 -34
  211. package/src/components/Avatar/index.ts +8 -8
  212. package/src/components/Button/Button.tsx +216 -205
  213. package/src/components/Button/utils.ts +152 -141
  214. package/src/components/CheckBox/CheckBox.tsx +118 -118
  215. package/src/components/Chip/Chip.tsx +82 -82
  216. package/src/components/Chip/utils.ts +109 -109
  217. package/src/components/Dialog/Dialog.tsx +124 -124
  218. package/src/components/Dialog/DialogBody.tsx +31 -31
  219. package/src/components/Dialog/DialogDescription.tsx +27 -27
  220. package/src/components/Dialog/DialogFoot.tsx +35 -35
  221. package/src/components/Dialog/DialogHead.tsx +50 -50
  222. package/src/components/Dialog/index.ts +10 -10
  223. package/src/components/Divider/Divider.tsx +22 -22
  224. package/src/components/Grid/Grid.tsx +61 -61
  225. package/src/components/Icon/Icon.tsx +31 -31
  226. package/src/components/IconButton/IconButton.tsx +44 -44
  227. package/src/components/Link/Link.tsx +38 -38
  228. package/src/components/Menu/Menu.tsx +142 -142
  229. package/src/components/Menu/MenuItem.tsx +33 -33
  230. package/src/components/Menu/MenuItemLabel.tsx +21 -21
  231. package/src/components/Menu/calculations.ts +33 -33
  232. package/src/components/Menu/index.ts +7 -7
  233. package/src/components/Portal/Portal.tsx +18 -18
  234. package/src/components/Portal/PortalContext.tsx +9 -9
  235. package/src/components/Portal/PortalProvider.tsx +36 -36
  236. package/src/components/Progress/Progress.tsx +66 -66
  237. package/src/components/Provider/ContextManager.tsx +8 -8
  238. package/src/components/Provider/NativeProvider.tsx +72 -72
  239. package/src/components/Radio/RadioGroup.tsx +39 -39
  240. package/src/components/Radio/RadioItem.tsx +72 -72
  241. package/src/components/Radio/index.ts +8 -8
  242. package/src/components/Slider/Slider.tsx +45 -45
  243. package/src/components/Stack/HStack.tsx +32 -32
  244. package/src/components/Stack/VStack.tsx +26 -26
  245. package/src/components/Stack/index.ts +8 -8
  246. package/src/components/StyledComponents/StyledText.tsx +49 -49
  247. package/src/components/StyledComponents/StyledView.tsx +44 -44
  248. package/src/components/StyledComponents/index.tsx +5 -5
  249. package/src/components/Surface/Surface.tsx +31 -31
  250. package/src/components/Switch/Switch.tsx +36 -36
  251. package/src/components/TouchableRipple/TouchableRipple.tsx +92 -92
  252. package/src/components/UserInput/UserInput.tsx +135 -135
  253. package/src/components/UserInput/UserInputV2.tsx +132 -132
  254. package/src/components/UserInput/generateColors.ts +13 -13
  255. package/src/constants/breakPoints.ts +17 -17
  256. package/src/constants/dialogSizes.ts +11 -11
  257. package/src/constants/index.ts +2 -2
  258. package/src/constants/theme.ts +32 -32
  259. package/src/constants/typographySizes.ts +19 -19
  260. package/src/helpers/CalculateGridSize.ts +25 -25
  261. package/src/helpers/DeviceSizeCategory.ts +21 -21
  262. package/src/helpers/ResponsiveCalculations.ts +107 -104
  263. package/src/helpers/index.ts +2 -2
  264. package/src/hooks/index.ts +3 -3
  265. package/src/hooks/useColorScheme.tsx +11 -11
  266. package/src/hooks/useConditionalWindowDimension.tsx +7 -7
  267. package/src/hooks/useScalingMode.tsx +6 -6
  268. package/src/hooks/useTheme.tsx +12 -12
  269. package/src/index.d.ts +2 -2
  270. package/src/index.ts +52 -52
  271. package/src/themes/DarkTheme.ts +177 -177
  272. package/src/themes/LightTheme.ts +88 -88
  273. package/src/themes/index.ts +3 -3
  274. package/src/types/avatar.type.ts +40 -40
  275. package/src/types/button.type.ts +79 -76
  276. package/src/types/checkbox.type.ts +64 -64
  277. package/src/types/chip.type.ts +65 -65
  278. package/src/types/common.type.ts +109 -109
  279. package/src/types/dialog.type.ts +89 -89
  280. package/src/types/divider.type.ts +15 -15
  281. package/src/types/grid.type.ts +71 -71
  282. package/src/types/index.ts +16 -16
  283. package/src/types/link.type.ts +14 -14
  284. package/src/types/menu.type.ts +100 -100
  285. package/src/types/progress.type.ts +15 -15
  286. package/src/types/radio.type.ts +78 -78
  287. package/src/types/stack.type.ts +46 -46
  288. package/src/types/styledComponents.type.ts +70 -70
  289. package/src/types/surface.type.ts +19 -19
  290. package/src/types/switch.type.ts +39 -39
  291. package/src/types/userInput.type.ts +98 -98
@@ -1,205 +1,216 @@
1
- import React, { useMemo } from 'react';
2
- import type { FC, JSX } from 'react';
3
- import { StyleSheet, TouchableOpacity, type ViewStyle } from "react-native";
4
- import { verticalScale, horizontalScale } from "../../helpers/ResponsiveCalculations";
5
- import { StyledText, StyledView } from '../StyledComponents';
6
- import { useTheme } from '../../hooks';
7
- import { getButtonColors } from './utils';
8
- import type { ButtonProps } from '../../types';
9
-
10
-
11
- const Button: FC<ButtonProps> = ({
12
- variant = 'contained',
13
- type = 'flat',
14
- fullWidth = false,
15
- paddingH = 19,
16
- paddingV = 12,
17
- bg,
18
- br = 8,
19
- stroke = 1,
20
- strokeColor,
21
- titleColor,
22
- title,
23
- fScale = 'base',
24
- fs,
25
- ff,
26
- size = 50,
27
- rippleColor,
28
- renderIcon,
29
- renderLeftIcon,
30
- renderRightIcon,
31
- disabled = false,
32
- containerStyle,
33
- titleStyle,
34
- onPress,
35
- children,
36
- ...rest
37
- }) => {
38
- const theme: any = useTheme();
39
-
40
- const { backgroundColor, buttonTextColor, buttonBorderColor } = getButtonColors({
41
- theme,
42
- variant,
43
- bg,
44
- titleColor,
45
- strokeColor,
46
- disabled
47
- });
48
-
49
- const STYLES = useMemo(customStyles, []);
50
-
51
- const dynamicStyles = {
52
- BUTTON_CONT: {
53
- backgroundColor: backgroundColor,
54
- borderWidth: variant === 'contained' ? 0 : stroke,
55
- borderColor: buttonBorderColor,
56
- },
57
- BUTTON_TEXT: {
58
- color: buttonTextColor,
59
- fontFamily: ff ?? '',
60
- },
61
- FLAT_BTN_MAIN_CONT: {
62
- borderRadius: verticalScale(br),
63
- alignSelf: fullWidth ? 'stretch' : 'flex-start' as ViewStyle['alignSelf'],
64
- },
65
- FLAT_BTN_INNER_CONT: {
66
- paddingVertical: verticalScale(paddingV),
67
- paddingHorizontal: horizontalScale(!fullWidth ? paddingH : 30),
68
- borderRadius: verticalScale(br),
69
- },
70
- ROUND_BTN_INNER_CONT: {
71
- height: verticalScale(size),
72
- width: verticalScale(size),
73
- }
74
- };
75
-
76
- const cloneElement = (element: JSX.Element): JSX.Element | null => {
77
- if (React.isValidElement<{ color?: string }>(element)) {
78
- return React.cloneElement(element, {
79
- color: element.props.color ?? buttonTextColor
80
- })
81
- }
82
- return null;
83
- }
84
-
85
- return (<>
86
- {type === 'flat' && (
87
- <StyledView style={[STYLES.FLAT_BTN_MAIN_CONT, dynamicStyles.FLAT_BTN_MAIN_CONT]}>
88
- <TouchableOpacity
89
- onPress={onPress}
90
- // rippleColor={rippleColor}
91
- disabled={disabled}
92
- // ref={ref}
93
- {...rest}
94
- >
95
-
96
- {/* <TouchableRipple
97
- onPress={onPress}
98
- rippleColor={rippleColor}
99
- disabled={disabled}
100
- // ref={ref}
101
- {...rest}
102
- > */}
103
- <StyledView
104
- style={[
105
- STYLES.FLAT_BTN_INNER_CONT,
106
- STYLES.BUTTON_CONT,
107
- dynamicStyles.FLAT_BTN_INNER_CONT,
108
- dynamicStyles.BUTTON_CONT,
109
- containerStyle
110
- ]}>
111
- {(renderLeftIcon || (fullWidth && renderRightIcon)) && (
112
- <StyledView f={fullWidth ? 1 : undefined}>
113
- {renderLeftIcon && cloneElement(renderLeftIcon)}
114
- </StyledView>
115
- )}
116
-
117
- <StyledView
118
- flexShrink={1}
119
- f={fullWidth ? 8 : undefined}
120
- >
121
- {
122
- (title ?? children) ?
123
- <StyledText numberOfLines={1} fs={fs} fScale={fScale}
124
- style={[
125
- STYLES.BUTTON_TEXT,
126
- dynamicStyles.BUTTON_TEXT,
127
- titleStyle,
128
- ]}
129
- >
130
- {title ?? children}
131
- </StyledText>
132
- :
133
- (renderIcon && cloneElement(renderIcon))
134
- }
135
- </StyledView>
136
-
137
- {(renderRightIcon || (fullWidth && renderLeftIcon)) && (
138
- <StyledView alignItems='flex-end' f={fullWidth ? 1 : undefined}>
139
- {renderRightIcon && cloneElement(renderRightIcon)}
140
- </StyledView>
141
- )}
142
- </StyledView>
143
- {/* </TouchableRipple> */}
144
- </TouchableOpacity>
145
-
146
- </StyledView>
147
- )}
148
-
149
- {type === 'round' && (
150
- <StyledView style={STYLES.ROUND_BTN_MAIN_CONT} >
151
- <TouchableOpacity
152
- onPress={onPress}
153
- // rippleColor={rippleColor}
154
- {...rest}
155
- >
156
- <StyledView
157
- style={[
158
- STYLES.BUTTON_CONT,
159
- STYLES.ROUND_BTN_INNER_CONT,
160
- dynamicStyles.BUTTON_CONT,
161
- dynamicStyles.ROUND_BTN_INNER_CONT,
162
- containerStyle
163
- ]}
164
- >
165
- {renderIcon && cloneElement(renderIcon)}
166
- </StyledView>
167
- </TouchableOpacity>
168
- </StyledView>
169
- )}
170
- </>
171
- );
172
- };
173
-
174
- export default Button;
175
- export type { ButtonProps };
176
-
177
- const customStyles = () => StyleSheet.create({
178
- BUTTON_CONT: {
179
- maxWidth: '100%',
180
- },
181
- BUTTON_TEXT: {
182
- textAlign: 'center',
183
- },
184
- FLAT_BTN_MAIN_CONT: {
185
- overflow: 'hidden',
186
- },
187
- FLAT_BTN_INNER_CONT: {
188
- flexDirection: 'row',
189
- alignItems: 'center',
190
- justifyContent: 'space-between',
191
- gap: horizontalScale(10),
192
- },
193
- ROUND_BTN_MAIN_CONT: {
194
- overflow: 'hidden',
195
- borderRadius: verticalScale(100),
196
- alignSelf: 'flex-start',
197
- },
198
- ROUND_BTN_INNER_CONT: {
199
- alignItems: 'center',
200
- justifyContent: 'center',
201
- }
202
- });
203
-
204
-
205
-
1
+ import React, { useMemo } from 'react';
2
+ import type { FC, JSX } from 'react';
3
+ import { ActivityIndicator, StyleSheet, TouchableOpacity, type ViewStyle } from "react-native";
4
+ import { verticalScale, horizontalScale } from "../../helpers/ResponsiveCalculations";
5
+ import { StyledText, StyledView } from '../StyledComponents';
6
+ import { useTheme } from '../../hooks';
7
+ import { getButtonColors } from './utils';
8
+ import type { ButtonProps } from '../../types';
9
+
10
+
11
+ const Button: FC<ButtonProps> = ({
12
+ variant = 'contained',
13
+ type = 'flat',
14
+ fullWidth = false,
15
+ paddingH = 19,
16
+ paddingV = 12,
17
+ bg,
18
+ br = 8,
19
+ stroke = 1,
20
+ strokeColor,
21
+ titleColor,
22
+ title,
23
+ fScale = 'base',
24
+ fs,
25
+ ff,
26
+ size = 50,
27
+ rippleColor,
28
+ renderIcon,
29
+ renderLeftIcon,
30
+ renderRightIcon,
31
+ disabled = false,
32
+ loading = true,
33
+ containerStyle,
34
+ titleStyle,
35
+ onPress,
36
+ children,
37
+ ...rest
38
+ }) => {
39
+ const theme: any = useTheme();
40
+
41
+ const { backgroundColor, buttonTextColor, buttonBorderColor } = getButtonColors({
42
+ theme,
43
+ variant,
44
+ bg,
45
+ titleColor,
46
+ strokeColor,
47
+ disabled,
48
+ loading
49
+ });
50
+
51
+ const STYLES = useMemo(customStyles, []);
52
+
53
+ const dynamicStyles = {
54
+ BUTTON_CONT: {
55
+ backgroundColor: backgroundColor,
56
+ borderWidth: variant === 'contained' ? 0 : stroke,
57
+ borderColor: buttonBorderColor,
58
+ },
59
+ BUTTON_TEXT: {
60
+ color: buttonTextColor,
61
+ fontFamily: ff ?? '',
62
+ },
63
+ FLAT_BTN_MAIN_CONT: {
64
+ borderRadius: verticalScale(br),
65
+ alignSelf: fullWidth ? 'stretch' : 'flex-start' as ViewStyle['alignSelf'],
66
+ },
67
+ FLAT_BTN_INNER_CONT: {
68
+ paddingVertical: verticalScale(paddingV),
69
+ paddingHorizontal: horizontalScale(!fullWidth ? paddingH : 30),
70
+ borderRadius: verticalScale(br),
71
+ },
72
+ ROUND_BTN_INNER_CONT: {
73
+ height: verticalScale(size),
74
+ width: verticalScale(size),
75
+ }
76
+ };
77
+
78
+ const cloneElement = (element: JSX.Element): JSX.Element | null => {
79
+ if (React.isValidElement<{ color?: string }>(element)) {
80
+ return React.cloneElement(element, {
81
+ color: element.props.color ?? buttonTextColor
82
+ })
83
+ }
84
+ return null;
85
+ }
86
+
87
+ return (<>
88
+ {type === 'flat' && (
89
+ <StyledView style={[STYLES.FLAT_BTN_MAIN_CONT, dynamicStyles.FLAT_BTN_MAIN_CONT]}>
90
+ <TouchableOpacity
91
+ onPress={onPress}
92
+ // rippleColor={rippleColor}
93
+ disabled={disabled || loading}
94
+ // ref={ref}
95
+ {...rest}
96
+ >
97
+
98
+ {/* <TouchableRipple
99
+ onPress={onPress}
100
+ rippleColor={rippleColor}
101
+ disabled={disabled}
102
+ // ref={ref}
103
+ {...rest}
104
+ > */}
105
+ <StyledView
106
+ style={[
107
+ STYLES.FLAT_BTN_INNER_CONT,
108
+ STYLES.BUTTON_CONT,
109
+ dynamicStyles.FLAT_BTN_INNER_CONT,
110
+ dynamicStyles.BUTTON_CONT,
111
+ containerStyle,
112
+ ]}
113
+ >
114
+ {(renderLeftIcon || (fullWidth && renderRightIcon)) && (
115
+ <StyledView f={fullWidth ? 1 : undefined}>
116
+ {renderLeftIcon && cloneElement(renderLeftIcon)}
117
+ </StyledView>
118
+ )}
119
+
120
+ <StyledView flexShrink={1} f={fullWidth ? 8 : undefined}>
121
+ {!loading ? (
122
+ (title ?? children) ? (
123
+ <StyledText
124
+ numberOfLines={1}
125
+ fs={fs}
126
+ fScale={fScale}
127
+ style={[
128
+ STYLES.BUTTON_TEXT,
129
+ dynamicStyles.BUTTON_TEXT,
130
+ titleStyle,
131
+ ]}
132
+ >
133
+ {title ?? children}
134
+ </StyledText>
135
+ ) : (
136
+ renderIcon && cloneElement(renderIcon)
137
+ )
138
+ ) : (
139
+ <ActivityIndicator
140
+ color={dynamicStyles.BUTTON_TEXT.color}
141
+ size="small"
142
+ />
143
+ )}
144
+ </StyledView>
145
+
146
+ {(renderRightIcon || (fullWidth && renderLeftIcon)) && (
147
+ <StyledView alignItems="flex-end" f={fullWidth ? 1 : undefined}>
148
+ {renderRightIcon && cloneElement(renderRightIcon)}
149
+ </StyledView>
150
+ )}
151
+ </StyledView>
152
+
153
+
154
+ {/* </TouchableRipple> */}
155
+ </TouchableOpacity>
156
+
157
+ </StyledView>
158
+ )}
159
+
160
+ {type === 'round' && (
161
+ <StyledView style={STYLES.ROUND_BTN_MAIN_CONT} >
162
+ <TouchableOpacity
163
+ onPress={onPress}
164
+ // rippleColor={rippleColor}
165
+ {...rest}
166
+ >
167
+ <StyledView
168
+ style={[
169
+ STYLES.BUTTON_CONT,
170
+ STYLES.ROUND_BTN_INNER_CONT,
171
+ dynamicStyles.BUTTON_CONT,
172
+ dynamicStyles.ROUND_BTN_INNER_CONT,
173
+ containerStyle
174
+ ]}
175
+ >
176
+ {renderIcon && cloneElement(renderIcon)}
177
+ </StyledView>
178
+ </TouchableOpacity>
179
+ </StyledView>
180
+ )}
181
+ </>
182
+ );
183
+ };
184
+
185
+ export default Button;
186
+ export type { ButtonProps };
187
+
188
+ const customStyles = () => StyleSheet.create({
189
+ BUTTON_CONT: {
190
+ maxWidth: '100%',
191
+ },
192
+ BUTTON_TEXT: {
193
+ textAlign: 'center',
194
+ },
195
+ FLAT_BTN_MAIN_CONT: {
196
+ overflow: 'hidden',
197
+ },
198
+ FLAT_BTN_INNER_CONT: {
199
+ flexDirection: 'row',
200
+ alignItems: 'center',
201
+ justifyContent: 'space-between',
202
+ gap: horizontalScale(10),
203
+ },
204
+ ROUND_BTN_MAIN_CONT: {
205
+ overflow: 'hidden',
206
+ borderRadius: verticalScale(100),
207
+ alignSelf: 'flex-start',
208
+ },
209
+ ROUND_BTN_INNER_CONT: {
210
+ alignItems: 'center',
211
+ justifyContent: 'center',
212
+ }
213
+ });
214
+
215
+
216
+