@jamadd/react-native-template-ui 0.8.4 → 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.
- package/package.json +2 -1
- package/src/components/button/AnimatedPressable.tsx +7 -0
- package/src/components/button/AnimatedThemedPressable.tsx +12 -0
- package/src/components/button/ThemedButton.tsx +45 -0
- package/src/components/button/ThemedIconButton.tsx +33 -0
- package/src/components/button/ThemedIconTextButton.tsx +56 -0
- package/src/components/button/ThemedPressable.tsx +12 -0
- package/src/components/icon/ThemedIcon.tsx +31 -0
- package/src/components/list/List.tsx +55 -0
- package/src/components/loading/ThemedLoading.tsx +29 -0
- package/src/components/overlay/actionSheet/ActionSheet.tsx +31 -0
- package/src/components/overlay/actionSheet/ActionSheetContentGesture.tsx +15 -0
- package/src/components/overlay/actionSheet/ActionSheetHeader.tsx +72 -0
- package/src/components/overlay/actionSheet/ActionSheetListView.tsx +54 -0
- package/src/components/overlay/actionSheet/ActionSheetListViewContent.tsx +32 -0
- package/src/components/overlay/actionSheet/ActionSheetOptionList.tsx +51 -0
- package/src/components/overlay/actionSheet/ActionSheetOptionListItem.tsx +43 -0
- package/src/components/overlay/actionSheet/ActionSheetOptions.tsx +61 -0
- package/src/components/overlay/actionSheet/ActionSheetScrollView.tsx +57 -0
- package/src/components/overlay/actionSheet/ActionSheetScrollViewContent.tsx +38 -0
- package/src/components/overlay/actionSheet/ActionSheetWrap.tsx +75 -0
- package/src/components/overlay/alert/Alert.tsx +86 -0
- package/src/components/overlay/alert/AlertButton.tsx +41 -0
- package/src/components/overlay/alert/AlertButtons.tsx +32 -0
- package/src/components/overlay/alert/AlertContent.tsx +60 -0
- package/src/components/overlay/alert/AlertWrap.tsx +93 -0
- package/src/components/overlay/modal/ThemedLoadingModal.tsx +47 -0
- package/src/components/overlay/modal/ThemedModal.tsx +42 -0
- package/src/components/overlay/toast/ThemedToast.tsx +160 -0
- package/src/components/provider/GestureProvider.tsx +9 -0
- package/src/components/provider/InsetsProvider.tsx +11 -0
- package/src/components/provider/ReactNativeTemplateProviders.tsx +20 -0
- package/src/components/provider/ThemeProvider.tsx +8 -0
- package/src/components/separator/ThemedSeparator.tsx +24 -0
- package/src/components/slider/Slider.tsx +229 -0
- package/src/components/slider/ThemedSlider.tsx +103 -0
- package/src/components/slider/ThemedSliderStepIndicator.tsx +24 -0
- package/src/components/switch/ThemedSwitch.tsx +49 -0
- package/src/components/text/Text.tsx +7 -0
- package/src/components/text/ThemedIconText.tsx +58 -0
- package/src/components/text/ThemedText.tsx +7 -0
- package/src/components/view/AnimatedThemedView.tsx +18 -0
- package/src/components/view/AnimatedView.tsx +7 -0
- package/src/components/view/Box.tsx +7 -0
- package/src/components/view/ThemedScreenWrap.tsx +48 -0
- package/src/components/view/ThemedScreenWrap.web.tsx +41 -0
- package/src/components/view/ThemedScrollView.tsx +54 -0
- package/src/components/view/ThemedView.tsx +19 -0
- package/src/hooks/button.ts +152 -0
- package/src/hooks/list.ts +42 -0
- package/src/hooks/overlay.ts +471 -0
- package/src/hooks/react.ts +34 -0
- package/src/hooks/reanimated.ts +6 -0
- package/src/hooks/separator.ts +29 -0
- package/src/hooks/style.ts +79 -0
- package/src/hooks/switch.ts +119 -0
- package/src/hooks/theme.ts +65 -0
- package/src/hooks/view.ts +28 -0
- package/src/index.ts +59 -0
- package/src/test/utils/const.ts +9 -0
- package/src/test/utils/func.ts +55 -0
- package/src/test/utils/testingLib.tsx +17 -0
- package/src/types/button.ts +50 -0
- package/src/types/global.d.ts +5 -0
- package/src/types/icon.ts +21 -0
- package/src/types/list.ts +61 -0
- package/src/types/loading.ts +14 -0
- package/src/types/overlay.ts +216 -0
- package/src/types/provider.ts +6 -0
- package/src/types/react.ts +8 -0
- package/src/types/reanimated.ts +11 -0
- package/src/types/separator.ts +28 -0
- package/src/types/slider.ts +59 -0
- package/src/types/style.ts +26 -0
- package/src/types/switch.ts +31 -0
- package/src/types/text.ts +25 -0
- package/src/types/theme.ts +39 -0
- package/src/types/view.ts +58 -0
- package/src/utils/button/const.ts +10 -0
- package/src/utils/overlay/const.ts +77 -0
- package/src/utils/overlay/func.ts +107 -0
- package/src/utils/reanimated/func.ts +39 -0
- package/src/utils/slider/const.ts +23 -0
- package/src/utils/style/const.ts +4 -0
- package/src/utils/style/func.ts +37 -0
- package/src/utils/switch/const.ts +2 -0
- package/src/utils/theme/const.ts +189 -0
- package/src/utils/theme/restyle.ts +87 -0
|
@@ -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;
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
/** @internal */
|
|
2
|
+
import { type FC } from 'react';
|
|
3
|
+
import { useAnimatedStyle } from 'react-native-reanimated';
|
|
4
|
+
import { useActionSheetOnDismiss } from '../../../hooks/overlay';
|
|
5
|
+
import type {
|
|
6
|
+
ActionSheetWrapProps,
|
|
7
|
+
ThemedModalProps,
|
|
8
|
+
} from '../../../types/overlay';
|
|
9
|
+
import {
|
|
10
|
+
getActionSheetContext,
|
|
11
|
+
getActionSheetMaxHeight,
|
|
12
|
+
} from '../../../utils/overlay/func';
|
|
13
|
+
import AnimatedThemedView from '../../view/AnimatedThemedView';
|
|
14
|
+
import ThemedModal from '../modal/ThemedModal';
|
|
15
|
+
|
|
16
|
+
const ActionSheetWrap: FC<ActionSheetWrapProps> = ({
|
|
17
|
+
wrapViewProps,
|
|
18
|
+
children,
|
|
19
|
+
visible,
|
|
20
|
+
}) => {
|
|
21
|
+
const {
|
|
22
|
+
expandable,
|
|
23
|
+
dismissable,
|
|
24
|
+
translateYSharedVal,
|
|
25
|
+
heightSharedVal,
|
|
26
|
+
expandableHeightSharedVal,
|
|
27
|
+
} = getActionSheetContext();
|
|
28
|
+
const onDismiss = useActionSheetOnDismiss();
|
|
29
|
+
const outerWrapAnimatedStyle = useAnimatedStyle(
|
|
30
|
+
() => ({
|
|
31
|
+
...wrapViewProps?.style,
|
|
32
|
+
height: heightSharedVal?.get() ?? 0,
|
|
33
|
+
transform: [{ translateY: translateYSharedVal?.get() ?? 0 }],
|
|
34
|
+
}),
|
|
35
|
+
[wrapViewProps, translateYSharedVal, heightSharedVal]
|
|
36
|
+
);
|
|
37
|
+
const innerWrapAnimatedStyle = useAnimatedStyle(
|
|
38
|
+
() => ({
|
|
39
|
+
height: expandable
|
|
40
|
+
? (expandableHeightSharedVal?.get() ?? 0)
|
|
41
|
+
: (heightSharedVal?.get() ?? 0),
|
|
42
|
+
}),
|
|
43
|
+
[expandable, heightSharedVal, expandableHeightSharedVal]
|
|
44
|
+
);
|
|
45
|
+
|
|
46
|
+
const contentWrapProps: ThemedModalProps['contentWrapProps'] = {
|
|
47
|
+
justifyContent: 'flex-end',
|
|
48
|
+
};
|
|
49
|
+
const onModalDismiss: ThemedModalProps['onDismiss'] = () => {
|
|
50
|
+
onDismiss();
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
return (
|
|
54
|
+
<ThemedModal
|
|
55
|
+
visible={visible}
|
|
56
|
+
contentWrapProps={contentWrapProps}
|
|
57
|
+
onDismiss={onModalDismiss}
|
|
58
|
+
dismissable={dismissable}
|
|
59
|
+
>
|
|
60
|
+
<AnimatedThemedView
|
|
61
|
+
alignSelf={'stretch'}
|
|
62
|
+
maxHeight={getActionSheetMaxHeight(expandable)}
|
|
63
|
+
overflow={'hidden'}
|
|
64
|
+
{...wrapViewProps}
|
|
65
|
+
animatedStyle={outerWrapAnimatedStyle}
|
|
66
|
+
>
|
|
67
|
+
<AnimatedThemedView animatedStyle={innerWrapAnimatedStyle}>
|
|
68
|
+
{children}
|
|
69
|
+
</AnimatedThemedView>
|
|
70
|
+
</AnimatedThemedView>
|
|
71
|
+
</ThemedModal>
|
|
72
|
+
);
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
export default ActionSheetWrap;
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { useLayoutEffect, useState, type FC } from 'react';
|
|
2
|
+
import { useAnimationSharedVal } from '../../../hooks/reanimated';
|
|
3
|
+
import type {
|
|
4
|
+
AlertContextVal,
|
|
5
|
+
AlertProps,
|
|
6
|
+
OverlayDismissAlertResult,
|
|
7
|
+
} from '../../../types/overlay';
|
|
8
|
+
import {
|
|
9
|
+
AlertContext,
|
|
10
|
+
overlayDismissResultDefaultText,
|
|
11
|
+
OverlayDismissResultType,
|
|
12
|
+
} from '../../../utils/overlay/const';
|
|
13
|
+
import AlertButtons from './AlertButtons';
|
|
14
|
+
import AlertContent from './AlertContent';
|
|
15
|
+
import AlertWrap from './AlertWrap';
|
|
16
|
+
|
|
17
|
+
const Alert: FC<AlertProps> = ({
|
|
18
|
+
customShowAnimation,
|
|
19
|
+
customHideAnimation,
|
|
20
|
+
wrapProps,
|
|
21
|
+
title,
|
|
22
|
+
titleTextProps,
|
|
23
|
+
description,
|
|
24
|
+
descriptionTextProps,
|
|
25
|
+
buttons,
|
|
26
|
+
buttonsWrapProps,
|
|
27
|
+
buttonProps,
|
|
28
|
+
onDismiss,
|
|
29
|
+
dismissable,
|
|
30
|
+
visible = true,
|
|
31
|
+
}) => {
|
|
32
|
+
const [alertVisible, setAlertVisible] = useState(visible);
|
|
33
|
+
const showSharedVal = useAnimationSharedVal();
|
|
34
|
+
useLayoutEffect(() => {
|
|
35
|
+
setAlertVisible(visible);
|
|
36
|
+
}, [visible]);
|
|
37
|
+
|
|
38
|
+
const handleDismiss = (result?: Partial<OverlayDismissAlertResult>) => {
|
|
39
|
+
const tempResult: OverlayDismissAlertResult = {
|
|
40
|
+
resultType: OverlayDismissResultType.Alert,
|
|
41
|
+
title,
|
|
42
|
+
description,
|
|
43
|
+
text: overlayDismissResultDefaultText,
|
|
44
|
+
};
|
|
45
|
+
onDismiss?.(result ? { ...tempResult, ...result } : tempResult);
|
|
46
|
+
setAlertVisible(false);
|
|
47
|
+
};
|
|
48
|
+
const alertContextVal: AlertContextVal = {
|
|
49
|
+
buttonProps,
|
|
50
|
+
onDismiss: (result) => {
|
|
51
|
+
if (customHideAnimation) {
|
|
52
|
+
customHideAnimation(showSharedVal, 0, () => {
|
|
53
|
+
handleDismiss(result);
|
|
54
|
+
});
|
|
55
|
+
} else {
|
|
56
|
+
showSharedVal.set(0);
|
|
57
|
+
handleDismiss(result);
|
|
58
|
+
}
|
|
59
|
+
},
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
return (
|
|
63
|
+
<AlertContext.Provider value={alertContextVal}>
|
|
64
|
+
<AlertWrap
|
|
65
|
+
customShowAnimation={customShowAnimation}
|
|
66
|
+
wrapProps={wrapProps}
|
|
67
|
+
title={title}
|
|
68
|
+
description={description}
|
|
69
|
+
buttons={buttons}
|
|
70
|
+
dismissable={dismissable}
|
|
71
|
+
visible={alertVisible}
|
|
72
|
+
showSharedVal={showSharedVal}
|
|
73
|
+
>
|
|
74
|
+
<AlertContent
|
|
75
|
+
title={title}
|
|
76
|
+
titleTextProps={titleTextProps}
|
|
77
|
+
description={description}
|
|
78
|
+
descriptionTextProps={descriptionTextProps}
|
|
79
|
+
/>
|
|
80
|
+
<AlertButtons buttons={buttons} buttonsWrapProps={buttonsWrapProps} />
|
|
81
|
+
</AlertWrap>
|
|
82
|
+
</AlertContext.Provider>
|
|
83
|
+
);
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
export default Alert;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { type FC } from 'react';
|
|
2
|
+
import type { ThemedButtonProps } from '../../../types/button';
|
|
3
|
+
import type { AlertButtonProps } from '../../../types/overlay';
|
|
4
|
+
import { AlertButtonType } from '../../../utils/overlay/const';
|
|
5
|
+
import { getAlertContext } from '../../../utils/overlay/func';
|
|
6
|
+
import { BorderSize } from '../../../utils/theme/const';
|
|
7
|
+
import ThemedButton from '../../button/ThemedButton';
|
|
8
|
+
|
|
9
|
+
const AlertButton: FC<AlertButtonProps> = ({
|
|
10
|
+
type = AlertButtonType.Primary,
|
|
11
|
+
text,
|
|
12
|
+
onPress,
|
|
13
|
+
props,
|
|
14
|
+
}) => {
|
|
15
|
+
const { buttonProps, onDismiss } = getAlertContext();
|
|
16
|
+
const themedButtonOnPress: ThemedButtonProps['onPress'] = (event) => {
|
|
17
|
+
onPress?.(event);
|
|
18
|
+
onDismiss?.({ type, text });
|
|
19
|
+
};
|
|
20
|
+
const isPrimary = type === AlertButtonType.Primary;
|
|
21
|
+
const isDestructive = type === AlertButtonType.Destructive;
|
|
22
|
+
const backgroundColor = isPrimary ? 'themePri' : 'background';
|
|
23
|
+
|
|
24
|
+
return (
|
|
25
|
+
<ThemedButton
|
|
26
|
+
onPress={themedButtonOnPress}
|
|
27
|
+
flex={1}
|
|
28
|
+
borderWidth={BorderSize.S}
|
|
29
|
+
borderColor={
|
|
30
|
+
type === AlertButtonType.Destructive ? 'err' : backgroundColor
|
|
31
|
+
}
|
|
32
|
+
backgroundColor={backgroundColor}
|
|
33
|
+
text={text}
|
|
34
|
+
textColor={isDestructive ? 'err' : isPrimary ? 'background' : 'themePri'}
|
|
35
|
+
{...buttonProps}
|
|
36
|
+
{...props}
|
|
37
|
+
/>
|
|
38
|
+
);
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
export default AlertButton;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { FC } from 'react';
|
|
2
|
+
import type { AlertButtonsProps } from '../../../types/overlay';
|
|
3
|
+
import ThemedView from '../../view/ThemedView';
|
|
4
|
+
import AlertButton from './AlertButton';
|
|
5
|
+
|
|
6
|
+
const AlertButtons: FC<AlertButtonsProps> = ({ buttons, buttonsWrapProps }) => {
|
|
7
|
+
const alertButtons: NonNullable<AlertButtonsProps['buttons']> = buttons ?? [
|
|
8
|
+
[{ text: 'OK' }],
|
|
9
|
+
];
|
|
10
|
+
|
|
11
|
+
return (
|
|
12
|
+
<ThemedView marginTop={'m'} gap={'s'} {...buttonsWrapProps}>
|
|
13
|
+
{alertButtons.map((row, rowIndex) => (
|
|
14
|
+
<ThemedView
|
|
15
|
+
key={`row_${row[0]?.text}_${rowIndex}`}
|
|
16
|
+
flexDirection={'row'}
|
|
17
|
+
gap={'s'}
|
|
18
|
+
>
|
|
19
|
+
{row.map(({ text, ...props }, buttonIndex) => (
|
|
20
|
+
<AlertButton
|
|
21
|
+
key={`button_${text}_${buttonIndex}`}
|
|
22
|
+
text={text}
|
|
23
|
+
{...props}
|
|
24
|
+
/>
|
|
25
|
+
))}
|
|
26
|
+
</ThemedView>
|
|
27
|
+
))}
|
|
28
|
+
</ThemedView>
|
|
29
|
+
);
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
export default AlertButtons;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import type { FC } from 'react';
|
|
2
|
+
import type { AlertProps } from '../../../types/overlay';
|
|
3
|
+
import ThemedText from '../../text/ThemedText';
|
|
4
|
+
|
|
5
|
+
const AlertContent: FC<
|
|
6
|
+
Pick<
|
|
7
|
+
AlertProps,
|
|
8
|
+
'title' | 'titleTextProps' | 'description' | 'descriptionTextProps'
|
|
9
|
+
>
|
|
10
|
+
> = ({
|
|
11
|
+
title,
|
|
12
|
+
titleTextProps: {
|
|
13
|
+
textVariant: titleTextVariant,
|
|
14
|
+
textFontSize: titleTextFontSize,
|
|
15
|
+
textFontWeight: titleTextFontWeight,
|
|
16
|
+
textColor: titleTextColor,
|
|
17
|
+
textStyle: titleTextStyle,
|
|
18
|
+
textProps: titleTextProps,
|
|
19
|
+
} = {},
|
|
20
|
+
description,
|
|
21
|
+
descriptionTextProps: {
|
|
22
|
+
textVariant: descriptionTextVariant,
|
|
23
|
+
textFontSize: descriptionTextFontSize,
|
|
24
|
+
textFontWeight: descriptionTextFontWeight,
|
|
25
|
+
textColor: descriptionTextColor,
|
|
26
|
+
textStyle: descriptionTextStyle,
|
|
27
|
+
textProps: descriptionTextProps,
|
|
28
|
+
} = {},
|
|
29
|
+
}) => {
|
|
30
|
+
return (
|
|
31
|
+
<>
|
|
32
|
+
<ThemedText
|
|
33
|
+
textAlign={'center'}
|
|
34
|
+
fontWeight={titleTextFontWeight ?? 'bold'}
|
|
35
|
+
variant={titleTextVariant}
|
|
36
|
+
fontSize={titleTextFontSize}
|
|
37
|
+
color={titleTextColor}
|
|
38
|
+
style={titleTextStyle}
|
|
39
|
+
{...titleTextProps}
|
|
40
|
+
>
|
|
41
|
+
{title}
|
|
42
|
+
</ThemedText>
|
|
43
|
+
{!!description && (
|
|
44
|
+
<ThemedText
|
|
45
|
+
textAlign={'center'}
|
|
46
|
+
variant={descriptionTextVariant ?? 'textS'}
|
|
47
|
+
fontSize={descriptionTextFontSize}
|
|
48
|
+
fontWeight={descriptionTextFontWeight}
|
|
49
|
+
color={descriptionTextColor}
|
|
50
|
+
style={descriptionTextStyle}
|
|
51
|
+
{...descriptionTextProps}
|
|
52
|
+
>
|
|
53
|
+
{description}
|
|
54
|
+
</ThemedText>
|
|
55
|
+
)}
|
|
56
|
+
</>
|
|
57
|
+
);
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
export default AlertContent;
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { useEffect, type FC } from 'react';
|
|
2
|
+
import type { ViewStyle } from 'react-native';
|
|
3
|
+
import { useAnimatedStyle, type SharedValue } from 'react-native-reanimated';
|
|
4
|
+
import type { AlertProps } from '../../../types/overlay';
|
|
5
|
+
import type { AnimationSharedValue } from '../../../types/reanimated';
|
|
6
|
+
import type { PropsWithRequiredChildren } from '../../../types/view';
|
|
7
|
+
import { overlayMaxWidthPercent } from '../../../utils/overlay/const';
|
|
8
|
+
import { getAlertContext } from '../../../utils/overlay/func';
|
|
9
|
+
import { updateSharedValWithSpring } from '../../../utils/reanimated/func';
|
|
10
|
+
import AnimatedThemedView from '../../view/AnimatedThemedView';
|
|
11
|
+
import ThemedModal from '../modal/ThemedModal';
|
|
12
|
+
|
|
13
|
+
const AlertWrap: FC<
|
|
14
|
+
PropsWithRequiredChildren<
|
|
15
|
+
Pick<
|
|
16
|
+
AlertProps,
|
|
17
|
+
| 'customShowAnimation'
|
|
18
|
+
| 'wrapProps'
|
|
19
|
+
| 'title'
|
|
20
|
+
| 'description'
|
|
21
|
+
| 'buttons'
|
|
22
|
+
| 'dismissable'
|
|
23
|
+
> & {
|
|
24
|
+
visible: boolean;
|
|
25
|
+
showSharedVal: AnimationSharedValue;
|
|
26
|
+
}
|
|
27
|
+
>
|
|
28
|
+
> = ({
|
|
29
|
+
customShowAnimation,
|
|
30
|
+
wrapProps,
|
|
31
|
+
title,
|
|
32
|
+
description,
|
|
33
|
+
buttons,
|
|
34
|
+
dismissable,
|
|
35
|
+
visible,
|
|
36
|
+
showSharedVal,
|
|
37
|
+
children,
|
|
38
|
+
}) => {
|
|
39
|
+
const animatedStyle = useAnimatedStyle<ViewStyle>(
|
|
40
|
+
() => ({
|
|
41
|
+
transform: [{ scale: showSharedVal.get() }],
|
|
42
|
+
}),
|
|
43
|
+
[showSharedVal]
|
|
44
|
+
);
|
|
45
|
+
useEffect(() => {
|
|
46
|
+
if (!visible) {
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
if (customShowAnimation) {
|
|
51
|
+
customShowAnimation(showSharedVal, 1);
|
|
52
|
+
} else {
|
|
53
|
+
updateSharedValWithSpring(showSharedVal as SharedValue<number>, 1, {
|
|
54
|
+
stiffness: 1800,
|
|
55
|
+
damping: 200,
|
|
56
|
+
mass: 20,
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
}, [
|
|
60
|
+
customShowAnimation,
|
|
61
|
+
title,
|
|
62
|
+
description,
|
|
63
|
+
buttons,
|
|
64
|
+
visible,
|
|
65
|
+
showSharedVal,
|
|
66
|
+
]);
|
|
67
|
+
|
|
68
|
+
const { onDismiss } = getAlertContext();
|
|
69
|
+
const modalOnDismiss = () => {
|
|
70
|
+
onDismiss?.();
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
return (
|
|
74
|
+
<ThemedModal
|
|
75
|
+
visible={visible}
|
|
76
|
+
onDismiss={modalOnDismiss}
|
|
77
|
+
dismissable={dismissable}
|
|
78
|
+
>
|
|
79
|
+
<AnimatedThemedView
|
|
80
|
+
width={overlayMaxWidthPercent}
|
|
81
|
+
padding={'l'}
|
|
82
|
+
gap={'m'}
|
|
83
|
+
backgroundColor={'background'}
|
|
84
|
+
animatedStyle={animatedStyle}
|
|
85
|
+
{...wrapProps}
|
|
86
|
+
>
|
|
87
|
+
{children}
|
|
88
|
+
</AnimatedThemedView>
|
|
89
|
+
</ThemedModal>
|
|
90
|
+
);
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
export default AlertWrap;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import type { FC } from 'react';
|
|
2
|
+
import type { ThemedLoadingModalProps } from '../../../types/overlay';
|
|
3
|
+
import { overlayMaxWidthPercent } from '../../../utils/overlay/const';
|
|
4
|
+
import ThemedLoading from '../../loading/ThemedLoading';
|
|
5
|
+
import ThemedText from '../../text/ThemedText';
|
|
6
|
+
import ThemedModal from './ThemedModal';
|
|
7
|
+
|
|
8
|
+
const ThemedLoadingModal: FC<ThemedLoadingModalProps> = ({
|
|
9
|
+
loadingSize,
|
|
10
|
+
loadingColor,
|
|
11
|
+
loadingProps,
|
|
12
|
+
text,
|
|
13
|
+
textVariant,
|
|
14
|
+
textFontSize,
|
|
15
|
+
textFontWeight,
|
|
16
|
+
textColor = 'textOverlay',
|
|
17
|
+
textStyle,
|
|
18
|
+
textProps,
|
|
19
|
+
...props
|
|
20
|
+
}) => {
|
|
21
|
+
return (
|
|
22
|
+
<ThemedModal {...props}>
|
|
23
|
+
<ThemedLoading
|
|
24
|
+
size={loadingSize}
|
|
25
|
+
color={loadingColor}
|
|
26
|
+
{...loadingProps}
|
|
27
|
+
/>
|
|
28
|
+
{!!text && (
|
|
29
|
+
<ThemedText
|
|
30
|
+
textAlign={'center'}
|
|
31
|
+
maxWidth={overlayMaxWidthPercent}
|
|
32
|
+
marginTop={'m'}
|
|
33
|
+
variant={textVariant}
|
|
34
|
+
fontSize={textFontSize}
|
|
35
|
+
fontWeight={textFontWeight}
|
|
36
|
+
color={textColor}
|
|
37
|
+
style={textStyle}
|
|
38
|
+
{...textProps}
|
|
39
|
+
>
|
|
40
|
+
{text}
|
|
41
|
+
</ThemedText>
|
|
42
|
+
)}
|
|
43
|
+
</ThemedModal>
|
|
44
|
+
);
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
export default ThemedLoadingModal;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import type { FC } from 'react';
|
|
2
|
+
import { Modal, StyleSheet } from 'react-native';
|
|
3
|
+
import type { ThemedModalProps } from '../../../types/overlay';
|
|
4
|
+
import ThemedPressable from '../../button/ThemedPressable';
|
|
5
|
+
import GestureProvider from '../../provider/GestureProvider';
|
|
6
|
+
import ThemedView from '../../view/ThemedView';
|
|
7
|
+
|
|
8
|
+
const ThemedModal: FC<ThemedModalProps> = ({
|
|
9
|
+
contentWrapProps,
|
|
10
|
+
onDismiss,
|
|
11
|
+
dismissable = true,
|
|
12
|
+
children,
|
|
13
|
+
...props
|
|
14
|
+
}) => {
|
|
15
|
+
return (
|
|
16
|
+
<Modal
|
|
17
|
+
animationType={'fade'}
|
|
18
|
+
transparent={true}
|
|
19
|
+
statusBarTranslucent={true}
|
|
20
|
+
{...props}
|
|
21
|
+
>
|
|
22
|
+
<GestureProvider>
|
|
23
|
+
<ThemedView
|
|
24
|
+
alignItems={'center'}
|
|
25
|
+
justifyContent={'center'}
|
|
26
|
+
backgroundColor={'backgroundOverlay'}
|
|
27
|
+
style={StyleSheet.absoluteFill}
|
|
28
|
+
{...contentWrapProps}
|
|
29
|
+
>
|
|
30
|
+
<ThemedPressable
|
|
31
|
+
onPress={onDismiss ?? null}
|
|
32
|
+
disabled={!dismissable}
|
|
33
|
+
style={StyleSheet.absoluteFill}
|
|
34
|
+
/>
|
|
35
|
+
{children}
|
|
36
|
+
</ThemedView>
|
|
37
|
+
</GestureProvider>
|
|
38
|
+
</Modal>
|
|
39
|
+
);
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
export default ThemedModal;
|