@umituz/react-native-design-system 2.6.3 → 2.6.6
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 +1 -1
- package/src/atoms/status-bar/AtomicStatusBar.tsx +2 -2
- package/src/molecules/splash/components/SplashScreen.tsx +44 -2
- package/src/molecules/splash/hooks/index.ts +6 -0
- package/src/molecules/splash/hooks/useSplashFlow.ts +31 -0
- package/src/molecules/splash/index.ts +3 -0
- package/src/theme/infrastructure/providers/DesignSystemProvider.tsx +29 -3
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.6",
|
|
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",
|
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
|
|
6
6
|
import React from 'react';
|
|
7
7
|
import { StatusBar, StatusBarProps } from 'react-native';
|
|
8
|
-
import { useTheme } from '../../theme
|
|
9
|
-
import { useAppDesignTokens } from '../../theme
|
|
8
|
+
import { useTheme } from '../../theme';
|
|
9
|
+
import { useAppDesignTokens } from '../../theme';
|
|
10
10
|
|
|
11
11
|
export interface AtomicStatusBarProps extends Omit<StatusBarProps, 'barStyle' | 'backgroundColor'> {
|
|
12
12
|
barStyle?: 'auto' | 'light-content' | 'dark-content';
|
|
@@ -18,7 +18,7 @@ export const SplashScreen: React.FC<SplashScreenProps> = ({
|
|
|
18
18
|
icon,
|
|
19
19
|
appName,
|
|
20
20
|
tagline,
|
|
21
|
-
colors,
|
|
21
|
+
colors: customColors,
|
|
22
22
|
gradientColors,
|
|
23
23
|
visible = true,
|
|
24
24
|
maxDuration,
|
|
@@ -27,8 +27,28 @@ export const SplashScreen: React.FC<SplashScreenProps> = ({
|
|
|
27
27
|
style,
|
|
28
28
|
}: SplashScreenProps) => {
|
|
29
29
|
const insets = useSafeAreaInsets();
|
|
30
|
+
const tokens = useAppDesignTokens();
|
|
30
31
|
const [timedOut, setTimedOut] = useState(false);
|
|
31
32
|
|
|
33
|
+
// Derive colors from tokens if not provided (theme-aware defaults)
|
|
34
|
+
const colors: SplashColors = customColors ?? {
|
|
35
|
+
background: tokens.colors.backgroundPrimary,
|
|
36
|
+
text: tokens.colors.textPrimary,
|
|
37
|
+
iconPlaceholder: `${tokens.colors.textPrimary}30`, // 30% opacity
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
if (__DEV__) {
|
|
41
|
+
console.log('[SplashScreen] Component render:', {
|
|
42
|
+
visible,
|
|
43
|
+
appName,
|
|
44
|
+
tagline,
|
|
45
|
+
hasIcon: !!icon,
|
|
46
|
+
hasCustomColors: !!customColors,
|
|
47
|
+
resolvedColors: colors,
|
|
48
|
+
hasGradient: !!gradientColors,
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
|
|
32
52
|
const handleTimeout = useCallback(() => {
|
|
33
53
|
if (__DEV__) {
|
|
34
54
|
console.log(`[SplashScreen] Timeout reached: ${maxDuration}ms`);
|
|
@@ -53,11 +73,15 @@ export const SplashScreen: React.FC<SplashScreenProps> = ({
|
|
|
53
73
|
|
|
54
74
|
if (!visible) {
|
|
55
75
|
if (__DEV__) {
|
|
56
|
-
console.log("[SplashScreen] Not visible, returning null");
|
|
76
|
+
console.log("[SplashScreen] Not visible (visible=false), returning null");
|
|
57
77
|
}
|
|
58
78
|
return null;
|
|
59
79
|
}
|
|
60
80
|
|
|
81
|
+
if (__DEV__) {
|
|
82
|
+
console.log("[SplashScreen] Rendering splash screen UI");
|
|
83
|
+
}
|
|
84
|
+
|
|
61
85
|
const iconPlaceholderColor = colors.iconPlaceholder ?? `${colors.text}30`;
|
|
62
86
|
|
|
63
87
|
const contentStyle = {
|
|
@@ -97,6 +121,15 @@ export const SplashScreen: React.FC<SplashScreenProps> = ({
|
|
|
97
121
|
</AtomicText>
|
|
98
122
|
) : null}
|
|
99
123
|
|
|
124
|
+
{/* Always show loading indicator during initialization */}
|
|
125
|
+
<View style={styles.loadingContainer}>
|
|
126
|
+
<ActivityIndicator
|
|
127
|
+
size="large"
|
|
128
|
+
color={colors.text}
|
|
129
|
+
style={styles.loadingIndicator}
|
|
130
|
+
/>
|
|
131
|
+
</View>
|
|
132
|
+
|
|
100
133
|
{timedOut && __DEV__ ? (
|
|
101
134
|
<AtomicText
|
|
102
135
|
type="labelSmall"
|
|
@@ -163,6 +196,15 @@ const styles = StyleSheet.create({
|
|
|
163
196
|
textAlign: "center",
|
|
164
197
|
opacity: 0.9,
|
|
165
198
|
},
|
|
199
|
+
loadingContainer: {
|
|
200
|
+
marginTop: SPLASH_CONSTANTS.CONTENT_PADDING,
|
|
201
|
+
alignItems: "center",
|
|
202
|
+
justifyContent: "center",
|
|
203
|
+
minHeight: 40,
|
|
204
|
+
},
|
|
205
|
+
loadingIndicator: {
|
|
206
|
+
opacity: 0.8,
|
|
207
|
+
},
|
|
166
208
|
timeoutText: {
|
|
167
209
|
textAlign: "center",
|
|
168
210
|
marginTop: 16,
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Splash Flow Hook
|
|
3
|
+
* Manages splash screen initialization state
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { useState, useEffect } from 'react';
|
|
7
|
+
import { DeviceEventEmitter } from 'react-native';
|
|
8
|
+
|
|
9
|
+
export interface UseSplashFlowOptions {
|
|
10
|
+
duration?: number;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export interface UseSplashFlowResult {
|
|
14
|
+
isInitialized: boolean;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export const useSplashFlow = (options: UseSplashFlowOptions = {}): UseSplashFlowResult => {
|
|
18
|
+
const { duration = 1500 } = options;
|
|
19
|
+
const [isInitialized, setIsInitialized] = useState(false);
|
|
20
|
+
|
|
21
|
+
useEffect(() => {
|
|
22
|
+
const timer = setTimeout(() => {
|
|
23
|
+
setIsInitialized(true);
|
|
24
|
+
DeviceEventEmitter.emit('splash-ready');
|
|
25
|
+
}, duration);
|
|
26
|
+
|
|
27
|
+
return () => clearTimeout(timer);
|
|
28
|
+
}, [duration]);
|
|
29
|
+
|
|
30
|
+
return { isInitialized };
|
|
31
|
+
};
|
|
@@ -67,6 +67,15 @@ export const DesignSystemProvider: React.FC<DesignSystemProviderProps> = ({
|
|
|
67
67
|
const initialize = useThemeStore((state) => state.initialize);
|
|
68
68
|
const setCustomColors = useDesignSystemTheme((state) => state.setCustomColors);
|
|
69
69
|
|
|
70
|
+
if (__DEV__) {
|
|
71
|
+
console.log('[DesignSystemProvider] Component render:', {
|
|
72
|
+
isInitialized,
|
|
73
|
+
showLoadingIndicator,
|
|
74
|
+
hasSplashConfig: !!splashConfig,
|
|
75
|
+
splashConfigKeys: splashConfig ? Object.keys(splashConfig) : [],
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
|
|
70
79
|
useEffect(() => {
|
|
71
80
|
if (__DEV__) console.log('[DesignSystemProvider] Initializing...');
|
|
72
81
|
|
|
@@ -79,29 +88,45 @@ export const DesignSystemProvider: React.FC<DesignSystemProviderProps> = ({
|
|
|
79
88
|
// Initialize theme store
|
|
80
89
|
initialize()
|
|
81
90
|
.then(() => {
|
|
82
|
-
if (__DEV__) console.log('[DesignSystemProvider] Initialized successfully');
|
|
91
|
+
if (__DEV__) console.log('[DesignSystemProvider] Initialized successfully - setting isInitialized to true');
|
|
83
92
|
setIsInitialized(true);
|
|
93
|
+
if (__DEV__) console.log('[DesignSystemProvider] State updated - calling onInitialized callback');
|
|
84
94
|
onInitialized?.();
|
|
85
95
|
})
|
|
86
96
|
.catch((error) => {
|
|
87
97
|
if (__DEV__) console.error('[DesignSystemProvider] Initialization failed:', error);
|
|
98
|
+
if (__DEV__) console.log('[DesignSystemProvider] Error occurred - setting isInitialized to true anyway');
|
|
88
99
|
setIsInitialized(true); // Still render app even on error
|
|
89
100
|
onError?.(error);
|
|
90
101
|
});
|
|
91
102
|
}, [initialize, customColors, setCustomColors, onInitialized, onError]);
|
|
92
103
|
|
|
93
104
|
const renderContent = () => {
|
|
105
|
+
if (__DEV__) {
|
|
106
|
+
console.log('[DesignSystemProvider] renderContent:', {
|
|
107
|
+
showLoadingIndicator,
|
|
108
|
+
isInitialized,
|
|
109
|
+
hasSplashConfig: !!splashConfig,
|
|
110
|
+
hasLoadingComponent: !!loadingComponent,
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
|
|
94
114
|
// Show loading indicator if requested and not yet initialized
|
|
95
115
|
if (showLoadingIndicator && !isInitialized) {
|
|
116
|
+
if (__DEV__) console.log('[DesignSystemProvider] Showing loading state');
|
|
117
|
+
|
|
96
118
|
if (loadingComponent) {
|
|
119
|
+
if (__DEV__) console.log('[DesignSystemProvider] Rendering custom loading component');
|
|
97
120
|
return <>{loadingComponent}</>;
|
|
98
121
|
}
|
|
99
|
-
|
|
122
|
+
|
|
100
123
|
// Use SplashScreen if config provided, otherwise fallback to ActivityIndicator
|
|
101
|
-
if (splashConfig
|
|
124
|
+
if (splashConfig) {
|
|
125
|
+
if (__DEV__) console.log('[DesignSystemProvider] Rendering SplashScreen with config:', splashConfig);
|
|
102
126
|
return <SplashScreen {...splashConfig} />;
|
|
103
127
|
}
|
|
104
128
|
|
|
129
|
+
if (__DEV__) console.log('[DesignSystemProvider] Rendering fallback ActivityIndicator');
|
|
105
130
|
return (
|
|
106
131
|
<View style={styles.loadingContainer}>
|
|
107
132
|
<ActivityIndicator size="large" />
|
|
@@ -109,6 +134,7 @@ export const DesignSystemProvider: React.FC<DesignSystemProviderProps> = ({
|
|
|
109
134
|
);
|
|
110
135
|
}
|
|
111
136
|
|
|
137
|
+
if (__DEV__) console.log('[DesignSystemProvider] Rendering children (app initialized)');
|
|
112
138
|
return <>{children}</>;
|
|
113
139
|
};
|
|
114
140
|
|