@umituz/react-native-design-system 2.6.6 → 2.6.8

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.6",
3
+ "version": "2.6.8",
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",
@@ -26,29 +26,11 @@ export const SplashScreen: React.FC<SplashScreenProps> = ({
26
26
  onReady,
27
27
  style,
28
28
  }: SplashScreenProps) => {
29
+ // ALL HOOKS MUST BE AT THE TOP (Rules of Hooks)
29
30
  const insets = useSafeAreaInsets();
30
31
  const tokens = useAppDesignTokens();
31
32
  const [timedOut, setTimedOut] = useState(false);
32
33
 
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
-
52
34
  const handleTimeout = useCallback(() => {
53
35
  if (__DEV__) {
54
36
  console.log(`[SplashScreen] Timeout reached: ${maxDuration}ms`);
@@ -71,6 +53,27 @@ export const SplashScreen: React.FC<SplashScreenProps> = ({
71
53
  return () => clearTimeout(timer);
72
54
  }, [maxDuration, visible, handleTimeout]);
73
55
 
56
+ // ALL HOOKS ABOVE - NOW SAFE TO USE OTHER LOGIC
57
+
58
+ // Derive colors from tokens if not provided (theme-aware defaults)
59
+ const colors: SplashColors = customColors ?? {
60
+ background: tokens.colors.backgroundPrimary,
61
+ text: tokens.colors.textPrimary,
62
+ iconPlaceholder: `${tokens.colors.textPrimary}30`, // 30% opacity
63
+ };
64
+
65
+ if (__DEV__) {
66
+ console.log('[SplashScreen] Component render:', {
67
+ visible,
68
+ appName,
69
+ tagline,
70
+ hasIcon: !!icon,
71
+ hasCustomColors: !!customColors,
72
+ resolvedColors: colors,
73
+ hasGradient: !!gradientColors,
74
+ });
75
+ }
76
+
74
77
  if (!visible) {
75
78
  if (__DEV__) {
76
79
  console.log("[SplashScreen] Not visible (visible=false), returning null");
@@ -63,28 +63,28 @@ export const DesignSystemProvider: React.FC<DesignSystemProviderProps> = ({
63
63
  onInitialized,
64
64
  onError,
65
65
  }: DesignSystemProviderProps) => {
66
+ // ALL HOOKS MUST BE AT THE TOP (Rules of Hooks)
66
67
  const [isInitialized, setIsInitialized] = useState(false);
68
+ const [minDisplayTimeMet, setMinDisplayTimeMet] = useState(false);
67
69
  const initialize = useThemeStore((state) => state.initialize);
68
70
  const setCustomColors = useDesignSystemTheme((state) => state.setCustomColors);
69
71
 
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
-
79
72
  useEffect(() => {
80
73
  if (__DEV__) console.log('[DesignSystemProvider] Initializing...');
81
-
74
+
82
75
  // Apply custom colors if provided
83
76
  if (customColors) {
84
77
  if (__DEV__) console.log('[DesignSystemProvider] Applying custom colors');
85
78
  setCustomColors(customColors);
86
79
  }
87
80
 
81
+ // Start minimum display timer (1.5 seconds)
82
+ const MIN_SPLASH_DISPLAY_TIME = 1500;
83
+ const displayTimer = setTimeout(() => {
84
+ if (__DEV__) console.log('[DesignSystemProvider] Minimum display time met (1.5s)');
85
+ setMinDisplayTimeMet(true);
86
+ }, MIN_SPLASH_DISPLAY_TIME);
87
+
88
88
  // Initialize theme store
89
89
  initialize()
90
90
  .then(() => {
@@ -99,20 +99,38 @@ export const DesignSystemProvider: React.FC<DesignSystemProviderProps> = ({
99
99
  setIsInitialized(true); // Still render app even on error
100
100
  onError?.(error);
101
101
  });
102
+
103
+ return () => clearTimeout(displayTimer);
102
104
  }, [initialize, customColors, setCustomColors, onInitialized, onError]);
103
105
 
106
+ // ALL HOOKS ABOVE - NOW SAFE TO USE OTHER LOGIC
107
+
108
+ if (__DEV__) {
109
+ console.log('[DesignSystemProvider] Component render:', {
110
+ isInitialized,
111
+ minDisplayTimeMet,
112
+ showLoadingIndicator,
113
+ hasSplashConfig: !!splashConfig,
114
+ splashConfigKeys: splashConfig ? Object.keys(splashConfig) : [],
115
+ });
116
+ }
117
+
104
118
  const renderContent = () => {
119
+ const shouldShowSplash = showLoadingIndicator && (!isInitialized || !minDisplayTimeMet);
120
+
105
121
  if (__DEV__) {
106
122
  console.log('[DesignSystemProvider] renderContent:', {
107
123
  showLoadingIndicator,
108
124
  isInitialized,
125
+ minDisplayTimeMet,
126
+ shouldShowSplash,
109
127
  hasSplashConfig: !!splashConfig,
110
128
  hasLoadingComponent: !!loadingComponent,
111
129
  });
112
130
  }
113
131
 
114
- // Show loading indicator if requested and not yet initialized
115
- if (showLoadingIndicator && !isInitialized) {
132
+ // Show loading indicator if requested and not yet ready (both conditions must be met)
133
+ if (shouldShowSplash) {
116
134
  if (__DEV__) console.log('[DesignSystemProvider] Showing loading state');
117
135
 
118
136
  if (loadingComponent) {