@umituz/react-native-design-system 2.6.2 → 2.6.5
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/index.ts +3 -0
- package/src/atoms/status-bar/AtomicStatusBar.tsx +37 -0
- package/src/atoms/status-bar/index.ts +6 -0
- package/src/molecules/splash/components/SplashScreen.tsx +31 -4
- 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/molecules/splash/types/index.ts +19 -2
- package/src/theme/infrastructure/providers/DesignSystemProvider.tsx +1 -1
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.5",
|
|
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",
|
package/src/atoms/index.ts
CHANGED
|
@@ -108,3 +108,6 @@ export { AtomicSwitch, type AtomicSwitchProps } from './AtomicSwitch';
|
|
|
108
108
|
|
|
109
109
|
// Touchable
|
|
110
110
|
export { AtomicTouchable, type AtomicTouchableProps } from './AtomicTouchable';
|
|
111
|
+
|
|
112
|
+
// StatusBar
|
|
113
|
+
export { AtomicStatusBar, type AtomicStatusBarProps } from './status-bar';
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AtomicStatusBar Component
|
|
3
|
+
* Theme-aware status bar that automatically adjusts based on theme mode
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import React from 'react';
|
|
7
|
+
import { StatusBar, StatusBarProps } from 'react-native';
|
|
8
|
+
import { useTheme } from '../../theme';
|
|
9
|
+
import { useAppDesignTokens } from '../../theme';
|
|
10
|
+
|
|
11
|
+
export interface AtomicStatusBarProps extends Omit<StatusBarProps, 'barStyle' | 'backgroundColor'> {
|
|
12
|
+
barStyle?: 'auto' | 'light-content' | 'dark-content';
|
|
13
|
+
backgroundColor?: string;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export const AtomicStatusBar: React.FC<AtomicStatusBarProps> = ({
|
|
17
|
+
barStyle = 'auto',
|
|
18
|
+
backgroundColor,
|
|
19
|
+
...props
|
|
20
|
+
}) => {
|
|
21
|
+
const { themeMode } = useTheme();
|
|
22
|
+
const tokens = useAppDesignTokens();
|
|
23
|
+
|
|
24
|
+
const resolvedBarStyle = barStyle === 'auto'
|
|
25
|
+
? themeMode === 'dark' ? 'light-content' : 'dark-content'
|
|
26
|
+
: barStyle;
|
|
27
|
+
|
|
28
|
+
const resolvedBackgroundColor = backgroundColor || tokens.colors.backgroundPrimary;
|
|
29
|
+
|
|
30
|
+
return (
|
|
31
|
+
<StatusBar
|
|
32
|
+
barStyle={resolvedBarStyle}
|
|
33
|
+
backgroundColor={resolvedBackgroundColor}
|
|
34
|
+
{...props}
|
|
35
|
+
/>
|
|
36
|
+
);
|
|
37
|
+
};
|
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Splash Screen Component
|
|
3
|
-
* Pure prop-driven component
|
|
3
|
+
* Pure prop-driven component with theme-aware defaults
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
import React, { useEffect, useState, useCallback } from "react";
|
|
7
|
-
import { View, Image, StyleSheet } from "react-native";
|
|
7
|
+
import { View, Image, StyleSheet, ActivityIndicator } from "react-native";
|
|
8
8
|
import { LinearGradient } from "expo-linear-gradient";
|
|
9
9
|
import { useSafeAreaInsets } from "react-native-safe-area-context";
|
|
10
10
|
import { AtomicText } from "../../../atoms";
|
|
11
|
-
import
|
|
11
|
+
import { useAppDesignTokens } from "../../../theme";
|
|
12
|
+
import type { SplashScreenProps, SplashColors } from "../types";
|
|
12
13
|
import { SPLASH_CONSTANTS } from "../constants";
|
|
13
14
|
|
|
14
15
|
declare const __DEV__: boolean;
|
|
@@ -17,7 +18,7 @@ export const SplashScreen: React.FC<SplashScreenProps> = ({
|
|
|
17
18
|
icon,
|
|
18
19
|
appName,
|
|
19
20
|
tagline,
|
|
20
|
-
colors,
|
|
21
|
+
colors: customColors,
|
|
21
22
|
gradientColors,
|
|
22
23
|
visible = true,
|
|
23
24
|
maxDuration,
|
|
@@ -26,8 +27,16 @@ export const SplashScreen: React.FC<SplashScreenProps> = ({
|
|
|
26
27
|
style,
|
|
27
28
|
}: SplashScreenProps) => {
|
|
28
29
|
const insets = useSafeAreaInsets();
|
|
30
|
+
const tokens = useAppDesignTokens();
|
|
29
31
|
const [timedOut, setTimedOut] = useState(false);
|
|
30
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
|
+
|
|
31
40
|
const handleTimeout = useCallback(() => {
|
|
32
41
|
if (__DEV__) {
|
|
33
42
|
console.log(`[SplashScreen] Timeout reached: ${maxDuration}ms`);
|
|
@@ -96,6 +105,15 @@ export const SplashScreen: React.FC<SplashScreenProps> = ({
|
|
|
96
105
|
</AtomicText>
|
|
97
106
|
) : null}
|
|
98
107
|
|
|
108
|
+
{/* Always show loading indicator during initialization */}
|
|
109
|
+
<View style={styles.loadingContainer}>
|
|
110
|
+
<ActivityIndicator
|
|
111
|
+
size="large"
|
|
112
|
+
color={colors.text}
|
|
113
|
+
style={styles.loadingIndicator}
|
|
114
|
+
/>
|
|
115
|
+
</View>
|
|
116
|
+
|
|
99
117
|
{timedOut && __DEV__ ? (
|
|
100
118
|
<AtomicText
|
|
101
119
|
type="labelSmall"
|
|
@@ -162,6 +180,15 @@ const styles = StyleSheet.create({
|
|
|
162
180
|
textAlign: "center",
|
|
163
181
|
opacity: 0.9,
|
|
164
182
|
},
|
|
183
|
+
loadingContainer: {
|
|
184
|
+
marginTop: SPLASH_CONSTANTS.CONTENT_PADDING,
|
|
185
|
+
alignItems: "center",
|
|
186
|
+
justifyContent: "center",
|
|
187
|
+
minHeight: 40,
|
|
188
|
+
},
|
|
189
|
+
loadingIndicator: {
|
|
190
|
+
opacity: 0.8,
|
|
191
|
+
},
|
|
165
192
|
timeoutText: {
|
|
166
193
|
textAlign: "center",
|
|
167
194
|
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,8 +67,25 @@ export interface SplashScreenProps {
|
|
|
67
67
|
/** App icon/logo image source */
|
|
68
68
|
icon?: ImageSourcePropType;
|
|
69
69
|
|
|
70
|
-
/**
|
|
71
|
-
|
|
70
|
+
/**
|
|
71
|
+
* Color configuration (optional - uses design tokens by default)
|
|
72
|
+
*
|
|
73
|
+
* If not provided, colors will be automatically derived from the current theme:
|
|
74
|
+
* - Light mode: dark text on light background
|
|
75
|
+
* - Dark mode: light text on dark background
|
|
76
|
+
*
|
|
77
|
+
* @example
|
|
78
|
+
* // Auto theme-aware (recommended)
|
|
79
|
+
* <SplashScreen appName="MyApp" icon={icon} />
|
|
80
|
+
*
|
|
81
|
+
* // Custom colors
|
|
82
|
+
* <SplashScreen
|
|
83
|
+
* appName="MyApp"
|
|
84
|
+
* icon={icon}
|
|
85
|
+
* colors={{ background: '#FF0000', text: '#FFFFFF' }}
|
|
86
|
+
* />
|
|
87
|
+
*/
|
|
88
|
+
colors?: SplashColors;
|
|
72
89
|
|
|
73
90
|
/** Optional gradient colors (overrides background color) */
|
|
74
91
|
gradientColors?: readonly [string, string, ...string[]];
|
|
@@ -98,7 +98,7 @@ export const DesignSystemProvider: React.FC<DesignSystemProviderProps> = ({
|
|
|
98
98
|
}
|
|
99
99
|
|
|
100
100
|
// Use SplashScreen if config provided, otherwise fallback to ActivityIndicator
|
|
101
|
-
if (splashConfig
|
|
101
|
+
if (splashConfig) {
|
|
102
102
|
return <SplashScreen {...splashConfig} />;
|
|
103
103
|
}
|
|
104
104
|
|