@0610studio/zs-ui 0.0.1
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/.eslintrc.js +5 -0
- package/README.md +3 -0
- package/android/.gradle/8.9/checksums/checksums.lock +0 -0
- package/android/.gradle/8.9/dependencies-accessors/gc.properties +0 -0
- package/android/.gradle/8.9/fileChanges/last-build.bin +0 -0
- package/android/.gradle/8.9/fileHashes/fileHashes.lock +0 -0
- package/android/.gradle/8.9/gc.properties +0 -0
- package/android/.gradle/buildOutputCleanup/buildOutputCleanup.lock +0 -0
- package/android/.gradle/buildOutputCleanup/cache.properties +2 -0
- package/android/.gradle/vcs-1/gc.properties +0 -0
- package/android/build.gradle +43 -0
- package/android/src/main/AndroidManifest.xml +2 -0
- package/android/src/main/java/kr/co/studio0610/zsui/ZsUiModule.kt +47 -0
- package/android/src/main/java/kr/co/studio0610/zsui/ZsUiView.kt +7 -0
- package/build/ZsUi.types.d.ts +7 -0
- package/build/ZsUi.types.d.ts.map +1 -0
- package/build/ZsUi.types.js +2 -0
- package/build/ZsUi.types.js.map +1 -0
- package/build/ZsUiModule.d.ts +3 -0
- package/build/ZsUiModule.d.ts.map +1 -0
- package/build/ZsUiModule.js +5 -0
- package/build/ZsUiModule.js.map +1 -0
- package/build/ZsUiModule.web.d.ts +7 -0
- package/build/ZsUiModule.web.d.ts.map +1 -0
- package/build/ZsUiModule.web.js +12 -0
- package/build/ZsUiModule.web.js.map +1 -0
- package/build/ZsUiView.d.ts +4 -0
- package/build/ZsUiView.d.ts.map +1 -0
- package/build/ZsUiView.js +7 -0
- package/build/ZsUiView.js.map +1 -0
- package/build/ZsUiView.web.d.ts +4 -0
- package/build/ZsUiView.web.d.ts.map +1 -0
- package/build/ZsUiView.web.js +7 -0
- package/build/ZsUiView.web.js.map +1 -0
- package/build/assets/SvgCheck.d.ts +7 -0
- package/build/assets/SvgCheck.d.ts.map +1 -0
- package/build/assets/SvgCheck.js +8 -0
- package/build/assets/SvgCheck.js.map +1 -0
- package/build/assets/SvgX.d.ts +6 -0
- package/build/assets/SvgX.d.ts.map +1 -0
- package/build/assets/SvgX.js +14 -0
- package/build/assets/SvgX.js.map +1 -0
- package/build/index.d.ts +5 -0
- package/build/index.d.ts.map +1 -0
- package/build/index.js +10 -0
- package/build/index.js.map +1 -0
- package/build/model/types.d.ts +84 -0
- package/build/model/types.d.ts.map +1 -0
- package/build/model/types.js +11 -0
- package/build/model/types.js.map +1 -0
- package/build/model/useNotify.d.ts +5 -0
- package/build/model/useNotify.d.ts.map +1 -0
- package/build/model/useNotify.js +11 -0
- package/build/model/useNotify.js.map +1 -0
- package/build/model/useNotifyProvider.d.ts +3 -0
- package/build/model/useNotifyProvider.d.ts.map +1 -0
- package/build/model/useNotifyProvider.js +165 -0
- package/build/model/useNotifyProvider.js.map +1 -0
- package/build/model/useThemeProvider.d.ts +19 -0
- package/build/model/useThemeProvider.d.ts.map +1 -0
- package/build/model/useThemeProvider.js +73 -0
- package/build/model/useThemeProvider.js.map +1 -0
- package/build/model/utils.d.ts +12 -0
- package/build/model/utils.d.ts.map +1 -0
- package/build/model/utils.js +26 -0
- package/build/model/utils.js.map +1 -0
- package/build/notify/AlertNotify/index.d.ts +5 -0
- package/build/notify/AlertNotify/index.d.ts.map +1 -0
- package/build/notify/AlertNotify/index.js +109 -0
- package/build/notify/AlertNotify/index.js.map +1 -0
- package/build/notify/BottomSheetNotify/index.d.ts +19 -0
- package/build/notify/BottomSheetNotify/index.d.ts.map +1 -0
- package/build/notify/BottomSheetNotify/index.js +90 -0
- package/build/notify/BottomSheetNotify/index.js.map +1 -0
- package/build/notify/BottomSheetNotify/model/useBottomSheetNotify.d.ts +43 -0
- package/build/notify/BottomSheetNotify/model/useBottomSheetNotify.d.ts.map +1 -0
- package/build/notify/BottomSheetNotify/model/useBottomSheetNotify.js +222 -0
- package/build/notify/BottomSheetNotify/model/useBottomSheetNotify.js.map +1 -0
- package/build/notify/BottomSheetNotify/types/index.d.ts +4 -0
- package/build/notify/BottomSheetNotify/types/index.d.ts.map +1 -0
- package/build/notify/BottomSheetNotify/types/index.js +2 -0
- package/build/notify/BottomSheetNotify/types/index.js.map +1 -0
- package/build/notify/BottomSheetNotify/ui/BSTextInput/index.d.ts +4 -0
- package/build/notify/BottomSheetNotify/ui/BSTextInput/index.d.ts.map +1 -0
- package/build/notify/BottomSheetNotify/ui/BSTextInput/index.js +14 -0
- package/build/notify/BottomSheetNotify/ui/BSTextInput/index.js.map +1 -0
- package/build/notify/BottomSheetNotify/ui/ContentsComponent/index.d.ts +19 -0
- package/build/notify/BottomSheetNotify/ui/ContentsComponent/index.d.ts.map +1 -0
- package/build/notify/BottomSheetNotify/ui/ContentsComponent/index.js +33 -0
- package/build/notify/BottomSheetNotify/ui/ContentsComponent/index.js.map +1 -0
- package/build/notify/LoadingNotify/index.d.ts +6 -0
- package/build/notify/LoadingNotify/index.d.ts.map +1 -0
- package/build/notify/LoadingNotify/index.js +28 -0
- package/build/notify/LoadingNotify/index.js.map +1 -0
- package/build/notify/PopOver/PopOverButton.d.ts +11 -0
- package/build/notify/PopOver/PopOverButton.d.ts.map +1 -0
- package/build/notify/PopOver/PopOverButton.js +31 -0
- package/build/notify/PopOver/PopOverButton.js.map +1 -0
- package/build/notify/PopOver/PopOverMenu.d.ts +4 -0
- package/build/notify/PopOver/PopOverMenu.d.ts.map +1 -0
- package/build/notify/PopOver/PopOverMenu.js +69 -0
- package/build/notify/PopOver/PopOverMenu.js.map +1 -0
- package/build/notify/SnackbarNotify/index.d.ts +7 -0
- package/build/notify/SnackbarNotify/index.d.ts.map +1 -0
- package/build/notify/SnackbarNotify/index.js +24 -0
- package/build/notify/SnackbarNotify/index.js.map +1 -0
- package/build/notify/SnackbarNotify/ui/SnackbarItem.d.ts +9 -0
- package/build/notify/SnackbarNotify/ui/SnackbarItem.d.ts.map +1 -0
- package/build/notify/SnackbarNotify/ui/SnackbarItem.js +72 -0
- package/build/notify/SnackbarNotify/ui/SnackbarItem.js.map +1 -0
- package/build/notify/index.d.ts +11 -0
- package/build/notify/index.d.ts.map +1 -0
- package/build/notify/index.js +11 -0
- package/build/notify/index.js.map +1 -0
- package/build/notify/ui/ModalBackground.d.ts +9 -0
- package/build/notify/ui/ModalBackground.d.ts.map +1 -0
- package/build/notify/ui/ModalBackground.js +27 -0
- package/build/notify/ui/ModalBackground.js.map +1 -0
- package/build/theme/index.d.ts +4 -0
- package/build/theme/index.d.ts.map +1 -0
- package/build/theme/index.js +4 -0
- package/build/theme/index.js.map +1 -0
- package/build/theme/palette.d.ts +62 -0
- package/build/theme/palette.d.ts.map +1 -0
- package/build/theme/palette.js +353 -0
- package/build/theme/palette.js.map +1 -0
- package/build/theme/types.d.ts +101 -0
- package/build/theme/types.d.ts.map +1 -0
- package/build/theme/types.js +5 -0
- package/build/theme/types.js.map +1 -0
- package/build/theme/typography.d.ts +5 -0
- package/build/theme/typography.d.ts.map +1 -0
- package/build/theme/typography.js +198 -0
- package/build/theme/typography.js.map +1 -0
- package/build/ui/ThrottleButton/index.d.ts +15 -0
- package/build/ui/ThrottleButton/index.d.ts.map +1 -0
- package/build/ui/ThrottleButton/index.js +74 -0
- package/build/ui/ThrottleButton/index.js.map +1 -0
- package/build/ui/ZSBottomButton/index.d.ts +16 -0
- package/build/ui/ZSBottomButton/index.d.ts.map +1 -0
- package/build/ui/ZSBottomButton/index.js +89 -0
- package/build/ui/ZSBottomButton/index.js.map +1 -0
- package/build/ui/ZSContainer/index.d.ts +19 -0
- package/build/ui/ZSContainer/index.d.ts.map +1 -0
- package/build/ui/ZSContainer/index.js +37 -0
- package/build/ui/ZSContainer/index.js.map +1 -0
- package/build/ui/ZSPressable/index.d.ts +17 -0
- package/build/ui/ZSPressable/index.d.ts.map +1 -0
- package/build/ui/ZSPressable/index.js +35 -0
- package/build/ui/ZSPressable/index.js.map +1 -0
- package/build/ui/ZSRadioGroup/index.d.ts +18 -0
- package/build/ui/ZSRadioGroup/index.d.ts.map +1 -0
- package/build/ui/ZSRadioGroup/index.js +82 -0
- package/build/ui/ZSRadioGroup/index.js.map +1 -0
- package/build/ui/ZSText/index.d.ts +11 -0
- package/build/ui/ZSText/index.d.ts.map +1 -0
- package/build/ui/ZSText/index.js +10 -0
- package/build/ui/ZSText/index.js.map +1 -0
- package/build/ui/ZSTextField/index.d.ts +31 -0
- package/build/ui/ZSTextField/index.d.ts.map +1 -0
- package/build/ui/ZSTextField/index.js +102 -0
- package/build/ui/ZSTextField/index.js.map +1 -0
- package/build/ui/ZSTextField/ui/ButtonClose.d.ts +6 -0
- package/build/ui/ZSTextField/ui/ButtonClose.d.ts.map +1 -0
- package/build/ui/ZSTextField/ui/ButtonClose.js +9 -0
- package/build/ui/ZSTextField/ui/ButtonClose.js.map +1 -0
- package/build/ui/ZSTextField/ui/ErrorComponent.d.ts +7 -0
- package/build/ui/ZSTextField/ui/ErrorComponent.d.ts.map +1 -0
- package/build/ui/ZSTextField/ui/ErrorComponent.js +16 -0
- package/build/ui/ZSTextField/ui/ErrorComponent.js.map +1 -0
- package/build/ui/ZSView/index.d.ts +8 -0
- package/build/ui/ZSView/index.d.ts.map +1 -0
- package/build/ui/ZSView/index.js +17 -0
- package/build/ui/ZSView/index.js.map +1 -0
- package/build/ui/atoms/AnimatedWrapper.d.ts +12 -0
- package/build/ui/atoms/AnimatedWrapper.d.ts.map +1 -0
- package/build/ui/atoms/AnimatedWrapper.js +61 -0
- package/build/ui/atoms/AnimatedWrapper.js.map +1 -0
- package/build/ui/atoms/ScrollViewAtom.d.ts +5 -0
- package/build/ui/atoms/ScrollViewAtom.d.ts.map +1 -0
- package/build/ui/atoms/ScrollViewAtom.js +10 -0
- package/build/ui/atoms/ScrollViewAtom.js.map +1 -0
- package/build/ui/atoms/TextAtom.d.ts +6 -0
- package/build/ui/atoms/TextAtom.d.ts.map +1 -0
- package/build/ui/atoms/TextAtom.js +9 -0
- package/build/ui/atoms/TextAtom.js.map +1 -0
- package/build/ui/atoms/ViewAtom.d.ts +6 -0
- package/build/ui/atoms/ViewAtom.d.ts.map +1 -0
- package/build/ui/atoms/ViewAtom.js +9 -0
- package/build/ui/atoms/ViewAtom.js.map +1 -0
- package/build/ui/index.d.ts +14 -0
- package/build/ui/index.d.ts.map +1 -0
- package/build/ui/index.js +14 -0
- package/build/ui/index.js.map +1 -0
- package/build/ui/types.d.ts +14 -0
- package/build/ui/types.d.ts.map +1 -0
- package/build/ui/types.js +2 -0
- package/build/ui/types.js.map +1 -0
- package/expo-module.config.json +9 -0
- package/ios/ZsUi.podspec +27 -0
- package/ios/ZsUiModule.swift +44 -0
- package/ios/ZsUiView.swift +7 -0
- package/package.json +54 -0
- package/src/ZsUi.types.ts +7 -0
- package/src/ZsUiModule.ts +5 -0
- package/src/ZsUiModule.web.ts +13 -0
- package/src/ZsUiView.tsx +11 -0
- package/src/ZsUiView.web.tsx +11 -0
- package/src/assets/SvgCheck.tsx +16 -0
- package/src/assets/SvgX.tsx +22 -0
- package/src/index.ts +52 -0
- package/src/model/types.ts +102 -0
- package/src/model/useNotify.ts +14 -0
- package/src/model/useNotifyProvider.tsx +251 -0
- package/src/model/useThemeProvider.tsx +99 -0
- package/src/model/utils.ts +31 -0
- package/src/notify/AlertNotify/index.tsx +177 -0
- package/src/notify/BottomSheetNotify/index.tsx +177 -0
- package/src/notify/BottomSheetNotify/model/useBottomSheetNotify.tsx +270 -0
- package/src/notify/BottomSheetNotify/types/index.ts +3 -0
- package/src/notify/BottomSheetNotify/ui/BSTextInput/index.tsx +28 -0
- package/src/notify/BottomSheetNotify/ui/ContentsComponent/index.tsx +76 -0
- package/src/notify/LoadingNotify/index.tsx +46 -0
- package/src/notify/PopOver/PopOverButton.tsx +56 -0
- package/src/notify/PopOver/PopOverMenu.tsx +95 -0
- package/src/notify/SnackbarNotify/index.tsx +43 -0
- package/src/notify/SnackbarNotify/ui/SnackbarItem.tsx +103 -0
- package/src/notify/index.ts +21 -0
- package/src/notify/ui/ModalBackground.tsx +46 -0
- package/src/theme/index.ts +3 -0
- package/src/theme/palette.ts +374 -0
- package/src/theme/types.ts +150 -0
- package/src/theme/typography.ts +199 -0
- package/src/ui/ThrottleButton/index.tsx +119 -0
- package/src/ui/ZSBottomButton/index.tsx +151 -0
- package/src/ui/ZSContainer/index.tsx +92 -0
- package/src/ui/ZSPressable/index.tsx +82 -0
- package/src/ui/ZSRadioGroup/index.tsx +141 -0
- package/src/ui/ZSText/index.tsx +22 -0
- package/src/ui/ZSTextField/index.tsx +200 -0
- package/src/ui/ZSTextField/ui/ButtonClose.tsx +20 -0
- package/src/ui/ZSTextField/ui/ErrorComponent.tsx +25 -0
- package/src/ui/ZSView/index.tsx +30 -0
- package/src/ui/atoms/AnimatedWrapper.tsx +89 -0
- package/src/ui/atoms/ScrollViewAtom.tsx +17 -0
- package/src/ui/atoms/TextAtom.tsx +15 -0
- package/src/ui/atoms/ViewAtom.tsx +15 -0
- package/src/ui/index.ts +27 -0
- package/src/ui/types.ts +12 -0
- package/tsconfig.json +9 -0
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import React, { useCallback } from "react";
|
|
2
|
+
import { FlexAlignType, Pressable, ViewProps } from "react-native";
|
|
3
|
+
import Animated, { interpolate, useAnimatedStyle, useSharedValue, withTiming, runOnJS } from "react-native-reanimated";
|
|
4
|
+
import AnimatedWrapper from "../atoms/AnimatedWrapper";
|
|
5
|
+
import type { ShadowLevel } from "../types";
|
|
6
|
+
|
|
7
|
+
const DEFAULT_DURATION = { duration: 100 };
|
|
8
|
+
|
|
9
|
+
interface ZSPressableProps extends ViewProps {
|
|
10
|
+
onPress: (value?: any) => void;
|
|
11
|
+
onLongPress?: (value?: any) => void;
|
|
12
|
+
pressedBackgroundColor?: string;
|
|
13
|
+
pressedBackgroundBorderRadius?: number;
|
|
14
|
+
flex?: number;
|
|
15
|
+
minWidth?: number;
|
|
16
|
+
isAnimation?: boolean;
|
|
17
|
+
elevationLevel?: ShadowLevel;
|
|
18
|
+
fullWidth?: boolean;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
function ZSPressable({
|
|
22
|
+
onPress,
|
|
23
|
+
onLongPress,
|
|
24
|
+
isAnimation = true,
|
|
25
|
+
pressedBackgroundColor = 'rgba(180, 180, 180, 0.1)',
|
|
26
|
+
pressedBackgroundBorderRadius = 16,
|
|
27
|
+
flex,
|
|
28
|
+
minWidth,
|
|
29
|
+
elevationLevel = 0,
|
|
30
|
+
fullWidth = false,
|
|
31
|
+
...props
|
|
32
|
+
}: ZSPressableProps) {
|
|
33
|
+
const isButtonPress = useSharedValue(0);
|
|
34
|
+
|
|
35
|
+
const boxAnimation = useAnimatedStyle(() => {
|
|
36
|
+
const scale = interpolate(
|
|
37
|
+
isButtonPress.value,
|
|
38
|
+
[0, 1],
|
|
39
|
+
[1, 0.96],
|
|
40
|
+
'clamp'
|
|
41
|
+
);
|
|
42
|
+
return {
|
|
43
|
+
transform: [{ scale: withTiming(scale, DEFAULT_DURATION) }],
|
|
44
|
+
};
|
|
45
|
+
}, []);
|
|
46
|
+
|
|
47
|
+
const handlePressStyle = useCallback(
|
|
48
|
+
(pressed: boolean) => {
|
|
49
|
+
runOnJS(() => {
|
|
50
|
+
isButtonPress.value = pressed ? 1 : 0;
|
|
51
|
+
})();
|
|
52
|
+
return {
|
|
53
|
+
backgroundColor: pressed ? pressedBackgroundColor : 'transparent',
|
|
54
|
+
borderRadius: pressedBackgroundBorderRadius,
|
|
55
|
+
flex: fullWidth ? 1 : flex,
|
|
56
|
+
minWidth: minWidth,
|
|
57
|
+
alignSelf: fullWidth ? 'stretch' : 'flex-start' as FlexAlignType,
|
|
58
|
+
};
|
|
59
|
+
},
|
|
60
|
+
[pressedBackgroundColor, pressedBackgroundBorderRadius, flex, minWidth, fullWidth]
|
|
61
|
+
);
|
|
62
|
+
|
|
63
|
+
return (
|
|
64
|
+
<Pressable
|
|
65
|
+
onPress={onPress}
|
|
66
|
+
onLongPress={onLongPress}
|
|
67
|
+
style={({ pressed }) => handlePressStyle(pressed)}
|
|
68
|
+
>
|
|
69
|
+
<Animated.View style={boxAnimation}>
|
|
70
|
+
<AnimatedWrapper
|
|
71
|
+
isAnimation={isAnimation}
|
|
72
|
+
elevationLevel={elevationLevel}
|
|
73
|
+
style={props.style}
|
|
74
|
+
>
|
|
75
|
+
{props.children}
|
|
76
|
+
</AnimatedWrapper>
|
|
77
|
+
</Animated.View>
|
|
78
|
+
</Pressable>
|
|
79
|
+
);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
export default ZSPressable;
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
import React, { useCallback, memo } from 'react';
|
|
2
|
+
import { ViewProps } from 'react-native';
|
|
3
|
+
import { RadioOption } from '../types';
|
|
4
|
+
import ViewAtom from '../atoms/ViewAtom';
|
|
5
|
+
import ZSText, { ZSTextProps } from '../ZSText';
|
|
6
|
+
import ZSPressable from '../ZSPressable';
|
|
7
|
+
import { useTheme } from '../../model/useThemeProvider';
|
|
8
|
+
import { SvgCheck } from '../../assets/SvgCheck';
|
|
9
|
+
|
|
10
|
+
function ZSRadioGroup({
|
|
11
|
+
options,
|
|
12
|
+
value,
|
|
13
|
+
onSelect,
|
|
14
|
+
containerStyle,
|
|
15
|
+
valueStyle,
|
|
16
|
+
minWidth,
|
|
17
|
+
disabled = false,
|
|
18
|
+
fullWidth = false,
|
|
19
|
+
selectStyle,
|
|
20
|
+
}: {
|
|
21
|
+
options: RadioOption[];
|
|
22
|
+
value?: RadioOption;
|
|
23
|
+
onSelect: (value: RadioOption) => void;
|
|
24
|
+
containerStyle?: ViewProps;
|
|
25
|
+
valueStyle?: ZSTextProps;
|
|
26
|
+
selectStyle?: ZSTextProps;
|
|
27
|
+
minWidth?: number;
|
|
28
|
+
disabled?: boolean;
|
|
29
|
+
fullWidth?: boolean;
|
|
30
|
+
}) {
|
|
31
|
+
const { palette } = useTheme();
|
|
32
|
+
|
|
33
|
+
const handleSelect = useCallback(
|
|
34
|
+
(option: RadioOption) => {
|
|
35
|
+
if (!disabled) {
|
|
36
|
+
onSelect(option);
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
[disabled, onSelect]
|
|
40
|
+
);
|
|
41
|
+
|
|
42
|
+
return (
|
|
43
|
+
<ViewAtom
|
|
44
|
+
style={{
|
|
45
|
+
flexDirection: fullWidth ? 'column' : 'row',
|
|
46
|
+
gap: 10,
|
|
47
|
+
flexWrap: fullWidth ? 'nowrap' : 'wrap',
|
|
48
|
+
width: '100%',
|
|
49
|
+
}}
|
|
50
|
+
{...containerStyle}
|
|
51
|
+
>
|
|
52
|
+
{options.map((option) => {
|
|
53
|
+
const isSelected = value?.index === option.index;
|
|
54
|
+
const setColor = isSelected ? palette.primary.light : palette.background.neutral;
|
|
55
|
+
|
|
56
|
+
return (
|
|
57
|
+
<ZSPressable
|
|
58
|
+
key={option.index}
|
|
59
|
+
onPress={() => handleSelect(option)}
|
|
60
|
+
pressedBackgroundColor="transparent"
|
|
61
|
+
flex={!minWidth ? 1 : undefined}
|
|
62
|
+
minWidth={minWidth}
|
|
63
|
+
fullWidth
|
|
64
|
+
>
|
|
65
|
+
<ViewAtom
|
|
66
|
+
style={{
|
|
67
|
+
flexDirection: 'row',
|
|
68
|
+
alignItems: 'center',
|
|
69
|
+
paddingVertical: 12,
|
|
70
|
+
borderWidth: 1,
|
|
71
|
+
paddingLeft: 10,
|
|
72
|
+
paddingRight: 15,
|
|
73
|
+
borderRadius: 26,
|
|
74
|
+
borderColor: setColor,
|
|
75
|
+
backgroundColor: isSelected ? palette.background.layer1 : 'transparent',
|
|
76
|
+
flex: 1,
|
|
77
|
+
}}
|
|
78
|
+
>
|
|
79
|
+
{/* fullWidth가 false일 때 동그라미 체크박스 표시 */}
|
|
80
|
+
{!fullWidth && (
|
|
81
|
+
<ViewAtom
|
|
82
|
+
style={{
|
|
83
|
+
width: 20,
|
|
84
|
+
height: 20,
|
|
85
|
+
borderWidth: 1,
|
|
86
|
+
borderRadius: 10,
|
|
87
|
+
borderColor: setColor,
|
|
88
|
+
justifyContent: 'center',
|
|
89
|
+
alignItems: 'center',
|
|
90
|
+
}}
|
|
91
|
+
>
|
|
92
|
+
<ViewAtom
|
|
93
|
+
style={{
|
|
94
|
+
width: 12,
|
|
95
|
+
height: 12,
|
|
96
|
+
borderRadius: 6,
|
|
97
|
+
backgroundColor: setColor,
|
|
98
|
+
}}
|
|
99
|
+
/>
|
|
100
|
+
</ViewAtom>
|
|
101
|
+
)}
|
|
102
|
+
{/* 옵션 텍스트 표시 */}
|
|
103
|
+
<ZSText style={{ marginLeft: 10 }} {...valueStyle}>
|
|
104
|
+
{option.value}
|
|
105
|
+
</ZSText>
|
|
106
|
+
|
|
107
|
+
{/* fullWidth가 true일 때 우측에 선택 버튼 표시 */}
|
|
108
|
+
{fullWidth && (
|
|
109
|
+
<ViewAtom style={{ flex: 1, flexDirection: 'row', justifyContent: 'flex-end' }}>
|
|
110
|
+
<ViewAtom
|
|
111
|
+
style={{
|
|
112
|
+
backgroundColor: isSelected
|
|
113
|
+
? palette.primary.main
|
|
114
|
+
: palette.background.layer2,
|
|
115
|
+
paddingHorizontal: 10,
|
|
116
|
+
borderRadius: 50,
|
|
117
|
+
minWidth: 42,
|
|
118
|
+
minHeight: 24,
|
|
119
|
+
justifyContent: 'center',
|
|
120
|
+
alignItems: 'center',
|
|
121
|
+
}}
|
|
122
|
+
>
|
|
123
|
+
{isSelected ? (
|
|
124
|
+
<SvgCheck size={18} />
|
|
125
|
+
) : (
|
|
126
|
+
<ZSText typo="body.5" {...selectStyle}>
|
|
127
|
+
선택
|
|
128
|
+
</ZSText>
|
|
129
|
+
)}
|
|
130
|
+
</ViewAtom>
|
|
131
|
+
</ViewAtom>
|
|
132
|
+
)}
|
|
133
|
+
</ViewAtom>
|
|
134
|
+
</ZSPressable>
|
|
135
|
+
);
|
|
136
|
+
})}
|
|
137
|
+
</ViewAtom>
|
|
138
|
+
);
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
export default memo(ZSRadioGroup);
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import React, { memo } from 'react';
|
|
2
|
+
import { TextProps } from "react-native/types";
|
|
3
|
+
import { useTheme } from "../../model/useThemeProvider";
|
|
4
|
+
import { TypoOptions, TypoStyle, TextColorOptions, TypoSubStyle } from "../../theme/types";
|
|
5
|
+
import TextAtom from "../atoms/TextAtom"
|
|
6
|
+
|
|
7
|
+
export interface ZSTextProps extends TextProps {
|
|
8
|
+
typo?: TypoOptions;
|
|
9
|
+
color?: TextColorOptions;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
function ZSText({
|
|
13
|
+
typo = 'body.2',
|
|
14
|
+
color = 'primary',
|
|
15
|
+
...props
|
|
16
|
+
}: ZSTextProps) {
|
|
17
|
+
const { palette, typography } = useTheme();
|
|
18
|
+
const [s01, s02] = typo.split('.') as [TypoStyle, TypoSubStyle];
|
|
19
|
+
return <TextAtom {...props} style={[typography[s01][s02], { color: palette.text[color] }, props.style]}>{props.children}</TextAtom>
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export default memo(ZSText);
|
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
import React, { useMemo, useCallback, useState, useEffect } from 'react';
|
|
2
|
+
import { LayoutChangeEvent, StyleProp, TextInput, TextInputProps, TextStyle, ViewStyle } from 'react-native';
|
|
3
|
+
import Animated, { interpolate, useAnimatedStyle, useSharedValue, withTiming } from 'react-native-reanimated';
|
|
4
|
+
import ButtonClose from './ui/ButtonClose';
|
|
5
|
+
import ErrorComponent from './ui/ErrorComponent';
|
|
6
|
+
import { TypoOptions, TypoStyle, TypoSubStyle } from '../../theme';
|
|
7
|
+
import { extractStyle } from '../../model/utils';
|
|
8
|
+
import { useTheme } from '../../model/useThemeProvider';
|
|
9
|
+
import ViewAtom from '../atoms/ViewAtom';
|
|
10
|
+
|
|
11
|
+
export type BoxStyle = 'outline' | 'underline' | 'inbox';
|
|
12
|
+
|
|
13
|
+
interface TextFieldProps {
|
|
14
|
+
typo?: TypoOptions;
|
|
15
|
+
status?: 'default' | 'error';
|
|
16
|
+
value: string;
|
|
17
|
+
onChangeText?: (text: string) => void;
|
|
18
|
+
inputBgColor?: string;
|
|
19
|
+
labelBgColor?: string;
|
|
20
|
+
label?: string;
|
|
21
|
+
labelColor?: string;
|
|
22
|
+
placeHolderColor?: string;
|
|
23
|
+
fontSize?: number;
|
|
24
|
+
borderColor?: string;
|
|
25
|
+
borderRadius?: number;
|
|
26
|
+
focusColor?: string;
|
|
27
|
+
errorColor?: string;
|
|
28
|
+
paddingHorizontal?: number;
|
|
29
|
+
borderWidth?: number;
|
|
30
|
+
errorMessage?: string;
|
|
31
|
+
textInputProps?: TextInputProps;
|
|
32
|
+
boxStyle?: BoxStyle;
|
|
33
|
+
innerBoxStyle?: 'top' | 'middle' | 'bottom';
|
|
34
|
+
disabled?: boolean;
|
|
35
|
+
allowFontScaling?: boolean;
|
|
36
|
+
isTextArea?: boolean;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
function ZSTextField({
|
|
40
|
+
typo = 'body.2',
|
|
41
|
+
status = 'default',
|
|
42
|
+
value,
|
|
43
|
+
onChangeText,
|
|
44
|
+
label = 'Placeholder',
|
|
45
|
+
labelColor = '#757575',
|
|
46
|
+
placeHolderColor = '#B1B1B1',
|
|
47
|
+
inputBgColor = 'white',
|
|
48
|
+
labelBgColor = 'white',
|
|
49
|
+
borderWidth = 1.2,
|
|
50
|
+
borderColor = '#E7EDF0',
|
|
51
|
+
focusColor = '#007AFF',
|
|
52
|
+
errorColor = '#FF3B30',
|
|
53
|
+
borderRadius = 14,
|
|
54
|
+
paddingHorizontal = 15,
|
|
55
|
+
errorMessage,
|
|
56
|
+
textInputProps,
|
|
57
|
+
boxStyle = 'outline',
|
|
58
|
+
innerBoxStyle,
|
|
59
|
+
disabled = false,
|
|
60
|
+
allowFontScaling = true,
|
|
61
|
+
isTextArea = false,
|
|
62
|
+
}: TextFieldProps): JSX.Element {
|
|
63
|
+
const { typography, palette } = useTheme();
|
|
64
|
+
const [primaryStyle, subStyle] = typo.split('.') as [TypoStyle, TypoSubStyle];
|
|
65
|
+
|
|
66
|
+
// 폰트 크기 및 패밀리 추출
|
|
67
|
+
const fontSize = useMemo(() => extractStyle(typography[primaryStyle][subStyle], 'fontSize') as number || 17, [typography, primaryStyle, subStyle]);
|
|
68
|
+
const fontFamily = useMemo(() => extractStyle(typography[primaryStyle][subStyle], 'fontFamily') as string || '', [typography, primaryStyle, subStyle]);
|
|
69
|
+
|
|
70
|
+
// 컴포넌트 상태 관리
|
|
71
|
+
const [isFocused, setIsFocused] = useState<boolean>(false);
|
|
72
|
+
const labelAnimationValue = useSharedValue(0);
|
|
73
|
+
const boxHeightValue = useSharedValue(0);
|
|
74
|
+
|
|
75
|
+
// 포커스 및 값 변경 시 라벨 애니메이션 트리거
|
|
76
|
+
useEffect(() => {
|
|
77
|
+
const shouldAnimate = value !== '' || isFocused;
|
|
78
|
+
labelAnimationValue.value = withTiming(shouldAnimate ? 1 : 0, { duration: 50 });
|
|
79
|
+
}, [value, isFocused, labelAnimationValue]);
|
|
80
|
+
|
|
81
|
+
// 라벨 애니메이션 스타일
|
|
82
|
+
const animatedLabelStyle = useAnimatedStyle(() => {
|
|
83
|
+
const labelFontSize = interpolate(
|
|
84
|
+
labelAnimationValue.value,
|
|
85
|
+
[0, 1],
|
|
86
|
+
[fontSize + (boxStyle === 'inbox' ? 5 : 0), boxStyle === 'inbox' ? 10 : 12],
|
|
87
|
+
'clamp'
|
|
88
|
+
);
|
|
89
|
+
|
|
90
|
+
const labelTop = interpolate(
|
|
91
|
+
labelAnimationValue.value,
|
|
92
|
+
[0, 1],
|
|
93
|
+
[
|
|
94
|
+
isTextArea ? 12 : 0,
|
|
95
|
+
isTextArea ? -12 : -(boxHeightValue.value / 2) - 1 + (boxStyle === 'inbox' ? 18 : 0),
|
|
96
|
+
],
|
|
97
|
+
'clamp'
|
|
98
|
+
);
|
|
99
|
+
|
|
100
|
+
return {
|
|
101
|
+
top: labelTop,
|
|
102
|
+
fontSize: labelFontSize,
|
|
103
|
+
};
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
// 레이아웃 핸들러
|
|
107
|
+
const handleLayout = useCallback((event: LayoutChangeEvent) => {
|
|
108
|
+
const { height } = event.nativeEvent.layout;
|
|
109
|
+
if (boxHeightValue.value !== height) boxHeightValue.value = height;
|
|
110
|
+
}, [boxHeightValue]);
|
|
111
|
+
|
|
112
|
+
// 포커스 및 블러 핸들러
|
|
113
|
+
const handleFocus = useCallback(() => setIsFocused(true), []);
|
|
114
|
+
const handleBlur = useCallback(() => setIsFocused(false), []);
|
|
115
|
+
|
|
116
|
+
// 상태에 따른 테두리 색상 설정
|
|
117
|
+
const computedBorderColor = useMemo(() => (
|
|
118
|
+
status === 'error' ? errorColor : isFocused ? focusColor : borderColor
|
|
119
|
+
), [status, errorColor, isFocused, focusColor, borderColor]);
|
|
120
|
+
|
|
121
|
+
// 상태에 따른 라벨 색상 설정
|
|
122
|
+
const computedLabelColor = useMemo(() => (
|
|
123
|
+
status === 'error' ? errorColor : isFocused ? focusColor : value ? labelColor : placeHolderColor
|
|
124
|
+
), [status, errorColor, isFocused, focusColor, value, placeHolderColor, labelColor]);
|
|
125
|
+
|
|
126
|
+
// 컨테이너 스타일 정의
|
|
127
|
+
const containerStyle: StyleProp<ViewStyle> = useMemo(() => ({
|
|
128
|
+
width: '100%',
|
|
129
|
+
justifyContent: isTextArea ? 'flex-start' : 'center',
|
|
130
|
+
borderRadius,
|
|
131
|
+
paddingHorizontal,
|
|
132
|
+
backgroundColor: inputBgColor,
|
|
133
|
+
paddingTop: boxStyle === 'inbox' ? 13 : 0,
|
|
134
|
+
...(boxStyle === 'outline' || boxStyle === 'inbox' ? { borderWidth } : {}),
|
|
135
|
+
...(boxStyle === 'underline' ? { borderBottomWidth: borderWidth } : {}),
|
|
136
|
+
...(innerBoxStyle === 'top' ? { borderBottomLeftRadius: 0, borderBottomRightRadius: 0, borderBottomWidth: borderWidth / 2 }
|
|
137
|
+
: innerBoxStyle === 'middle' ? { borderRadius: 0, borderTopWidth: borderWidth / 2, borderBottomWidth: borderWidth / 2 }
|
|
138
|
+
: innerBoxStyle === 'bottom' ? { borderTopLeftRadius: 0, borderTopRightRadius: 0, borderTopWidth: borderWidth / 2 }
|
|
139
|
+
: {}),
|
|
140
|
+
}), [isTextArea, borderRadius, paddingHorizontal, inputBgColor, borderWidth, boxStyle, innerBoxStyle]);
|
|
141
|
+
|
|
142
|
+
// 라벨 스타일 정의
|
|
143
|
+
const labelTextStyle: StyleProp<TextStyle> = useMemo(() => ({
|
|
144
|
+
fontSize,
|
|
145
|
+
left: paddingHorizontal,
|
|
146
|
+
backgroundColor: labelBgColor,
|
|
147
|
+
paddingHorizontal: boxStyle === 'outline' ? 5 : 0,
|
|
148
|
+
paddingVertical: 2,
|
|
149
|
+
textAlignVertical: 'center',
|
|
150
|
+
fontFamily,
|
|
151
|
+
borderRadius: boxStyle === 'outline' ? 20 : 0,
|
|
152
|
+
overflow: 'hidden',
|
|
153
|
+
}), [fontSize, paddingHorizontal, labelBgColor, boxStyle, fontFamily]);
|
|
154
|
+
|
|
155
|
+
// 텍스트 변경 핸들러
|
|
156
|
+
const handleTextChange = useCallback((text: string) => {
|
|
157
|
+
if (onChangeText) onChangeText(text);
|
|
158
|
+
}, [onChangeText]);
|
|
159
|
+
|
|
160
|
+
return (
|
|
161
|
+
<>
|
|
162
|
+
<ViewAtom
|
|
163
|
+
style={[containerStyle, { borderColor: computedBorderColor }]}
|
|
164
|
+
onLayout={handleLayout}
|
|
165
|
+
pointerEvents={disabled ? 'none' : 'auto'}
|
|
166
|
+
>
|
|
167
|
+
<TextInput
|
|
168
|
+
{...textInputProps}
|
|
169
|
+
style={[
|
|
170
|
+
{ paddingTop: 7, paddingBottom: 5 },
|
|
171
|
+
textInputProps?.style,
|
|
172
|
+
{ fontSize, width: '100%', paddingRight: 25, fontFamily },
|
|
173
|
+
]}
|
|
174
|
+
value={value}
|
|
175
|
+
onFocus={handleFocus}
|
|
176
|
+
onBlur={handleBlur}
|
|
177
|
+
onChangeText={handleTextChange}
|
|
178
|
+
allowFontScaling={allowFontScaling}
|
|
179
|
+
selectionColor={palette.grey[50]}
|
|
180
|
+
/>
|
|
181
|
+
|
|
182
|
+
<ViewAtom pointerEvents="none" style={{ position: 'absolute' }}>
|
|
183
|
+
<Animated.Text allowFontScaling={allowFontScaling} style={[animatedLabelStyle, labelTextStyle, { color: computedLabelColor }]}>
|
|
184
|
+
{label}
|
|
185
|
+
</Animated.Text>
|
|
186
|
+
</ViewAtom>
|
|
187
|
+
|
|
188
|
+
{(value && isFocused) && (
|
|
189
|
+
<ButtonClose marginTop={isTextArea ? 13 : undefined} onChangeText={onChangeText} />
|
|
190
|
+
)}
|
|
191
|
+
</ViewAtom>
|
|
192
|
+
|
|
193
|
+
{status === 'error' && errorMessage && (
|
|
194
|
+
<ErrorComponent errorMessage={errorMessage} errorColor={errorColor} fontFamily={fontFamily} />
|
|
195
|
+
)}
|
|
196
|
+
</>
|
|
197
|
+
);
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
export default ZSTextField;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { TouchableOpacity } from "react-native";
|
|
2
|
+
import { SvgX } from "../../../assets/SvgX";
|
|
3
|
+
|
|
4
|
+
const ButtonClose = ({
|
|
5
|
+
onChangeText,
|
|
6
|
+
marginTop
|
|
7
|
+
}: {
|
|
8
|
+
onChangeText?: (text: string) => void;
|
|
9
|
+
marginTop?: number
|
|
10
|
+
}) => {
|
|
11
|
+
return (
|
|
12
|
+
<TouchableOpacity style={{ position: 'absolute', padding: 3, right: 15, borderRadius: 30, backgroundColor: '#e6e6e6', justifyContent: 'center', alignItems: 'center', ...marginTop && { top: marginTop } }}
|
|
13
|
+
hitSlop={{ top: 10, right: 10, bottom: 10, left: 10 }}
|
|
14
|
+
onPress={() => { onChangeText?.(''); }}>
|
|
15
|
+
<SvgX color="#5E696E" />
|
|
16
|
+
</TouchableOpacity>
|
|
17
|
+
)
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export default ButtonClose;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { Text, View } from "react-native";
|
|
2
|
+
|
|
3
|
+
const ErrorComponent = ({
|
|
4
|
+
errorMessage, errorColor, fontFamily
|
|
5
|
+
}:{
|
|
6
|
+
errorMessage: string;
|
|
7
|
+
errorColor: string;
|
|
8
|
+
fontFamily: string;
|
|
9
|
+
}) => {
|
|
10
|
+
return (
|
|
11
|
+
<View style={{ width: '100%', flexDirection: 'row', alignItems: 'center', paddingLeft: 3, marginTop: 5 }}>
|
|
12
|
+
<View style={{ width: 18, height: 18, justifyContent: 'center', alignItems: 'center', borderRadius: 30, backgroundColor: errorColor }}>
|
|
13
|
+
<Text allowFontScaling={false} style={{ fontWeight: 'bold', color: 'white', textAlign: 'center', textAlignVertical: 'center', fontSize: 11, fontFamily: fontFamily }}>
|
|
14
|
+
{`!`}
|
|
15
|
+
</Text>
|
|
16
|
+
</View>
|
|
17
|
+
|
|
18
|
+
<Text allowFontScaling={false} style={{ marginLeft: 5, fontSize: 14, color: errorColor, fontFamily: fontFamily }}>
|
|
19
|
+
{errorMessage}
|
|
20
|
+
</Text>
|
|
21
|
+
</View>
|
|
22
|
+
)
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export default ErrorComponent;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import React, { memo, useMemo } from 'react';
|
|
2
|
+
import { ViewProps, StyleSheet } from 'react-native';
|
|
3
|
+
import { useTheme } from '../../model/useThemeProvider';
|
|
4
|
+
import AnimatedWrapper from '../atoms/AnimatedWrapper';
|
|
5
|
+
|
|
6
|
+
type Props = ViewProps & {
|
|
7
|
+
isAnimation?: boolean;
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
const ZSView: React.FC<Props> = ({ isAnimation = false, style, children, ...rest }) => {
|
|
11
|
+
const { palette } = useTheme();
|
|
12
|
+
|
|
13
|
+
const styles = useMemo(
|
|
14
|
+
() =>
|
|
15
|
+
StyleSheet.create({
|
|
16
|
+
container: {
|
|
17
|
+
backgroundColor: palette.background.base,
|
|
18
|
+
},
|
|
19
|
+
}),
|
|
20
|
+
[palette.background.base],
|
|
21
|
+
);
|
|
22
|
+
|
|
23
|
+
return (
|
|
24
|
+
<AnimatedWrapper isAnimation={isAnimation} style={[styles.container, style]} {...rest}>
|
|
25
|
+
{children}
|
|
26
|
+
</AnimatedWrapper>
|
|
27
|
+
);
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
export default memo(ZSView);
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import React, { useMemo, useCallback } from 'react';
|
|
2
|
+
import { View, ViewProps, Platform } from 'react-native';
|
|
3
|
+
import Animated, { FadeInDown, FadeOut, useAnimatedStyle, withTiming, useSharedValue, runOnJS } from 'react-native-reanimated';
|
|
4
|
+
import { useTheme } from '../../model/useThemeProvider';
|
|
5
|
+
import { ShadowLevel, ShadowStyle } from '../types';
|
|
6
|
+
|
|
7
|
+
const DEFAULT_DURATION = 200 as const;
|
|
8
|
+
const SHADOW_DURATION = 50 as const;
|
|
9
|
+
const IOS_SHADOW: readonly ShadowStyle[] = [
|
|
10
|
+
{ shadowOffset: { width: 0, height: 1 }, shadowOpacity: 1, shadowRadius: 1.00 },
|
|
11
|
+
{ shadowOffset: { width: 0, height: 1 }, shadowOpacity: 1, shadowRadius: 1.41 },
|
|
12
|
+
{ shadowOffset: { width: 0, height: 1 }, shadowOpacity: 1, shadowRadius: 2.22 },
|
|
13
|
+
{ shadowOffset: { width: 0, height: 2 }, shadowOpacity: 1, shadowRadius: 2.62 },
|
|
14
|
+
{ shadowOffset: { width: 0, height: 2 }, shadowOpacity: 1, shadowRadius: 3.84 },
|
|
15
|
+
{ shadowOffset: { width: 0, height: 3 }, shadowOpacity: 1, shadowRadius: 4.65 },
|
|
16
|
+
{ shadowOffset: { width: 0, height: 3 }, shadowOpacity: 1, shadowRadius: 4.65 },
|
|
17
|
+
{ shadowOffset: { width: 0, height: 4 }, shadowOpacity: 1, shadowRadius: 4.65 },
|
|
18
|
+
{ shadowOffset: { width: 0, height: 4 }, shadowOpacity: 1, shadowRadius: 5.46 },
|
|
19
|
+
{ shadowOffset: { width: 0, height: 5 }, shadowOpacity: 1, shadowRadius: 6.27 },
|
|
20
|
+
] as const;
|
|
21
|
+
|
|
22
|
+
interface AnimatedWrapperProps extends ViewProps {
|
|
23
|
+
isAnimation: boolean;
|
|
24
|
+
elevationLevel?: ShadowLevel;
|
|
25
|
+
duration?: number;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
function AnimatedWrapper({
|
|
29
|
+
isAnimation = true,
|
|
30
|
+
elevationLevel = 0,
|
|
31
|
+
duration = DEFAULT_DURATION,
|
|
32
|
+
style,
|
|
33
|
+
children,
|
|
34
|
+
...props
|
|
35
|
+
}: AnimatedWrapperProps) {
|
|
36
|
+
const { palette } = useTheme();
|
|
37
|
+
const opacity = useSharedValue(0);
|
|
38
|
+
|
|
39
|
+
// 그림자 및 기타 스타일을 플랫폼에 맞게 미리 계산
|
|
40
|
+
const staticStyle = useMemo(() => {
|
|
41
|
+
if (Platform.OS === 'ios') {
|
|
42
|
+
const { shadowOpacity, ...rest } = IOS_SHADOW[elevationLevel];
|
|
43
|
+
return { shadowColor: palette.elevationShadow[elevationLevel], ...rest };
|
|
44
|
+
}
|
|
45
|
+
return { shadowColor: palette.elevationShadow[elevationLevel] };
|
|
46
|
+
}, [elevationLevel, palette]);
|
|
47
|
+
|
|
48
|
+
// 애니메이션 스타일 정의 (iOS 그림자 및 Android elevation 처리)
|
|
49
|
+
const animatedStyle = useAnimatedStyle(() => {
|
|
50
|
+
if (Platform.OS === 'ios') {
|
|
51
|
+
return { shadowOpacity: opacity.value * IOS_SHADOW[elevationLevel].shadowOpacity };
|
|
52
|
+
}
|
|
53
|
+
return { elevation: opacity.value * elevationLevel };
|
|
54
|
+
}, [elevationLevel]);
|
|
55
|
+
|
|
56
|
+
// 컴포넌트가 등장할 때 애니메이션 핸들링
|
|
57
|
+
const onEntering = useCallback(() => {
|
|
58
|
+
opacity.value = withTiming(1, { duration: SHADOW_DURATION });
|
|
59
|
+
}, [opacity]);
|
|
60
|
+
|
|
61
|
+
// 애니메이션 속성 메모이제이션
|
|
62
|
+
const animationProps = useMemo(() => ({
|
|
63
|
+
entering: FadeInDown.duration(duration).withCallback((finished) => {
|
|
64
|
+
'worklet';
|
|
65
|
+
if (finished) {
|
|
66
|
+
runOnJS(onEntering)();
|
|
67
|
+
}
|
|
68
|
+
}),
|
|
69
|
+
exiting: FadeOut.duration(50),
|
|
70
|
+
}), [duration, onEntering]);
|
|
71
|
+
|
|
72
|
+
// 애니메이션이 비활성화된 경우 기본 View로 렌더링
|
|
73
|
+
if (!isAnimation) {
|
|
74
|
+
return <View style={[style, staticStyle]} {...props}>{children}</View>;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
// 애니메이션이 적용된 View로 렌더링
|
|
78
|
+
return (
|
|
79
|
+
<Animated.View
|
|
80
|
+
style={[style, staticStyle, animatedStyle]}
|
|
81
|
+
{...animationProps}
|
|
82
|
+
{...props}
|
|
83
|
+
>
|
|
84
|
+
{children}
|
|
85
|
+
</Animated.View>
|
|
86
|
+
);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
export default React.memo(AnimatedWrapper);
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import React, { forwardRef } from 'react';
|
|
2
|
+
import { ScrollView, ScrollViewProps } from 'react-native';
|
|
3
|
+
|
|
4
|
+
type ScrollViewAtomProps = ScrollViewProps;
|
|
5
|
+
|
|
6
|
+
// scrollViewRef를 제거하고 ref로 대체합니다.
|
|
7
|
+
const ScrollViewAtom = forwardRef<ScrollView, ScrollViewAtomProps>(function ScrollViewAtom(
|
|
8
|
+
{ children, style, ...props }, ref
|
|
9
|
+
) {
|
|
10
|
+
return (
|
|
11
|
+
<ScrollView ref={ref} {...props} style={style}>
|
|
12
|
+
{children}
|
|
13
|
+
</ScrollView>
|
|
14
|
+
);
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
export default ScrollViewAtom;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Text, TextProps } from 'react-native';
|
|
3
|
+
|
|
4
|
+
type TextAtomProps = TextProps & {
|
|
5
|
+
};
|
|
6
|
+
|
|
7
|
+
function TextAtom({ children, ...props }: TextAtomProps) {
|
|
8
|
+
return (
|
|
9
|
+
<Text {...props}>
|
|
10
|
+
{children}
|
|
11
|
+
</Text>
|
|
12
|
+
);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export default TextAtom;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { View, ViewProps } from 'react-native';
|
|
3
|
+
|
|
4
|
+
type ViewAtomProps = ViewProps & {
|
|
5
|
+
};
|
|
6
|
+
|
|
7
|
+
function ViewAtom({ children, ...props }: ViewAtomProps) {
|
|
8
|
+
return (
|
|
9
|
+
<View {...props}>
|
|
10
|
+
{children}
|
|
11
|
+
</View>
|
|
12
|
+
);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export default ViewAtom;
|
package/src/ui/index.ts
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import ZSView from './ZSView';
|
|
2
|
+
import AnimatedWrapper from './atoms/AnimatedWrapper';
|
|
3
|
+
import TextAtom from './atoms/TextAtom';
|
|
4
|
+
import ScrollViewAtom from './atoms/ScrollViewAtom';
|
|
5
|
+
import ZSContainer from './ZSContainer';
|
|
6
|
+
import ZSPressable from './ZSPressable';
|
|
7
|
+
import ZSText from './ZSText';
|
|
8
|
+
import ThrottleButton from './ThrottleButton';
|
|
9
|
+
import ZSTextField from './ZSTextField';
|
|
10
|
+
import ZSRadioGroup from './ZSRadioGroup';
|
|
11
|
+
import ZSBottomButton from './ZSBottomButton';
|
|
12
|
+
import * as types from './types';
|
|
13
|
+
|
|
14
|
+
export {
|
|
15
|
+
ZSView,
|
|
16
|
+
AnimatedWrapper,
|
|
17
|
+
TextAtom,
|
|
18
|
+
ScrollViewAtom,
|
|
19
|
+
ZSContainer,
|
|
20
|
+
ZSPressable,
|
|
21
|
+
ZSText,
|
|
22
|
+
ThrottleButton,
|
|
23
|
+
ZSTextField,
|
|
24
|
+
ZSRadioGroup,
|
|
25
|
+
ZSBottomButton,
|
|
26
|
+
types
|
|
27
|
+
};
|