@umituz/react-native-splash 1.6.0 → 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.6.
|
|
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",
|
|
@@ -8,15 +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 { generateGradientFromColor } from "../utils/splashGradient.utils";
|
|
20
16
|
import type { SplashOptions } from "../../domain/entities/SplashOptions";
|
|
21
17
|
|
|
22
18
|
export interface SplashScreenProps extends SplashOptions {
|
|
@@ -43,20 +39,8 @@ export const SplashScreen: React.FC<SplashScreenProps> = ({
|
|
|
43
39
|
}) => {
|
|
44
40
|
const insets = useSafeAreaInsets();
|
|
45
41
|
const { t } = useLocalization();
|
|
46
|
-
const { themeMode } = useDesignSystemTheme();
|
|
47
42
|
const tokens = useAppDesignTokens();
|
|
48
43
|
|
|
49
|
-
const isDark = themeMode === "dark";
|
|
50
|
-
|
|
51
|
-
// Use provided gradientColors, or generate from backgroundColor, or fallback to backgroundColor as single color
|
|
52
|
-
const finalGradientColors: readonly string[] =
|
|
53
|
-
gradientColors ||
|
|
54
|
-
(backgroundColor
|
|
55
|
-
? generateGradientFromColor(backgroundColor, isDark)
|
|
56
|
-
: backgroundColor
|
|
57
|
-
? [backgroundColor]
|
|
58
|
-
: [tokens.colors.primary]);
|
|
59
|
-
|
|
60
44
|
const styles = getStyles(insets, tokens.spacing);
|
|
61
45
|
|
|
62
46
|
useEffect(() => {
|
|
@@ -77,44 +61,70 @@ export const SplashScreen: React.FC<SplashScreenProps> = ({
|
|
|
77
61
|
const displayTagline = tagline || t("branding.tagline", "Your tagline here");
|
|
78
62
|
const displayLoadingText = loadingText || t("general.loading", "Loading...");
|
|
79
63
|
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
{renderLogo ? (
|
|
92
|
-
renderLogo()
|
|
93
|
-
) : (
|
|
94
|
-
<SplashLogo logo={logo} />
|
|
95
|
-
)}
|
|
96
|
-
|
|
97
|
-
{renderContent ? (
|
|
98
|
-
renderContent()
|
|
99
|
-
) : (
|
|
100
|
-
<SplashTypography
|
|
101
|
-
appName={displayAppName}
|
|
102
|
-
tagline={displayTagline}
|
|
103
|
-
tokens={tokens}
|
|
104
|
-
/>
|
|
105
|
-
)}
|
|
106
|
-
</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;
|
|
107
75
|
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
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}
|
|
111
93
|
tokens={tokens}
|
|
112
|
-
bottomInset={insets.bottom}
|
|
113
94
|
/>
|
|
114
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
|
+
);
|
|
115
109
|
|
|
116
|
-
|
|
117
|
-
|
|
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
|
+
)}
|
|
118
128
|
</View>
|
|
119
129
|
);
|
|
120
130
|
};
|