@jamadd/react-native-template-ui 0.8.5 → 0.8.7

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 (248) hide show
  1. package/lib/module/components/button/AnimatedThemedPressable.js +13 -3
  2. package/lib/module/components/button/AnimatedThemedPressable.js.map +1 -1
  3. package/lib/module/components/button/ThemedButton.js +84 -23
  4. package/lib/module/components/button/ThemedButton.js.map +1 -1
  5. package/lib/module/components/button/ThemedIconButton.js +62 -16
  6. package/lib/module/components/button/ThemedIconButton.js.map +1 -1
  7. package/lib/module/components/button/ThemedIconTextButton.js +118 -29
  8. package/lib/module/components/button/ThemedIconTextButton.js.map +1 -1
  9. package/lib/module/components/button/ThemedPressable.js +13 -3
  10. package/lib/module/components/button/ThemedPressable.js.map +1 -1
  11. package/lib/module/components/icon/ThemedIcon.js +56 -15
  12. package/lib/module/components/icon/ThemedIcon.js.map +1 -1
  13. package/lib/module/components/list/List.js +131 -39
  14. package/lib/module/components/list/List.js.map +1 -1
  15. package/lib/module/components/loading/ThemedLoading.js +50 -13
  16. package/lib/module/components/loading/ThemedLoading.js.map +1 -1
  17. package/lib/module/components/overlay/actionSheet/ActionSheet.js +64 -19
  18. package/lib/module/components/overlay/actionSheet/ActionSheet.js.map +1 -1
  19. package/lib/module/components/overlay/actionSheet/ActionSheet.web.js +76 -0
  20. package/lib/module/components/overlay/actionSheet/ActionSheet.web.js.map +1 -0
  21. package/lib/module/components/overlay/actionSheet/ActionSheetContentGesture.js +19 -8
  22. package/lib/module/components/overlay/actionSheet/ActionSheetContentGesture.js.map +1 -1
  23. package/lib/module/components/overlay/actionSheet/ActionSheetHeader.js +87 -31
  24. package/lib/module/components/overlay/actionSheet/ActionSheetHeader.js.map +1 -1
  25. package/lib/module/components/overlay/actionSheet/ActionSheetHeader.web.js +113 -0
  26. package/lib/module/components/overlay/actionSheet/ActionSheetHeader.web.js.map +1 -0
  27. package/lib/module/components/overlay/actionSheet/ActionSheetListView.js +69 -28
  28. package/lib/module/components/overlay/actionSheet/ActionSheetListView.js.map +1 -1
  29. package/lib/module/components/overlay/actionSheet/ActionSheetListViewContent.js +39 -14
  30. package/lib/module/components/overlay/actionSheet/ActionSheetListViewContent.js.map +1 -1
  31. package/lib/module/components/overlay/actionSheet/ActionSheetOptionList.js +58 -25
  32. package/lib/module/components/overlay/actionSheet/ActionSheetOptionList.js.map +1 -1
  33. package/lib/module/components/overlay/actionSheet/ActionSheetOptionListItem.js +45 -21
  34. package/lib/module/components/overlay/actionSheet/ActionSheetOptionListItem.js.map +1 -1
  35. package/lib/module/components/overlay/actionSheet/ActionSheetOptions.js +75 -32
  36. package/lib/module/components/overlay/actionSheet/ActionSheetOptions.js.map +1 -1
  37. package/lib/module/components/overlay/actionSheet/ActionSheetScrollView.js +72 -30
  38. package/lib/module/components/overlay/actionSheet/ActionSheetScrollView.js.map +1 -1
  39. package/lib/module/components/overlay/actionSheet/ActionSheetScrollViewContent.js +45 -18
  40. package/lib/module/components/overlay/actionSheet/ActionSheetScrollViewContent.js.map +1 -1
  41. package/lib/module/components/overlay/actionSheet/ActionSheetWrap.js +152 -36
  42. package/lib/module/components/overlay/actionSheet/ActionSheetWrap.js.map +1 -1
  43. package/lib/module/components/overlay/alert/Alert.js +142 -51
  44. package/lib/module/components/overlay/alert/Alert.js.map +1 -1
  45. package/lib/module/components/overlay/alert/AlertButton.js +62 -26
  46. package/lib/module/components/overlay/alert/AlertButton.js.map +1 -1
  47. package/lib/module/components/overlay/alert/AlertButtons.js +58 -23
  48. package/lib/module/components/overlay/alert/AlertButtons.js.map +1 -1
  49. package/lib/module/components/overlay/alert/AlertContent.js +76 -17
  50. package/lib/module/components/overlay/alert/AlertContent.js.map +1 -1
  51. package/lib/module/components/overlay/alert/AlertWrap.js +125 -43
  52. package/lib/module/components/overlay/alert/AlertWrap.js.map +1 -1
  53. package/lib/module/components/overlay/modal/ThemedLoadingModal.js +96 -21
  54. package/lib/module/components/overlay/modal/ThemedLoadingModal.js.map +1 -1
  55. package/lib/module/components/overlay/modal/ThemedModal.js +76 -23
  56. package/lib/module/components/overlay/modal/ThemedModal.js.map +1 -1
  57. package/lib/module/components/overlay/toast/ThemedToast.js +339 -90
  58. package/lib/module/components/overlay/toast/ThemedToast.js.map +1 -1
  59. package/lib/module/components/provider/GestureProvider.js +15 -3
  60. package/lib/module/components/provider/GestureProvider.js.map +1 -1
  61. package/lib/module/components/provider/InsetsProvider.js +15 -3
  62. package/lib/module/components/provider/InsetsProvider.js.map +1 -1
  63. package/lib/module/components/provider/ReactNativeTemplateProviders.js +23 -11
  64. package/lib/module/components/provider/ReactNativeTemplateProviders.js.map +1 -1
  65. package/lib/module/components/provider/ThemeProvider.js +15 -3
  66. package/lib/module/components/provider/ThemeProvider.js.map +1 -1
  67. package/lib/module/components/separator/ThemedSeparator.js +53 -14
  68. package/lib/module/components/separator/ThemedSeparator.js.map +1 -1
  69. package/lib/module/components/slider/Slider.js +625 -137
  70. package/lib/module/components/slider/Slider.js.map +1 -1
  71. package/lib/module/components/slider/ThemedSlider.js +178 -54
  72. package/lib/module/components/slider/ThemedSlider.js.map +1 -1
  73. package/lib/module/components/slider/ThemedSlider.web.js +206 -0
  74. package/lib/module/components/slider/ThemedSlider.web.js.map +1 -0
  75. package/lib/module/components/slider/ThemedSliderStepIndicator.js +40 -15
  76. package/lib/module/components/slider/ThemedSliderStepIndicator.js.map +1 -1
  77. package/lib/module/components/switch/ThemedSwitch.js +81 -21
  78. package/lib/module/components/switch/ThemedSwitch.js.map +1 -1
  79. package/lib/module/components/text/ThemedIconText.js +124 -35
  80. package/lib/module/components/text/ThemedIconText.js.map +1 -1
  81. package/lib/module/components/text/ThemedText.js +15 -3
  82. package/lib/module/components/text/ThemedText.js.map +1 -1
  83. package/lib/module/components/view/AnimatedThemedView.js +42 -11
  84. package/lib/module/components/view/AnimatedThemedView.js.map +1 -1
  85. package/lib/module/components/view/ThemedScreenWrap.js +144 -39
  86. package/lib/module/components/view/ThemedScreenWrap.js.map +1 -1
  87. package/lib/module/components/view/ThemedScreenWrap.web.js +111 -32
  88. package/lib/module/components/view/ThemedScreenWrap.web.js.map +1 -1
  89. package/lib/module/components/view/ThemedScrollView.js +126 -38
  90. package/lib/module/components/view/ThemedScrollView.js.map +1 -1
  91. package/lib/module/components/view/ThemedView.js +33 -10
  92. package/lib/module/components/view/ThemedView.js.map +1 -1
  93. package/lib/module/hooks/button.js +263 -84
  94. package/lib/module/hooks/button.js.map +1 -1
  95. package/lib/module/hooks/list.js +50 -10
  96. package/lib/module/hooks/list.js.map +1 -1
  97. package/lib/module/hooks/overlay.js +575 -187
  98. package/lib/module/hooks/overlay.js.map +1 -1
  99. package/lib/module/hooks/react.js +90 -27
  100. package/lib/module/hooks/react.js.map +1 -1
  101. package/lib/module/hooks/reanimated.js.map +1 -1
  102. package/lib/module/hooks/style.js +43 -18
  103. package/lib/module/hooks/style.js.map +1 -1
  104. package/lib/module/hooks/switch.js +182 -43
  105. package/lib/module/hooks/switch.js.map +1 -1
  106. package/lib/module/hooks/theme.js +17 -8
  107. package/lib/module/hooks/theme.js.map +1 -1
  108. package/lib/module/hooks/view.js +56 -14
  109. package/lib/module/hooks/view.js.map +1 -1
  110. package/lib/module/index.js +2 -2
  111. package/lib/module/index.js.map +1 -1
  112. package/lib/module/utils/reanimated/func.js +60 -10
  113. package/lib/module/utils/reanimated/func.js.map +1 -1
  114. package/lib/typescript/src/components/overlay/actionSheet/ActionSheet.web.d.ts +5 -0
  115. package/lib/typescript/src/components/overlay/actionSheet/ActionSheet.web.d.ts.map +1 -0
  116. package/lib/typescript/src/components/overlay/actionSheet/ActionSheetContentGesture.d.ts +0 -2
  117. package/lib/typescript/src/components/overlay/actionSheet/ActionSheetContentGesture.d.ts.map +1 -1
  118. package/lib/typescript/src/components/overlay/actionSheet/ActionSheetHeader.d.ts +0 -2
  119. package/lib/typescript/src/components/overlay/actionSheet/ActionSheetHeader.d.ts.map +1 -1
  120. package/lib/typescript/src/components/overlay/actionSheet/ActionSheetHeader.web.d.ts +4 -0
  121. package/lib/typescript/src/components/overlay/actionSheet/ActionSheetHeader.web.d.ts.map +1 -0
  122. package/lib/typescript/src/components/overlay/actionSheet/ActionSheetListView.d.ts +0 -2
  123. package/lib/typescript/src/components/overlay/actionSheet/ActionSheetListView.d.ts.map +1 -1
  124. package/lib/typescript/src/components/overlay/actionSheet/ActionSheetListViewContent.d.ts +0 -2
  125. package/lib/typescript/src/components/overlay/actionSheet/ActionSheetListViewContent.d.ts.map +1 -1
  126. package/lib/typescript/src/components/overlay/actionSheet/ActionSheetOptionList.d.ts +0 -2
  127. package/lib/typescript/src/components/overlay/actionSheet/ActionSheetOptionList.d.ts.map +1 -1
  128. package/lib/typescript/src/components/overlay/actionSheet/ActionSheetOptionListItem.d.ts +0 -2
  129. package/lib/typescript/src/components/overlay/actionSheet/ActionSheetOptionListItem.d.ts.map +1 -1
  130. package/lib/typescript/src/components/overlay/actionSheet/ActionSheetOptions.d.ts +0 -2
  131. package/lib/typescript/src/components/overlay/actionSheet/ActionSheetOptions.d.ts.map +1 -1
  132. package/lib/typescript/src/components/overlay/actionSheet/ActionSheetScrollView.d.ts +0 -2
  133. package/lib/typescript/src/components/overlay/actionSheet/ActionSheetScrollView.d.ts.map +1 -1
  134. package/lib/typescript/src/components/overlay/actionSheet/ActionSheetScrollViewContent.d.ts +0 -2
  135. package/lib/typescript/src/components/overlay/actionSheet/ActionSheetScrollViewContent.d.ts.map +1 -1
  136. package/lib/typescript/src/components/overlay/actionSheet/ActionSheetWrap.d.ts +0 -2
  137. package/lib/typescript/src/components/overlay/actionSheet/ActionSheetWrap.d.ts.map +1 -1
  138. package/lib/typescript/src/components/slider/Slider.d.ts +3 -2
  139. package/lib/typescript/src/components/slider/Slider.d.ts.map +1 -1
  140. package/lib/typescript/src/components/slider/ThemedSlider.d.ts.map +1 -1
  141. package/lib/typescript/src/components/slider/ThemedSlider.web.d.ts +5 -0
  142. package/lib/typescript/src/components/slider/ThemedSlider.web.d.ts.map +1 -0
  143. package/lib/typescript/src/components/slider/ThemedSliderStepIndicator.d.ts +3 -2
  144. package/lib/typescript/src/components/slider/ThemedSliderStepIndicator.d.ts.map +1 -1
  145. package/lib/typescript/src/components/view/AnimatedView.d.ts +0 -2
  146. package/lib/typescript/src/components/view/AnimatedView.d.ts.map +1 -1
  147. package/lib/typescript/src/hooks/overlay.d.ts +0 -27
  148. package/lib/typescript/src/hooks/overlay.d.ts.map +1 -1
  149. package/lib/typescript/src/hooks/switch.d.ts +1 -20
  150. package/lib/typescript/src/hooks/switch.d.ts.map +1 -1
  151. package/lib/typescript/src/types/list.d.ts +1 -10
  152. package/lib/typescript/src/types/list.d.ts.map +1 -1
  153. package/lib/typescript/src/types/overlay.d.ts +1 -31
  154. package/lib/typescript/src/types/overlay.d.ts.map +1 -1
  155. package/lib/typescript/src/utils/overlay/const.d.ts +0 -33
  156. package/lib/typescript/src/utils/overlay/const.d.ts.map +1 -1
  157. package/lib/typescript/src/utils/reanimated/func.d.ts +1 -5
  158. package/lib/typescript/src/utils/reanimated/func.d.ts.map +1 -1
  159. package/lib/typescript/src/utils/switch/const.d.ts +1 -2
  160. package/lib/typescript/src/utils/switch/const.d.ts.map +1 -1
  161. package/package.json +14 -15
  162. package/src/components/button/AnimatedPressable.tsx +0 -7
  163. package/src/components/button/AnimatedThemedPressable.tsx +0 -12
  164. package/src/components/button/ThemedButton.tsx +0 -45
  165. package/src/components/button/ThemedIconButton.tsx +0 -33
  166. package/src/components/button/ThemedIconTextButton.tsx +0 -56
  167. package/src/components/button/ThemedPressable.tsx +0 -12
  168. package/src/components/icon/ThemedIcon.tsx +0 -31
  169. package/src/components/list/List.tsx +0 -55
  170. package/src/components/loading/ThemedLoading.tsx +0 -29
  171. package/src/components/overlay/actionSheet/ActionSheet.tsx +0 -31
  172. package/src/components/overlay/actionSheet/ActionSheetContentGesture.tsx +0 -15
  173. package/src/components/overlay/actionSheet/ActionSheetHeader.tsx +0 -72
  174. package/src/components/overlay/actionSheet/ActionSheetListView.tsx +0 -54
  175. package/src/components/overlay/actionSheet/ActionSheetListViewContent.tsx +0 -32
  176. package/src/components/overlay/actionSheet/ActionSheetOptionList.tsx +0 -51
  177. package/src/components/overlay/actionSheet/ActionSheetOptionListItem.tsx +0 -43
  178. package/src/components/overlay/actionSheet/ActionSheetOptions.tsx +0 -61
  179. package/src/components/overlay/actionSheet/ActionSheetScrollView.tsx +0 -57
  180. package/src/components/overlay/actionSheet/ActionSheetScrollViewContent.tsx +0 -38
  181. package/src/components/overlay/actionSheet/ActionSheetWrap.tsx +0 -75
  182. package/src/components/overlay/alert/Alert.tsx +0 -86
  183. package/src/components/overlay/alert/AlertButton.tsx +0 -41
  184. package/src/components/overlay/alert/AlertButtons.tsx +0 -32
  185. package/src/components/overlay/alert/AlertContent.tsx +0 -60
  186. package/src/components/overlay/alert/AlertWrap.tsx +0 -93
  187. package/src/components/overlay/modal/ThemedLoadingModal.tsx +0 -47
  188. package/src/components/overlay/modal/ThemedModal.tsx +0 -42
  189. package/src/components/overlay/toast/ThemedToast.tsx +0 -160
  190. package/src/components/provider/GestureProvider.tsx +0 -9
  191. package/src/components/provider/InsetsProvider.tsx +0 -11
  192. package/src/components/provider/ReactNativeTemplateProviders.tsx +0 -20
  193. package/src/components/provider/ThemeProvider.tsx +0 -8
  194. package/src/components/separator/ThemedSeparator.tsx +0 -24
  195. package/src/components/slider/Slider.tsx +0 -229
  196. package/src/components/slider/ThemedSlider.tsx +0 -103
  197. package/src/components/slider/ThemedSliderStepIndicator.tsx +0 -24
  198. package/src/components/switch/ThemedSwitch.tsx +0 -49
  199. package/src/components/text/Text.tsx +0 -7
  200. package/src/components/text/ThemedIconText.tsx +0 -58
  201. package/src/components/text/ThemedText.tsx +0 -7
  202. package/src/components/view/AnimatedThemedView.tsx +0 -18
  203. package/src/components/view/AnimatedView.tsx +0 -7
  204. package/src/components/view/Box.tsx +0 -7
  205. package/src/components/view/ThemedScreenWrap.tsx +0 -48
  206. package/src/components/view/ThemedScreenWrap.web.tsx +0 -41
  207. package/src/components/view/ThemedScrollView.tsx +0 -54
  208. package/src/components/view/ThemedView.tsx +0 -19
  209. package/src/hooks/button.ts +0 -152
  210. package/src/hooks/list.ts +0 -42
  211. package/src/hooks/overlay.ts +0 -471
  212. package/src/hooks/react.ts +0 -34
  213. package/src/hooks/reanimated.ts +0 -6
  214. package/src/hooks/separator.ts +0 -29
  215. package/src/hooks/style.ts +0 -79
  216. package/src/hooks/switch.ts +0 -119
  217. package/src/hooks/theme.ts +0 -65
  218. package/src/hooks/view.ts +0 -28
  219. package/src/index.ts +0 -59
  220. package/src/test/utils/const.ts +0 -9
  221. package/src/test/utils/func.ts +0 -55
  222. package/src/test/utils/testingLib.tsx +0 -17
  223. package/src/types/button.ts +0 -50
  224. package/src/types/global.d.ts +0 -5
  225. package/src/types/icon.ts +0 -21
  226. package/src/types/list.ts +0 -61
  227. package/src/types/loading.ts +0 -14
  228. package/src/types/overlay.ts +0 -216
  229. package/src/types/provider.ts +0 -6
  230. package/src/types/react.ts +0 -8
  231. package/src/types/reanimated.ts +0 -11
  232. package/src/types/separator.ts +0 -28
  233. package/src/types/slider.ts +0 -59
  234. package/src/types/style.ts +0 -26
  235. package/src/types/switch.ts +0 -31
  236. package/src/types/text.ts +0 -25
  237. package/src/types/theme.ts +0 -39
  238. package/src/types/view.ts +0 -58
  239. package/src/utils/button/const.ts +0 -10
  240. package/src/utils/overlay/const.ts +0 -77
  241. package/src/utils/overlay/func.ts +0 -107
  242. package/src/utils/reanimated/func.ts +0 -39
  243. package/src/utils/slider/const.ts +0 -23
  244. package/src/utils/style/const.ts +0 -4
  245. package/src/utils/style/func.ts +0 -37
  246. package/src/utils/switch/const.ts +0 -2
  247. package/src/utils/theme/const.ts +0 -189
  248. package/src/utils/theme/restyle.ts +0 -87
@@ -1,229 +0,0 @@
1
- import { useMappingHelper } from '@shopify/flash-list';
2
- import { memo, useLayoutEffect, useMemo, useState, type FC } from 'react';
3
- import { Gesture, GestureDetector } from 'react-native-gesture-handler';
4
- import {
5
- useAnimatedStyle,
6
- useSharedValue,
7
- withTiming,
8
- } from 'react-native-reanimated';
9
- import { scheduleOnRN } from 'react-native-worklets';
10
- import { useWindowDimensionsWidth } from '../../hooks/style';
11
- import { useViewRef } from '../../hooks/view';
12
- import type {
13
- NumberSlider,
14
- SliderProps,
15
- StringSlider,
16
- } from '../../types/slider';
17
- import {
18
- sliderStepIndicatorDefaultWidth,
19
- sliderThumbDefaultSize,
20
- SliderTrackSize,
21
- } from '../../utils/slider/const';
22
- import AnimatedThemedView from '../view/AnimatedThemedView';
23
- import ThemedView from '../view/ThemedView';
24
- import ThemedSliderStepIndicator from './ThemedSliderStepIndicator';
25
-
26
- const Slider: FC<SliderProps> = ({
27
- range,
28
- steps = 1,
29
- stepIndicator,
30
- stepIndicatorProps,
31
- snapToStepAnimated = true,
32
- onValueChange,
33
- sliderWrapProps,
34
- trackSize = SliderTrackSize.M,
35
- trackActiveColor = 'themePri',
36
- trackActiveProps,
37
- trackInactiveColor = 'separator',
38
- trackInactiveProps,
39
- thumbSize = sliderThumbDefaultSize,
40
- thumbColor = 'themePri',
41
- thumbProps,
42
- gestureActivateDuration = 40,
43
- setSelectedVal,
44
- selectedValSharedVal,
45
- }) => {
46
- const windowWidth = useWindowDimensionsWidth();
47
- const isNumRange = typeof range[0] === 'number';
48
- const processedRange = isNumRange ? range.sort() : range;
49
- const totalSteps = isNumRange
50
- ? Math.abs(
51
- (processedRange as NumberSlider['range'])[1] -
52
- (processedRange as NumberSlider['range'])[0]
53
- ) / steps
54
- : processedRange.length - 1;
55
- const stepsFractionDigits = useMemo(() => {
56
- if (!isNumRange || Number.isInteger(steps)) {
57
- return 0;
58
- }
59
-
60
- const stepsStrSplit = steps.toString().split('.');
61
- if (stepsStrSplit.length < 2) {
62
- return 0;
63
- }
64
-
65
- return stepsStrSplit[1]?.length ?? 0;
66
- }, [isNumRange, steps]);
67
- const thumbSizeHalf = thumbSize / 2;
68
- const { getMappingKey } = useMappingHelper();
69
- const trackViewRef = useViewRef();
70
- const [sliderWidth, setSliderWidth] = useState<number>();
71
- const [trackWidth, setTrackWidth] = useState<number>();
72
- const [stepWidth, setStepWidth] = useState<number>();
73
- const xSharedVal = useSharedValue(-(trackWidth ?? 0));
74
- const trackAnimatedStyle = useAnimatedStyle(
75
- () => ({ transform: [{ translateX: xSharedVal.get() }] }),
76
- [trackWidth]
77
- );
78
- const thumbAnimatedStyle = useAnimatedStyle(
79
- () => ({ transform: [{ translateX: xSharedVal.get() - thumbSizeHalf }] }),
80
- [thumbSizeHalf]
81
- );
82
- useLayoutEffect(() => {
83
- trackViewRef.current?.measure((_x, _y, w) => {
84
- const tempWidth = w - thumbSize;
85
- const tempStepWidth = tempWidth / totalSteps;
86
- setSliderWidth(w + thumbSize + thumbSizeHalf);
87
- setTrackWidth(tempWidth);
88
- setStepWidth(tempStepWidth);
89
- let index = 0;
90
- if (isNumRange) {
91
- const numRange = processedRange as NumberSlider['range'];
92
- const numCurrentValue =
93
- selectedValSharedVal?.get() as NumberSlider['defaultValue'];
94
- index = numCurrentValue ? (numCurrentValue - numRange[0]) / steps : 0;
95
- } else {
96
- const strRange = processedRange as StringSlider['range'];
97
- const strCurrentValue =
98
- selectedValSharedVal?.get() as StringSlider['defaultValue'];
99
- index = strCurrentValue ? strRange.indexOf(strCurrentValue) : 0;
100
- }
101
- xSharedVal.set(-(totalSteps - index) * tempStepWidth);
102
- });
103
- }, [thumbSize, isNumRange, processedRange, totalSteps]);
104
-
105
- const updateSelectedVal = (x: number) => {
106
- if (!stepWidth) {
107
- return;
108
- }
109
-
110
- if (isNumRange) {
111
- const numRange = processedRange as NumberSlider['range'];
112
- const numIndex = Math.round(x / stepWidth);
113
- const tempSelectedVal = Number(
114
- (numRange[1] - numIndex * steps).toFixed(stepsFractionDigits)
115
- );
116
- setSelectedVal?.(tempSelectedVal);
117
- onValueChange(tempSelectedVal);
118
- } else {
119
- const strRange = processedRange as StringSlider['range'];
120
- const strIndex = Math.round(x / stepWidth);
121
- const tempSelectedVal = strRange[totalSteps - strIndex];
122
- setSelectedVal?.(tempSelectedVal);
123
- onValueChange(tempSelectedVal!);
124
- }
125
- };
126
- const updateXSharedVal = (x: number, animated = false) => {
127
- 'worklet';
128
- const tempX = Math.min(0, Math.max(x, -(trackWidth ?? 0)));
129
- xSharedVal.set(animated ? withTiming(tempX) : tempX);
130
- scheduleOnRN(updateSelectedVal, Math.abs(tempX));
131
- };
132
- const touchStart = useSharedValue(0);
133
- const gesture = Gesture.Simultaneous(
134
- Gesture.LongPress()
135
- .minDuration(gestureActivateDuration)
136
- .maxDistance(windowWidth * 10)
137
- .shouldCancelWhenOutside(false)
138
- .onStart(({ x }) => {
139
- if (sliderWidth) {
140
- updateXSharedVal(-(sliderWidth - (x + thumbSize + thumbSizeHalf)));
141
- }
142
- })
143
- .onEnd(({ x }) => {
144
- if (sliderWidth && stepWidth) {
145
- const nearestStep = Math.round(
146
- -(sliderWidth - (x + thumbSize + thumbSizeHalf)) / stepWidth
147
- );
148
- updateXSharedVal(nearestStep * stepWidth, snapToStepAnimated);
149
- }
150
- }),
151
- Gesture.Pan()
152
- .manualActivation(true)
153
- .shouldCancelWhenOutside(false)
154
- .onBegin(() => {
155
- touchStart.set(Date.now());
156
- })
157
- .onTouchesMove(({}, state) => {
158
- const timeToCheck = Date.now() - touchStart.get();
159
- if (timeToCheck >= gestureActivateDuration) {
160
- state.activate();
161
- } else {
162
- state.fail();
163
- }
164
- })
165
- .onChange(({ changeX }) => {
166
- updateXSharedVal(xSharedVal.get() + changeX);
167
- })
168
- .onEnd(() => {
169
- if (stepWidth) {
170
- const nearestStep = Math.round(xSharedVal.get() / stepWidth);
171
- updateXSharedVal(nearestStep * stepWidth, snapToStepAnimated);
172
- }
173
- })
174
- );
175
-
176
- return (
177
- <GestureDetector gesture={gesture}>
178
- <ThemedView
179
- ref={trackViewRef}
180
- alignItems={'center'}
181
- justifyContent={'center'}
182
- alignSelf={'stretch'}
183
- height={thumbSize}
184
- {...sliderWrapProps}
185
- >
186
- <ThemedView
187
- position={'absolute'}
188
- width={trackWidth}
189
- height={trackSize}
190
- overflow={'hidden'}
191
- backgroundColor={trackInactiveColor}
192
- {...trackActiveProps}
193
- >
194
- <AnimatedThemedView
195
- height={trackSize}
196
- backgroundColor={trackActiveColor}
197
- animatedStyle={trackAnimatedStyle}
198
- {...trackInactiveProps}
199
- />
200
- </ThemedView>
201
- {!!stepIndicator &&
202
- processedRange.map((value, index) => (
203
- <ThemedSliderStepIndicator
204
- key={getMappingKey(value, index)}
205
- left={
206
- index * (stepWidth ?? 0) +
207
- thumbSizeHalf -
208
- sliderStepIndicatorDefaultWidth / 2
209
- }
210
- height={thumbSize}
211
- {...stepIndicatorProps}
212
- />
213
- ))}
214
- <AnimatedThemedView
215
- position={'absolute'}
216
- right={-thumbSizeHalf}
217
- width={thumbSize}
218
- aspectRatio={1}
219
- opacity={0.8}
220
- backgroundColor={thumbColor}
221
- animatedStyle={thumbAnimatedStyle}
222
- {...thumbProps}
223
- />
224
- </ThemedView>
225
- </GestureDetector>
226
- );
227
- };
228
-
229
- export default memo(Slider);
@@ -1,103 +0,0 @@
1
- import { memo, useLayoutEffect, type FC } from 'react';
2
- import { useSharedValue } from 'react-native-reanimated';
3
- import { useDeferredState } from '../../hooks/react';
4
- import { useThemeSpacing } from '../../hooks/theme';
5
- import type { SliderProps, ThemedSliderProps } from '../../types/slider';
6
- import type { ThemedTextProps } from '../../types/text';
7
- import type { ThemedViewProps } from '../../types/view';
8
- import {
9
- sliderThumbDefaultSize,
10
- SliderValueDisplayMode,
11
- } from '../../utils/slider/const';
12
- import ThemedView from '../view/ThemedView';
13
- import Slider from './Slider';
14
-
15
- const ThemedText: FC<ThemedTextProps> = require('../text/ThemedText').default;
16
-
17
- const MemoThemedText = memo(ThemedText);
18
-
19
- const ThemedSlider: FC<ThemedSliderProps> = ({
20
- defaultValue,
21
- wrapProps: { paddingHorizontal, px, ...wrapProps } = {},
22
- valueDisplayMode = SliderValueDisplayMode.None,
23
- valueDisplayWrapProps,
24
- valueTextProps,
25
- valueDescription,
26
- valueDescriptionTextProps,
27
- ...props
28
- }) => {
29
- const { thumbSize } = props;
30
- const themeSpacing = useThemeSpacing();
31
-
32
- const {
33
- state: selectedVal,
34
- setState: setSelectedVal,
35
- deferredState: deferredSelectedValue,
36
- } = useDeferredState(defaultValue);
37
- const selectedValSharedVal = useSharedValue(selectedVal);
38
- useLayoutEffect(() => {
39
- selectedValSharedVal.set(selectedVal);
40
- }, [selectedVal]);
41
-
42
- const thumbSizeHalf = (thumbSize ?? sliderThumbDefaultSize) / 2;
43
- const wrapStyle: ThemedViewProps['style'] = {
44
- marginHorizontal:
45
- typeof paddingHorizontal === 'string'
46
- ? themeSpacing[paddingHorizontal]
47
- : typeof px === 'string'
48
- ? themeSpacing[px]
49
- : thumbSizeHalf,
50
- };
51
- const isValueDisplayModeNone =
52
- valueDisplayMode === SliderValueDisplayMode.None;
53
- const isValueDisplayModeTop = valueDisplayMode === SliderValueDisplayMode.Top;
54
- const isValueDisplayModeBottom =
55
- valueDisplayMode === SliderValueDisplayMode.Bottom;
56
- const valueDisplayComponent = !isValueDisplayModeNone && (
57
- <ThemedView
58
- flexDirection={'row'}
59
- alignItems={'center'}
60
- alignSelf={'stretch'}
61
- {...valueDisplayWrapProps}
62
- >
63
- {!!valueDescription && (
64
- <MemoThemedText
65
- variant={'textS'}
66
- flex={1}
67
- textAlign={'center'}
68
- {...valueDescriptionTextProps}
69
- >
70
- {valueDescription}
71
- </MemoThemedText>
72
- )}
73
- <MemoThemedText
74
- variant={'textSBold'}
75
- flex={1}
76
- textAlign={'center'}
77
- {...valueTextProps}
78
- >
79
- {deferredSelectedValue}
80
- </MemoThemedText>
81
- </ThemedView>
82
- );
83
- const sliderProps = {
84
- ...props,
85
- setSelectedVal,
86
- selectedValSharedVal,
87
- } as SliderProps;
88
-
89
- return (
90
- <ThemedView
91
- paddingVertical={'s'}
92
- gap={'xs'}
93
- style={wrapStyle}
94
- {...wrapProps}
95
- >
96
- {isValueDisplayModeTop && valueDisplayComponent}
97
- <Slider {...sliderProps} />
98
- {isValueDisplayModeBottom && valueDisplayComponent}
99
- </ThemedView>
100
- );
101
- };
102
-
103
- export default ThemedSlider;
@@ -1,24 +0,0 @@
1
- /** @internal */
2
- import type { FC } from 'react';
3
- import { memo } from 'react';
4
- import type { ThemedSliderStepIndicatorProps } from '../../types/slider';
5
- import { sliderStepIndicatorDefaultWidth } from '../../utils/slider/const';
6
- import ThemedView from '../view/ThemedView';
7
-
8
- const ThemedSliderStepIndicator: FC<ThemedSliderStepIndicatorProps> = ({
9
- width = sliderStepIndicatorDefaultWidth,
10
- height,
11
- ...props
12
- }) => {
13
- return (
14
- <ThemedView
15
- position={'absolute'}
16
- width={width}
17
- height={height}
18
- backgroundColor={'themePri'}
19
- {...props}
20
- />
21
- );
22
- };
23
-
24
- export default memo(ThemedSliderStepIndicator);
@@ -1,49 +0,0 @@
1
- import type { FC } from 'react';
2
- import { useThemedSwitch } from '../../hooks/switch';
3
- import type { ThemedSwitchProps } from '../../types/switch';
4
- import { SwitchSize } from '../../utils/theme/const';
5
- import AnimatedThemedPressable from '../button/AnimatedThemedPressable';
6
- import AnimatedThemedView from '../view/AnimatedThemedView';
7
-
8
- const ThemedSwitch: FC<ThemedSwitchProps> = ({
9
- onPress,
10
- enabled,
11
- size = SwitchSize.M,
12
- onPressDelayConfig,
13
- customEnableAnimation,
14
- customDisableAnimation,
15
- customColors,
16
- thumbProps,
17
- style,
18
- ...props
19
- }) => {
20
- const { toggleSwitch, trackAnimatedStyle, thumbAnimatedStyle } =
21
- useThemedSwitch(
22
- onPress,
23
- enabled,
24
- size,
25
- onPressDelayConfig,
26
- customEnableAnimation,
27
- customDisableAnimation,
28
- customColors
29
- );
30
-
31
- return (
32
- <AnimatedThemedPressable
33
- onPress={toggleSwitch}
34
- style={style}
35
- animatedStyle={trackAnimatedStyle}
36
- role={'switch'}
37
- {...props}
38
- >
39
- <AnimatedThemedView
40
- width={size}
41
- aspectRatio={1}
42
- animatedStyle={thumbAnimatedStyle}
43
- {...thumbProps}
44
- />
45
- </AnimatedThemedPressable>
46
- );
47
- };
48
-
49
- export default ThemedSwitch;
@@ -1,7 +0,0 @@
1
- /** @internal */
2
- import { createText } from '@shopify/restyle';
3
- import type { Theme } from '../../types/theme';
4
-
5
- const Text = createText<Theme>();
6
-
7
- export default Text;
@@ -1,58 +0,0 @@
1
- import type { FC } from 'react';
2
- import type { ThemedIconTextProps } from '../../types/text';
3
- import ThemedIcon from '../icon/ThemedIcon';
4
- import ThemedView from '../view/ThemedView';
5
- import ThemedText from './ThemedText';
6
-
7
- const ThemedIconText: FC<ThemedIconTextProps> = ({
8
- flip = false,
9
- iconName,
10
- iconSize,
11
- iconColor,
12
- iconStyle,
13
- iconProps,
14
- text,
15
- textVariant,
16
- textFontSize,
17
- textFontWeight,
18
- textColor,
19
- textStyle,
20
- textProps,
21
- ...props
22
- }) => {
23
- const themedText = (
24
- <ThemedText
25
- numberOfLines={1}
26
- variant={textVariant}
27
- fontSize={textFontSize}
28
- fontWeight={textFontWeight}
29
- color={textColor}
30
- style={textStyle}
31
- {...textProps}
32
- >
33
- {text}
34
- </ThemedText>
35
- );
36
-
37
- return (
38
- <ThemedView
39
- flexDirection={'row'}
40
- alignItems={'center'}
41
- gap={'s'}
42
- backgroundColor={'transparent'}
43
- {...props}
44
- >
45
- {flip && themedText}
46
- <ThemedIcon
47
- name={iconName}
48
- size={iconSize}
49
- color={iconColor}
50
- style={iconStyle}
51
- {...iconProps}
52
- />
53
- {!flip && themedText}
54
- </ThemedView>
55
- );
56
- };
57
-
58
- export default ThemedIconText;
@@ -1,7 +0,0 @@
1
- import type { FC } from 'react';
2
- import type { ThemedTextProps } from '../../types/text';
3
- import Text from './Text';
4
-
5
- const ThemedText: FC<ThemedTextProps> = (props) => <Text {...props} />;
6
-
7
- export default ThemedText;
@@ -1,18 +0,0 @@
1
- import type { FC } from 'react';
2
- import { useAnimatedThemedView } from '../../hooks/view';
3
- import type { AnimatedThemedViewProps } from '../../types/view';
4
- import AnimatedView from './AnimatedView';
5
-
6
- const AnimatedThemedView: FC<AnimatedThemedViewProps> = ({
7
- backgroundColor = 'background',
8
- ...props
9
- }) => {
10
- const animatedThemedViewProps = useAnimatedThemedView({
11
- backgroundColor,
12
- ...props,
13
- });
14
-
15
- return <AnimatedView {...animatedThemedViewProps} />;
16
- };
17
-
18
- export default AnimatedThemedView;
@@ -1,7 +0,0 @@
1
- /** @internal */
2
- import { View } from 'react-native';
3
- import Animated from 'react-native-reanimated';
4
-
5
- const AnimatedView = Animated.createAnimatedComponent(View);
6
-
7
- export default AnimatedView;
@@ -1,7 +0,0 @@
1
- /** @internal */
2
- import { createBox } from '@shopify/restyle';
3
- import type { Theme } from '../../types/theme';
4
-
5
- const Box = createBox<Theme>();
6
-
7
- export default Box;
@@ -1,48 +0,0 @@
1
- import { useEffect, type FC } from 'react';
2
- import type { ViewStyle } from 'react-native';
3
- import { useInsetsStyle } from '../../hooks/style';
4
- import type { ThemedScreenWrapProps } from '../../types/view';
5
- import { composeStyles } from '../../utils/style/func';
6
- import ThemedView from './ThemedView';
7
-
8
- const ThemedScreenWrap: FC<ThemedScreenWrapProps> = ({
9
- effectSetup,
10
- effectCleanup,
11
- effectDependencies = [],
12
- style: themedScreenWrapStyle,
13
- insets,
14
- insetTop,
15
- insetBottom,
16
- insetLeft,
17
- insetRight,
18
- insetsPadding,
19
- insetPaddingTop,
20
- insetPaddingBottom,
21
- insetPaddingLeft,
22
- insetPaddingRight,
23
- ...props
24
- }) => {
25
- const insetsStyle = useInsetsStyle({
26
- insets,
27
- insetTop,
28
- insetBottom,
29
- insetLeft,
30
- insetRight,
31
- insetsPadding,
32
- insetPaddingTop,
33
- insetPaddingBottom,
34
- insetPaddingLeft,
35
- insetPaddingRight,
36
- });
37
- useEffect(() => {
38
- effectSetup?.();
39
-
40
- return effectCleanup;
41
- }, effectDependencies);
42
-
43
- const style = composeStyles<ViewStyle>(themedScreenWrapStyle, insetsStyle);
44
-
45
- return <ThemedView flex={1} style={style} {...props} />;
46
- };
47
-
48
- export default ThemedScreenWrap;
@@ -1,41 +0,0 @@
1
- import type { FC } from 'react';
2
- import type { ViewStyle } from 'react-native';
3
- import { useInsetsStyle, useWindowDimensionsHeight } from '../../hooks/style';
4
- import type { ThemedScreenWrapProps } from '../../types/view';
5
- import { composeStyles } from '../../utils/style/func';
6
- import ThemedView from './ThemedView';
7
-
8
- const ThemedScreenWrap: FC<ThemedScreenWrapProps> = ({
9
- style: themedScreenWrapStyle,
10
- insets,
11
- insetTop,
12
- insetBottom,
13
- insetLeft,
14
- insetRight,
15
- insetsPadding,
16
- insetPaddingTop,
17
- insetPaddingBottom,
18
- insetPaddingLeft,
19
- insetPaddingRight,
20
- ...props
21
- }) => {
22
- const height = useWindowDimensionsHeight();
23
- const insetsStyle = useInsetsStyle({
24
- insets,
25
- insetTop,
26
- insetBottom,
27
- insetLeft,
28
- insetRight,
29
- insetsPadding,
30
- insetPaddingTop,
31
- insetPaddingBottom,
32
- insetPaddingLeft,
33
- insetPaddingRight,
34
- });
35
-
36
- const style = composeStyles<ViewStyle>(themedScreenWrapStyle, insetsStyle);
37
-
38
- return <ThemedView height={height} style={style} {...props} />;
39
- };
40
-
41
- export default ThemedScreenWrap;
@@ -1,54 +0,0 @@
1
- import { useRestyle } from '@shopify/restyle';
2
- import type { FC } from 'react';
3
- import { ScrollView } from 'react-native';
4
- import { useInsetsStyle } from '../../hooks/style';
5
- import type { ThemedScrollViewProps } from '../../types/view';
6
- import { composeStyles } from '../../utils/style/func';
7
- import { themedScrollViewRestyleFuncs } from '../../utils/theme/restyle';
8
-
9
- const ThemedScrollView: FC<ThemedScrollViewProps> = ({
10
- insets,
11
- insetTop,
12
- insetBottom = true,
13
- insetLeft,
14
- insetRight,
15
- insetsPadding,
16
- insetPaddingTop,
17
- insetPaddingBottom = 'm',
18
- insetPaddingLeft,
19
- insetPaddingRight,
20
- ...props
21
- }) => {
22
- const { contentContainerStyle: restyleContentContainerStyle, ...restyles } =
23
- useRestyle(themedScrollViewRestyleFuncs, props);
24
- const insetsStyle = useInsetsStyle({
25
- insets,
26
- insetTop,
27
- insetBottom,
28
- insetLeft,
29
- insetRight,
30
- insetsPadding,
31
- insetPaddingTop,
32
- insetPaddingBottom,
33
- insetPaddingLeft,
34
- insetPaddingRight,
35
- });
36
-
37
- const contentContainerStyle = composeStyles(
38
- restyleContentContainerStyle,
39
- insetsStyle
40
- );
41
-
42
- return (
43
- <ScrollView
44
- showsVerticalScrollIndicator={__DEV__}
45
- showsHorizontalScrollIndicator={__DEV__}
46
- contentContainerStyle={contentContainerStyle}
47
- accessible={true}
48
- role={'group'}
49
- {...restyles}
50
- />
51
- );
52
- };
53
-
54
- export default ThemedScrollView;
@@ -1,19 +0,0 @@
1
- import type { FC } from 'react';
2
- import type { ThemedViewProps } from '../../types/view';
3
- import Box from './Box';
4
-
5
- const ThemedView: FC<ThemedViewProps> = ({
6
- backgroundColor = 'background',
7
- ...props
8
- }) => {
9
- return (
10
- <Box
11
- backgroundColor={backgroundColor}
12
- accessible={true}
13
- role={'group'}
14
- {...props}
15
- />
16
- );
17
- };
18
-
19
- export default ThemedView;