@umituz/react-native-splash 1.6.4 → 1.7.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.
Files changed (42) hide show
  1. package/LICENSE +0 -0
  2. package/README.md +0 -0
  3. package/lib/__tests__/mocks/expoLinearGradient.js +7 -0
  4. package/lib/__tests__/mocks/reactNative.js +16 -0
  5. package/lib/__tests__/setup.ts +57 -0
  6. package/lib/__tests__/utils/testUtils.tsx +86 -0
  7. package/lib/domain/entities/SplashOptions.ts +74 -0
  8. package/lib/index.ts +31 -0
  9. package/lib/presentation/components/SplashDecorations.tsx +56 -0
  10. package/lib/presentation/components/SplashErrorBoundary.tsx +63 -0
  11. package/lib/presentation/components/SplashLoading.tsx +74 -0
  12. package/lib/presentation/components/SplashLogo.tsx +80 -0
  13. package/lib/presentation/components/SplashScreen.tsx +175 -0
  14. package/lib/presentation/components/SplashTypography.tsx +72 -0
  15. package/lib/presentation/hooks/useSplash.ts +70 -0
  16. package/lib/presentation/utils/splashGradient.utils.ts +47 -0
  17. package/lib/types/expo-linear-gradient.d.ts +12 -0
  18. package/package.json +18 -5
  19. package/src/__tests__/SplashScreen.test.tsx +161 -0
  20. package/src/__tests__/accessibility/Accessibility.test.tsx +264 -0
  21. package/src/__tests__/basic/Basic.test.tsx +106 -0
  22. package/src/__tests__/basic/Simple.test.tsx +32 -0
  23. package/src/__tests__/edge-cases/EdgeCases.test.tsx +446 -0
  24. package/src/__tests__/integration/SplashScreen.integration.test.tsx +200 -0
  25. package/src/__tests__/mocks/expoLinearGradient.js +7 -0
  26. package/src/__tests__/mocks/reactNative.js +16 -0
  27. package/src/__tests__/performance/Performance.test.tsx +297 -0
  28. package/src/__tests__/setup.ts +57 -0
  29. package/src/__tests__/useSplash.test.tsx +123 -0
  30. package/src/__tests__/utils/testUtils.tsx +86 -0
  31. package/src/__tests__/visual/VisualRegression.test.tsx +338 -0
  32. package/src/domain/entities/SplashOptions.ts +7 -0
  33. package/src/index.ts +2 -0
  34. package/src/presentation/components/SplashDecorations.tsx +13 -5
  35. package/src/presentation/components/SplashErrorBoundary.tsx +63 -0
  36. package/src/presentation/components/SplashLoading.tsx +7 -5
  37. package/src/presentation/components/SplashLogo.tsx +4 -2
  38. package/src/presentation/components/SplashScreen.tsx +43 -26
  39. package/src/presentation/components/SplashTypography.tsx +6 -4
  40. package/src/presentation/hooks/useSplash.ts +70 -0
  41. package/src/presentation/utils/splashGradient.utils.ts +0 -0
  42. package/src/types/expo-linear-gradient.d.ts +12 -0
@@ -11,14 +11,16 @@ export interface SplashTypographyProps {
11
11
  appName: string;
12
12
  tagline?: string;
13
13
  tokens: DesignTokens;
14
+ textColor?: string;
14
15
  }
15
16
 
16
17
  export const SplashTypography: React.FC<SplashTypographyProps> = ({
17
18
  appName,
18
19
  tagline,
19
20
  tokens,
21
+ textColor = "#FFFFFF",
20
22
  }) => {
21
- const styles = getStyles(tokens);
23
+ const styles = getStyles(tokens, textColor);
22
24
 
23
25
  return (
24
26
  <View style={styles.container}>
@@ -34,7 +36,7 @@ export const SplashTypography: React.FC<SplashTypographyProps> = ({
34
36
  );
35
37
  };
36
38
 
37
- const getStyles = (tokens: DesignTokens) => {
39
+ const getStyles = (tokens: DesignTokens, textColor: string) => {
38
40
  return StyleSheet.create({
39
41
  container: {
40
42
  alignItems: "center",
@@ -43,7 +45,7 @@ const getStyles = (tokens: DesignTokens) => {
43
45
  appName: {
44
46
  fontSize: 48,
45
47
  fontWeight: "800" as const,
46
- color: "#FFFFFF",
48
+ color: textColor,
47
49
  textAlign: "center" as const,
48
50
  marginBottom: tokens.spacing.md,
49
51
  letterSpacing: -1.2,
@@ -54,7 +56,7 @@ const getStyles = (tokens: DesignTokens) => {
54
56
  },
55
57
  tagline: {
56
58
  fontSize: 17,
57
- color: "#FFFFFF",
59
+ color: textColor,
58
60
  textAlign: "center" as const,
59
61
  opacity: 0.95,
60
62
  maxWidth: 320,
@@ -0,0 +1,70 @@
1
+ /**
2
+ * Use Splash Hook
3
+ * Single Responsibility: Manage splash screen state and timing
4
+ */
5
+
6
+ import { useEffect, useState, useRef } from "react";
7
+
8
+ interface UseSplashOptions {
9
+ minimumDisplayTime?: number;
10
+ onReady?: () => void | Promise<void>;
11
+ autoHide?: boolean;
12
+ }
13
+
14
+ export const useSplash = ({
15
+ minimumDisplayTime = 1500,
16
+ onReady,
17
+ autoHide = true,
18
+ }: UseSplashOptions = {}) => {
19
+ const [isVisible, setIsVisible] = useState(true);
20
+ const [isReady, setIsReady] = useState(false);
21
+ const timerRef = useRef<NodeJS.Timeout>();
22
+ const isReadyRef = useRef(false);
23
+
24
+ const hide = () => {
25
+ setIsVisible(false);
26
+ };
27
+
28
+ const show = () => {
29
+ setIsVisible(true);
30
+ };
31
+
32
+ const markReady = async () => {
33
+ if (isReadyRef.current) return;
34
+
35
+ isReadyRef.current = true;
36
+ setIsReady(true);
37
+
38
+ if (onReady) {
39
+ try {
40
+ await onReady();
41
+ } catch (error) {
42
+ if (__DEV__) {
43
+ console.error("Splash onReady error:", error);
44
+ }
45
+ }
46
+ }
47
+
48
+ if (autoHide) {
49
+ timerRef.current = setTimeout(() => {
50
+ hide();
51
+ }, minimumDisplayTime);
52
+ }
53
+ };
54
+
55
+ useEffect(() => {
56
+ return () => {
57
+ if (timerRef.current) {
58
+ clearTimeout(timerRef.current);
59
+ }
60
+ };
61
+ }, []);
62
+
63
+ return {
64
+ isVisible,
65
+ isReady,
66
+ hide,
67
+ show,
68
+ markReady,
69
+ };
70
+ };
File without changes
@@ -0,0 +1,12 @@
1
+ declare module 'expo-linear-gradient' {
2
+ import { View, ViewProps } from 'react-native';
3
+
4
+ export interface LinearGradientProps extends ViewProps {
5
+ colors: readonly string[];
6
+ start?: { x: number; y: number };
7
+ end?: { x: number; y: number };
8
+ locations?: readonly number[];
9
+ }
10
+
11
+ export const LinearGradient: React.FC<LinearGradientProps>;
12
+ }