@jamadd/react-native-template-ui 0.8.5 → 0.8.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/module/components/overlay/actionSheet/ActionSheet.web.js +31 -0
- package/lib/module/components/overlay/actionSheet/ActionSheet.web.js.map +1 -0
- package/lib/module/components/overlay/actionSheet/ActionSheetHeader.web.js +57 -0
- package/lib/module/components/overlay/actionSheet/ActionSheetHeader.web.js.map +1 -0
- package/lib/module/components/overlay/actionSheet/ActionSheetListView.js +1 -1
- package/lib/module/components/overlay/actionSheet/ActionSheetListView.js.map +1 -1
- package/lib/module/components/overlay/actionSheet/ActionSheetOptions.js +1 -1
- package/lib/module/components/overlay/actionSheet/ActionSheetOptions.js.map +1 -1
- package/lib/module/components/overlay/actionSheet/ActionSheetScrollView.js +1 -1
- package/lib/module/components/overlay/actionSheet/ActionSheetScrollView.js.map +1 -1
- package/lib/module/components/slider/ThemedSlider.web.js +82 -0
- package/lib/module/components/slider/ThemedSlider.web.js.map +1 -0
- package/lib/module/index.js +2 -2
- package/lib/module/index.js.map +1 -1
- package/lib/typescript/src/components/overlay/actionSheet/ActionSheet.web.d.ts +5 -0
- package/lib/typescript/src/components/overlay/actionSheet/ActionSheet.web.d.ts.map +1 -0
- package/lib/typescript/src/components/overlay/actionSheet/ActionSheetContentGesture.d.ts +0 -2
- package/lib/typescript/src/components/overlay/actionSheet/ActionSheetContentGesture.d.ts.map +1 -1
- package/lib/typescript/src/components/overlay/actionSheet/ActionSheetHeader.d.ts +0 -2
- package/lib/typescript/src/components/overlay/actionSheet/ActionSheetHeader.d.ts.map +1 -1
- package/lib/typescript/src/components/overlay/actionSheet/ActionSheetHeader.web.d.ts +4 -0
- package/lib/typescript/src/components/overlay/actionSheet/ActionSheetHeader.web.d.ts.map +1 -0
- package/lib/typescript/src/components/overlay/actionSheet/ActionSheetListView.d.ts +0 -2
- package/lib/typescript/src/components/overlay/actionSheet/ActionSheetListView.d.ts.map +1 -1
- package/lib/typescript/src/components/overlay/actionSheet/ActionSheetListViewContent.d.ts +0 -2
- package/lib/typescript/src/components/overlay/actionSheet/ActionSheetListViewContent.d.ts.map +1 -1
- package/lib/typescript/src/components/overlay/actionSheet/ActionSheetOptionList.d.ts +0 -2
- package/lib/typescript/src/components/overlay/actionSheet/ActionSheetOptionList.d.ts.map +1 -1
- package/lib/typescript/src/components/overlay/actionSheet/ActionSheetOptionListItem.d.ts +0 -2
- package/lib/typescript/src/components/overlay/actionSheet/ActionSheetOptionListItem.d.ts.map +1 -1
- package/lib/typescript/src/components/overlay/actionSheet/ActionSheetOptions.d.ts +0 -2
- package/lib/typescript/src/components/overlay/actionSheet/ActionSheetOptions.d.ts.map +1 -1
- package/lib/typescript/src/components/overlay/actionSheet/ActionSheetScrollView.d.ts +0 -2
- package/lib/typescript/src/components/overlay/actionSheet/ActionSheetScrollView.d.ts.map +1 -1
- package/lib/typescript/src/components/overlay/actionSheet/ActionSheetScrollViewContent.d.ts +0 -2
- package/lib/typescript/src/components/overlay/actionSheet/ActionSheetScrollViewContent.d.ts.map +1 -1
- package/lib/typescript/src/components/overlay/actionSheet/ActionSheetWrap.d.ts +0 -2
- package/lib/typescript/src/components/overlay/actionSheet/ActionSheetWrap.d.ts.map +1 -1
- package/lib/typescript/src/components/slider/ThemedSlider.web.d.ts +5 -0
- package/lib/typescript/src/components/slider/ThemedSlider.web.d.ts.map +1 -0
- package/lib/typescript/src/components/view/AnimatedView.d.ts +0 -2
- package/lib/typescript/src/components/view/AnimatedView.d.ts.map +1 -1
- package/lib/typescript/src/hooks/overlay.d.ts +0 -27
- package/lib/typescript/src/hooks/overlay.d.ts.map +1 -1
- package/lib/typescript/src/hooks/switch.d.ts +1 -20
- package/lib/typescript/src/hooks/switch.d.ts.map +1 -1
- package/lib/typescript/src/types/list.d.ts +1 -10
- package/lib/typescript/src/types/list.d.ts.map +1 -1
- package/lib/typescript/src/types/overlay.d.ts +1 -31
- package/lib/typescript/src/types/overlay.d.ts.map +1 -1
- package/lib/typescript/src/utils/overlay/const.d.ts +0 -33
- package/lib/typescript/src/utils/overlay/const.d.ts.map +1 -1
- package/lib/typescript/src/utils/reanimated/func.d.ts +1 -5
- package/lib/typescript/src/utils/reanimated/func.d.ts.map +1 -1
- package/lib/typescript/src/utils/switch/const.d.ts +1 -2
- package/lib/typescript/src/utils/switch/const.d.ts.map +1 -1
- package/package.json +1 -2
- package/src/components/button/AnimatedPressable.tsx +0 -7
- package/src/components/button/AnimatedThemedPressable.tsx +0 -12
- package/src/components/button/ThemedButton.tsx +0 -45
- package/src/components/button/ThemedIconButton.tsx +0 -33
- package/src/components/button/ThemedIconTextButton.tsx +0 -56
- package/src/components/button/ThemedPressable.tsx +0 -12
- package/src/components/icon/ThemedIcon.tsx +0 -31
- package/src/components/list/List.tsx +0 -55
- package/src/components/loading/ThemedLoading.tsx +0 -29
- package/src/components/overlay/actionSheet/ActionSheet.tsx +0 -31
- package/src/components/overlay/actionSheet/ActionSheetContentGesture.tsx +0 -15
- package/src/components/overlay/actionSheet/ActionSheetHeader.tsx +0 -72
- package/src/components/overlay/actionSheet/ActionSheetListView.tsx +0 -54
- package/src/components/overlay/actionSheet/ActionSheetListViewContent.tsx +0 -32
- package/src/components/overlay/actionSheet/ActionSheetOptionList.tsx +0 -51
- package/src/components/overlay/actionSheet/ActionSheetOptionListItem.tsx +0 -43
- package/src/components/overlay/actionSheet/ActionSheetOptions.tsx +0 -61
- package/src/components/overlay/actionSheet/ActionSheetScrollView.tsx +0 -57
- package/src/components/overlay/actionSheet/ActionSheetScrollViewContent.tsx +0 -38
- package/src/components/overlay/actionSheet/ActionSheetWrap.tsx +0 -75
- package/src/components/overlay/alert/Alert.tsx +0 -86
- package/src/components/overlay/alert/AlertButton.tsx +0 -41
- package/src/components/overlay/alert/AlertButtons.tsx +0 -32
- package/src/components/overlay/alert/AlertContent.tsx +0 -60
- package/src/components/overlay/alert/AlertWrap.tsx +0 -93
- package/src/components/overlay/modal/ThemedLoadingModal.tsx +0 -47
- package/src/components/overlay/modal/ThemedModal.tsx +0 -42
- package/src/components/overlay/toast/ThemedToast.tsx +0 -160
- package/src/components/provider/GestureProvider.tsx +0 -9
- package/src/components/provider/InsetsProvider.tsx +0 -11
- package/src/components/provider/ReactNativeTemplateProviders.tsx +0 -20
- package/src/components/provider/ThemeProvider.tsx +0 -8
- package/src/components/separator/ThemedSeparator.tsx +0 -24
- package/src/components/slider/Slider.tsx +0 -229
- package/src/components/slider/ThemedSlider.tsx +0 -103
- package/src/components/slider/ThemedSliderStepIndicator.tsx +0 -24
- package/src/components/switch/ThemedSwitch.tsx +0 -49
- package/src/components/text/Text.tsx +0 -7
- package/src/components/text/ThemedIconText.tsx +0 -58
- package/src/components/text/ThemedText.tsx +0 -7
- package/src/components/view/AnimatedThemedView.tsx +0 -18
- package/src/components/view/AnimatedView.tsx +0 -7
- package/src/components/view/Box.tsx +0 -7
- package/src/components/view/ThemedScreenWrap.tsx +0 -48
- package/src/components/view/ThemedScreenWrap.web.tsx +0 -41
- package/src/components/view/ThemedScrollView.tsx +0 -54
- package/src/components/view/ThemedView.tsx +0 -19
- package/src/hooks/button.ts +0 -152
- package/src/hooks/list.ts +0 -42
- package/src/hooks/overlay.ts +0 -471
- package/src/hooks/react.ts +0 -34
- package/src/hooks/reanimated.ts +0 -6
- package/src/hooks/separator.ts +0 -29
- package/src/hooks/style.ts +0 -79
- package/src/hooks/switch.ts +0 -119
- package/src/hooks/theme.ts +0 -65
- package/src/hooks/view.ts +0 -28
- package/src/index.ts +0 -59
- package/src/test/utils/const.ts +0 -9
- package/src/test/utils/func.ts +0 -55
- package/src/test/utils/testingLib.tsx +0 -17
- package/src/types/button.ts +0 -50
- package/src/types/global.d.ts +0 -5
- package/src/types/icon.ts +0 -21
- package/src/types/list.ts +0 -61
- package/src/types/loading.ts +0 -14
- package/src/types/overlay.ts +0 -216
- package/src/types/provider.ts +0 -6
- package/src/types/react.ts +0 -8
- package/src/types/reanimated.ts +0 -11
- package/src/types/separator.ts +0 -28
- package/src/types/slider.ts +0 -59
- package/src/types/style.ts +0 -26
- package/src/types/switch.ts +0 -31
- package/src/types/text.ts +0 -25
- package/src/types/theme.ts +0 -39
- package/src/types/view.ts +0 -58
- package/src/utils/button/const.ts +0 -10
- package/src/utils/overlay/const.ts +0 -77
- package/src/utils/overlay/func.ts +0 -107
- package/src/utils/reanimated/func.ts +0 -39
- package/src/utils/slider/const.ts +0 -23
- package/src/utils/style/const.ts +0 -4
- package/src/utils/style/func.ts +0 -37
- package/src/utils/switch/const.ts +0 -2
- package/src/utils/theme/const.ts +0 -189
- package/src/utils/theme/restyle.ts +0 -87
|
@@ -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,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,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,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;
|
package/src/hooks/button.ts
DELETED
|
@@ -1,152 +0,0 @@
|
|
|
1
|
-
import { useRestyle } from '@shopify/restyle';
|
|
2
|
-
import { useCallback, useEffect, useMemo, useRef } from 'react';
|
|
3
|
-
import type {
|
|
4
|
-
AnimatedPressableProps,
|
|
5
|
-
AnimatedThemedPressableProps,
|
|
6
|
-
OnPressDelayConfig,
|
|
7
|
-
PressableOnPress,
|
|
8
|
-
PressableProps,
|
|
9
|
-
ThemedPressableProps,
|
|
10
|
-
} from '../types/button';
|
|
11
|
-
import type { Timeout } from '../types/react';
|
|
12
|
-
import { ButtonScaleRatio, OnPressDelayType } from '../utils/button/const';
|
|
13
|
-
import { composeStyles } from '../utils/style/func';
|
|
14
|
-
import {
|
|
15
|
-
animatedThemedPressableRestyleFuncs,
|
|
16
|
-
themedPressableRestyleFuncs,
|
|
17
|
-
} from '../utils/theme/restyle';
|
|
18
|
-
|
|
19
|
-
export function useDelayedOnPress(
|
|
20
|
-
onPress: PressableOnPress | null,
|
|
21
|
-
onPressDelayConfig?: OnPressDelayConfig
|
|
22
|
-
) {
|
|
23
|
-
const onPressTimestamp = useRef(0);
|
|
24
|
-
const debounceTimeout = useRef<Timeout>(undefined);
|
|
25
|
-
const clearDebounceTimeout = useCallback(() => {
|
|
26
|
-
if (debounceTimeout.current) {
|
|
27
|
-
clearTimeout(debounceTimeout.current);
|
|
28
|
-
}
|
|
29
|
-
}, [debounceTimeout]);
|
|
30
|
-
useEffect(() => {
|
|
31
|
-
return () => {
|
|
32
|
-
clearDebounceTimeout();
|
|
33
|
-
};
|
|
34
|
-
}, []);
|
|
35
|
-
|
|
36
|
-
return useMemo<PressableOnPress>(() => {
|
|
37
|
-
const tempOnPress =
|
|
38
|
-
onPress ??
|
|
39
|
-
(() => {
|
|
40
|
-
console.warn('onPress is not defined');
|
|
41
|
-
});
|
|
42
|
-
if (!onPressDelayConfig) {
|
|
43
|
-
return tempOnPress;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
const { type, wait } = onPressDelayConfig;
|
|
47
|
-
switch (type) {
|
|
48
|
-
case OnPressDelayType.Debounce:
|
|
49
|
-
return (event) => {
|
|
50
|
-
clearDebounceTimeout();
|
|
51
|
-
debounceTimeout.current = setTimeout(() => {
|
|
52
|
-
tempOnPress(event);
|
|
53
|
-
}, wait);
|
|
54
|
-
};
|
|
55
|
-
case OnPressDelayType.Throttle:
|
|
56
|
-
return (event) => {
|
|
57
|
-
if (onPressTimestamp.current > Date.now()) {
|
|
58
|
-
return;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
tempOnPress(event);
|
|
62
|
-
onPressTimestamp.current = Date.now() + wait;
|
|
63
|
-
};
|
|
64
|
-
default:
|
|
65
|
-
return tempOnPress;
|
|
66
|
-
}
|
|
67
|
-
}, [
|
|
68
|
-
onPress,
|
|
69
|
-
onPressDelayConfig,
|
|
70
|
-
onPressTimestamp,
|
|
71
|
-
debounceTimeout,
|
|
72
|
-
clearDebounceTimeout,
|
|
73
|
-
]);
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
function usePressableProps({
|
|
77
|
-
onPress,
|
|
78
|
-
scaleRatio = ButtonScaleRatio.None,
|
|
79
|
-
onPressDelayConfig,
|
|
80
|
-
style,
|
|
81
|
-
}: Pick<
|
|
82
|
-
PressableProps,
|
|
83
|
-
'onPress' | 'scaleRatio' | 'onPressDelayConfig' | 'style'
|
|
84
|
-
>) {
|
|
85
|
-
const pressableOnPress = useDelayedOnPress(
|
|
86
|
-
onPress ?? null,
|
|
87
|
-
onPressDelayConfig
|
|
88
|
-
);
|
|
89
|
-
|
|
90
|
-
const styleCb: PressableProps['style'] =
|
|
91
|
-
typeof style === 'function' || scaleRatio === ButtonScaleRatio.None
|
|
92
|
-
? style
|
|
93
|
-
: ({ pressed }) =>
|
|
94
|
-
composeStyles(
|
|
95
|
-
{ transform: [{ scale: pressed ? scaleRatio : 1 }] },
|
|
96
|
-
style
|
|
97
|
-
);
|
|
98
|
-
const pressableProps: PressableProps = {
|
|
99
|
-
onPress: pressableOnPress,
|
|
100
|
-
style: styleCb,
|
|
101
|
-
};
|
|
102
|
-
|
|
103
|
-
return pressableProps;
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
export function useThemedPressable({
|
|
107
|
-
onPress,
|
|
108
|
-
scaleRatio,
|
|
109
|
-
onPressDelayConfig,
|
|
110
|
-
...props
|
|
111
|
-
}: ThemedPressableProps) {
|
|
112
|
-
const { style, ...restyle } = useRestyle(themedPressableRestyleFuncs, props);
|
|
113
|
-
const pressableProps = usePressableProps({
|
|
114
|
-
onPress,
|
|
115
|
-
scaleRatio,
|
|
116
|
-
onPressDelayConfig,
|
|
117
|
-
style,
|
|
118
|
-
});
|
|
119
|
-
|
|
120
|
-
const themedPressableProps: ThemedPressableProps = {
|
|
121
|
-
...restyle,
|
|
122
|
-
...pressableProps,
|
|
123
|
-
};
|
|
124
|
-
|
|
125
|
-
return themedPressableProps;
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
export function useAnimatedThemedPressable({
|
|
129
|
-
onPress,
|
|
130
|
-
onPressDelayConfig,
|
|
131
|
-
animatedStyle,
|
|
132
|
-
...props
|
|
133
|
-
}: AnimatedThemedPressableProps) {
|
|
134
|
-
const { style, ...restyle } = useRestyle(
|
|
135
|
-
animatedThemedPressableRestyleFuncs,
|
|
136
|
-
props
|
|
137
|
-
);
|
|
138
|
-
const pressableProps = usePressableProps({
|
|
139
|
-
onPress,
|
|
140
|
-
scaleRatio: ButtonScaleRatio.None,
|
|
141
|
-
onPressDelayConfig,
|
|
142
|
-
style,
|
|
143
|
-
});
|
|
144
|
-
|
|
145
|
-
const animatedThemedPressableProps: Omit<AnimatedPressableProps, 'key'> = {
|
|
146
|
-
...restyle,
|
|
147
|
-
...pressableProps,
|
|
148
|
-
style: [pressableProps.style, animatedStyle],
|
|
149
|
-
};
|
|
150
|
-
|
|
151
|
-
return animatedThemedPressableProps;
|
|
152
|
-
}
|
package/src/hooks/list.ts
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import { useRef } from 'react';
|
|
2
|
-
import type {
|
|
3
|
-
ListItemSeparatorComponent,
|
|
4
|
-
ListItemSeparatorProps,
|
|
5
|
-
ListRef,
|
|
6
|
-
} from '../types/list';
|
|
7
|
-
import { useThemedSeparator } from './separator';
|
|
8
|
-
|
|
9
|
-
export function useListRef<T>() {
|
|
10
|
-
return useRef<ListRef<T>>(null);
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export function useListItemSeparatorComponent(
|
|
14
|
-
props: ListItemSeparatorProps = {},
|
|
15
|
-
hideForLeadingItemTypes: string[] = [],
|
|
16
|
-
hideForTrailingItemTypes: string[] = []
|
|
17
|
-
) {
|
|
18
|
-
const ThemedSeparator = useThemedSeparator(
|
|
19
|
-
props.size,
|
|
20
|
-
props.vertical,
|
|
21
|
-
props.backgroundColor,
|
|
22
|
-
props.style
|
|
23
|
-
);
|
|
24
|
-
|
|
25
|
-
const ListItemSeparatorComponent: ListItemSeparatorComponent = ({
|
|
26
|
-
leadingItem,
|
|
27
|
-
trailingItem,
|
|
28
|
-
}) => {
|
|
29
|
-
if (
|
|
30
|
-
(typeof leadingItem === 'object' &&
|
|
31
|
-
hideForLeadingItemTypes.includes(leadingItem.type)) ||
|
|
32
|
-
(typeof trailingItem === 'object' &&
|
|
33
|
-
hideForTrailingItemTypes.includes(trailingItem.type))
|
|
34
|
-
) {
|
|
35
|
-
return null;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
return ThemedSeparator;
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
return ListItemSeparatorComponent;
|
|
42
|
-
}
|