@umituz/react-native-design-system 4.25.88 → 4.25.90
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.90",
|
|
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": "./dist/index.d.ts",
|
|
@@ -28,7 +28,8 @@ export interface ComputedResponsivePositioning {
|
|
|
28
28
|
}
|
|
29
29
|
|
|
30
30
|
export const computeResponsivePositioning = (
|
|
31
|
-
insets: { top: number; bottom: number; left: number; right: number }
|
|
31
|
+
insets: { top: number; bottom: number; left: number; right: number },
|
|
32
|
+
dimensions?: { width: number; height: number }
|
|
32
33
|
): ComputedResponsivePositioning => ({
|
|
33
34
|
horizontalPadding: getResponsiveHorizontalPadding(undefined, insets),
|
|
34
35
|
verticalPadding: getResponsiveVerticalPadding(insets),
|
|
@@ -36,7 +37,7 @@ export const computeResponsivePositioning = (
|
|
|
36
37
|
fabPosition: getResponsiveFABPosition(insets),
|
|
37
38
|
screenLayoutConfig: getScreenLayoutConfig(insets),
|
|
38
39
|
tabBarConfig: getResponsiveTabBarConfig(insets),
|
|
39
|
-
modalLayout: getResponsiveModalLayout(),
|
|
40
|
-
bottomSheetLayout: getResponsiveBottomSheetLayout(),
|
|
41
|
-
dialogLayout: getResponsiveDialogLayout(),
|
|
40
|
+
modalLayout: getResponsiveModalLayout(dimensions),
|
|
41
|
+
bottomSheetLayout: getResponsiveBottomSheetLayout(dimensions),
|
|
42
|
+
dialogLayout: getResponsiveDialogLayout(dimensions),
|
|
42
43
|
});
|
|
@@ -70,9 +70,9 @@ export const getResponsiveMinModalHeight = (dimensions?: { height: number }): nu
|
|
|
70
70
|
}
|
|
71
71
|
};
|
|
72
72
|
|
|
73
|
-
export const getResponsiveModalWidth = (): number => {
|
|
73
|
+
export const getResponsiveModalWidth = (dimensions?: { width: number }): number => {
|
|
74
74
|
try {
|
|
75
|
-
const { width } = getScreenDimensions();
|
|
75
|
+
const { width } = dimensions || getScreenDimensions();
|
|
76
76
|
const isTabletDevice = isTablet();
|
|
77
77
|
|
|
78
78
|
const widthPercent = isTabletDevice
|
|
@@ -89,9 +89,9 @@ export const getResponsiveModalWidth = (): number => {
|
|
|
89
89
|
}
|
|
90
90
|
};
|
|
91
91
|
|
|
92
|
-
export const getResponsiveModalHeight = (): number => {
|
|
92
|
+
export const getResponsiveModalHeight = (dimensions?: { height: number }): number => {
|
|
93
93
|
try {
|
|
94
|
-
const { height } = getScreenDimensions();
|
|
94
|
+
const { height } = dimensions || getScreenDimensions();
|
|
95
95
|
const isTabletDevice = isTablet();
|
|
96
96
|
|
|
97
97
|
if (isTabletDevice) {
|
|
@@ -136,12 +136,12 @@ export const getResponsiveBackdropOpacity = (): number => {
|
|
|
136
136
|
return MODAL_CONFIG.BACKDROP_OPACITY_DEFAULT;
|
|
137
137
|
};
|
|
138
138
|
|
|
139
|
-
export const getResponsiveModalLayout = (): ResponsiveModalLayout => {
|
|
139
|
+
export const getResponsiveModalLayout = (dimensions?: { width: number; height: number }): ResponsiveModalLayout => {
|
|
140
140
|
const isTabletDevice = isTablet();
|
|
141
141
|
|
|
142
142
|
return {
|
|
143
|
-
width: getResponsiveModalWidth(),
|
|
144
|
-
height: getResponsiveModalHeight(),
|
|
143
|
+
width: getResponsiveModalWidth(dimensions),
|
|
144
|
+
height: getResponsiveModalHeight(dimensions),
|
|
145
145
|
maxWidth: getResponsiveModalMaxWidth(),
|
|
146
146
|
borderRadius: getResponsiveModalBorderRadius(),
|
|
147
147
|
backdropOpacity: getResponsiveBackdropOpacity(),
|
|
@@ -151,8 +151,8 @@ export const getResponsiveModalLayout = (): ResponsiveModalLayout => {
|
|
|
151
151
|
};
|
|
152
152
|
};
|
|
153
153
|
|
|
154
|
-
export const getResponsiveBottomSheetLayout = (): ResponsiveBottomSheetLayout => {
|
|
155
|
-
const { height } = getScreenDimensions();
|
|
154
|
+
export const getResponsiveBottomSheetLayout = (dimensions?: { width: number; height: number }): ResponsiveBottomSheetLayout => {
|
|
155
|
+
const { height } = dimensions || getScreenDimensions();
|
|
156
156
|
|
|
157
157
|
return {
|
|
158
158
|
minHeight: MODAL_CONFIG.BOTTOM_SHEET_MIN_HEIGHT,
|
|
@@ -161,8 +161,8 @@ export const getResponsiveBottomSheetLayout = (): ResponsiveBottomSheetLayout =>
|
|
|
161
161
|
};
|
|
162
162
|
};
|
|
163
163
|
|
|
164
|
-
export const getResponsiveDialogLayout = (): ResponsiveDialogLayout => {
|
|
165
|
-
const { width, height } = getScreenDimensions();
|
|
164
|
+
export const getResponsiveDialogLayout = (dimensions?: { width: number; height: number }): ResponsiveDialogLayout => {
|
|
165
|
+
const { width, height } = dimensions || getScreenDimensions();
|
|
166
166
|
|
|
167
167
|
return {
|
|
168
168
|
width: Math.min(
|
|
@@ -59,7 +59,7 @@ export const useResponsive = (): UseResponsiveReturn => {
|
|
|
59
59
|
const dimensions = { width, height };
|
|
60
60
|
const deviceInfo = computeDeviceInfo(dimensions);
|
|
61
61
|
const sizes = computeResponsiveSizes(dimensions);
|
|
62
|
-
const positioning = computeResponsivePositioning(insets);
|
|
62
|
+
const positioning = computeResponsivePositioning(insets, dimensions);
|
|
63
63
|
const onboarding = computeOnboardingSizes(deviceInfo);
|
|
64
64
|
const iPadLayout = deviceInfo.isTabletDevice ? getIPadLayoutInfo() : null;
|
|
65
65
|
|
|
@@ -46,7 +46,8 @@ export const DesignSystemProvider: React.FC<DesignSystemProviderProps> = ({
|
|
|
46
46
|
iconNames,
|
|
47
47
|
}) => {
|
|
48
48
|
const [isInitialized, setIsInitialized] = useState(false);
|
|
49
|
-
const
|
|
49
|
+
const hasCustomFonts = fonts != null && Object.keys(fonts).length > 0;
|
|
50
|
+
const [fontsLoaded, fontError] = useFonts(hasCustomFonts ? fonts : EMPTY_FONTS);
|
|
50
51
|
|
|
51
52
|
const initialize = useTheme((state) => state.initialize);
|
|
52
53
|
const setCustomColors = useTheme((state) => state.setCustomColors);
|
|
@@ -75,14 +76,26 @@ export const DesignSystemProvider: React.FC<DesignSystemProviderProps> = ({
|
|
|
75
76
|
setDefaultThemeMode(initialThemeMode);
|
|
76
77
|
setGlobalThemeMode(initialThemeMode);
|
|
77
78
|
|
|
79
|
+
// Safety timeout: if initialization takes too long, proceed anyway
|
|
80
|
+
const safetyTimer = setTimeout(() => {
|
|
81
|
+
setIsInitialized((prev) => {
|
|
82
|
+
if (!prev) onError?.(new Error('DesignSystemProvider initialization timed out'));
|
|
83
|
+
return true;
|
|
84
|
+
});
|
|
85
|
+
}, 5000);
|
|
86
|
+
|
|
78
87
|
initialize()
|
|
79
88
|
.then(() => {
|
|
89
|
+
clearTimeout(safetyTimer);
|
|
80
90
|
setIsInitialized(true);
|
|
81
91
|
})
|
|
82
92
|
.catch((error) => {
|
|
93
|
+
clearTimeout(safetyTimer);
|
|
83
94
|
setIsInitialized(true);
|
|
84
95
|
onError?.(error);
|
|
85
96
|
});
|
|
97
|
+
|
|
98
|
+
return () => clearTimeout(safetyTimer);
|
|
86
99
|
}, [
|
|
87
100
|
customColors,
|
|
88
101
|
initialThemeMode,
|
|
@@ -95,11 +108,14 @@ export const DesignSystemProvider: React.FC<DesignSystemProviderProps> = ({
|
|
|
95
108
|
setGlobalThemeMode,
|
|
96
109
|
]);
|
|
97
110
|
|
|
111
|
+
// Skip font loading gate when no custom fonts are provided
|
|
112
|
+
const effectiveFontsLoaded = hasCustomFonts ? fontsLoaded : true;
|
|
113
|
+
|
|
98
114
|
useEffect(() => {
|
|
99
|
-
if (isInitialized &&
|
|
115
|
+
if (isInitialized && effectiveFontsLoaded) {
|
|
100
116
|
onInitialized?.();
|
|
101
117
|
}
|
|
102
|
-
}, [isInitialized,
|
|
118
|
+
}, [isInitialized, effectiveFontsLoaded, onInitialized]);
|
|
103
119
|
|
|
104
120
|
useEffect(() => {
|
|
105
121
|
if (fontError) {
|
|
@@ -107,7 +123,7 @@ export const DesignSystemProvider: React.FC<DesignSystemProviderProps> = ({
|
|
|
107
123
|
}
|
|
108
124
|
}, [fontError, onError]);
|
|
109
125
|
|
|
110
|
-
const isLoading = showLoadingIndicator && (!isInitialized || !
|
|
126
|
+
const isLoading = showLoadingIndicator && (!isInitialized || !effectiveFontsLoaded);
|
|
111
127
|
|
|
112
128
|
let content: ReactNode;
|
|
113
129
|
|
|
@@ -149,6 +165,6 @@ const styles = StyleSheet.create({
|
|
|
149
165
|
flex: 1,
|
|
150
166
|
justifyContent: 'center',
|
|
151
167
|
alignItems: 'center',
|
|
152
|
-
backgroundColor: '#
|
|
168
|
+
backgroundColor: '#FFFFFF',
|
|
153
169
|
},
|
|
154
170
|
});
|