@umituz/react-native-design-system 4.25.65 → 4.25.67
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": "4.25.
|
|
3
|
+
"version": "4.25.67",
|
|
4
4
|
"description": "Universal design system for React Native apps - Consolidated package with atoms, molecules, organisms, theme, typography, responsive, safe area, exception, infinite scroll, UUID, image, timezone, offline, onboarding, and loading utilities",
|
|
5
5
|
"main": "./src/index.ts",
|
|
6
6
|
"types": "./src/index.ts",
|
|
@@ -4,24 +4,33 @@
|
|
|
4
4
|
|
|
5
5
|
import React from 'react';
|
|
6
6
|
import { StyleSheet, View, Modal, Pressable } from 'react-native';
|
|
7
|
-
import { AtomicButton } from '../../atoms';
|
|
7
|
+
import { AtomicButton, AtomicText, AtomicIcon } from '../../atoms';
|
|
8
8
|
import { useAppDesignTokens } from '../../theme';
|
|
9
|
-
import { Alert } from './AlertTypes';
|
|
9
|
+
import { Alert, AlertType } from './AlertTypes';
|
|
10
10
|
import { getAlertBackgroundColor } from './utils/alertUtils';
|
|
11
11
|
import { useAlertDismissHandler } from './hooks';
|
|
12
|
-
import { AlertContent } from './components';
|
|
13
12
|
|
|
14
13
|
interface AlertModalProps {
|
|
15
14
|
alert: Alert;
|
|
16
15
|
}
|
|
17
16
|
|
|
17
|
+
const getAlertIconName = (type: AlertType): string => {
|
|
18
|
+
switch (type) {
|
|
19
|
+
case AlertType.SUCCESS: return 'checkmark-circle';
|
|
20
|
+
case AlertType.ERROR: return 'alertCircle';
|
|
21
|
+
case AlertType.WARNING: return 'alertCircle';
|
|
22
|
+
case AlertType.INFO: return 'info';
|
|
23
|
+
default: return 'info';
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
|
|
18
27
|
export const AlertModal: React.FC<AlertModalProps> = ({ alert }) => {
|
|
19
28
|
const tokens = useAppDesignTokens();
|
|
20
|
-
|
|
21
|
-
// Use shared hook (replaces 8 lines of duplicate code)
|
|
22
29
|
const handleClose = useAlertDismissHandler(alert);
|
|
23
30
|
|
|
24
|
-
const
|
|
31
|
+
const accentColor = getAlertBackgroundColor(alert.type, tokens);
|
|
32
|
+
const iconName = getAlertIconName(alert.type);
|
|
33
|
+
const hasTwoActions = alert.actions.length === 2;
|
|
25
34
|
|
|
26
35
|
return (
|
|
27
36
|
<Modal
|
|
@@ -39,47 +48,73 @@ export const AlertModal: React.FC<AlertModalProps> = ({ alert }) => {
|
|
|
39
48
|
styles.modal,
|
|
40
49
|
{
|
|
41
50
|
backgroundColor: tokens.colors.backgroundPrimary,
|
|
42
|
-
borderRadius: tokens.borders.radius.
|
|
51
|
+
borderRadius: tokens.borders.radius.xl ?? 20,
|
|
43
52
|
borderWidth: 1,
|
|
44
53
|
borderColor: tokens.colors.border,
|
|
45
54
|
}
|
|
46
55
|
]}>
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
56
|
+
{/* Icon circle */}
|
|
57
|
+
<View style={[
|
|
58
|
+
styles.iconCircle,
|
|
59
|
+
{ backgroundColor: accentColor + '22' }
|
|
60
|
+
]}>
|
|
61
|
+
<AtomicIcon
|
|
62
|
+
name={iconName}
|
|
63
|
+
customSize={36}
|
|
64
|
+
customColor={accentColor}
|
|
55
65
|
/>
|
|
56
66
|
</View>
|
|
57
67
|
|
|
58
|
-
|
|
68
|
+
{/* Title */}
|
|
69
|
+
<AtomicText
|
|
70
|
+
type="titleLarge"
|
|
71
|
+
style={[styles.title, { color: tokens.colors.textPrimary }]}
|
|
72
|
+
>
|
|
73
|
+
{alert.title}
|
|
74
|
+
</AtomicText>
|
|
75
|
+
|
|
76
|
+
{/* Message */}
|
|
77
|
+
{!!alert.message && (
|
|
78
|
+
<AtomicText
|
|
79
|
+
type="bodyMedium"
|
|
80
|
+
style={[styles.message, { color: tokens.colors.textSecondary }]}
|
|
81
|
+
>
|
|
82
|
+
{alert.message}
|
|
83
|
+
</AtomicText>
|
|
84
|
+
)}
|
|
59
85
|
|
|
60
|
-
|
|
61
|
-
|
|
86
|
+
{/* Actions */}
|
|
87
|
+
<View style={[
|
|
88
|
+
hasTwoActions ? styles.actionsRow : styles.actionsColumn,
|
|
89
|
+
{ marginTop: tokens.spacing.lg, gap: tokens.spacing.sm }
|
|
90
|
+
]}>
|
|
91
|
+
{alert.actions.length === 0 ? (
|
|
92
|
+
<AtomicButton
|
|
93
|
+
title="Close"
|
|
94
|
+
onPress={handleClose}
|
|
95
|
+
fullWidth
|
|
96
|
+
/>
|
|
97
|
+
) : (
|
|
98
|
+
alert.actions.map((action, index) => (
|
|
62
99
|
<AtomicButton
|
|
63
|
-
key={action.id}
|
|
100
|
+
key={action.id ?? String(index)}
|
|
64
101
|
title={action.label}
|
|
65
|
-
variant={
|
|
102
|
+
variant={
|
|
103
|
+
action.style === 'destructive' ? 'danger'
|
|
104
|
+
: action.style === 'secondary' ? 'outline'
|
|
105
|
+
: 'primary'
|
|
106
|
+
}
|
|
66
107
|
onPress={async () => {
|
|
67
108
|
await action.onPress();
|
|
68
109
|
if (action.closeOnPress ?? true) {
|
|
69
110
|
handleClose();
|
|
70
111
|
}
|
|
71
112
|
}}
|
|
72
|
-
fullWidth
|
|
113
|
+
fullWidth={!hasTwoActions}
|
|
114
|
+
style={hasTwoActions ? styles.actionButtonHalf : undefined}
|
|
73
115
|
/>
|
|
74
|
-
))
|
|
75
|
-
|
|
76
|
-
<AtomicButton
|
|
77
|
-
title="Close"
|
|
78
|
-
onPress={handleClose}
|
|
79
|
-
fullWidth
|
|
80
|
-
/>
|
|
81
|
-
)}
|
|
82
|
-
</View>
|
|
116
|
+
))
|
|
117
|
+
)}
|
|
83
118
|
</View>
|
|
84
119
|
</View>
|
|
85
120
|
</View>
|
|
@@ -92,25 +127,44 @@ const styles = StyleSheet.create({
|
|
|
92
127
|
flex: 1,
|
|
93
128
|
justifyContent: 'center',
|
|
94
129
|
alignItems: 'center',
|
|
95
|
-
padding:
|
|
130
|
+
padding: 24,
|
|
96
131
|
},
|
|
97
132
|
backdrop: {
|
|
98
133
|
...StyleSheet.absoluteFillObject,
|
|
99
|
-
backgroundColor: 'rgba(0,0,0,0.
|
|
134
|
+
backgroundColor: 'rgba(0,0,0,0.55)',
|
|
100
135
|
},
|
|
101
136
|
modal: {
|
|
102
137
|
width: '100%',
|
|
103
|
-
maxWidth:
|
|
104
|
-
|
|
105
|
-
},
|
|
106
|
-
header: {
|
|
107
|
-
padding: 20,
|
|
138
|
+
maxWidth: 360,
|
|
139
|
+
padding: 28,
|
|
108
140
|
alignItems: 'center',
|
|
109
141
|
},
|
|
110
|
-
|
|
142
|
+
iconCircle: {
|
|
143
|
+
width: 76,
|
|
144
|
+
height: 76,
|
|
145
|
+
borderRadius: 38,
|
|
146
|
+
justifyContent: 'center',
|
|
111
147
|
alignItems: 'center',
|
|
148
|
+
marginBottom: 20,
|
|
149
|
+
},
|
|
150
|
+
title: {
|
|
151
|
+
fontWeight: '700',
|
|
152
|
+
textAlign: 'center',
|
|
153
|
+
marginBottom: 8,
|
|
112
154
|
},
|
|
113
|
-
|
|
155
|
+
message: {
|
|
156
|
+
textAlign: 'center',
|
|
157
|
+
lineHeight: 22,
|
|
158
|
+
opacity: 0.85,
|
|
159
|
+
},
|
|
160
|
+
actionsRow: {
|
|
161
|
+
flexDirection: 'row',
|
|
114
162
|
width: '100%',
|
|
115
163
|
},
|
|
164
|
+
actionsColumn: {
|
|
165
|
+
width: '100%',
|
|
166
|
+
},
|
|
167
|
+
actionButtonHalf: {
|
|
168
|
+
flex: 1,
|
|
169
|
+
},
|
|
116
170
|
});
|
|
@@ -30,7 +30,10 @@ export class AlertService {
|
|
|
30
30
|
message,
|
|
31
31
|
position: options?.position || defaultPosition,
|
|
32
32
|
icon: options?.icon,
|
|
33
|
-
actions: options?.actions
|
|
33
|
+
actions: options?.actions?.map(action => ({
|
|
34
|
+
id: generateUUID(),
|
|
35
|
+
...action,
|
|
36
|
+
})) || [],
|
|
34
37
|
dismissible: options?.dismissible ?? true,
|
|
35
38
|
duration: options?.duration,
|
|
36
39
|
onDismiss: options?.onDismiss,
|