@umituz/react-native-design-system 4.25.89 → 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",
|
|
@@ -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
|
});
|