@umituz/react-native-design-system 2.6.90 → 2.6.92
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.6.
|
|
3
|
+
"version": "2.6.92",
|
|
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",
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ColorPalette, ThemeMode } from "./ColorPalette";
|
|
2
|
-
|
|
2
|
+
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Font weight type compatible with React Navigation v7
|
|
@@ -51,7 +51,7 @@ export interface NavigationTheme {
|
|
|
51
51
|
* Compatible with React Navigation v7+
|
|
52
52
|
*/
|
|
53
53
|
export const createNavigationTheme = (
|
|
54
|
-
colors: ColorPalette
|
|
54
|
+
colors: ColorPalette,
|
|
55
55
|
themeMode: ThemeMode
|
|
56
56
|
): NavigationTheme => ({
|
|
57
57
|
dark: themeMode === "dark",
|
package/src/theme/index.ts
CHANGED
|
@@ -9,7 +9,6 @@ import type { CustomThemeColors } from '../../core/CustomColors';
|
|
|
9
9
|
import { SplashScreen } from '../../../molecules/splash';
|
|
10
10
|
import type { SplashScreenProps } from '../../../molecules/splash/types';
|
|
11
11
|
|
|
12
|
-
|
|
13
12
|
declare const __DEV__: boolean;
|
|
14
13
|
|
|
15
14
|
interface DesignSystemProviderProps {
|
|
@@ -45,9 +44,7 @@ export const DesignSystemProvider: React.FC<DesignSystemProviderProps> = ({
|
|
|
45
44
|
onInitialized,
|
|
46
45
|
onError,
|
|
47
46
|
}: DesignSystemProviderProps) => {
|
|
48
|
-
// ALL HOOKS MUST BE AT THE TOP (Rules of Hooks)
|
|
49
47
|
const [isInitialized, setIsInitialized] = useState(false);
|
|
50
|
-
const [minDisplayTimeMet, setMinDisplayTimeMet] = useState(false);
|
|
51
48
|
|
|
52
49
|
// Load fonts if provided
|
|
53
50
|
const [fontsLoaded, fontError] = fonts ? useFonts(fonts) : [true, null];
|
|
@@ -56,110 +53,59 @@ export const DesignSystemProvider: React.FC<DesignSystemProviderProps> = ({
|
|
|
56
53
|
const setCustomColors = useDesignSystemTheme((state) => state.setCustomColors);
|
|
57
54
|
|
|
58
55
|
useEffect(() => {
|
|
59
|
-
if (__DEV__) console.log('[DesignSystemProvider] Initializing...');
|
|
60
|
-
|
|
61
56
|
// Apply custom colors if provided
|
|
62
57
|
if (customColors) {
|
|
63
|
-
if (__DEV__) console.log('[DesignSystemProvider] Applying custom colors');
|
|
64
58
|
setCustomColors(customColors);
|
|
65
59
|
}
|
|
66
60
|
|
|
67
|
-
// Start minimum display timer (1.5 seconds)
|
|
68
|
-
const MIN_SPLASH_DISPLAY_TIME = 1500;
|
|
69
|
-
const displayTimer = setTimeout(() => {
|
|
70
|
-
if (__DEV__) console.log('[DesignSystemProvider] Minimum display time met (1.5s)');
|
|
71
|
-
setMinDisplayTimeMet(true);
|
|
72
|
-
}, MIN_SPLASH_DISPLAY_TIME);
|
|
73
|
-
|
|
74
61
|
// Initialize theme store
|
|
75
62
|
initialize()
|
|
76
63
|
.then(() => {
|
|
77
|
-
if (__DEV__) console.log('[DesignSystemProvider] Theme initialized successfully');
|
|
78
64
|
setIsInitialized(true);
|
|
79
65
|
})
|
|
80
66
|
.catch((error) => {
|
|
81
|
-
if (__DEV__) console.error('[DesignSystemProvider] Initialization failed:', error);
|
|
82
67
|
setIsInitialized(true); // Still render app even on error
|
|
83
68
|
onError?.(error);
|
|
84
69
|
});
|
|
85
|
-
|
|
86
|
-
return () => clearTimeout(displayTimer);
|
|
87
70
|
}, [initialize, customColors, setCustomColors, onError]);
|
|
88
71
|
|
|
89
72
|
// Handle initialization completion when both theme and fonts are ready
|
|
90
73
|
useEffect(() => {
|
|
91
|
-
if (isInitialized && fontsLoaded
|
|
92
|
-
if (__DEV__) console.log('[DesignSystemProvider] All systems ready - calling onInitialized');
|
|
74
|
+
if (isInitialized && fontsLoaded) {
|
|
93
75
|
onInitialized?.();
|
|
94
76
|
}
|
|
95
|
-
}, [isInitialized, fontsLoaded,
|
|
77
|
+
}, [isInitialized, fontsLoaded, onInitialized]);
|
|
96
78
|
|
|
97
79
|
// Handle font errors
|
|
98
80
|
useEffect(() => {
|
|
99
81
|
if (fontError) {
|
|
100
|
-
if (__DEV__) console.error('[DesignSystemProvider] Font loading failed:', fontError);
|
|
101
82
|
onError?.(fontError);
|
|
102
83
|
}
|
|
103
84
|
}, [fontError, onError]);
|
|
104
85
|
|
|
105
|
-
//
|
|
106
|
-
|
|
107
|
-
if (__DEV__) {
|
|
108
|
-
console.log('[DesignSystemProvider] Component render:', {
|
|
109
|
-
isInitialized,
|
|
110
|
-
fontsLoaded,
|
|
111
|
-
minDisplayTimeMet,
|
|
112
|
-
showLoadingIndicator,
|
|
113
|
-
hasSplashConfig: !!splashConfig,
|
|
114
|
-
});
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
const renderContent = () => {
|
|
118
|
-
// Show splash if:
|
|
119
|
-
// 1. Loading indicator is enabled AND
|
|
120
|
-
// 2. Either theme not init OR fonts not loaded OR min time not met
|
|
121
|
-
const shouldShowSplash = showLoadingIndicator && (!isInitialized || !fontsLoaded || !minDisplayTimeMet);
|
|
86
|
+
// Determine if we should show loading state
|
|
87
|
+
const isLoading = showLoadingIndicator && (!isInitialized || !fontsLoaded);
|
|
122
88
|
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
isInitialized,
|
|
127
|
-
fontsLoaded,
|
|
128
|
-
minDisplayTimeMet
|
|
129
|
-
});
|
|
89
|
+
if (isLoading) {
|
|
90
|
+
if (loadingComponent) {
|
|
91
|
+
return <>{loadingComponent}</>;
|
|
130
92
|
}
|
|
131
93
|
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
if (__DEV__) console.log('[DesignSystemProvider] Showing loading state');
|
|
135
|
-
|
|
136
|
-
if (loadingComponent) {
|
|
137
|
-
if (__DEV__) console.log('[DesignSystemProvider] Rendering custom loading component');
|
|
138
|
-
return <>{loadingComponent}</>;
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
// Use SplashScreen if config provided, otherwise fallback to ActivityIndicator
|
|
142
|
-
if (splashConfig) {
|
|
143
|
-
if (__DEV__) console.log('[DesignSystemProvider] Rendering SplashScreen with config:', splashConfig);
|
|
144
|
-
return <SplashScreen {...splashConfig} visible={shouldShowSplash} />;
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
if (__DEV__) console.log('[DesignSystemProvider] Rendering fallback ActivityIndicator');
|
|
148
|
-
return (
|
|
149
|
-
<View style={styles.loadingContainer}>
|
|
150
|
-
<ActivityIndicator size="large" />
|
|
151
|
-
</View>
|
|
152
|
-
);
|
|
94
|
+
if (splashConfig) {
|
|
95
|
+
return <SplashScreen {...splashConfig} visible={true} />;
|
|
153
96
|
}
|
|
154
97
|
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
98
|
+
return (
|
|
99
|
+
<View style={styles.loadingContainer}>
|
|
100
|
+
<ActivityIndicator size="large" />
|
|
101
|
+
</View>
|
|
102
|
+
);
|
|
103
|
+
}
|
|
158
104
|
|
|
159
105
|
return (
|
|
160
106
|
<GestureHandlerRootView style={{ flex: 1 }}>
|
|
161
107
|
<SafeAreaProvider initialMetrics={initialWindowMetrics}>
|
|
162
|
-
{
|
|
108
|
+
{children}
|
|
163
109
|
</SafeAreaProvider>
|
|
164
110
|
</GestureHandlerRootView>
|
|
165
111
|
);
|