@umituz/react-native-design-system 2.0.10 → 2.0.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/index.ts +14 -0
- package/src/molecules/BaseModal.tsx +98 -0
- package/src/molecules/index.ts +1 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@umituz/react-native-design-system",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.12",
|
|
4
4
|
"description": "Universal design system for React Native apps - Consolidated package with atoms, molecules, organisms, theme, typography, responsive and safe area utilities",
|
|
5
5
|
"main": "./src/index.ts",
|
|
6
6
|
"types": "./src/index.ts",
|
package/src/index.ts
CHANGED
|
@@ -94,6 +94,14 @@ export {
|
|
|
94
94
|
getResponsiveFABPosition,
|
|
95
95
|
getResponsiveModalMaxHeight,
|
|
96
96
|
getResponsiveMinModalHeight,
|
|
97
|
+
getResponsiveModalWidth,
|
|
98
|
+
getResponsiveModalHeight,
|
|
99
|
+
getResponsiveModalBorderRadius,
|
|
100
|
+
getResponsiveModalMaxWidth,
|
|
101
|
+
getResponsiveBackdropOpacity,
|
|
102
|
+
getResponsiveModalLayout,
|
|
103
|
+
getResponsiveBottomSheetLayout,
|
|
104
|
+
getResponsiveDialogLayout,
|
|
97
105
|
getResponsiveIconContainerSize,
|
|
98
106
|
getResponsiveGridColumns,
|
|
99
107
|
getResponsiveMaxWidth,
|
|
@@ -106,6 +114,10 @@ export {
|
|
|
106
114
|
PLATFORM_CONSTANTS,
|
|
107
115
|
isValidTouchTarget,
|
|
108
116
|
DeviceType,
|
|
117
|
+
type ResponsiveModalLayout,
|
|
118
|
+
type ResponsiveBottomSheetLayout,
|
|
119
|
+
type ResponsiveDialogLayout,
|
|
120
|
+
type UseResponsiveReturn,
|
|
109
121
|
} from './responsive';
|
|
110
122
|
|
|
111
123
|
// =============================================================================
|
|
@@ -161,8 +173,10 @@ export {
|
|
|
161
173
|
SearchBar,
|
|
162
174
|
IconContainer,
|
|
163
175
|
ScreenHeader,
|
|
176
|
+
BaseModal,
|
|
164
177
|
ConfirmationModal,
|
|
165
178
|
useConfirmationModal,
|
|
179
|
+
type BaseModalProps,
|
|
166
180
|
} from './molecules';
|
|
167
181
|
|
|
168
182
|
// =============================================================================
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* BaseModal Component
|
|
3
|
+
* Generic fullscreen modal with responsive design
|
|
4
|
+
* Used across all modals in the app for consistency
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import React from 'react';
|
|
8
|
+
import { View, Modal, StyleSheet, TouchableOpacity, ViewStyle } from 'react-native';
|
|
9
|
+
import { useAppDesignTokens } from '../theme';
|
|
10
|
+
import { useResponsive } from '../responsive';
|
|
11
|
+
|
|
12
|
+
export interface BaseModalProps {
|
|
13
|
+
visible: boolean;
|
|
14
|
+
onClose: () => void;
|
|
15
|
+
children: React.ReactNode;
|
|
16
|
+
dismissOnBackdrop?: boolean;
|
|
17
|
+
contentStyle?: ViewStyle;
|
|
18
|
+
testID?: string;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export const BaseModal: React.FC<BaseModalProps> = ({
|
|
22
|
+
visible,
|
|
23
|
+
onClose,
|
|
24
|
+
children,
|
|
25
|
+
dismissOnBackdrop = true,
|
|
26
|
+
contentStyle,
|
|
27
|
+
testID = 'base-modal',
|
|
28
|
+
}) => {
|
|
29
|
+
const tokens = useAppDesignTokens();
|
|
30
|
+
const { modalLayout } = useResponsive();
|
|
31
|
+
|
|
32
|
+
const handleBackdropPress = React.useCallback(() => {
|
|
33
|
+
if (dismissOnBackdrop) {
|
|
34
|
+
onClose();
|
|
35
|
+
}
|
|
36
|
+
}, [dismissOnBackdrop, onClose]);
|
|
37
|
+
|
|
38
|
+
if (!visible) return null;
|
|
39
|
+
|
|
40
|
+
return (
|
|
41
|
+
<Modal
|
|
42
|
+
visible={visible}
|
|
43
|
+
transparent
|
|
44
|
+
animationType="fade"
|
|
45
|
+
onRequestClose={onClose}
|
|
46
|
+
statusBarTranslucent
|
|
47
|
+
testID={testID}
|
|
48
|
+
>
|
|
49
|
+
<View style={styles.overlay}>
|
|
50
|
+
<TouchableOpacity
|
|
51
|
+
style={[
|
|
52
|
+
styles.backdrop,
|
|
53
|
+
{ backgroundColor: `rgba(0, 0, 0, ${modalLayout.backdropOpacity})` }
|
|
54
|
+
]}
|
|
55
|
+
activeOpacity={1}
|
|
56
|
+
onPress={handleBackdropPress}
|
|
57
|
+
testID={`${testID}-backdrop`}
|
|
58
|
+
/>
|
|
59
|
+
|
|
60
|
+
<View
|
|
61
|
+
style={[
|
|
62
|
+
styles.content,
|
|
63
|
+
{
|
|
64
|
+
width: modalLayout.width,
|
|
65
|
+
height: modalLayout.height,
|
|
66
|
+
borderRadius: modalLayout.borderRadius,
|
|
67
|
+
backgroundColor: tokens.colors.backgroundPrimary,
|
|
68
|
+
borderColor: tokens.colors.border,
|
|
69
|
+
},
|
|
70
|
+
contentStyle,
|
|
71
|
+
]}
|
|
72
|
+
testID={`${testID}-content`}
|
|
73
|
+
>
|
|
74
|
+
{children}
|
|
75
|
+
</View>
|
|
76
|
+
</View>
|
|
77
|
+
</Modal>
|
|
78
|
+
);
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
const styles = StyleSheet.create({
|
|
82
|
+
overlay: {
|
|
83
|
+
flex: 1,
|
|
84
|
+
justifyContent: 'center',
|
|
85
|
+
alignItems: 'center',
|
|
86
|
+
},
|
|
87
|
+
backdrop: {
|
|
88
|
+
position: 'absolute',
|
|
89
|
+
top: 0,
|
|
90
|
+
left: 0,
|
|
91
|
+
right: 0,
|
|
92
|
+
bottom: 0,
|
|
93
|
+
},
|
|
94
|
+
content: {
|
|
95
|
+
overflow: 'hidden',
|
|
96
|
+
borderWidth: 1,
|
|
97
|
+
},
|
|
98
|
+
});
|
package/src/molecules/index.ts
CHANGED
|
@@ -9,6 +9,7 @@ export { ListItem, type ListItemProps } from './ListItem';
|
|
|
9
9
|
export { SearchBar, type SearchBarProps } from './SearchBar';
|
|
10
10
|
export { IconContainer } from './IconContainer';
|
|
11
11
|
export { ScreenHeader, type ScreenHeaderProps } from './ScreenHeader';
|
|
12
|
+
export { BaseModal, type BaseModalProps } from './BaseModal';
|
|
12
13
|
export { ConfirmationModal } from './ConfirmationModalMain';
|
|
13
14
|
export { useConfirmationModal } from './confirmation-modal/useConfirmationModal';
|
|
14
15
|
|