@umituz/react-native-splash 2.1.3 → 2.1.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@umituz/react-native-splash",
3
- "version": "2.1.3",
4
- "description": "Ultra minimal splash screen for React Native apps. Just icon, name, and tagline.",
3
+ "version": "2.1.5",
4
+ "description": "Ultra minimal splash screen for React Native apps with design system integration and theme provider pattern.",
5
5
  "main": "./src/index.ts",
6
6
  "types": "./src/index.ts",
7
7
  "scripts": {
@@ -16,7 +16,9 @@
16
16
  "splash",
17
17
  "splash-screen",
18
18
  "loading",
19
- "minimal"
19
+ "minimal",
20
+ "design-system",
21
+ "theme-provider"
20
22
  ],
21
23
  "author": "Ümit UZ <umit@umituz.com>",
22
24
  "license": "MIT",
@@ -25,16 +27,21 @@
25
27
  "url": "https://github.com/umituz/react-native-splash"
26
28
  },
27
29
  "peerDependencies": {
30
+ "@umituz/react-native-design-system": "latest",
31
+ "expo-linear-gradient": ">=13.0.0",
28
32
  "expo-splash-screen": ">=0.23.0",
29
33
  "react": ">=18.2.0",
30
34
  "react-native": ">=0.74.0",
31
35
  "react-native-safe-area-context": ">=4.0.0"
32
36
  },
33
37
  "devDependencies": {
38
+ "@umituz/react-native-design-system": "latest",
39
+ "expo-linear-gradient": "~15.0.7",
34
40
  "expo-splash-screen": "~0.27.0",
35
41
  "@types/react": "~19.1.10",
36
42
  "react": "19.1.0",
37
43
  "react-native": "0.81.5",
44
+ "react-native-safe-area-context": "^5.6.0",
38
45
  "typescript": "~5.9.2"
39
46
  },
40
47
  "publishConfig": {
@@ -1,5 +1,6 @@
1
1
  /**
2
2
  * Splash Options - Ultra Minimal Configuration
3
+ * Theme/colors managed by SplashThemeProvider
3
4
  */
4
5
 
5
6
  import type { ImageSourcePropType } from "react-native";
@@ -13,16 +14,4 @@ export interface SplashOptions {
13
14
 
14
15
  /** Tagline or subtitle */
15
16
  tagline?: string;
16
-
17
- /** Background color (default: #6366F1) */
18
- backgroundColor?: string;
19
-
20
- /** Gradient colors - if provided, overrides backgroundColor */
21
- gradientColors?: readonly [string, string, ...string[]];
22
-
23
- /** Text color (default: #FFFFFF) */
24
- textColor?: string;
25
-
26
- /** Show loading indicator (default: true) */
27
- showLoading?: boolean;
28
17
  }
package/src/index.ts CHANGED
@@ -2,30 +2,27 @@
2
2
  * React Native Splash - Public API
3
3
  *
4
4
  * Ultra minimal splash screen for React Native apps.
5
- * Just displays icon, app name, and tagline.
6
- * Parent component controls visibility and timing.
5
+ * Centralized theme management with provider pattern.
7
6
  *
8
7
  * Usage:
9
- * import { SplashScreen } from '@umituz/react-native-splash';
8
+ * import { SplashThemeProvider, SplashScreen } from '@umituz/react-native-splash';
10
9
  *
11
- * // In your app:
12
- * const [showSplash, setShowSplash] = useState(true);
13
- *
14
- * useEffect(() => {
15
- * // Your initialization logic
16
- * initializeApp().then(() => setShowSplash(false));
17
- * }, []);
18
- *
19
- * if (showSplash) {
20
- * return (
21
- * <SplashScreen
22
- * icon={require('./assets/icon.png')}
23
- * appName="My App"
24
- * tagline="Your tagline here"
25
- * />
26
- * );
27
- * }
10
+ * <SplashThemeProvider gradientColors={['#FF0080', '#7928CA']}>
11
+ * <SplashScreen
12
+ * icon={require('./assets/icon.png')}
13
+ * appName="My App"
14
+ * tagline="Your tagline here"
15
+ * visible={showSplash}
16
+ * maxDuration={10000}
17
+ * onTimeout={() => console.warn('Splash timeout')}
18
+ * />
19
+ * </SplashThemeProvider>
28
20
  */
29
21
 
30
22
  export type { SplashOptions } from "./domain/entities/SplashOptions";
31
23
  export { SplashScreen, type SplashScreenProps } from "./presentation/components/SplashScreen";
24
+ export {
25
+ SplashThemeProvider,
26
+ type SplashThemeProviderProps,
27
+ useSplashTheme,
28
+ } from "./presentation/providers/SplashThemeProvider";
@@ -1,74 +1,131 @@
1
1
  /**
2
2
  * Splash Screen Component
3
- *
4
- * Ultra minimal splash screen - just displays icon, name, and tagline.
5
- * Parent component controls visibility and timing.
3
+ * Ultra minimal splash screen with design system integration
4
+ * Parent component controls visibility and timing
6
5
  */
7
6
 
8
- import React from "react";
9
- import { View, Text, Image, StyleSheet, ActivityIndicator } from "react-native";
7
+ import React, { useEffect, useState } from "react";
8
+ import { View, Image, StyleSheet } from "react-native";
10
9
  import { LinearGradient } from "expo-linear-gradient";
11
10
  import { useSafeAreaInsets } from "react-native-safe-area-context";
11
+ import { AtomicText, useAppDesignTokens } from "@umituz/react-native-design-system";
12
12
  import type { SplashOptions } from "../../domain/entities/SplashOptions";
13
+ import { useSplashTheme } from "../providers/SplashThemeProvider";
13
14
 
14
15
  export interface SplashScreenProps extends SplashOptions {
15
- /** Control visibility from parent */
16
16
  visible?: boolean;
17
+ maxDuration?: number;
18
+ onTimeout?: () => void;
17
19
  }
18
20
 
19
- const DEFAULT_BG = "#6366F1";
20
- const DEFAULT_TEXT = "#FFFFFF";
21
-
22
21
  export const SplashScreen: React.FC<SplashScreenProps> = ({
23
22
  icon,
24
23
  appName = "",
25
24
  tagline = "",
26
- backgroundColor = DEFAULT_BG,
27
- gradientColors,
28
- textColor = DEFAULT_TEXT,
29
- showLoading = true,
30
25
  visible = true,
26
+ maxDuration,
27
+ onTimeout,
31
28
  }) => {
32
29
  const insets = useSafeAreaInsets();
30
+ const tokens = useAppDesignTokens();
31
+ const { colors, gradientColors } = useSplashTheme();
32
+ const [timedOut, setTimedOut] = useState(false);
33
33
 
34
- React.useEffect(() => {
34
+ useEffect(() => {
35
35
  if (__DEV__) {
36
36
  console.log(`[SplashScreen] Mounted - appName: ${appName}, visible: ${visible}`);
37
37
  }
38
38
  }, [appName, visible]);
39
39
 
40
+ useEffect(() => {
41
+ if (!maxDuration || !visible) return;
42
+
43
+ const timer = setTimeout(() => {
44
+ if (__DEV__) {
45
+ console.log(`[SplashScreen] Timeout reached: ${maxDuration}ms`);
46
+ }
47
+ setTimedOut(true);
48
+ onTimeout?.();
49
+ }, maxDuration);
50
+
51
+ return () => clearTimeout(timer);
52
+ }, [maxDuration, visible, onTimeout]);
53
+
40
54
  if (!visible) {
41
- if (__DEV__) console.log('[SplashScreen] Not visible, returning null');
55
+ if (__DEV__) console.log("[SplashScreen] Not visible, returning null");
42
56
  return null;
43
57
  }
44
58
 
45
59
  const content = (
46
- <View style={[styles.content, { paddingTop: insets.top, paddingBottom: insets.bottom }]}>
60
+ <View
61
+ style={[
62
+ styles.content,
63
+ {
64
+ paddingTop: insets.top + tokens.spacing.xl,
65
+ paddingBottom: insets.bottom + tokens.spacing.xl,
66
+ },
67
+ ]}
68
+ >
47
69
  <View style={styles.center}>
48
70
  {icon ? (
49
71
  <Image source={icon} style={styles.icon} resizeMode="contain" />
50
72
  ) : (
51
- <View style={styles.iconPlaceholder} />
73
+ <View
74
+ style={[
75
+ styles.iconPlaceholder,
76
+ { backgroundColor: colors.iconPlaceholderBg },
77
+ ]}
78
+ />
52
79
  )}
53
80
 
54
81
  {appName ? (
55
- <Text style={[styles.title, { color: textColor }]}>{appName}</Text>
82
+ <AtomicText
83
+ type="displaySmall"
84
+ style={[
85
+ styles.title,
86
+ {
87
+ color: colors.textColor,
88
+ marginBottom: tokens.spacing.sm,
89
+ },
90
+ ]}
91
+ >
92
+ {appName}
93
+ </AtomicText>
56
94
  ) : null}
57
95
 
58
96
  {tagline ? (
59
- <Text style={[styles.subtitle, { color: textColor }]}>{tagline}</Text>
97
+ <AtomicText
98
+ type="bodyLarge"
99
+ style={[
100
+ styles.subtitle,
101
+ {
102
+ color: colors.textColor,
103
+ opacity: 0.9,
104
+ },
105
+ ]}
106
+ >
107
+ {tagline}
108
+ </AtomicText>
60
109
  ) : null}
61
- </View>
62
110
 
63
- {showLoading ? (
64
- <View style={styles.loading}>
65
- <ActivityIndicator color={textColor} size="small" />
66
- </View>
67
- ) : null}
111
+ {timedOut && __DEV__ ? (
112
+ <AtomicText
113
+ type="labelSmall"
114
+ style={[
115
+ styles.timeoutWarning,
116
+ {
117
+ color: colors.textColor,
118
+ marginTop: tokens.spacing.md,
119
+ },
120
+ ]}
121
+ >
122
+ ⚠️ Initialization timeout
123
+ </AtomicText>
124
+ ) : null}
125
+ </View>
68
126
  </View>
69
127
  );
70
128
 
71
- // Use gradient if colors provided, otherwise solid background
72
129
  if (gradientColors && gradientColors.length >= 2) {
73
130
  return (
74
131
  <LinearGradient
@@ -83,7 +140,7 @@ export const SplashScreen: React.FC<SplashScreenProps> = ({
83
140
  }
84
141
 
85
142
  return (
86
- <View style={[styles.container, { backgroundColor }]}>
143
+ <View style={[styles.container, { backgroundColor: colors.backgroundColor }]}>
87
144
  {content}
88
145
  </View>
89
146
  );
@@ -112,22 +169,16 @@ const styles = StyleSheet.create({
112
169
  width: 100,
113
170
  height: 100,
114
171
  borderRadius: 50,
115
- backgroundColor: "rgba(255,255,255,0.2)",
116
172
  marginBottom: 24,
117
173
  },
118
174
  title: {
119
- fontSize: 32,
120
- fontWeight: "700",
121
175
  textAlign: "center",
122
- marginBottom: 8,
176
+ fontWeight: "800",
123
177
  },
124
178
  subtitle: {
125
- fontSize: 16,
126
179
  textAlign: "center",
127
- opacity: 0.9,
128
180
  },
129
- loading: {
130
- alignItems: "center",
131
- paddingBottom: 48,
181
+ timeoutWarning: {
182
+ textAlign: "center",
132
183
  },
133
184
  });
@@ -0,0 +1,63 @@
1
+ /**
2
+ * Splash Theme Provider
3
+ * Centralized theme management for splash screen
4
+ * Follows provider pattern like onboarding package
5
+ */
6
+
7
+ import React, { createContext, useContext, useMemo } from "react";
8
+ import { useAppDesignTokens } from "@umituz/react-native-design-system";
9
+
10
+ interface SplashColors {
11
+ backgroundColor: string;
12
+ textColor: string;
13
+ iconPlaceholderBg: string;
14
+ }
15
+
16
+ interface SplashThemeValue {
17
+ colors: SplashColors;
18
+ gradientColors?: readonly [string, string, ...string[]];
19
+ }
20
+
21
+ const SplashTheme = createContext<SplashThemeValue | null>(null);
22
+
23
+ export interface SplashThemeProviderProps {
24
+ children: React.ReactNode;
25
+ gradientColors?: readonly [string, string, ...string[]];
26
+ customColors?: Partial<SplashColors>;
27
+ }
28
+
29
+ export const SplashThemeProvider = ({
30
+ children,
31
+ gradientColors,
32
+ customColors,
33
+ }: SplashThemeProviderProps) => {
34
+ const tokens = useAppDesignTokens();
35
+
36
+ const colors = useMemo<SplashColors>(() => {
37
+ const defaults: SplashColors = {
38
+ backgroundColor: tokens.colors.primary,
39
+ textColor: tokens.colors.onPrimary,
40
+ iconPlaceholderBg: tokens.colors.onPrimary + "30",
41
+ };
42
+
43
+ return {
44
+ ...defaults,
45
+ ...customColors,
46
+ };
47
+ }, [tokens, customColors]);
48
+
49
+ const value = useMemo(
50
+ () => ({ colors, gradientColors }),
51
+ [colors, gradientColors]
52
+ );
53
+
54
+ return <SplashTheme.Provider value={value}>{children}</SplashTheme.Provider>;
55
+ };
56
+
57
+ export const useSplashTheme = (): SplashThemeValue => {
58
+ const theme = useContext(SplashTheme);
59
+ if (!theme) {
60
+ throw new Error("useSplashTheme must be used within SplashThemeProvider");
61
+ }
62
+ return theme;
63
+ };
package/LICENSE DELETED
@@ -1,22 +0,0 @@
1
- MIT License
2
-
3
- Copyright (c) 2025 Ümit UZ
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
22
-
package/README.md DELETED
@@ -1,93 +0,0 @@
1
- # @umituz/react-native-splash
2
-
3
- Simple splash screen for React Native apps with logo, app name, and loading indicator. Minimal dependencies, no over-engineering.
4
-
5
- ## Features
6
-
7
- - ✅ **Simple & Lightweight**: No animations, no gradients, just the essentials
8
- - ✅ **Minimal Dependencies**: Only requires AtomicIcon and localization
9
- - ✅ **Customizable**: Logo, app name, tagline, background color
10
- - ✅ **Loading Indicator**: Built-in ActivityIndicator
11
- - ✅ **Type-Safe**: Full TypeScript support
12
-
13
- ## Installation
14
-
15
- ```bash
16
- npm install @umituz/react-native-splash
17
- ```
18
-
19
- ## Usage
20
-
21
- ### Basic Example
22
-
23
- ```typescript
24
- import { SplashScreen } from '@umituz/react-native-splash';
25
-
26
- <SplashScreen
27
- appName="My App"
28
- tagline="Your tagline here"
29
- logo="Sparkles"
30
- onReady={() => {
31
- // Navigate to main app
32
- }}
33
- />
34
- ```
35
-
36
- ### With Custom Background
37
-
38
- ```typescript
39
- <SplashScreen
40
- appName="My App"
41
- tagline="Your tagline here"
42
- logo="Sparkles"
43
- backgroundColor="#3B82F6"
44
- loadingText="Loading..."
45
- showLoading={true}
46
- minimumDisplayTime={1500}
47
- onReady={handleReady}
48
- />
49
- ```
50
-
51
- ### Custom Render Functions
52
-
53
- ```typescript
54
- <SplashScreen
55
- appName="My App"
56
- renderLogo={() => <CustomLogo />}
57
- renderContent={() => <CustomContent />}
58
- renderFooter={() => <CustomFooter />}
59
- onReady={handleReady}
60
- />
61
- ```
62
-
63
- ## API Reference
64
-
65
- ### `SplashOptions`
66
-
67
- ```typescript
68
- interface SplashOptions {
69
- appName?: string;
70
- tagline?: string;
71
- logo?: ReactNode | string;
72
- backgroundColor?: string;
73
- loadingText?: string;
74
- showLoading?: boolean;
75
- minimumDisplayTime?: number;
76
- onReady?: () => void | Promise<void>;
77
- renderLogo?: () => ReactNode;
78
- renderContent?: () => ReactNode;
79
- renderFooter?: () => ReactNode;
80
- }
81
- ```
82
-
83
- ## Architecture
84
-
85
- - **Domain Layer**: Entities and interfaces (business logic)
86
- - **Presentation Layer**: Components (UI)
87
-
88
- No app-specific code, fully generic and reusable.
89
-
90
- ## License
91
-
92
- MIT
93
-