@umituz/react-native-design-system 2.0.10 → 2.0.11

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@umituz/react-native-design-system",
3
- "version": "2.0.10",
3
+ "version": "2.0.11",
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",
@@ -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
+ });
@@ -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