@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,165 @@
|
|
|
1
|
+
import { useCallback, useRef, useState } from 'react';
|
|
2
|
+
import { Dimensions, Keyboard } from 'react-native';
|
|
3
|
+
import NotifyContext from './useNotify';
|
|
4
|
+
import AlertNotify from '../notify/AlertNotify';
|
|
5
|
+
import SnackbarNotify from '../notify/SnackbarNotify';
|
|
6
|
+
import BottomSheetNotify from '../notify/BottomSheetNotify';
|
|
7
|
+
import LoadingNotify from '../notify/LoadingNotify';
|
|
8
|
+
import PopOverMenu from '../notify/PopOver/PopOverMenu';
|
|
9
|
+
const BS_MAX_HEIGHT = Dimensions.get('window').height - 120;
|
|
10
|
+
export function NotifyProvider({ customSnackbar, loaderComponent, children }) {
|
|
11
|
+
// Alert
|
|
12
|
+
const [title, setTitle] = useState('');
|
|
13
|
+
const [informative, setInformative] = useState('');
|
|
14
|
+
const [alertVisible, setAlertVisible] = useState(false);
|
|
15
|
+
const [actions, setActions] = useState();
|
|
16
|
+
const [isBackgroundTouchClose, setIsBackgroundTouchClose] = useState(true);
|
|
17
|
+
const [titleStyle, setTitleStyle] = useState();
|
|
18
|
+
const [informativeStyle, setInformativeStyle] = useState();
|
|
19
|
+
const [secondaryButtonStyle, setSecondaryButtonStyle] = useState();
|
|
20
|
+
const [primaryButtonStyle, setPrimaryButtonStyle] = useState();
|
|
21
|
+
const [secondaryButtonTextStyle, setSecondaryButtonTextStyle] = useState();
|
|
22
|
+
const [primaryButtonTextStyle, setPrimaryButtonTextStyle] = useState();
|
|
23
|
+
const [singleButtonTextStyle, setSingleButtonTextStyle] = useState();
|
|
24
|
+
// Snackbar
|
|
25
|
+
const [snackItemStack, setSnackItemStack] = useState([]);
|
|
26
|
+
// BottomSheet
|
|
27
|
+
const [contentsGestureEnable, setContentsGestureEnable] = useState(false);
|
|
28
|
+
const [bottomSheetVisible, setBottomSheetVisible] = useState(false);
|
|
29
|
+
const [bottomSheetBackgroundColor, setBottomSheetBackgroundColor] = useState();
|
|
30
|
+
const [bottomSheetComponent, setBottomSheetComponent] = useState(false);
|
|
31
|
+
const [bottomSheetPadding, setBottomSheetPadding] = useState(undefined);
|
|
32
|
+
const [bottomSheetMarginX, setBottomSheetMarginX] = useState(undefined);
|
|
33
|
+
const [bottomSheetMaxHeight, setBottomSheetMaxHeight] = useState(BS_MAX_HEIGHT);
|
|
34
|
+
const [bottomSheetScrollView, setBottomSheetScrollView] = useState(true);
|
|
35
|
+
const [isBottomRadius, setIsBottomRadius] = useState(true);
|
|
36
|
+
const [handleVisible, setHandleVisible] = useState(true);
|
|
37
|
+
const [marginBottomBS, setMarginBottomBs] = useState(undefined);
|
|
38
|
+
const bottomSheetRef = useRef(null);
|
|
39
|
+
// Loading
|
|
40
|
+
const [loaderVisible, setLoaderVisible] = useState(false);
|
|
41
|
+
// PopOver
|
|
42
|
+
const [popOverVisible, setPopOverVisible] = useState(false);
|
|
43
|
+
const [popOverLocation, setPopOverLocation] = useState({ px: 0, py: 0 });
|
|
44
|
+
const [popOverComponent, setPopOverComponent] = useState(false);
|
|
45
|
+
// ---
|
|
46
|
+
const [fontFamily, setFontFamily] = useState(undefined);
|
|
47
|
+
const showAlert = ({ title, informative, actions, isBackgroundTouchClose = true, titleStyle, informativeStyle, secondaryButtonStyle, primaryButtonStyle, secondaryButtonTextStyle, primaryButtonTextStyle, singleButtonTextStyle, }) => {
|
|
48
|
+
Keyboard.dismiss();
|
|
49
|
+
setTitle(title);
|
|
50
|
+
setInformative(informative);
|
|
51
|
+
setActions(actions || {});
|
|
52
|
+
setIsBackgroundTouchClose(isBackgroundTouchClose);
|
|
53
|
+
setAlertVisible(true);
|
|
54
|
+
setTitleStyle(titleStyle);
|
|
55
|
+
setInformativeStyle(informativeStyle);
|
|
56
|
+
setSecondaryButtonStyle(secondaryButtonStyle);
|
|
57
|
+
setPrimaryButtonStyle(primaryButtonStyle);
|
|
58
|
+
setSecondaryButtonTextStyle(secondaryButtonTextStyle);
|
|
59
|
+
setPrimaryButtonTextStyle(primaryButtonTextStyle);
|
|
60
|
+
setSingleButtonTextStyle(singleButtonTextStyle);
|
|
61
|
+
setFontFamily(fontFamily);
|
|
62
|
+
};
|
|
63
|
+
const showBottomSheet = ({ isHandleVisible = true, component, contentsGestureEnable = true, marginHorizontal, padding, marginBottom, backgroundColor, isBottomRadius = true, maxHeight, isScrollView = true }) => {
|
|
64
|
+
Keyboard.dismiss();
|
|
65
|
+
padding && setBottomSheetPadding(padding);
|
|
66
|
+
marginBottom && setMarginBottomBs(marginBottom);
|
|
67
|
+
marginHorizontal && setBottomSheetMarginX(marginHorizontal);
|
|
68
|
+
backgroundColor && setBottomSheetBackgroundColor(backgroundColor);
|
|
69
|
+
maxHeight && setBottomSheetMaxHeight(maxHeight);
|
|
70
|
+
setContentsGestureEnable(contentsGestureEnable);
|
|
71
|
+
setHandleVisible(isHandleVisible);
|
|
72
|
+
setBottomSheetScrollView(isScrollView);
|
|
73
|
+
setIsBottomRadius(isBottomRadius);
|
|
74
|
+
setBottomSheetComponent(component);
|
|
75
|
+
bottomSheetRef.current?.handleVisible(true);
|
|
76
|
+
};
|
|
77
|
+
const showLoader = () => {
|
|
78
|
+
setLoaderVisible(true);
|
|
79
|
+
};
|
|
80
|
+
const showPopOverMenu = ({ px, py, component }) => {
|
|
81
|
+
setPopOverLocation({ px, py });
|
|
82
|
+
setPopOverComponent(component);
|
|
83
|
+
setPopOverVisible(true);
|
|
84
|
+
};
|
|
85
|
+
const showSnackBar = ({ message, type = 'success', index = Date.now(), snackbarDuration = 3000 }) => {
|
|
86
|
+
// TODO: 스택 쌓고싶은데 삭제될 때 참조를 잃어서 삭제가 안되는 문제가 있음.
|
|
87
|
+
setSnackItemStack((prev) => {
|
|
88
|
+
if (prev.length === 0) {
|
|
89
|
+
return [...prev, { message, type, index: index, snackbarDuration: snackbarDuration }];
|
|
90
|
+
}
|
|
91
|
+
else {
|
|
92
|
+
return prev;
|
|
93
|
+
}
|
|
94
|
+
;
|
|
95
|
+
});
|
|
96
|
+
};
|
|
97
|
+
const hideSnackBar = (index) => {
|
|
98
|
+
setSnackItemStack((prev) => prev.filter((item) => item.index !== index));
|
|
99
|
+
};
|
|
100
|
+
const hideNotify = useCallback((option) => {
|
|
101
|
+
switch (option) {
|
|
102
|
+
case 'alert':
|
|
103
|
+
setAlertVisible(false);
|
|
104
|
+
break;
|
|
105
|
+
case 'snack':
|
|
106
|
+
setSnackItemStack([]);
|
|
107
|
+
break;
|
|
108
|
+
case 'bottomSheet':
|
|
109
|
+
bottomSheetRef.current?.handleVisible(false);
|
|
110
|
+
break;
|
|
111
|
+
case 'loader':
|
|
112
|
+
setLoaderVisible(false);
|
|
113
|
+
break;
|
|
114
|
+
case 'popOver':
|
|
115
|
+
setPopOverVisible(false);
|
|
116
|
+
break;
|
|
117
|
+
case 'all':
|
|
118
|
+
setAlertVisible(false);
|
|
119
|
+
setSnackItemStack([]);
|
|
120
|
+
setLoaderVisible(false);
|
|
121
|
+
setPopOverVisible(false);
|
|
122
|
+
bottomSheetRef.current?.handleVisible(false);
|
|
123
|
+
break;
|
|
124
|
+
default:
|
|
125
|
+
break;
|
|
126
|
+
}
|
|
127
|
+
;
|
|
128
|
+
}, []);
|
|
129
|
+
return (<NotifyContext.Provider value={{
|
|
130
|
+
alertVisible,
|
|
131
|
+
setAlertVisible,
|
|
132
|
+
// ---
|
|
133
|
+
snackItemStack,
|
|
134
|
+
hideSnackBar,
|
|
135
|
+
// ---
|
|
136
|
+
bottomSheetVisible,
|
|
137
|
+
setBottomSheetVisible,
|
|
138
|
+
// ---
|
|
139
|
+
loaderVisible,
|
|
140
|
+
// ---
|
|
141
|
+
popOverVisible,
|
|
142
|
+
setPopOverVisible,
|
|
143
|
+
// ---
|
|
144
|
+
showAlert,
|
|
145
|
+
showSnackBar,
|
|
146
|
+
showBottomSheet,
|
|
147
|
+
showLoader,
|
|
148
|
+
showPopOverMenu,
|
|
149
|
+
// ---
|
|
150
|
+
hideNotify,
|
|
151
|
+
}}>
|
|
152
|
+
{children}
|
|
153
|
+
|
|
154
|
+
<BottomSheetNotify ref={bottomSheetRef} bottomSheetComponent={bottomSheetComponent} contentsGestureEnable={contentsGestureEnable} bottomSheetPadding={bottomSheetPadding} marginBottomBS={marginBottomBS} isHandleVisible={handleVisible} bottomSheetMarginX={bottomSheetMarginX} isBottomRadius={isBottomRadius} bottomSheetBackgroundColor={bottomSheetBackgroundColor} maxHeight={bottomSheetMaxHeight} isScrollView={bottomSheetScrollView}/>
|
|
155
|
+
|
|
156
|
+
<PopOverMenu px={popOverLocation?.px} py={popOverLocation?.py} component={popOverComponent}/>
|
|
157
|
+
|
|
158
|
+
<SnackbarNotify customSnackbar={customSnackbar}/>
|
|
159
|
+
|
|
160
|
+
<AlertNotify title={title} informative={informative} actions={actions || {}} isBackgroundTouchClose={isBackgroundTouchClose} titleStyle={titleStyle} informativeStyle={informativeStyle} secondaryButtonStyle={secondaryButtonStyle} primaryButtonStyle={primaryButtonStyle} secondaryButtonTextStyle={secondaryButtonTextStyle} primaryButtonTextStyle={primaryButtonTextStyle} singleButtonTextStyle={singleButtonTextStyle}/>
|
|
161
|
+
|
|
162
|
+
<LoadingNotify loaderComponent={loaderComponent}/>
|
|
163
|
+
</NotifyContext.Provider>);
|
|
164
|
+
}
|
|
165
|
+
//# sourceMappingURL=useNotifyProvider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useNotifyProvider.js","sourceRoot":"","sources":["../../src/model/useNotifyProvider.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACtD,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAoC,MAAM,cAAc,CAAC;AACtF,OAAO,aAAa,MAAM,aAAa,CAAC;AAExC,OAAO,WAAW,MAAM,uBAAuB,CAAC;AAChD,OAAO,cAAc,MAAM,0BAA0B,CAAC;AACtD,OAAO,iBAAiB,MAAM,6BAA6B,CAAC;AAC5D,OAAO,aAAa,MAAM,yBAAyB,CAAC;AACpD,OAAO,WAAW,MAAM,+BAA+B,CAAC;AAExD,MAAM,aAAa,GAAG,UAAU,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC,MAAM,GAAG,GAAG,CAAC;AAE5D,MAAM,UAAU,cAAc,CAAC,EAC3B,cAAc,EACd,eAAe,EACf,QAAQ,EACU;IAClB,QAAQ;IACR,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,QAAQ,CAAS,EAAE,CAAC,CAAC;IAC/C,MAAM,CAAC,WAAW,EAAE,cAAc,CAAC,GAAG,QAAQ,CAAS,EAAE,CAAC,CAAC;IAC3D,MAAM,CAAC,YAAY,EAAE,eAAe,CAAC,GAAG,QAAQ,CAAU,KAAK,CAAC,CAAC;IACjE,MAAM,CAAC,OAAO,EAAE,UAAU,CAAC,GAAG,QAAQ,EAAgB,CAAC;IACvD,MAAM,CAAC,sBAAsB,EAAE,yBAAyB,CAAC,GAAG,QAAQ,CAAU,IAAI,CAAC,CAAC;IACpF,MAAM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C,CAAC,cAAc,CAAC,CAC/B,0BAA0B,CAAC,CAAC,0BAA0B,CAAC,CACvD,SAAS,CAAC,CAAC,oBAAoB,CAAC,CAChC,YAAY,CAAC,CAAC,qBAAqB,CAAC,EAGxC;;YAAA,CAAC,WAAW,CACR,EAAE,CAAC,CAAC,eAAe,EAAE,EAAE,CAAC,CACxB,EAAE,CAAC,CAAC,eAAe,EAAE,EAAE,CAAC,CACxB,SAAS,CAAC,CAAC,gBAAgB,CAAC,EAGhC;;YAAA,CAAC,cAAc,CACX,cAAc,CAAC,CAAC,cAAc,CAAC,EAGnC;;YAAA,CAAC,WAAW,CACR,KAAK,CAAC,CAAC,KAAK,CAAC,CACb,WAAW,CAAC,CAAC,WAAW,CAAC,CACzB,OAAO,CAAC,CAAC,OAAO,IAAI,EAAkB,CAAC,CACvC,sBAAsB,CAAC,CAAC,sBAAsB,CAAC,CAC/C,UAAU,CAAC,CAAC,UAAU,CAAC,CACvB,gBAAgB,CAAC,CAAC,gBAAgB,CAAC,CACnC,oBAAoB,CAAC,CAAC,oBAAoB,CAAC,CAC3C,kBAAkB,CAAC,CAAC,kBAAkB,CAAC,CACvC,wBAAwB,CAAC,CAAC,wBAAwB,CAAC,CACnD,sBAAsB,CAAC,CAAC,sBAAsB,CAAC,CAC/C,qBAAqB,CAAC,CAAC,qBAAqB,CAAC,EAGjD;;YAAA,CAAC,aAAa,CACV,eAAe,CAAC,CAAC,eAAe,CAAC,EAEzC;QAAA,EAAE,aAAa,CAAC,QAAQ,CAAC,CAC5B,CAAC;AACN,CAAC","sourcesContent":["import { useCallback, useRef, useState } from 'react';\nimport { Dimensions, Keyboard, TextProps, TouchableOpacityProps } from 'react-native';\nimport NotifyContext from './useNotify';\nimport { AlertActions, BottomSheetRef, HideOption, NotifyProviderProps, PopOverMenuProps, ShowAlertProps, ShowBottomSheetProps, ShowSnackBarProps, SnackItem } from './types';\nimport AlertNotify from '../notify/AlertNotify';\nimport SnackbarNotify from '../notify/SnackbarNotify';\nimport BottomSheetNotify from '../notify/BottomSheetNotify';\nimport LoadingNotify from '../notify/LoadingNotify';\nimport PopOverMenu from '../notify/PopOver/PopOverMenu';\n\nconst BS_MAX_HEIGHT = Dimensions.get('window').height - 120;\n\nexport function NotifyProvider({\n customSnackbar,\n loaderComponent,\n children\n}: NotifyProviderProps) {\n // Alert\n const [title, setTitle] = useState<string>('');\n const [informative, setInformative] = useState<string>('');\n const [alertVisible, setAlertVisible] = useState<boolean>(false);\n const [actions, setActions] = useState<AlertActions>();\n const [isBackgroundTouchClose, setIsBackgroundTouchClose] = useState<boolean>(true);\n const [titleStyle, setTitleStyle] = useState<TextProps['style']>();\n const [informativeStyle, setInformativeStyle] = useState<TextProps['style']>();\n const [secondaryButtonStyle, setSecondaryButtonStyle] = useState<TouchableOpacityProps['style']>();\n const [primaryButtonStyle, setPrimaryButtonStyle] = useState<TouchableOpacityProps['style']>();\n const [secondaryButtonTextStyle, setSecondaryButtonTextStyle] = useState<TextProps['style']>();\n const [primaryButtonTextStyle, setPrimaryButtonTextStyle] = useState<TextProps['style']>();\n const [singleButtonTextStyle, setSingleButtonTextStyle] = useState<TextProps['style']>();\n\n // Snackbar\n const [snackItemStack, setSnackItemStack] = useState<SnackItem[]>([]);\n\n // BottomSheet\n const [contentsGestureEnable, setContentsGestureEnable] = useState<boolean>(false);\n const [bottomSheetVisible, setBottomSheetVisible] = useState<boolean>(false);\n const [bottomSheetBackgroundColor, setBottomSheetBackgroundColor] = useState<string>();\n const [bottomSheetComponent, setBottomSheetComponent] = useState<React.ReactNode>(false);\n const [bottomSheetPadding, setBottomSheetPadding] = useState<number | undefined>(undefined);\n const [bottomSheetMarginX, setBottomSheetMarginX] = useState<number | undefined>(undefined);\n const [bottomSheetMaxHeight, setBottomSheetMaxHeight] = useState<number>(BS_MAX_HEIGHT);\n const [bottomSheetScrollView, setBottomSheetScrollView] = useState<boolean>(true);\n const [isBottomRadius, setIsBottomRadius] = useState<boolean>(true);\n const [handleVisible, setHandleVisible] = useState<boolean>(true);\n const [marginBottomBS, setMarginBottomBs] = useState<number | undefined>(undefined);\n const bottomSheetRef = useRef<BottomSheetRef | null>(null);\n\n // Loading\n const [loaderVisible, setLoaderVisible] = useState<boolean>(false);\n\n // PopOver\n const [popOverVisible, setPopOverVisible] = useState<boolean>(false);\n const [popOverLocation, setPopOverLocation] = useState<{ px: PopOverMenuProps['px'], py: PopOverMenuProps['py'] }>({ px: 0, py: 0 });\n const [popOverComponent, setPopOverComponent] = useState<React.ReactNode>(false);\n\n // ---\n const [fontFamily, setFontFamily] = useState<string | undefined | { title?: string; info?: string; label?: string; }>(undefined);\n\n\n const showAlert = ({\n title,\n informative,\n actions,\n isBackgroundTouchClose = true,\n titleStyle,\n informativeStyle,\n secondaryButtonStyle,\n primaryButtonStyle,\n secondaryButtonTextStyle,\n primaryButtonTextStyle,\n singleButtonTextStyle,\n }: ShowAlertProps) => {\n Keyboard.dismiss();\n setTitle(title);\n setInformative(informative);\n setActions(actions || {} as AlertActions);\n setIsBackgroundTouchClose(isBackgroundTouchClose);\n setAlertVisible(true);\n\n setTitleStyle(titleStyle);\n setInformativeStyle(informativeStyle);\n setSecondaryButtonStyle(secondaryButtonStyle);\n setPrimaryButtonStyle(primaryButtonStyle);\n setSecondaryButtonTextStyle(secondaryButtonTextStyle);\n setPrimaryButtonTextStyle(primaryButtonTextStyle);\n setSingleButtonTextStyle(singleButtonTextStyle);\n\n setFontFamily(fontFamily);\n };\n\n const showBottomSheet = ({\n isHandleVisible = true,\n component,\n contentsGestureEnable = true,\n marginHorizontal,\n padding,\n marginBottom,\n backgroundColor,\n isBottomRadius = true,\n maxHeight,\n isScrollView = true\n }: ShowBottomSheetProps) => {\n Keyboard.dismiss();\n padding && setBottomSheetPadding(padding);\n marginBottom && setMarginBottomBs(marginBottom);\n marginHorizontal && setBottomSheetMarginX(marginHorizontal);\n backgroundColor && setBottomSheetBackgroundColor(backgroundColor);\n maxHeight && setBottomSheetMaxHeight(maxHeight);\n setContentsGestureEnable(contentsGestureEnable);\n setHandleVisible(isHandleVisible);\n setBottomSheetScrollView(isScrollView);\n setIsBottomRadius(isBottomRadius);\n setBottomSheetComponent(component);\n bottomSheetRef.current?.handleVisible(true);\n };\n\n const showLoader = () => {\n setLoaderVisible(true);\n };\n\n const showPopOverMenu = ({\n px,\n py,\n component\n }: PopOverMenuProps) => {\n setPopOverLocation({ px, py });\n setPopOverComponent(component);\n setPopOverVisible(true);\n }\n\n const showSnackBar = ({\n message,\n type = 'success',\n index = Date.now(),\n snackbarDuration = 3000\n }: ShowSnackBarProps) => {\n // TODO: 스택 쌓고싶은데 삭제될 때 참조를 잃어서 삭제가 안되는 문제가 있음.\n setSnackItemStack((prev) => {\n if (prev.length === 0) {\n return [...prev, { message, type, index: index, snackbarDuration: snackbarDuration }];\n } else {\n return prev;\n };\n });\n };\n\n const hideSnackBar = (index: number) => {\n setSnackItemStack((prev) => prev.filter((item) => item.index !== index));\n };\n\n const hideNotify = useCallback((option: HideOption) => {\n switch (option) {\n case 'alert':\n setAlertVisible(false);\n break;\n case 'snack':\n setSnackItemStack([]);\n break;\n case 'bottomSheet':\n bottomSheetRef.current?.handleVisible(false);\n break;\n case 'loader':\n setLoaderVisible(false);\n break;\n case 'popOver':\n setPopOverVisible(false);\n break;\n case 'all':\n setAlertVisible(false);\n setSnackItemStack([]);\n setLoaderVisible(false);\n setPopOverVisible(false);\n bottomSheetRef.current?.handleVisible(false);\n break;\n default:\n break;\n };\n }, []);\n\n\n return (\n <NotifyContext.Provider value={{\n alertVisible,\n setAlertVisible,\n // ---\n snackItemStack,\n hideSnackBar,\n // ---\n bottomSheetVisible,\n setBottomSheetVisible,\n // ---\n loaderVisible,\n // ---\n popOverVisible,\n setPopOverVisible,\n // ---\n showAlert,\n showSnackBar,\n showBottomSheet,\n showLoader,\n showPopOverMenu,\n // ---\n hideNotify,\n }}>\n {children}\n\n <BottomSheetNotify\n ref={bottomSheetRef}\n bottomSheetComponent={bottomSheetComponent}\n contentsGestureEnable={contentsGestureEnable}\n bottomSheetPadding={bottomSheetPadding}\n marginBottomBS={marginBottomBS}\n isHandleVisible={handleVisible}\n bottomSheetMarginX={bottomSheetMarginX}\n isBottomRadius={isBottomRadius}\n bottomSheetBackgroundColor={bottomSheetBackgroundColor}\n maxHeight={bottomSheetMaxHeight}\n isScrollView={bottomSheetScrollView}\n />\n\n <PopOverMenu\n px={popOverLocation?.px}\n py={popOverLocation?.py}\n component={popOverComponent}\n />\n\n <SnackbarNotify\n customSnackbar={customSnackbar}\n />\n\n <AlertNotify\n title={title}\n informative={informative}\n actions={actions || {} as AlertActions}\n isBackgroundTouchClose={isBackgroundTouchClose}\n titleStyle={titleStyle}\n informativeStyle={informativeStyle}\n secondaryButtonStyle={secondaryButtonStyle}\n primaryButtonStyle={primaryButtonStyle}\n secondaryButtonTextStyle={secondaryButtonTextStyle}\n primaryButtonTextStyle={primaryButtonTextStyle}\n singleButtonTextStyle={singleButtonTextStyle}\n />\n\n <LoadingNotify\n loaderComponent={loaderComponent}\n />\n </NotifyContext.Provider>\n );\n}\n"]}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Theme, ThemeFonts, TypographyVariantsProps } from '../theme/types';
|
|
3
|
+
export interface ThemeProviderProps {
|
|
4
|
+
themeFonts?: ThemeFonts;
|
|
5
|
+
children: React.ReactNode;
|
|
6
|
+
}
|
|
7
|
+
export interface ThemeProps {
|
|
8
|
+
palette: Palette;
|
|
9
|
+
typography: TypographyVariantsProps;
|
|
10
|
+
}
|
|
11
|
+
export interface Palette extends Theme {
|
|
12
|
+
mode: 'light' | 'dark';
|
|
13
|
+
isUsingSystemColorScheme: boolean;
|
|
14
|
+
setUseSystemColorScheme: (useSystem: boolean) => void;
|
|
15
|
+
toggleTheme: () => void;
|
|
16
|
+
}
|
|
17
|
+
export declare const useTheme: () => ThemeProps;
|
|
18
|
+
export declare const ThemeProvider: React.FC<ThemeProviderProps>;
|
|
19
|
+
//# sourceMappingURL=useThemeProvider.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useThemeProvider.d.ts","sourceRoot":"","sources":["../../src/model/useThemeProvider.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAkE,MAAM,OAAO,CAAC;AAIvF,OAAO,EAAE,KAAK,EAAE,UAAU,EAAE,uBAAuB,EAAE,MAAM,gBAAgB,CAAC;AAG5E,MAAM,WAAW,kBAAkB;IAC/B,UAAU,CAAC,EAAE,UAAU,CAAC;IACxB,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;CAC7B;AAED,MAAM,WAAW,UAAU;IACvB,OAAO,EAAE,OAAO,CAAC;IACjB,UAAU,EAAE,uBAAuB,CAAC;CACvC;AAED,MAAM,WAAW,OAAQ,SAAQ,KAAK;IAClC,IAAI,EAAE,OAAO,GAAG,MAAM,CAAC;IACvB,wBAAwB,EAAE,OAAO,CAAC;IAClC,uBAAuB,EAAE,CAAC,SAAS,EAAE,OAAO,KAAK,IAAI,CAAC;IACtD,WAAW,EAAE,MAAM,IAAI,CAAC;CAC3B;AAID,eAAO,MAAM,QAAQ,kBAMpB,CAAA;AAED,eAAO,MAAM,aAAa,EAAE,KAAK,CAAC,EAAE,CAAC,kBAAkB,CAgEtD,CAAA"}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import React, { createContext, useContext, useMemo, useState, useEffect } from 'react';
|
|
2
|
+
import { useColorScheme } from 'react-native';
|
|
3
|
+
import AsyncStorage from '@react-native-async-storage/async-storage';
|
|
4
|
+
import palette from '../theme/palette';
|
|
5
|
+
import typography from '../theme/typography';
|
|
6
|
+
const ThemeContext = createContext(null);
|
|
7
|
+
export const useTheme = () => {
|
|
8
|
+
const context = useContext(ThemeContext);
|
|
9
|
+
if (!context) {
|
|
10
|
+
throw new Error('useTheme must be used within a ThemeProvider');
|
|
11
|
+
}
|
|
12
|
+
return context;
|
|
13
|
+
};
|
|
14
|
+
export const ThemeProvider = ({ themeFonts, children }) => {
|
|
15
|
+
const systemColorScheme = useColorScheme(); // 시스템 다크 모드 감지
|
|
16
|
+
const [isUsingSystemColorScheme, setUseSystemColorScheme] = useState(true);
|
|
17
|
+
const [mode, setMode] = useState(systemColorScheme === 'dark' ? 'dark' : 'light');
|
|
18
|
+
// AsyncStorage에서 시스템 모드 사용 설정 값 로드
|
|
19
|
+
useEffect(() => {
|
|
20
|
+
const loadSettings = async () => {
|
|
21
|
+
try {
|
|
22
|
+
const storedUseSystemColorScheme = await AsyncStorage.getItem('useSystemColorScheme');
|
|
23
|
+
if (storedUseSystemColorScheme !== null) {
|
|
24
|
+
setUseSystemColorScheme(storedUseSystemColorScheme === 'true');
|
|
25
|
+
}
|
|
26
|
+
const storedMode = await AsyncStorage.getItem('themeMode');
|
|
27
|
+
if (storedMode) {
|
|
28
|
+
setMode(storedMode === 'dark' ? 'dark' : 'light');
|
|
29
|
+
}
|
|
30
|
+
else {
|
|
31
|
+
setMode(systemColorScheme === 'dark' ? 'dark' : 'light');
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
catch (error) {
|
|
35
|
+
console.error('Failed to load theme settings', error);
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
loadSettings();
|
|
39
|
+
}, [systemColorScheme]);
|
|
40
|
+
// 시스템 다크 모드 변경에 따른 효과 적용
|
|
41
|
+
useEffect(() => {
|
|
42
|
+
if (isUsingSystemColorScheme) {
|
|
43
|
+
setMode(systemColorScheme === 'dark' ? 'dark' : 'light');
|
|
44
|
+
}
|
|
45
|
+
}, [systemColorScheme, isUsingSystemColorScheme]);
|
|
46
|
+
// 테마 토글 함수
|
|
47
|
+
const toggleTheme = async () => {
|
|
48
|
+
setUseSystemColorScheme(false); // 사용자 지정 모드로 전환
|
|
49
|
+
setMode((prevMode) => {
|
|
50
|
+
const newMode = prevMode === 'light' ? 'dark' : 'light';
|
|
51
|
+
AsyncStorage.setItem('themeMode', newMode); // 로컬스토리지에 저장
|
|
52
|
+
return newMode;
|
|
53
|
+
});
|
|
54
|
+
};
|
|
55
|
+
// 시스템 모드 사용 설정 변경 함수
|
|
56
|
+
const handleSetUseSystemColorScheme = async (useSystem) => {
|
|
57
|
+
setUseSystemColorScheme(useSystem);
|
|
58
|
+
await AsyncStorage.setItem('useSystemColorScheme', useSystem.toString());
|
|
59
|
+
};
|
|
60
|
+
const themeValue = useMemo(() => ({
|
|
61
|
+
palette: {
|
|
62
|
+
isUsingSystemColorScheme,
|
|
63
|
+
setUseSystemColorScheme: handleSetUseSystemColorScheme,
|
|
64
|
+
toggleTheme,
|
|
65
|
+
...palette({ mode }), // 선택된 모드에 따른 팔레트 적용
|
|
66
|
+
},
|
|
67
|
+
typography: typography({ themeFonts }),
|
|
68
|
+
}), [mode, isUsingSystemColorScheme, typography, themeFonts]);
|
|
69
|
+
return (<ThemeContext.Provider value={themeValue}>
|
|
70
|
+
{children}
|
|
71
|
+
</ThemeContext.Provider>);
|
|
72
|
+
};
|
|
73
|
+
//# sourceMappingURL=useThemeProvider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useThemeProvider.js","sourceRoot":"","sources":["../../src/model/useThemeProvider.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,aAAa,EAAE,UAAU,EAAE,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACvF,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,YAAY,MAAM,2CAA2C,CAAC;AACrE,OAAO,OAAO,MAAM,kBAAkB,CAAC;AAEvC,OAAO,UAAU,MAAM,qBAAqB,CAAC;AAmB7C,MAAM,YAAY,GAAG,aAAa,CAAoB,IAAI,CAAC,CAAC;AAE5D,MAAM,CAAC,MAAM,QAAQ,GAAG,GAAG,EAAE;IACzB,MAAM,OAAO,GAAG,UAAU,CAAC,YAAY,CAAC,CAAC;IACzC,IAAI,CAAC,OAAO,EAAE,CAAC;QACX,MAAM,IAAI,KA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AU,EAAE,UAAU,CAAC,CAAC,CAAC;IAE9D,OAAO,CACH,CAAC,YAAY,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,UAAU,CAAC,CACrC;YAAA,CAAC,QAAQ,CACb;QAAA,EAAE,YAAY,CAAC,QAAQ,CAAC,CAC3B,CAAC;AACN,CAAC,CAAA","sourcesContent":["import React, { createContext, useContext, useMemo, useState, useEffect } from 'react';\nimport { useColorScheme } from 'react-native';\nimport AsyncStorage from '@react-native-async-storage/async-storage';\nimport palette from '../theme/palette';\nimport { Theme, ThemeFonts, TypographyVariantsProps } from '../theme/types';\nimport typography from '../theme/typography';\n\nexport interface ThemeProviderProps {\n themeFonts?: ThemeFonts;\n children: React.ReactNode;\n}\n\nexport interface ThemeProps {\n palette: Palette;\n typography: TypographyVariantsProps;\n}\n\nexport interface Palette extends Theme {\n mode: 'light' | 'dark';\n isUsingSystemColorScheme: boolean;\n setUseSystemColorScheme: (useSystem: boolean) => void;\n toggleTheme: () => void;\n}\n\nconst ThemeContext = createContext<ThemeProps | null>(null);\n\nexport const useTheme = () => {\n const context = useContext(ThemeContext);\n if (!context) {\n throw new Error('useTheme must be used within a ThemeProvider');\n }\n return context;\n}\n\nexport const ThemeProvider: React.FC<ThemeProviderProps> = ({ themeFonts, children }) => {\n const systemColorScheme = useColorScheme(); // 시스템 다크 모드 감지\n const [isUsingSystemColorScheme, setUseSystemColorScheme] = useState(true);\n const [mode, setMode] = useState<'light' | 'dark'>(systemColorScheme === 'dark' ? 'dark' : 'light');\n\n // AsyncStorage에서 시스템 모드 사용 설정 값 로드\n useEffect(() => {\n const loadSettings = async () => {\n try {\n const storedUseSystemColorScheme = await AsyncStorage.getItem('useSystemColorScheme');\n if (storedUseSystemColorScheme !== null) {\n setUseSystemColorScheme(storedUseSystemColorScheme === 'true');\n }\n const storedMode = await AsyncStorage.getItem('themeMode');\n if (storedMode) {\n setMode(storedMode === 'dark' ? 'dark' : 'light');\n } else {\n setMode(systemColorScheme === 'dark' ? 'dark' : 'light');\n }\n } catch (error) {\n console.error('Failed to load theme settings', error);\n }\n };\n loadSettings();\n }, [systemColorScheme]);\n\n // 시스템 다크 모드 변경에 따른 효과 적용\n useEffect(() => {\n if (isUsingSystemColorScheme) {\n setMode(systemColorScheme === 'dark' ? 'dark' : 'light');\n }\n }, [systemColorScheme, isUsingSystemColorScheme]);\n\n // 테마 토글 함수\n const toggleTheme = async () => {\n setUseSystemColorScheme(false); // 사용자 지정 모드로 전환\n setMode((prevMode) => {\n const newMode = prevMode === 'light' ? 'dark' : 'light';\n AsyncStorage.setItem('themeMode', newMode); // 로컬스토리지에 저장\n return newMode;\n });\n };\n\n // 시스템 모드 사용 설정 변경 함수\n const handleSetUseSystemColorScheme = async (useSystem: boolean) => {\n setUseSystemColorScheme(useSystem);\n await AsyncStorage.setItem('useSystemColorScheme', useSystem.toString());\n };\n\n const themeValue = useMemo(() => ({\n palette: {\n isUsingSystemColorScheme,\n setUseSystemColorScheme: handleSetUseSystemColorScheme,\n toggleTheme,\n ...palette({ mode }), // 선택된 모드에 따른 팔레트 적용\n },\n typography: typography({ themeFonts }),\n }), [mode, isUsingSystemColorScheme, typography, themeFonts]);\n\n return (\n <ThemeContext.Provider value={themeValue}>\n {children}\n </ThemeContext.Provider>\n );\n}\n"]}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { StyleProp, TextStyle } from "react-native";
|
|
2
|
+
/**
|
|
3
|
+
* 사각형의 너비와 높이에 따라 비슷한 비율의 테두리 반지름을 계산합니다.
|
|
4
|
+
* @param width 사각형의 너비입니다.
|
|
5
|
+
* @param height 사각형의 높이입니다.
|
|
6
|
+
* @param borderRadius 기본 테두리 반지름입니다.
|
|
7
|
+
* @returns 계산된 테두리 반지름입니다.
|
|
8
|
+
*/
|
|
9
|
+
export declare const calculateRadius: (width: number, height: number, borderRadius: number) => number;
|
|
10
|
+
export declare const withPromise: <T extends unknown[]>(fn: (...args: T) => Promise<unknown>) => ((...args: T) => void);
|
|
11
|
+
export declare const extractStyle: (style: StyleProp<TextStyle>, attribute: keyof TextStyle) => TextStyle[keyof TextStyle] | undefined;
|
|
12
|
+
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/model/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAEpD;;;;;;GAMG;AACH,eAAO,MAAM,eAAe,UAAW,MAAM,UAAU,MAAM,gBAAgB,MAAM,WAIlF,CAAC;AAEF,eAAO,MAAM,WAAW,GAAI,CAAC,SAAS,OAAO,EAAE,MAAM,CAAC,GAAG,IAAI,EAAE,CAAC,KAAK,OAAO,CAAC,OAAO,CAAC,KAAG,CAAC,CAAC,GAAG,IAAI,EAAE,CAAC,KAAK,IAAI,CAE5G,CAAC;AAEF,eAAO,MAAM,YAAY,UACd,SAAS,CAAC,SAAS,CAAC,aAChB,MAAM,SAAS,KAC3B,SAAS,CAAC,MAAM,SAAS,CAAC,GAAG,SAQ/B,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 사각형의 너비와 높이에 따라 비슷한 비율의 테두리 반지름을 계산합니다.
|
|
3
|
+
* @param width 사각형의 너비입니다.
|
|
4
|
+
* @param height 사각형의 높이입니다.
|
|
5
|
+
* @param borderRadius 기본 테두리 반지름입니다.
|
|
6
|
+
* @returns 계산된 테두리 반지름입니다.
|
|
7
|
+
*/
|
|
8
|
+
export const calculateRadius = (width, height, borderRadius) => {
|
|
9
|
+
const radiusRatio = Math.max((width / height), (height / width));
|
|
10
|
+
const calc = borderRadius * (radiusRatio > 1 ? radiusRatio / 2 : radiusRatio);
|
|
11
|
+
return calc;
|
|
12
|
+
};
|
|
13
|
+
export const withPromise = (fn) => {
|
|
14
|
+
return (...args) => { void fn(...args); };
|
|
15
|
+
};
|
|
16
|
+
export const extractStyle = (style, attribute) => {
|
|
17
|
+
if (Array.isArray(style)) {
|
|
18
|
+
const foundStyle = style.find(item => typeof item === 'object' && item !== null && attribute in item);
|
|
19
|
+
return foundStyle?.[attribute];
|
|
20
|
+
}
|
|
21
|
+
else if (typeof style === 'object' && style !== null && attribute in style) {
|
|
22
|
+
return style[attribute];
|
|
23
|
+
}
|
|
24
|
+
return undefined;
|
|
25
|
+
};
|
|
26
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/model/utils.ts"],"names":[],"mappings":"AAEA;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,KAAa,EAAE,MAAc,EAAE,YAAoB,EAAE,EAAE;IACnF,MAAM,WAAW,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,KAAK,GAAG,MAAM,CAAC,EAAE,CAAC,MAAM,GAAG,KAAK,CAAC,CAAC,CAAC;IACjE,MAAM,IAAI,GAAG,YAAY,GAAG,CAAC,WAAW,GAAG,CAAC,CAAC,CAAC,CAAC,WAAW,GAAG,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC;IAC9E,OAAO,IAAI,CAAC;AAChB,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,WAAW,GAAG,CAAsB,EAAoC,EAA0B,EAAE;IAC7G,OAAO,CAAC,GAAG,IAAI,EAAE,EAAE,GAAG,KAAK,EAAE,CAAC,GAAG,IAAI,CAAC,CAAA,CAAC,CAAC,CAAC;AAC7C,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,YAAY,GAAG,CACxB,KAA2B,EAC3B,SAA0B,EACY,EAAE;IACxC,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QACvB,MAAM,UAAU,GAAG,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,OAAO,IAAI,KAAK,QAAQ,IAAI,IAAI,KAAK,IAAI,IAAI,SAAS,IAAI,IAAI,CAAC,CAAC;QACtG,OAAO,UAAU,EAAE,CAAC,SAAoC,CAAC,CAAC;IAC9D,CAAC;SAAM,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,SAAS,IAAI,KAAK,EAAE,CAAC;QAC3E,OAAO,KAAK,CAAC,SAAS,CAAC,CAAC;IAC5B,CAAC;IACD,OAAO,SAAS,CAAC;AACrB,CAAC,CAAC","sourcesContent":["import { StyleProp, TextStyle } from \"react-native\";\n\n/**\n * 사각형의 너비와 높이에 따라 비슷한 비율의 테두리 반지름을 계산합니다.\n * @param width 사각형의 너비입니다.\n * @param height 사각형의 높이입니다.\n * @param borderRadius 기본 테두리 반지름입니다.\n * @returns 계산된 테두리 반지름입니다.\n */\nexport const calculateRadius = (width: number, height: number, borderRadius: number) => {\n const radiusRatio = Math.max((width / height), (height / width));\n const calc = borderRadius * (radiusRatio > 1 ? radiusRatio / 2 : radiusRatio);\n return calc;\n};\n\nexport const withPromise = <T extends unknown[]>(fn: (...args: T) => Promise<unknown>): ((...args: T) => void) => {\n return (...args) => { void fn(...args) };\n};\n\nexport const extractStyle = (\n style: StyleProp<TextStyle>,\n attribute: keyof TextStyle\n): TextStyle[keyof TextStyle] | undefined => {\n if (Array.isArray(style)) {\n const foundStyle = style.find(item => typeof item === 'object' && item !== null && attribute in item);\n return foundStyle?.[attribute as keyof typeof foundStyle];\n } else if (typeof style === 'object' && style !== null && attribute in style) {\n return style[attribute];\n }\n return undefined;\n};\n"]}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { ShowAlertProps } from '../../model/types';
|
|
3
|
+
declare function AlertNotify({ actions, title, informative, isBackgroundTouchClose, titleStyle, informativeStyle, secondaryButtonStyle, primaryButtonStyle, secondaryButtonTextStyle, primaryButtonTextStyle, singleButtonTextStyle, }: ShowAlertProps): React.JSX.Element | null;
|
|
4
|
+
export default AlertNotify;
|
|
5
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/notify/AlertNotify/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA0C,MAAM,OAAO,CAAC;AAG/D,OAAO,EAAgB,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAUjE,iBAAS,WAAW,CAAC,EACnB,OAAO,EACP,KAAK,EACL,WAAW,EACX,sBAAsB,EACtB,UAAU,EACV,gBAAgB,EAChB,oBAAoB,EACpB,kBAAkB,EAClB,wBAAwB,EACxB,sBAAsB,EACtB,qBAAqB,GACtB,EAAE,cAAc,4BAwGhB;AAED,eAAe,WAAW,CAAC"}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import React, { useCallback, useEffect, useMemo } from 'react';
|
|
2
|
+
import { Dimensions, KeyboardAvoidingView, Platform, Pressable, StyleSheet, TouchableOpacity, BackHandler } from 'react-native';
|
|
3
|
+
import Animated, { FadeInDown, FadeOutDown } from 'react-native-reanimated';
|
|
4
|
+
import { useNotify } from '../../model/useNotify';
|
|
5
|
+
import { useTheme } from '../../model/useThemeProvider';
|
|
6
|
+
import { ZSText } from '../../ui';
|
|
7
|
+
import ModalBackground from '../ui/ModalBackground';
|
|
8
|
+
import ViewAtom from '../../ui/atoms/ViewAtom';
|
|
9
|
+
const modalWidth = Dimensions.get('window').width - 60;
|
|
10
|
+
function AlertNotify({ actions, title, informative, isBackgroundTouchClose, titleStyle, informativeStyle, secondaryButtonStyle, primaryButtonStyle, secondaryButtonTextStyle, primaryButtonTextStyle, singleButtonTextStyle, }) {
|
|
11
|
+
const { alertVisible, setAlertVisible } = useNotify();
|
|
12
|
+
const { palette: { background, text, primary: primaryColor } } = useTheme();
|
|
13
|
+
const styles = useMemo(() => createStyles({ background }), [background, text, primaryColor]);
|
|
14
|
+
// 버튼 클릭 핸들러 함수, 콜백 메모이제이션으로 성능 최적화
|
|
15
|
+
const handleButtonPress = useCallback((onPressFunction) => () => {
|
|
16
|
+
if (onPressFunction) {
|
|
17
|
+
onPressFunction();
|
|
18
|
+
}
|
|
19
|
+
setAlertVisible(false);
|
|
20
|
+
}, [setAlertVisible]);
|
|
21
|
+
// 뒤로가기 버튼 핸들러 함수
|
|
22
|
+
const backPressHandler = useCallback(() => {
|
|
23
|
+
if (alertVisible) {
|
|
24
|
+
setAlertVisible(false);
|
|
25
|
+
return true;
|
|
26
|
+
}
|
|
27
|
+
return false;
|
|
28
|
+
}, [alertVisible, setAlertVisible]);
|
|
29
|
+
// 뒤로가기 버튼 리스너 설정
|
|
30
|
+
useEffect(() => {
|
|
31
|
+
const backHandler = BackHandler.addEventListener('hardwareBackPress', backPressHandler);
|
|
32
|
+
return () => backHandler.remove();
|
|
33
|
+
}, [backPressHandler]);
|
|
34
|
+
// content를 useMemo로 감싸서 불필요한 재렌더링 방지
|
|
35
|
+
const content = useMemo(() => {
|
|
36
|
+
const { primary, secondary } = actions || {};
|
|
37
|
+
return (<Animated.View entering={FadeInDown.duration(300)} exiting={FadeOutDown.duration(100)}>
|
|
38
|
+
<Pressable style={[styles.contentContainer, { width: modalWidth }]}>
|
|
39
|
+
{title && (<ZSText typo='title.2' style={[styles.title, titleStyle]}>{title}</ZSText>)}
|
|
40
|
+
{informative && (<ZSText typo='body.3' style={[styles.informative, informativeStyle]}>{informative}</ZSText>)}
|
|
41
|
+
{actions && (<ViewAtom style={styles.buttonContainer}>
|
|
42
|
+
{secondary ? (<>
|
|
43
|
+
<TouchableOpacity style={[
|
|
44
|
+
styles.button,
|
|
45
|
+
{ backgroundColor: background.neutral, marginRight: 8 },
|
|
46
|
+
secondaryButtonStyle
|
|
47
|
+
]} onPress={handleButtonPress(secondary?.onPress)}>
|
|
48
|
+
<ZSText typo='subTitle.2' style={[secondaryButtonTextStyle]}>{secondary.label}</ZSText>
|
|
49
|
+
</TouchableOpacity>
|
|
50
|
+
|
|
51
|
+
<TouchableOpacity style={[styles.button, { backgroundColor: primaryColor.main }, primaryButtonStyle]} onPress={handleButtonPress(primary?.onPress)}>
|
|
52
|
+
<ZSText typo='subTitle.2' color='white' style={[secondaryButtonTextStyle]}>{primary?.label}</ZSText>
|
|
53
|
+
</TouchableOpacity>
|
|
54
|
+
</>) : (<TouchableOpacity onPress={handleButtonPress(primary?.onPress)} hitSlop={{ top: 10, bottom: 10, left: 10, right: 10 }}>
|
|
55
|
+
<TouchableOpacity style={[styles.button, { backgroundColor: primaryColor.main }, primaryButtonStyle]} onPress={handleButtonPress(primary?.onPress)}>
|
|
56
|
+
<ZSText typo='subTitle.2' color='white' style={[secondaryButtonTextStyle]}>{primary?.label || '확인'}</ZSText>
|
|
57
|
+
</TouchableOpacity>
|
|
58
|
+
</TouchableOpacity>)}
|
|
59
|
+
</ViewAtom>)}
|
|
60
|
+
</Pressable>
|
|
61
|
+
</Animated.View>);
|
|
62
|
+
}, [title, informative, actions, handleButtonPress, titleStyle, informativeStyle, secondaryButtonStyle, primaryButtonStyle, secondaryButtonTextStyle, primaryButtonTextStyle, singleButtonTextStyle]);
|
|
63
|
+
return alertVisible ? (<ModalBackground onPress={() => { if (isBackgroundTouchClose)
|
|
64
|
+
setAlertVisible(false); }}>
|
|
65
|
+
<KeyboardAvoidingView style={styles.avoidingView} behavior={Platform.OS === 'ios' ? 'padding' : undefined} enabled>
|
|
66
|
+
{content}
|
|
67
|
+
</KeyboardAvoidingView>
|
|
68
|
+
</ModalBackground>) : null;
|
|
69
|
+
}
|
|
70
|
+
export default AlertNotify;
|
|
71
|
+
const createStyles = ({ background, }) => StyleSheet.create({
|
|
72
|
+
title: {
|
|
73
|
+
marginBottom: 8,
|
|
74
|
+
width: '100%',
|
|
75
|
+
paddingHorizontal: 4
|
|
76
|
+
},
|
|
77
|
+
informative: {
|
|
78
|
+
marginTop: 8,
|
|
79
|
+
width: '100%',
|
|
80
|
+
paddingHorizontal: 4
|
|
81
|
+
},
|
|
82
|
+
buttonContainer: {
|
|
83
|
+
flexDirection: 'row',
|
|
84
|
+
width: '100%',
|
|
85
|
+
marginTop: 24,
|
|
86
|
+
alignItems: 'center',
|
|
87
|
+
justifyContent: 'flex-end',
|
|
88
|
+
},
|
|
89
|
+
button: {
|
|
90
|
+
flex: 1,
|
|
91
|
+
justifyContent: 'center',
|
|
92
|
+
alignItems: 'center',
|
|
93
|
+
paddingVertical: 14,
|
|
94
|
+
borderRadius: 12,
|
|
95
|
+
},
|
|
96
|
+
avoidingView: {
|
|
97
|
+
flex: 1,
|
|
98
|
+
justifyContent: 'center'
|
|
99
|
+
},
|
|
100
|
+
contentContainer: {
|
|
101
|
+
alignItems: 'center',
|
|
102
|
+
backgroundColor: background.base,
|
|
103
|
+
borderRadius: 22,
|
|
104
|
+
paddingBottom: 18,
|
|
105
|
+
paddingTop: 24,
|
|
106
|
+
paddingHorizontal: 20
|
|
107
|
+
},
|
|
108
|
+
});
|
|
109
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/notify/AlertNotify/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,WAAW,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAC/D,OAAO,EAAE,UAAU,EAAE,oBAAoB,EAAE,QAAQ,EAAE,SAAS,EAAE,UAAU,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAChI,OAAO,QAAQ,EAAE,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAE5E,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAClD,OAAO,EAAE,QAAQ,EAAE,MAAM,8BAA8B,CAAC;AAExD,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,eAAe,MAAM,uBAAuB,CAAC;AACpD,OAAO,QAAQ,MAAM,yBAAyB,CAAC;AAE/C,MAAM,UAAU,GAAG,UAAU,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AAC;KACrB;IACD,eAAe,EAAE;QACf,aAAa,EAAE,KAAK;QACpB,KAAK,EAAE,MAAM;QACb,SAAS,EAAE,EAAE;QACb,UAAU,EAAE,QAAQ;QACpB,cAAc,EAAE,UAAU;KAC3B;IACD,MAAM,EAAE;QACN,IAAI,EAAE,CAAC;QACP,cAAc,EAAE,QAAQ;QACxB,UAAU,EAAE,QAAQ;QACpB,eAAe,EAAE,EAAE;QACnB,YAAY,EAAE,EAAE;KACjB;IACD,YAAY,EAAE;QACZ,IAAI,EAAE,CAAC;QACP,cAAc,EAAE,QAAQ;KACzB;IACD,gBAAgB,EAAE;QAChB,UAAU,EAAE,QAAQ;QACpB,eAAe,EAAE,UAAU,CAAC,IAAI;QAChC,YAAY,EAAE,EAAE;QAChB,aAAa,EAAE,EAAE;QACjB,UAAU,EAAE,EAAE;QACd,iBAAiB,EAAE,EAAE;KACtB;CACF,CAAC,CAAC","sourcesContent":["import React, { useCallback, useEffect, useMemo } from 'react';\nimport { Dimensions, KeyboardAvoidingView, Platform, Pressable, StyleSheet, TouchableOpacity, BackHandler } from 'react-native';\nimport Animated, { FadeInDown, FadeOutDown } from 'react-native-reanimated';\nimport { AlertActions, ShowAlertProps } from '../../model/types';\nimport { useNotify } from '../../model/useNotify';\nimport { useTheme } from '../../model/useThemeProvider';\nimport { ThemeBackground } from '../../theme';\nimport { ZSText } from '../../ui';\nimport ModalBackground from '../ui/ModalBackground';\nimport ViewAtom from '../../ui/atoms/ViewAtom';\n\nconst modalWidth = Dimensions.get('window').width - 60;\n\nfunction AlertNotify({\n actions,\n title,\n informative,\n isBackgroundTouchClose,\n titleStyle,\n informativeStyle,\n secondaryButtonStyle,\n primaryButtonStyle,\n secondaryButtonTextStyle,\n primaryButtonTextStyle,\n singleButtonTextStyle,\n}: ShowAlertProps) {\n const { alertVisible, setAlertVisible } = useNotify();\n const { palette: { background, text, primary: primaryColor } } = useTheme();\n\n const styles = useMemo(\n () => createStyles({ background }),\n [background, text, primaryColor]\n );\n\n // 버튼 클릭 핸들러 함수, 콜백 메모이제이션으로 성능 최적화\n const handleButtonPress = useCallback(\n (onPressFunction?: () => void) => () => {\n if (onPressFunction) {\n onPressFunction();\n }\n setAlertVisible(false);\n },\n [setAlertVisible]\n );\n\n // 뒤로가기 버튼 핸들러 함수\n const backPressHandler = useCallback(() => {\n if (alertVisible) {\n setAlertVisible(false);\n return true;\n }\n return false;\n }, [alertVisible, setAlertVisible]);\n\n // 뒤로가기 버튼 리스너 설정\n useEffect(() => {\n const backHandler = BackHandler.addEventListener('hardwareBackPress', backPressHandler);\n return () => backHandler.remove();\n }, [backPressHandler]);\n\n // content를 useMemo로 감싸서 불필요한 재렌더링 방지\n const content = useMemo(() => {\n const { primary, secondary } = actions || {} as AlertActions;\n\n return (\n <Animated.View\n entering={FadeInDown.duration(300)}\n exiting={FadeOutDown.duration(100)}\n >\n <Pressable style={[styles.contentContainer, { width: modalWidth }]}>\n {title && (\n <ZSText typo='title.2' style={[styles.title, titleStyle]}>{title}</ZSText>\n )}\n {informative && (\n <ZSText typo='body.3' style={[styles.informative, informativeStyle]}>{informative}</ZSText>\n )}\n {actions && (\n <ViewAtom style={styles.buttonContainer}>\n {secondary ? (\n <>\n <TouchableOpacity\n style={[\n styles.button,\n { backgroundColor: background.neutral, marginRight: 8 },\n secondaryButtonStyle\n ]}\n onPress={handleButtonPress(secondary?.onPress)}\n >\n <ZSText typo='subTitle.2' style={[secondaryButtonTextStyle]}>{secondary.label}</ZSText>\n </TouchableOpacity>\n\n <TouchableOpacity\n style={[styles.button, { backgroundColor: primaryColor.main }, primaryButtonStyle]}\n onPress={handleButtonPress(primary?.onPress)}\n >\n <ZSText typo='subTitle.2' color='white' style={[secondaryButtonTextStyle]}>{primary?.label}</ZSText>\n </TouchableOpacity>\n </>\n ) : (\n <TouchableOpacity\n onPress={handleButtonPress(primary?.onPress)}\n hitSlop={{ top: 10, bottom: 10, left: 10, right: 10 }}\n >\n <TouchableOpacity\n style={[styles.button, { backgroundColor: primaryColor.main }, primaryButtonStyle]}\n onPress={handleButtonPress(primary?.onPress)}\n >\n <ZSText typo='subTitle.2' color='white' style={[secondaryButtonTextStyle]}>{primary?.label || '확인'}</ZSText>\n </TouchableOpacity>\n </TouchableOpacity>\n )}\n </ViewAtom>\n )}\n </Pressable>\n </Animated.View>\n );\n }, [title, informative, actions, handleButtonPress, titleStyle, informativeStyle, secondaryButtonStyle, primaryButtonStyle, secondaryButtonTextStyle, primaryButtonTextStyle, singleButtonTextStyle]);\n\n return alertVisible ? (\n <ModalBackground onPress={() => { if (isBackgroundTouchClose) setAlertVisible(false); }}>\n <KeyboardAvoidingView\n style={styles.avoidingView}\n behavior={Platform.OS === 'ios' ? 'padding' : undefined}\n enabled\n >\n {content}\n </KeyboardAvoidingView>\n </ModalBackground>\n ) : null;\n}\n\nexport default AlertNotify;\n\nconst createStyles = ({\n background,\n}: {\n background: ThemeBackground;\n}) =>\n StyleSheet.create({\n title: {\n marginBottom: 8,\n width: '100%',\n paddingHorizontal: 4\n },\n informative: {\n marginTop: 8,\n width: '100%',\n paddingHorizontal: 4\n },\n buttonContainer: {\n flexDirection: 'row',\n width: '100%',\n marginTop: 24,\n alignItems: 'center',\n justifyContent: 'flex-end',\n },\n button: {\n flex: 1,\n justifyContent: 'center',\n alignItems: 'center',\n paddingVertical: 14,\n borderRadius: 12,\n },\n avoidingView: {\n flex: 1,\n justifyContent: 'center'\n },\n contentContainer: {\n alignItems: 'center',\n backgroundColor: background.base,\n borderRadius: 22,\n paddingBottom: 18,\n paddingTop: 24,\n paddingHorizontal: 20\n },\n });\n\n"]}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { ViewProps } from 'react-native';
|
|
3
|
+
import { BottomSheetNotifyRef } from './types';
|
|
4
|
+
interface Props extends ViewProps {
|
|
5
|
+
marginBottomBS?: number;
|
|
6
|
+
bottomSheetBackgroundColor?: string;
|
|
7
|
+
bottomSheetPadding?: number;
|
|
8
|
+
closeOffset?: number;
|
|
9
|
+
contentsGestureEnable?: boolean;
|
|
10
|
+
isHandleVisible?: boolean;
|
|
11
|
+
bottomSheetMarginX?: number;
|
|
12
|
+
isBottomRadius?: boolean;
|
|
13
|
+
maxHeight?: number;
|
|
14
|
+
isScrollView?: boolean;
|
|
15
|
+
bottomSheetComponent: React.ReactNode;
|
|
16
|
+
}
|
|
17
|
+
declare const _default: React.ForwardRefExoticComponent<Props & React.RefAttributes<BottomSheetNotifyRef>>;
|
|
18
|
+
export default _default;
|
|
19
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/notify/BottomSheetNotify/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAmD,MAAM,OAAO,CAAC;AACxE,OAAO,EAA0B,SAAS,EAAY,MAAM,cAAc,CAAC;AAI3E,OAAO,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAC;AAU/C,UAAU,KAAM,SAAQ,SAAS;IAC/B,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,0BAA0B,CAAC,EAAE,MAAM,CAAC;IACpC,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,qBAAqB,CAAC,EAAE,OAAO,CAAC;IAChC,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,oBAAoB,EAAE,KAAK,CAAC,SAAS,CAAC;CACvC;;AAqJD,wBAA6C"}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import React, { forwardRef, useImperativeHandle, useMemo } from 'react';
|
|
2
|
+
import { StyleSheet, Dimensions, Keyboard } from 'react-native';
|
|
3
|
+
import { GestureDetector, GestureHandlerRootView } from 'react-native-gesture-handler';
|
|
4
|
+
import Animated, { FadeIn, FadeOut } from 'react-native-reanimated';
|
|
5
|
+
import useBottomSheetNotify from './model/useBottomSheetNotify';
|
|
6
|
+
import ContentsComponent from './ui/ContentsComponent';
|
|
7
|
+
import { useTheme } from '../../model/useThemeProvider';
|
|
8
|
+
import ViewAtom from '../../ui/atoms/ViewAtom';
|
|
9
|
+
import { ZSView } from '../../ui';
|
|
10
|
+
const DEFAULT_BORDER_RADIUS = 24;
|
|
11
|
+
const BS_MAX_HEIGHT = Dimensions.get('window').height - 120;
|
|
12
|
+
function BottomSheetNotify(props, ref) {
|
|
13
|
+
const { marginBottomBS = 15, bottomSheetPadding = 20, bottomSheetBackgroundColor, closeOffset = Dimensions.get('window').height, contentsGestureEnable = true, isHandleVisible = true, bottomSheetMarginX = 10, isBottomRadius = true, isScrollView = true, maxHeight = BS_MAX_HEIGHT, bottomSheetComponent } = props;
|
|
14
|
+
const { HANDLE_HEIGHT, bottomSheetVisible, bsAnimatedStyle, onGestureEvent, handleVisible, onTapEvent, openPosition, screenWidth, screenHeight, panGestureRef, listScrollPosition, bsModalBgStyle, backgroundPressHandler } = useBottomSheetNotify({
|
|
15
|
+
bottomSheetPadding,
|
|
16
|
+
closeOffset,
|
|
17
|
+
contentsGestureEnable,
|
|
18
|
+
bottomSheetMarginX,
|
|
19
|
+
isHandleVisible,
|
|
20
|
+
});
|
|
21
|
+
const { palette: { background, text, primary, modalBgColor } } = useTheme();
|
|
22
|
+
const styles = useMemo(() => createStyles({ background, text, primary, modalBgColor }), [background, text, primary, modalBgColor]);
|
|
23
|
+
useImperativeHandle(ref, () => ({
|
|
24
|
+
handleVisible,
|
|
25
|
+
}));
|
|
26
|
+
return bottomSheetVisible && bottomSheetComponent ? (<Animated.View style={[styles.modalBg, bsModalBgStyle]} entering={FadeIn.duration(50)} exiting={FadeOut.duration(50)} onTouchEnd={backgroundPressHandler} // 외부 터치 시 시트 닫기
|
|
27
|
+
>
|
|
28
|
+
<GestureHandlerRootView style={styles.rootViewWrapper}>
|
|
29
|
+
<GestureDetector gesture={onGestureEvent}>
|
|
30
|
+
<Animated.View onTouchEnd={(e) => {
|
|
31
|
+
e.stopPropagation();
|
|
32
|
+
Keyboard.dismiss(); // 키보드 숨김
|
|
33
|
+
}} style={[
|
|
34
|
+
styles.sheet,
|
|
35
|
+
{
|
|
36
|
+
width: screenWidth,
|
|
37
|
+
height: screenHeight,
|
|
38
|
+
paddingHorizontal: bottomSheetPadding,
|
|
39
|
+
left: bottomSheetMarginX,
|
|
40
|
+
right: bottomSheetMarginX,
|
|
41
|
+
borderTopLeftRadius: DEFAULT_BORDER_RADIUS,
|
|
42
|
+
borderTopRightRadius: DEFAULT_BORDER_RADIUS,
|
|
43
|
+
borderBottomLeftRadius: isBottomRadius ? DEFAULT_BORDER_RADIUS : 0,
|
|
44
|
+
borderBottomRightRadius: isBottomRadius ? DEFAULT_BORDER_RADIUS : 0,
|
|
45
|
+
backgroundColor: bottomSheetBackgroundColor || background.base,
|
|
46
|
+
},
|
|
47
|
+
bsAnimatedStyle, // 애니메이션 스타일 적용
|
|
48
|
+
]}>
|
|
49
|
+
{isHandleVisible && (<ZSView style={[styles.handleContainer, { height: HANDLE_HEIGHT }]}>
|
|
50
|
+
<ViewAtom style={styles.handle}/>
|
|
51
|
+
</ZSView>)}
|
|
52
|
+
|
|
53
|
+
<GestureDetector gesture={onTapEvent}>
|
|
54
|
+
<ContentsComponent HANDLE_HEIGHT={HANDLE_HEIGHT} panGestureRef={panGestureRef} listScrollPosition={listScrollPosition} openPosition={openPosition} marginBottomBS={marginBottomBS} screenHeight={screenHeight} bottomSheetComponent={bottomSheetComponent} bottomSheetPadding={bottomSheetPadding} maxHeight={maxHeight} isScrollView={isScrollView}/>
|
|
55
|
+
</GestureDetector>
|
|
56
|
+
</Animated.View>
|
|
57
|
+
</GestureDetector>
|
|
58
|
+
</GestureHandlerRootView>
|
|
59
|
+
</Animated.View>) : null;
|
|
60
|
+
}
|
|
61
|
+
const createStyles = ({ background, text, primary, modalBgColor, }) => StyleSheet.create({
|
|
62
|
+
modalBg: {
|
|
63
|
+
position: 'absolute',
|
|
64
|
+
width: Dimensions.get('window').width,
|
|
65
|
+
height: Dimensions.get('window').height,
|
|
66
|
+
bottom: 0,
|
|
67
|
+
},
|
|
68
|
+
sheet: {
|
|
69
|
+
position: 'absolute',
|
|
70
|
+
zIndex: 9000,
|
|
71
|
+
overflow: 'hidden',
|
|
72
|
+
},
|
|
73
|
+
handleContainer: {
|
|
74
|
+
width: '100%',
|
|
75
|
+
alignItems: 'center',
|
|
76
|
+
paddingTop: 13,
|
|
77
|
+
},
|
|
78
|
+
handle: {
|
|
79
|
+
backgroundColor: background.layer2,
|
|
80
|
+
width: 50,
|
|
81
|
+
height: 4,
|
|
82
|
+
borderRadius: 2,
|
|
83
|
+
},
|
|
84
|
+
rootViewWrapper: {
|
|
85
|
+
width: '100%',
|
|
86
|
+
height: '100%',
|
|
87
|
+
},
|
|
88
|
+
});
|
|
89
|
+
export default forwardRef(BottomSheetNotify);
|
|
90
|
+
//# sourceMappingURL=index.js.map
|