@umituz/react-native-splash 2.1.7 → 2.1.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-splash",
3
- "version": "2.1.7",
3
+ "version": "2.1.8",
4
4
  "description": "Minimal prop-driven splash screen for React Native apps with design system integration.",
5
5
  "main": "./src/index.ts",
6
6
  "types": "./src/index.ts",
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * Splash Screen Component
3
- * Fully prop-driven splash screen - no provider required
4
- * Main app controls all styling via props
3
+ * Supports both prop-driven and provider-based theming
4
+ * Main app controls all styling via props or SplashThemeProvider
5
5
  */
6
6
 
7
7
  import React, { useEffect, useState, useCallback } from "react";
@@ -9,18 +9,24 @@ import { View, Image, StyleSheet } from "react-native";
9
9
  import { LinearGradient } from "expo-linear-gradient";
10
10
  import { useSafeAreaInsets } from "react-native-safe-area-context";
11
11
  import { AtomicText } from "@umituz/react-native-design-system";
12
- import type { SplashScreenProps } from "../types";
12
+ import type { SplashScreenProps, SplashColors } from "../types";
13
+ import { useSplashTheme } from "../providers/SplashThemeProvider";
13
14
 
14
15
  const ICON_SIZE = 120;
15
16
  const ICON_PLACEHOLDER_SIZE = 100;
16
17
  const CONTENT_PADDING = 24;
17
18
 
19
+ const DEFAULT_COLORS: SplashColors = {
20
+ background: "#000000",
21
+ text: "#FFFFFF",
22
+ };
23
+
18
24
  export const SplashScreen: React.FC<SplashScreenProps> = ({
19
25
  icon,
20
26
  appName,
21
27
  tagline,
22
- colors,
23
- gradientColors,
28
+ colors: propColors,
29
+ gradientColors: propGradientColors,
24
30
  visible = true,
25
31
  maxDuration,
26
32
  onTimeout,
@@ -29,6 +35,10 @@ export const SplashScreen: React.FC<SplashScreenProps> = ({
29
35
  }) => {
30
36
  const insets = useSafeAreaInsets();
31
37
  const [timedOut, setTimedOut] = useState(false);
38
+ const themeContext = useSplashTheme();
39
+
40
+ const colors = propColors ?? themeContext?.colors ?? DEFAULT_COLORS;
41
+ const gradientColors = propGradientColors ?? themeContext?.gradientColors;
32
42
 
33
43
  const handleTimeout = useCallback(() => {
34
44
  if (__DEV__) {
package/src/index.ts CHANGED
@@ -1,24 +1,24 @@
1
1
  /**
2
2
  * React Native Splash - Public API
3
3
  *
4
- * Minimal splash screen for React Native apps.
5
- * Fully prop-driven - no provider required.
4
+ * Splash screen for React Native apps with theme support.
5
+ * Supports both prop-driven and provider-based theming.
6
6
  *
7
- * Usage:
8
- * import { SplashScreen } from '@umituz/react-native-splash';
7
+ * Usage with provider:
8
+ * import { SplashScreen, SplashThemeProvider } from '@umituz/react-native-splash';
9
9
  *
10
- * <SplashScreen
11
- * appName="My App"
12
- * tagline="Your tagline here"
13
- * colors={{
14
- * background: tokens.colors.primary,
15
- * text: tokens.colors.onPrimary,
16
- * }}
17
- * icon={require('./assets/icon.png')}
18
- * onReady={() => setReady(true)}
19
- * />
10
+ * <SplashThemeProvider
11
+ * gradientColors={[tokens.colors.primary, tokens.colors.secondary]}
12
+ * customColors={{ textColor: tokens.colors.onPrimary }}
13
+ * >
14
+ * <SplashScreen
15
+ * appName="My App"
16
+ * tagline="Your tagline here"
17
+ * icon={require('./assets/icon.png')}
18
+ * />
19
+ * </SplashThemeProvider>
20
20
  *
21
- * With gradient:
21
+ * Usage with props:
22
22
  * <SplashScreen
23
23
  * appName="My App"
24
24
  * colors={{ background: '#000', text: '#fff' }}
@@ -26,5 +26,17 @@
26
26
  * />
27
27
  */
28
28
 
29
- export type { SplashScreenProps, SplashColors } from "./types";
29
+ // Types
30
+ export type {
31
+ SplashScreenProps,
32
+ SplashColors,
33
+ SplashCustomColors,
34
+ SplashThemeProviderProps,
35
+ SplashThemeContextValue,
36
+ } from "./types";
37
+
38
+ // Components
30
39
  export { SplashScreen } from "./components/SplashScreen";
40
+
41
+ // Providers
42
+ export { SplashThemeProvider, useSplashTheme } from "./providers";
@@ -0,0 +1,48 @@
1
+ /**
2
+ * Splash Theme Provider
3
+ * Provides theme context for SplashScreen components
4
+ */
5
+
6
+ import React, { createContext, useContext, useMemo } from "react";
7
+ import type {
8
+ SplashThemeProviderProps,
9
+ SplashThemeContextValue,
10
+ } from "../types";
11
+
12
+ const DEFAULT_COLORS = {
13
+ background: "#000000",
14
+ text: "#FFFFFF",
15
+ };
16
+
17
+ const SplashThemeContext = createContext<SplashThemeContextValue | null>(null);
18
+
19
+ export const useSplashTheme = (): SplashThemeContextValue | null => {
20
+ return useContext(SplashThemeContext);
21
+ };
22
+
23
+ export const SplashThemeProvider: React.FC<SplashThemeProviderProps> = ({
24
+ children,
25
+ gradientColors,
26
+ customColors,
27
+ }) => {
28
+ const value = useMemo<SplashThemeContextValue>(() => {
29
+ const background =
30
+ customColors?.backgroundColor ??
31
+ (gradientColors?.[0] || DEFAULT_COLORS.background);
32
+
33
+ return {
34
+ colors: {
35
+ background,
36
+ text: customColors?.textColor ?? DEFAULT_COLORS.text,
37
+ iconPlaceholder: customColors?.iconPlaceholderColor,
38
+ },
39
+ gradientColors,
40
+ };
41
+ }, [gradientColors, customColors]);
42
+
43
+ return (
44
+ <SplashThemeContext.Provider value={value}>
45
+ {children}
46
+ </SplashThemeContext.Provider>
47
+ );
48
+ };
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Splash Providers
3
+ */
4
+
5
+ export { SplashThemeProvider, useSplashTheme } from "./SplashThemeProvider";
@@ -4,6 +4,7 @@
4
4
  */
5
5
 
6
6
  import type { ImageSourcePropType, StyleProp, ViewStyle } from "react-native";
7
+ import type { ReactNode } from "react";
7
8
 
8
9
  /**
9
10
  * Splash screen color configuration
@@ -18,9 +19,43 @@ export interface SplashColors {
18
19
  iconPlaceholder?: string;
19
20
  }
20
21
 
22
+ /**
23
+ * Custom colors for SplashThemeProvider
24
+ */
25
+ export interface SplashCustomColors {
26
+ /** Text color for app name and tagline */
27
+ textColor: string;
28
+ /** Background color when not using gradient */
29
+ backgroundColor?: string;
30
+ /** Background color for icon placeholder circle */
31
+ iconPlaceholderColor?: string;
32
+ }
33
+
34
+ /**
35
+ * SplashThemeProvider props
36
+ */
37
+ export interface SplashThemeProviderProps {
38
+ /** Children components */
39
+ children: ReactNode;
40
+ /** Gradient colors for background */
41
+ gradientColors?: readonly [string, string, ...string[]];
42
+ /** Custom color configuration */
43
+ customColors?: SplashCustomColors;
44
+ }
45
+
46
+ /**
47
+ * Splash theme context value
48
+ */
49
+ export interface SplashThemeContextValue {
50
+ /** Resolved colors for splash screen */
51
+ colors: SplashColors;
52
+ /** Gradient colors if provided */
53
+ gradientColors?: readonly [string, string, ...string[]];
54
+ }
55
+
21
56
  /**
22
57
  * Splash screen component props
23
- * Fully prop-driven - no provider required
58
+ * Can be used standalone with colors prop or with SplashThemeProvider
24
59
  */
25
60
  export interface SplashScreenProps {
26
61
  /** App name to display */
@@ -32,8 +67,8 @@ export interface SplashScreenProps {
32
67
  /** App icon/logo image source */
33
68
  icon?: ImageSourcePropType;
34
69
 
35
- /** Color configuration - required for proper theming */
36
- colors: SplashColors;
70
+ /** Color configuration - optional when using SplashThemeProvider */
71
+ colors?: SplashColors;
37
72
 
38
73
  /** Optional gradient colors (overrides background color) */
39
74
  gradientColors?: readonly [string, string, ...string[]];