@umituz/react-native-splash 1.5.4 → 1.6.1
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": "1.
|
|
3
|
+
"version": "1.6.1",
|
|
4
4
|
"description": "Generic splash screen for React Native apps with animations, gradients, and customizable branding. SOLID, DRY, KISS principles applied.",
|
|
5
5
|
"main": "./src/index.ts",
|
|
6
6
|
"types": "./src/index.ts",
|
|
@@ -27,10 +27,16 @@ export interface SplashOptions {
|
|
|
27
27
|
logo?: ReactNode | string;
|
|
28
28
|
|
|
29
29
|
/**
|
|
30
|
-
* Background color
|
|
30
|
+
* Background color (will generate gradient automatically)
|
|
31
31
|
*/
|
|
32
32
|
backgroundColor?: string;
|
|
33
33
|
|
|
34
|
+
/**
|
|
35
|
+
* Custom gradient colors (overrides backgroundColor)
|
|
36
|
+
* If provided, backgroundColor is ignored
|
|
37
|
+
*/
|
|
38
|
+
gradientColors?: readonly string[];
|
|
39
|
+
|
|
34
40
|
/**
|
|
35
41
|
* Loading text
|
|
36
42
|
*/
|
|
@@ -8,18 +8,11 @@ import { View, StyleSheet } from "react-native";
|
|
|
8
8
|
import { LinearGradient } from "expo-linear-gradient";
|
|
9
9
|
import { useSafeAreaInsets } from "react-native-safe-area-context";
|
|
10
10
|
import { useLocalization } from "@umituz/react-native-localization";
|
|
11
|
-
import {
|
|
12
|
-
useDesignSystemTheme,
|
|
13
|
-
useAppDesignTokens,
|
|
14
|
-
} from "@umituz/react-native-design-system-theme";
|
|
11
|
+
import { useAppDesignTokens } from "@umituz/react-native-design-system-theme";
|
|
15
12
|
import { SplashLogo } from "./SplashLogo";
|
|
16
13
|
import { SplashTypography } from "./SplashTypography";
|
|
17
14
|
import { SplashLoading } from "./SplashLoading";
|
|
18
15
|
import { SplashDecorations } from "./SplashDecorations";
|
|
19
|
-
import {
|
|
20
|
-
getDefaultGradient,
|
|
21
|
-
generateGradientFromColor,
|
|
22
|
-
} from "../utils/splashGradient.utils";
|
|
23
16
|
import type { SplashOptions } from "../../domain/entities/SplashOptions";
|
|
24
17
|
|
|
25
18
|
export interface SplashScreenProps extends SplashOptions {
|
|
@@ -34,6 +27,7 @@ export const SplashScreen: React.FC<SplashScreenProps> = ({
|
|
|
34
27
|
tagline,
|
|
35
28
|
logo,
|
|
36
29
|
backgroundColor,
|
|
30
|
+
gradientColors,
|
|
37
31
|
loadingText,
|
|
38
32
|
showLoading = true,
|
|
39
33
|
minimumDisplayTime = 1500,
|
|
@@ -45,15 +39,8 @@ export const SplashScreen: React.FC<SplashScreenProps> = ({
|
|
|
45
39
|
}) => {
|
|
46
40
|
const insets = useSafeAreaInsets();
|
|
47
41
|
const { t } = useLocalization();
|
|
48
|
-
const { themeMode } = useDesignSystemTheme();
|
|
49
42
|
const tokens = useAppDesignTokens();
|
|
50
43
|
|
|
51
|
-
const isDark = themeMode === "dark";
|
|
52
|
-
|
|
53
|
-
const gradientColors = backgroundColor
|
|
54
|
-
? generateGradientFromColor(backgroundColor, isDark)
|
|
55
|
-
: getDefaultGradient(isDark);
|
|
56
|
-
|
|
57
44
|
const styles = getStyles(insets, tokens.spacing);
|
|
58
45
|
|
|
59
46
|
useEffect(() => {
|
|
@@ -74,44 +61,70 @@ export const SplashScreen: React.FC<SplashScreenProps> = ({
|
|
|
74
61
|
const displayTagline = tagline || t("branding.tagline", "Your tagline here");
|
|
75
62
|
const displayLoadingText = loadingText || t("general.loading", "Loading...");
|
|
76
63
|
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
{renderLogo ? (
|
|
89
|
-
renderLogo()
|
|
90
|
-
) : (
|
|
91
|
-
<SplashLogo logo={logo} />
|
|
92
|
-
)}
|
|
93
|
-
|
|
94
|
-
{renderContent ? (
|
|
95
|
-
renderContent()
|
|
96
|
-
) : (
|
|
97
|
-
<SplashTypography
|
|
98
|
-
appName={displayAppName}
|
|
99
|
-
tagline={displayTagline}
|
|
100
|
-
tokens={tokens}
|
|
101
|
-
/>
|
|
102
|
-
)}
|
|
103
|
-
</View>
|
|
64
|
+
// Use gradientColors if provided, otherwise use backgroundColor as solid color
|
|
65
|
+
const finalBackgroundColor = gradientColors
|
|
66
|
+
? undefined
|
|
67
|
+
: backgroundColor || tokens.colors.primary;
|
|
68
|
+
|
|
69
|
+
const finalGradientColors: readonly string[] = gradientColors || [
|
|
70
|
+
finalBackgroundColor!,
|
|
71
|
+
];
|
|
72
|
+
|
|
73
|
+
// Use LinearGradient only if gradientColors provided (length > 1)
|
|
74
|
+
const hasGradient = gradientColors && gradientColors.length > 1;
|
|
104
75
|
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
76
|
+
const content = (
|
|
77
|
+
<>
|
|
78
|
+
<SplashDecorations />
|
|
79
|
+
|
|
80
|
+
<View style={styles.content}>
|
|
81
|
+
{renderLogo ? (
|
|
82
|
+
renderLogo()
|
|
83
|
+
) : (
|
|
84
|
+
<SplashLogo logo={logo} />
|
|
85
|
+
)}
|
|
86
|
+
|
|
87
|
+
{renderContent ? (
|
|
88
|
+
renderContent()
|
|
89
|
+
) : (
|
|
90
|
+
<SplashTypography
|
|
91
|
+
appName={displayAppName}
|
|
92
|
+
tagline={displayTagline}
|
|
108
93
|
tokens={tokens}
|
|
109
|
-
bottomInset={insets.bottom}
|
|
110
94
|
/>
|
|
111
95
|
)}
|
|
96
|
+
</View>
|
|
97
|
+
|
|
98
|
+
{showLoading && (
|
|
99
|
+
<SplashLoading
|
|
100
|
+
loadingText={displayLoadingText}
|
|
101
|
+
tokens={tokens}
|
|
102
|
+
bottomInset={insets.bottom}
|
|
103
|
+
/>
|
|
104
|
+
)}
|
|
105
|
+
|
|
106
|
+
{renderFooter && renderFooter()}
|
|
107
|
+
</>
|
|
108
|
+
);
|
|
112
109
|
|
|
113
|
-
|
|
114
|
-
|
|
110
|
+
return (
|
|
111
|
+
<View style={styles.container}>
|
|
112
|
+
{hasGradient ? (
|
|
113
|
+
<LinearGradient
|
|
114
|
+
colors={finalGradientColors}
|
|
115
|
+
start={{ x: 0, y: 0 }}
|
|
116
|
+
end={{ x: 1, y: 1 }}
|
|
117
|
+
style={styles.gradient}
|
|
118
|
+
>
|
|
119
|
+
{content}
|
|
120
|
+
</LinearGradient>
|
|
121
|
+
) : (
|
|
122
|
+
<View
|
|
123
|
+
style={[styles.gradient, { backgroundColor: finalBackgroundColor }]}
|
|
124
|
+
>
|
|
125
|
+
{content}
|
|
126
|
+
</View>
|
|
127
|
+
)}
|
|
115
128
|
</View>
|
|
116
129
|
);
|
|
117
130
|
};
|
|
@@ -25,15 +25,6 @@ export const adjustColorBrightness = (hex: string, percent: number): string => {
|
|
|
25
25
|
);
|
|
26
26
|
};
|
|
27
27
|
|
|
28
|
-
/**
|
|
29
|
-
* Get default gradient colors based on theme
|
|
30
|
-
*/
|
|
31
|
-
export const getDefaultGradient = (isDark: boolean): readonly string[] => {
|
|
32
|
-
return isDark
|
|
33
|
-
? (["#1E1B4B", "#312E81", "#4C1D95", "#6B21A8"] as const) // Dark indigo to purple
|
|
34
|
-
: (["#6366F1", "#8B5CF6", "#A855F7", "#EC4899"] as const); // Indigo to pink
|
|
35
|
-
};
|
|
36
|
-
|
|
37
28
|
/**
|
|
38
29
|
* Generate gradient colors from backgroundColor
|
|
39
30
|
*/
|