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

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 (128) hide show
  1. package/lib/module/components/overlay/actionSheet/ActionSheetListView.js +2 -0
  2. package/lib/module/components/overlay/actionSheet/ActionSheetListView.js.map +1 -1
  3. package/lib/module/components/overlay/actionSheet/ActionSheetListViewContent.js +1 -0
  4. package/lib/module/components/overlay/actionSheet/ActionSheetListViewContent.js.map +1 -1
  5. package/lib/typescript/src/components/overlay/actionSheet/ActionSheetContentGesture.d.ts +2 -0
  6. package/lib/typescript/src/components/overlay/actionSheet/ActionSheetContentGesture.d.ts.map +1 -1
  7. package/lib/typescript/src/components/overlay/actionSheet/ActionSheetHeader.d.ts +2 -0
  8. package/lib/typescript/src/components/overlay/actionSheet/ActionSheetHeader.d.ts.map +1 -1
  9. package/lib/typescript/src/components/overlay/actionSheet/ActionSheetListView.d.ts +1 -0
  10. package/lib/typescript/src/components/overlay/actionSheet/ActionSheetListView.d.ts.map +1 -1
  11. package/lib/typescript/src/components/overlay/actionSheet/ActionSheetListViewContent.d.ts +1 -0
  12. package/lib/typescript/src/components/overlay/actionSheet/ActionSheetListViewContent.d.ts.map +1 -1
  13. package/lib/typescript/src/components/overlay/actionSheet/ActionSheetOptionList.d.ts +2 -0
  14. package/lib/typescript/src/components/overlay/actionSheet/ActionSheetOptionList.d.ts.map +1 -1
  15. package/lib/typescript/src/components/overlay/actionSheet/ActionSheetOptionListItem.d.ts +2 -0
  16. package/lib/typescript/src/components/overlay/actionSheet/ActionSheetOptionListItem.d.ts.map +1 -1
  17. package/lib/typescript/src/components/overlay/actionSheet/ActionSheetOptions.d.ts +2 -0
  18. package/lib/typescript/src/components/overlay/actionSheet/ActionSheetOptions.d.ts.map +1 -1
  19. package/lib/typescript/src/components/overlay/actionSheet/ActionSheetScrollView.d.ts +2 -0
  20. package/lib/typescript/src/components/overlay/actionSheet/ActionSheetScrollView.d.ts.map +1 -1
  21. package/lib/typescript/src/components/overlay/actionSheet/ActionSheetScrollViewContent.d.ts +2 -0
  22. package/lib/typescript/src/components/overlay/actionSheet/ActionSheetScrollViewContent.d.ts.map +1 -1
  23. package/lib/typescript/src/components/overlay/actionSheet/ActionSheetWrap.d.ts +2 -0
  24. package/lib/typescript/src/components/overlay/actionSheet/ActionSheetWrap.d.ts.map +1 -1
  25. package/lib/typescript/src/components/view/AnimatedView.d.ts +2 -0
  26. package/lib/typescript/src/components/view/AnimatedView.d.ts.map +1 -1
  27. package/lib/typescript/src/hooks/overlay.d.ts +27 -0
  28. package/lib/typescript/src/hooks/overlay.d.ts.map +1 -1
  29. package/lib/typescript/src/hooks/switch.d.ts +20 -1
  30. package/lib/typescript/src/hooks/switch.d.ts.map +1 -1
  31. package/lib/typescript/src/types/list.d.ts +10 -1
  32. package/lib/typescript/src/types/list.d.ts.map +1 -1
  33. package/lib/typescript/src/types/overlay.d.ts +31 -1
  34. package/lib/typescript/src/types/overlay.d.ts.map +1 -1
  35. package/lib/typescript/src/utils/overlay/const.d.ts +33 -0
  36. package/lib/typescript/src/utils/overlay/const.d.ts.map +1 -1
  37. package/lib/typescript/src/utils/reanimated/func.d.ts +5 -1
  38. package/lib/typescript/src/utils/reanimated/func.d.ts.map +1 -1
  39. package/lib/typescript/src/utils/switch/const.d.ts +2 -1
  40. package/lib/typescript/src/utils/switch/const.d.ts.map +1 -1
  41. package/package.json +2 -1
  42. package/src/components/button/AnimatedPressable.tsx +7 -0
  43. package/src/components/button/AnimatedThemedPressable.tsx +12 -0
  44. package/src/components/button/ThemedButton.tsx +45 -0
  45. package/src/components/button/ThemedIconButton.tsx +33 -0
  46. package/src/components/button/ThemedIconTextButton.tsx +56 -0
  47. package/src/components/button/ThemedPressable.tsx +12 -0
  48. package/src/components/icon/ThemedIcon.tsx +31 -0
  49. package/src/components/list/List.tsx +55 -0
  50. package/src/components/loading/ThemedLoading.tsx +29 -0
  51. package/src/components/overlay/actionSheet/ActionSheet.tsx +31 -0
  52. package/src/components/overlay/actionSheet/ActionSheetContentGesture.tsx +15 -0
  53. package/src/components/overlay/actionSheet/ActionSheetHeader.tsx +72 -0
  54. package/src/components/overlay/actionSheet/ActionSheetListView.tsx +54 -0
  55. package/src/components/overlay/actionSheet/ActionSheetListViewContent.tsx +32 -0
  56. package/src/components/overlay/actionSheet/ActionSheetOptionList.tsx +51 -0
  57. package/src/components/overlay/actionSheet/ActionSheetOptionListItem.tsx +43 -0
  58. package/src/components/overlay/actionSheet/ActionSheetOptions.tsx +61 -0
  59. package/src/components/overlay/actionSheet/ActionSheetScrollView.tsx +57 -0
  60. package/src/components/overlay/actionSheet/ActionSheetScrollViewContent.tsx +38 -0
  61. package/src/components/overlay/actionSheet/ActionSheetWrap.tsx +75 -0
  62. package/src/components/overlay/alert/Alert.tsx +86 -0
  63. package/src/components/overlay/alert/AlertButton.tsx +41 -0
  64. package/src/components/overlay/alert/AlertButtons.tsx +32 -0
  65. package/src/components/overlay/alert/AlertContent.tsx +60 -0
  66. package/src/components/overlay/alert/AlertWrap.tsx +93 -0
  67. package/src/components/overlay/modal/ThemedLoadingModal.tsx +47 -0
  68. package/src/components/overlay/modal/ThemedModal.tsx +42 -0
  69. package/src/components/overlay/toast/ThemedToast.tsx +160 -0
  70. package/src/components/provider/GestureProvider.tsx +9 -0
  71. package/src/components/provider/InsetsProvider.tsx +11 -0
  72. package/src/components/provider/ReactNativeTemplateProviders.tsx +20 -0
  73. package/src/components/provider/ThemeProvider.tsx +8 -0
  74. package/src/components/separator/ThemedSeparator.tsx +24 -0
  75. package/src/components/slider/Slider.tsx +229 -0
  76. package/src/components/slider/ThemedSlider.tsx +103 -0
  77. package/src/components/slider/ThemedSliderStepIndicator.tsx +24 -0
  78. package/src/components/switch/ThemedSwitch.tsx +49 -0
  79. package/src/components/text/Text.tsx +7 -0
  80. package/src/components/text/ThemedIconText.tsx +58 -0
  81. package/src/components/text/ThemedText.tsx +7 -0
  82. package/src/components/view/AnimatedThemedView.tsx +18 -0
  83. package/src/components/view/AnimatedView.tsx +7 -0
  84. package/src/components/view/Box.tsx +7 -0
  85. package/src/components/view/ThemedScreenWrap.tsx +48 -0
  86. package/src/components/view/ThemedScreenWrap.web.tsx +41 -0
  87. package/src/components/view/ThemedScrollView.tsx +54 -0
  88. package/src/components/view/ThemedView.tsx +19 -0
  89. package/src/hooks/button.ts +152 -0
  90. package/src/hooks/list.ts +42 -0
  91. package/src/hooks/overlay.ts +471 -0
  92. package/src/hooks/react.ts +34 -0
  93. package/src/hooks/reanimated.ts +6 -0
  94. package/src/hooks/separator.ts +29 -0
  95. package/src/hooks/style.ts +79 -0
  96. package/src/hooks/switch.ts +119 -0
  97. package/src/hooks/theme.ts +65 -0
  98. package/src/hooks/view.ts +28 -0
  99. package/src/index.ts +59 -0
  100. package/src/test/utils/const.ts +9 -0
  101. package/src/test/utils/func.ts +55 -0
  102. package/src/test/utils/testingLib.tsx +17 -0
  103. package/src/types/button.ts +50 -0
  104. package/src/types/global.d.ts +5 -0
  105. package/src/types/icon.ts +21 -0
  106. package/src/types/list.ts +61 -0
  107. package/src/types/loading.ts +14 -0
  108. package/src/types/overlay.ts +216 -0
  109. package/src/types/provider.ts +6 -0
  110. package/src/types/react.ts +8 -0
  111. package/src/types/reanimated.ts +11 -0
  112. package/src/types/separator.ts +28 -0
  113. package/src/types/slider.ts +59 -0
  114. package/src/types/style.ts +26 -0
  115. package/src/types/switch.ts +31 -0
  116. package/src/types/text.ts +25 -0
  117. package/src/types/theme.ts +39 -0
  118. package/src/types/view.ts +58 -0
  119. package/src/utils/button/const.ts +10 -0
  120. package/src/utils/overlay/const.ts +77 -0
  121. package/src/utils/overlay/func.ts +107 -0
  122. package/src/utils/reanimated/func.ts +39 -0
  123. package/src/utils/slider/const.ts +23 -0
  124. package/src/utils/style/const.ts +4 -0
  125. package/src/utils/style/func.ts +37 -0
  126. package/src/utils/switch/const.ts +2 -0
  127. package/src/utils/theme/const.ts +189 -0
  128. package/src/utils/theme/restyle.ts +87 -0
@@ -0,0 +1,56 @@
1
+ import type { FC } from 'react';
2
+ import type { ThemedIconTextButtonProps } from '../../types/button';
3
+ import { ButtonScaleRatio } from '../../utils/button/const';
4
+ import ThemedIconText from '../text/ThemedIconText';
5
+ import ThemedPressable from './ThemedPressable';
6
+
7
+ const ThemedIconTextButton: FC<ThemedIconTextButtonProps> = ({
8
+ flip,
9
+ iconTextProps,
10
+ iconName,
11
+ iconSize,
12
+ iconColor,
13
+ iconStyle,
14
+ iconProps,
15
+ text,
16
+ textVariant,
17
+ textFontSize,
18
+ textFontWeight,
19
+ textColor = 'themePri',
20
+ textStyle,
21
+ textProps,
22
+ children,
23
+ ...props
24
+ }) => {
25
+ return (
26
+ <ThemedPressable
27
+ scaleRatio={ButtonScaleRatio.Rectangle}
28
+ flexDirection={'row'}
29
+ alignItems={'center'}
30
+ justifyContent={children ? 'space-between' : 'center'}
31
+ paddingVertical={'s'}
32
+ paddingHorizontal={'m'}
33
+ {...props}
34
+ >
35
+ <ThemedIconText
36
+ iconName={iconName}
37
+ iconSize={iconSize}
38
+ iconColor={iconColor}
39
+ iconStyle={iconStyle}
40
+ iconProps={iconProps}
41
+ text={text}
42
+ textVariant={textVariant}
43
+ textFontSize={textFontSize}
44
+ textFontWeight={textFontWeight}
45
+ textColor={textColor}
46
+ textStyle={textStyle}
47
+ textProps={textProps}
48
+ flip={flip}
49
+ {...iconTextProps}
50
+ />
51
+ {children}
52
+ </ThemedPressable>
53
+ );
54
+ };
55
+
56
+ export default ThemedIconTextButton;
@@ -0,0 +1,12 @@
1
+ import { type FC } from 'react';
2
+ import { Pressable } from 'react-native';
3
+ import { useThemedPressable } from '../../hooks/button';
4
+ import type { ThemedPressableProps } from '../../types/button';
5
+
6
+ const ThemedPressable: FC<ThemedPressableProps> = (props) => {
7
+ const themedPressableProps = useThemedPressable(props);
8
+
9
+ return <Pressable {...themedPressableProps} />;
10
+ };
11
+
12
+ export default ThemedPressable;
@@ -0,0 +1,31 @@
1
+ import Icon, { IconSize } from '@jamadd/react-native-template-icons';
2
+ import { useRestyle } from '@shopify/restyle';
3
+ import type { FC } from 'react';
4
+ import type { ThemedIconProps } from '../../types/icon';
5
+ import {
6
+ themedIconColorRestyleFuncs,
7
+ themedIconRestyleFuncs,
8
+ } from '../../utils/theme/restyle';
9
+
10
+ const ThemedIcon: FC<ThemedIconProps> = ({
11
+ name,
12
+ size = IconSize.M,
13
+ color = 'themePri',
14
+ ...props
15
+ }) => {
16
+ const restyle = useRestyle(themedIconRestyleFuncs, props);
17
+ const colorRestyle = useRestyle(themedIconColorRestyleFuncs, {
18
+ color,
19
+ } as Pick<ThemedIconProps, 'color'>) as { style: { color: string }[] };
20
+
21
+ return (
22
+ <Icon
23
+ name={name}
24
+ size={size}
25
+ color={colorRestyle.style[0]?.color}
26
+ {...restyle}
27
+ />
28
+ );
29
+ };
30
+
31
+ export default ThemedIcon;
@@ -0,0 +1,55 @@
1
+ import { FlashList, type ListRenderItem } from '@shopify/flash-list';
2
+ import type { ViewStyle } from 'react-native';
3
+ import { useInsetsStyle } from '../../hooks/style';
4
+ import type { ListProps } from '../../types/list';
5
+ import { composeStyles } from '../../utils/style/func';
6
+
7
+ function List<T>({
8
+ Item,
9
+ insets,
10
+ insetTop,
11
+ insetBottom = true,
12
+ insetLeft,
13
+ insetRight,
14
+ insetsPadding,
15
+ insetPaddingTop,
16
+ insetPaddingBottom = 'm',
17
+ insetPaddingLeft,
18
+ insetPaddingRight,
19
+ contentContainerStyle,
20
+ ...props
21
+ }: ListProps<T>) {
22
+ const insetsStyle = useInsetsStyle({
23
+ insets,
24
+ insetTop,
25
+ insetBottom,
26
+ insetLeft,
27
+ insetRight,
28
+ insetsPadding,
29
+ insetPaddingTop,
30
+ insetPaddingBottom,
31
+ insetPaddingLeft,
32
+ insetPaddingRight,
33
+ });
34
+
35
+ const renderItem: ListRenderItem<T> = (listItemProps) => (
36
+ <Item {...listItemProps} />
37
+ );
38
+ const listContentContainerStyle = composeStyles<ViewStyle>(
39
+ insetsStyle,
40
+ contentContainerStyle
41
+ );
42
+
43
+ return (
44
+ <FlashList
45
+ renderItem={renderItem}
46
+ overScrollMode={'always'}
47
+ showsVerticalScrollIndicator={__DEV__}
48
+ showsHorizontalScrollIndicator={__DEV__}
49
+ contentContainerStyle={listContentContainerStyle}
50
+ {...props}
51
+ />
52
+ );
53
+ }
54
+
55
+ export default List;
@@ -0,0 +1,29 @@
1
+ import { useRestyle } from '@shopify/restyle';
2
+ import type { FC } from 'react';
3
+ import { ActivityIndicator } from 'react-native';
4
+ import type { ThemedLoadingProps } from '../../types/loading';
5
+ import {
6
+ themedLoadingColorRestyleFuncs,
7
+ themedLoadingRestyleFuncs,
8
+ } from '../../utils/theme/restyle';
9
+
10
+ const ThemedLoading: FC<ThemedLoadingProps> = ({
11
+ size = 'large',
12
+ color = 'themePri',
13
+ ...props
14
+ }) => {
15
+ const restyle = useRestyle(themedLoadingRestyleFuncs, props);
16
+ const colorRestyle = useRestyle(themedLoadingColorRestyleFuncs, {
17
+ color,
18
+ } as Pick<ThemedLoadingProps, 'color'>) as { style: { color: string }[] };
19
+
20
+ return (
21
+ <ActivityIndicator
22
+ size={size}
23
+ color={colorRestyle.style[0]?.color}
24
+ {...restyle}
25
+ />
26
+ );
27
+ };
28
+
29
+ export default ThemedLoading;
@@ -0,0 +1,31 @@
1
+ import type { FC } from 'react';
2
+ import type {
3
+ ActionSheetListViewProps,
4
+ ActionSheetOptionsProps,
5
+ ActionSheetProps,
6
+ ActionSheetScrollViewProps,
7
+ } from '../../../types/overlay';
8
+
9
+ const ActionSheetOptions: FC<ActionSheetOptionsProps> =
10
+ require('./ActionSheetOptions').default;
11
+ const ActionSheetScrollView: FC<ActionSheetScrollViewProps> =
12
+ require('./ActionSheetScrollView').default;
13
+ const ActionSheetListView: FC<ActionSheetListViewProps> =
14
+ require('./ActionSheetListView').default;
15
+
16
+ const ActionSheet: FC<ActionSheetProps> = ({
17
+ dismissable = true,
18
+ ...props
19
+ }) => {
20
+ if (props.options?.length) {
21
+ return <ActionSheetOptions dismissable={dismissable} {...props} />;
22
+ } else if (props.children) {
23
+ return <ActionSheetScrollView dismissable={dismissable} {...props} />;
24
+ } else if (props.listProps) {
25
+ return <ActionSheetListView dismissable={dismissable} {...props} />;
26
+ } else {
27
+ return null;
28
+ }
29
+ };
30
+
31
+ export default ActionSheet;
@@ -0,0 +1,15 @@
1
+ /** @internal */
2
+ import type { FC } from 'react';
3
+ import { GestureDetector } from 'react-native-gesture-handler';
4
+ import { useActionSheetContentGesture } from '../../../hooks/overlay';
5
+ import type { PropsWithRequiredChildren } from '../../../types/view';
6
+
7
+ const ActionSheetContentGesture: FC<PropsWithRequiredChildren> = ({
8
+ children,
9
+ }) => {
10
+ const gesture = useActionSheetContentGesture();
11
+
12
+ return <GestureDetector gesture={gesture}>{children}</GestureDetector>;
13
+ };
14
+
15
+ export default ActionSheetContentGesture;
@@ -0,0 +1,72 @@
1
+ /** @internal */
2
+ import type { FC } from 'react';
3
+ import { GestureDetector } from 'react-native-gesture-handler';
4
+ import {
5
+ useActionSheetGesture,
6
+ useActionSheetHeaderMinHeight,
7
+ useActionSheetOnDismiss,
8
+ } from '../../../hooks/overlay';
9
+ import type { ThemedIconButtonProps } from '../../../types/button';
10
+ import type { ActionSheetHeaderProps } from '../../../types/overlay';
11
+ import type { ThemedTextProps } from '../../../types/text';
12
+ import {
13
+ actionSheetHeaderIconSize,
14
+ actionSheetHeaderPadding,
15
+ } from '../../../utils/overlay/const';
16
+ import { getActionSheetContext } from '../../../utils/overlay/func';
17
+ import { BorderSize } from '../../../utils/theme/const';
18
+ import ThemedView from '../../view/ThemedView';
19
+
20
+ const ThemedText: FC<ThemedTextProps> =
21
+ require('../../text/ThemedText').default;
22
+ const ThemedIconButton: FC<ThemedIconButtonProps> =
23
+ require('../../button/ThemedIconButton').default;
24
+
25
+ const ActionSheetHeader: FC<ActionSheetHeaderProps> = ({
26
+ headerShowIcon = true,
27
+ headerWrapProps,
28
+ headerTextProps,
29
+ headerIconButtonProps,
30
+ }) => {
31
+ const gesture = useActionSheetGesture();
32
+ const minHeight = useActionSheetHeaderMinHeight();
33
+ const onDismiss = useActionSheetOnDismiss();
34
+
35
+ const { title, headerViewRef } = getActionSheetContext();
36
+ const onIconPress: ThemedIconButtonProps['onPress'] = () => {
37
+ onDismiss();
38
+ };
39
+
40
+ return (
41
+ <GestureDetector gesture={gesture}>
42
+ <ThemedView
43
+ ref={headerViewRef}
44
+ justifyContent={'center'}
45
+ alignItems={'center'}
46
+ minHeight={minHeight}
47
+ padding={actionSheetHeaderPadding}
48
+ borderBottomWidth={BorderSize.S}
49
+ borderColor={'border'}
50
+ {...headerWrapProps}
51
+ >
52
+ {!!title && (
53
+ <ThemedText variant={'textMBold'} {...headerTextProps}>
54
+ {title}
55
+ </ThemedText>
56
+ )}
57
+ {headerShowIcon && (
58
+ <ThemedIconButton
59
+ onPress={onIconPress}
60
+ iconName={'cross'}
61
+ iconSize={actionSheetHeaderIconSize}
62
+ position={'absolute'}
63
+ left={0}
64
+ {...headerIconButtonProps}
65
+ />
66
+ )}
67
+ </ThemedView>
68
+ </GestureDetector>
69
+ );
70
+ };
71
+
72
+ export default ActionSheetHeader;
@@ -0,0 +1,54 @@
1
+ /** @internal */
2
+ import { type FC } from 'react';
3
+ import {
4
+ useActionSheetListView,
5
+ useActionSheetVisible,
6
+ } from '../../../hooks/overlay';
7
+ import type { ActionSheetListViewProps } from '../../../types/overlay';
8
+ import { ActionSheetContext } from '../../../utils/overlay/const';
9
+ import ActionSheetHeader from './ActionSheetHeader';
10
+ import ActionSheetListViewContent from './ActionSheetListViewContent';
11
+ import ActionSheetWrap from './ActionSheetWrap';
12
+
13
+ const ActionSheetListView: FC<ActionSheetListViewProps> = ({
14
+ title,
15
+ expandable,
16
+ listProps,
17
+ onDismiss,
18
+ dismissable,
19
+ wrapViewProps,
20
+ headerShowIcon,
21
+ headerWrapProps,
22
+ headerTextProps,
23
+ headerIconButtonProps,
24
+ visible,
25
+ }) => {
26
+ const { actionSheetVisible } = useActionSheetVisible(visible);
27
+ const actionSheetContextVal = useActionSheetListView(
28
+ title,
29
+ expandable,
30
+ listProps,
31
+ onDismiss,
32
+ dismissable,
33
+ actionSheetVisible
34
+ );
35
+
36
+ return (
37
+ <ActionSheetContext.Provider value={actionSheetContextVal}>
38
+ <ActionSheetWrap
39
+ visible={actionSheetVisible}
40
+ wrapViewProps={wrapViewProps}
41
+ >
42
+ <ActionSheetHeader
43
+ headerShowIcon={headerShowIcon}
44
+ headerWrapProps={headerWrapProps}
45
+ headerTextProps={headerTextProps}
46
+ headerIconButtonProps={headerIconButtonProps}
47
+ />
48
+ <ActionSheetListViewContent listProps={listProps} />
49
+ </ActionSheetWrap>
50
+ </ActionSheetContext.Provider>
51
+ );
52
+ };
53
+
54
+ export default ActionSheetListView;
@@ -0,0 +1,32 @@
1
+ /** @internal */
2
+ import { useLayoutEffect, type FC } from 'react';
3
+ import type {
4
+ ActionSheetListViewListRefObj,
5
+ ActionSheetListViewProps,
6
+ } from '../../../types/overlay';
7
+ import { getActionSheetContext } from '../../../utils/overlay/func';
8
+ import List from '../../list/List';
9
+ import ActionSheetContentGesture from './ActionSheetContentGesture';
10
+
11
+ const ActionSheetListViewContent: FC<
12
+ Pick<ActionSheetListViewProps, 'listProps'>
13
+ > = ({ listProps }) => {
14
+ const { contentAnimatedRefObj, setContentHeight } = getActionSheetContext();
15
+ useLayoutEffect(() => {
16
+ const contentHeight = (
17
+ contentAnimatedRefObj as ActionSheetListViewListRefObj
18
+ ).current?.getChildContainerDimensions().height;
19
+ setContentHeight?.(contentHeight ?? 0);
20
+ });
21
+
22
+ return (
23
+ <ActionSheetContentGesture>
24
+ <List
25
+ ref={contentAnimatedRefObj as ActionSheetListViewListRefObj}
26
+ {...listProps}
27
+ />
28
+ </ActionSheetContentGesture>
29
+ );
30
+ };
31
+
32
+ export default ActionSheetListViewContent;
@@ -0,0 +1,51 @@
1
+ /** @internal */
2
+ import { type FC } from 'react';
3
+ import {
4
+ useActionSheetOnDismiss,
5
+ useActionSheetOptItemSize,
6
+ } from '../../../hooks/overlay';
7
+ import type { ListKeyExtractor } from '../../../types/list';
8
+ import type {
9
+ ActionSheetOptionListExtraData,
10
+ ActionSheetOption,
11
+ ActionSheetOptionListRefObj,
12
+ ActionSheetOptionsProps,
13
+ } from '../../../types/overlay';
14
+ import { getActionSheetContext } from '../../../utils/overlay/func';
15
+ import List from '../../list/List';
16
+ import ActionSheetContentGesture from './ActionSheetContentGesture';
17
+ import ActionSheetOptionListItem from './ActionSheetOptionListItem';
18
+
19
+ const ActionSheetOptionList: FC<
20
+ Pick<
21
+ ActionSheetOptionsProps,
22
+ 'options' | 'optionListProps' | 'optionListItemProps'
23
+ >
24
+ > = ({ options, optionListProps, optionListItemProps }) => {
25
+ const { insetsStyle } = useActionSheetOptItemSize(optionListProps);
26
+ const onDismiss = useActionSheetOnDismiss();
27
+
28
+ const { contentAnimatedRefObj } = getActionSheetContext();
29
+ const keyExtractor: ListKeyExtractor<ActionSheetOption> = ({ text }, index) =>
30
+ `${text}_${index}`;
31
+ const extraData: ActionSheetOptionListExtraData = {
32
+ optionListItemProps,
33
+ onDismiss,
34
+ };
35
+
36
+ return (
37
+ <ActionSheetContentGesture>
38
+ <List
39
+ ref={contentAnimatedRefObj as ActionSheetOptionListRefObj}
40
+ data={options}
41
+ Item={ActionSheetOptionListItem}
42
+ keyExtractor={keyExtractor}
43
+ extraData={extraData}
44
+ contentContainerStyle={insetsStyle}
45
+ {...optionListProps}
46
+ />
47
+ </ActionSheetContentGesture>
48
+ );
49
+ };
50
+
51
+ export default ActionSheetOptionList;
@@ -0,0 +1,43 @@
1
+ /** @internal */
2
+ import type { FC } from 'react';
3
+ import type { ThemedButtonProps } from '../../../types/button';
4
+ import type { ListItemProps } from '../../../types/list';
5
+ import type {
6
+ ActionSheetOption,
7
+ ActionSheetOptionListExtraData,
8
+ } from '../../../types/overlay';
9
+ import {
10
+ actionSheetOptionListItemPadding,
11
+ actionSheetOptionListItemTextVariant,
12
+ } from '../../../utils/overlay/const';
13
+ import ThemedButton from '../../button/ThemedButton';
14
+
15
+ const ActionSheetOptionListItem: FC<ListItemProps<ActionSheetOption>> = ({
16
+ item: { text, onPress, props },
17
+ extraData,
18
+ }) => {
19
+ const { optionListItemProps, onDismiss } =
20
+ extraData as ActionSheetOptionListExtraData;
21
+ const onItemPress: ThemedButtonProps['onPress'] = (event) => {
22
+ onPress?.(event);
23
+ onDismiss(text);
24
+ };
25
+
26
+ return (
27
+ <ThemedButton
28
+ onPress={onItemPress}
29
+ alignItems={'flex-start'}
30
+ paddingVertical={actionSheetOptionListItemPadding}
31
+ backgroundColor={'background'}
32
+ text={text}
33
+ textVariant={
34
+ actionSheetOptionListItemTextVariant as ThemedButtonProps['textVariant']
35
+ }
36
+ textColor={'text'}
37
+ {...optionListItemProps}
38
+ {...props}
39
+ />
40
+ );
41
+ };
42
+
43
+ export default ActionSheetOptionListItem;
@@ -0,0 +1,61 @@
1
+ /** @internal */
2
+ import type { FC } from 'react';
3
+ import {
4
+ useActionSheetOpts,
5
+ useActionSheetVisible,
6
+ } from '../../../hooks/overlay';
7
+ import type { ActionSheetOptionsProps } from '../../../types/overlay';
8
+ import { ActionSheetContext } from '../../../utils/overlay/const';
9
+ import ActionSheetHeader from './ActionSheetHeader';
10
+ import ActionSheetOptionList from './ActionSheetOptionList';
11
+ import ActionSheetWrap from './ActionSheetWrap';
12
+
13
+ const ActionSheetOptions: FC<ActionSheetOptionsProps> = ({
14
+ title,
15
+ expandable,
16
+ options,
17
+ optionListProps,
18
+ optionListItemProps,
19
+ onDismiss,
20
+ dismissable,
21
+ wrapViewProps,
22
+ headerShowIcon,
23
+ headerWrapProps,
24
+ headerTextProps,
25
+ headerIconButtonProps,
26
+ visible,
27
+ }) => {
28
+ const { actionSheetVisible } = useActionSheetVisible(visible);
29
+ const actionSheetContextVal = useActionSheetOpts(
30
+ title,
31
+ expandable,
32
+ options,
33
+ optionListProps,
34
+ onDismiss,
35
+ dismissable,
36
+ actionSheetVisible
37
+ );
38
+
39
+ return (
40
+ <ActionSheetContext.Provider value={actionSheetContextVal}>
41
+ <ActionSheetWrap
42
+ visible={actionSheetVisible}
43
+ wrapViewProps={wrapViewProps}
44
+ >
45
+ <ActionSheetHeader
46
+ headerShowIcon={headerShowIcon}
47
+ headerWrapProps={headerWrapProps}
48
+ headerTextProps={headerTextProps}
49
+ headerIconButtonProps={headerIconButtonProps}
50
+ />
51
+ <ActionSheetOptionList
52
+ options={options}
53
+ optionListProps={optionListProps}
54
+ optionListItemProps={optionListItemProps}
55
+ />
56
+ </ActionSheetWrap>
57
+ </ActionSheetContext.Provider>
58
+ );
59
+ };
60
+
61
+ export default ActionSheetOptions;
@@ -0,0 +1,57 @@
1
+ /** @internal */
2
+ import type { FC } from 'react';
3
+ import {
4
+ useActionSheetScrollView,
5
+ useActionSheetVisible,
6
+ } from '../../../hooks/overlay';
7
+ import type { ActionSheetScrollViewProps } from '../../../types/overlay';
8
+ import { ActionSheetContext } from '../../../utils/overlay/const';
9
+ import ActionSheetHeader from './ActionSheetHeader';
10
+ import ActionSheetScrollViewContent from './ActionSheetScrollViewContent';
11
+ import ActionSheetWrap from './ActionSheetWrap';
12
+
13
+ const ActionSheetScrollView: FC<ActionSheetScrollViewProps> = ({
14
+ title,
15
+ expandable,
16
+ scrollViewProps,
17
+ children,
18
+ onDismiss,
19
+ dismissable,
20
+ wrapViewProps,
21
+ headerShowIcon,
22
+ headerWrapProps,
23
+ headerTextProps,
24
+ headerIconButtonProps,
25
+ visible,
26
+ }) => {
27
+ const { actionSheetVisible } = useActionSheetVisible(visible);
28
+ const actionSheetContextVal = useActionSheetScrollView(
29
+ title,
30
+ expandable,
31
+ scrollViewProps,
32
+ onDismiss,
33
+ dismissable,
34
+ actionSheetVisible
35
+ );
36
+
37
+ return (
38
+ <ActionSheetContext.Provider value={actionSheetContextVal}>
39
+ <ActionSheetWrap
40
+ visible={actionSheetVisible}
41
+ wrapViewProps={wrapViewProps}
42
+ >
43
+ <ActionSheetHeader
44
+ headerShowIcon={headerShowIcon}
45
+ headerWrapProps={headerWrapProps}
46
+ headerTextProps={headerTextProps}
47
+ headerIconButtonProps={headerIconButtonProps}
48
+ />
49
+ <ActionSheetScrollViewContent scrollViewProps={scrollViewProps}>
50
+ {children}
51
+ </ActionSheetScrollViewContent>
52
+ </ActionSheetWrap>
53
+ </ActionSheetContext.Provider>
54
+ );
55
+ };
56
+
57
+ export default ActionSheetScrollView;
@@ -0,0 +1,38 @@
1
+ /** @internal */
2
+ import { type FC } from 'react';
3
+ import type { ActionSheetScrollViewProps } from '../../../types/overlay';
4
+ import type {
5
+ OnContentSizeChange,
6
+ PropsWithRequiredChildren,
7
+ ScrollViewRefObj,
8
+ } from '../../../types/view';
9
+ import { getActionSheetContext } from '../../../utils/overlay/func';
10
+ import ThemedScrollView from '../../view/ThemedScrollView';
11
+ import ActionSheetContentGesture from './ActionSheetContentGesture';
12
+
13
+ const ActionSheetScrollViewContent: FC<
14
+ PropsWithRequiredChildren<Pick<ActionSheetScrollViewProps, 'scrollViewProps'>>
15
+ > = ({ scrollViewProps, children }) => {
16
+ const { contentAnimatedRefObj, setContentHeight } = getActionSheetContext();
17
+ const onContentSizeChange: OnContentSizeChange = (
18
+ width: number,
19
+ height: number
20
+ ) => {
21
+ setContentHeight?.(height);
22
+ scrollViewProps?.onContentSizeChange?.(width, height);
23
+ };
24
+
25
+ return (
26
+ <ActionSheetContentGesture>
27
+ <ThemedScrollView
28
+ ref={contentAnimatedRefObj as ScrollViewRefObj}
29
+ {...scrollViewProps}
30
+ onContentSizeChange={onContentSizeChange}
31
+ >
32
+ {children}
33
+ </ThemedScrollView>
34
+ </ActionSheetContentGesture>
35
+ );
36
+ };
37
+
38
+ export default ActionSheetScrollViewContent;