react-native-bootsplash 5.0.3 → 5.1.0-beta.0

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 (44) hide show
  1. package/README.md +5 -5
  2. package/android/src/main/java/com/zoontek/rnbootsplash/RNBootSplashModuleImpl.java +147 -120
  3. package/android/src/main/res/layout/splash_screen_view.xml +23 -0
  4. package/android/src/main/res/layout/splash_screen_view_samsung_oneui_4.xml +25 -0
  5. package/android/src/main/res/values/styles.xml +4 -16
  6. package/android/src/main/res/values-v23/styles.xml +1 -1
  7. package/android/src/main/res/values-v29/styles.xml +4 -0
  8. package/android/src/newarch/com/zoontek/rnbootsplash/RNBootSplashModule.java +1 -1
  9. package/android/src/oldarch/com/zoontek/rnbootsplash/RNBootSplashModule.java +1 -1
  10. package/dist/commonjs/NativeRNBootSplash.js +1 -2
  11. package/dist/commonjs/NativeRNBootSplash.js.map +1 -1
  12. package/dist/commonjs/NativeRNBootSplash.web.js +3 -3
  13. package/dist/commonjs/NativeRNBootSplash.web.js.map +1 -1
  14. package/dist/commonjs/addon/index.js +29 -29
  15. package/dist/commonjs/addon/index.js.map +1 -1
  16. package/dist/commonjs/generate.js +17 -19
  17. package/dist/commonjs/generate.js.map +1 -1
  18. package/dist/commonjs/index.js +27 -17
  19. package/dist/commonjs/index.js.map +1 -1
  20. package/dist/module/NativeRNBootSplash.js.map +1 -1
  21. package/dist/module/NativeRNBootSplash.web.js +2 -1
  22. package/dist/module/NativeRNBootSplash.web.js.map +1 -1
  23. package/dist/module/addon/index.js +29 -29
  24. package/dist/module/addon/index.js.map +1 -1
  25. package/dist/module/generate.js +13 -16
  26. package/dist/module/generate.js.map +1 -1
  27. package/dist/module/index.js +26 -15
  28. package/dist/module/index.js.map +1 -1
  29. package/dist/typescript/NativeRNBootSplash.d.ts +1 -0
  30. package/dist/typescript/NativeRNBootSplash.d.ts.map +1 -1
  31. package/dist/typescript/NativeRNBootSplash.web.d.ts +1 -0
  32. package/dist/typescript/NativeRNBootSplash.web.d.ts.map +1 -1
  33. package/dist/typescript/addon/index.d.ts.map +1 -1
  34. package/dist/typescript/generate.d.ts +1 -1
  35. package/dist/typescript/generate.d.ts.map +1 -1
  36. package/dist/typescript/index.d.ts +2 -2
  37. package/dist/typescript/index.d.ts.map +1 -1
  38. package/ios/RNBootSplash.mm +3 -2
  39. package/package.json +20 -18
  40. package/src/NativeRNBootSplash.ts +5 -1
  41. package/src/NativeRNBootSplash.web.ts +5 -1
  42. package/src/generate.ts +6 -6
  43. package/src/index.ts +46 -32
  44. package/android/src/main/java/com/zoontek/rnbootsplash/RNBootSplashDialog.java +0 -52
package/src/generate.ts CHANGED
@@ -9,9 +9,9 @@ import { parse as parseHtml } from "node-html-parser";
9
9
  import path from "path";
10
10
  import pc from "picocolors";
11
11
  import { Options as PrettierOptions } from "prettier";
12
- import htmlPlugin from "prettier/parser-html";
13
- import cssPlugin from "prettier/parser-postcss";
14
- import prettier from "prettier/standalone";
12
+ import * as htmlPlugin from "prettier/plugins/html";
13
+ import * as cssPlugin from "prettier/plugins/postcss";
14
+ import * as prettier from "prettier/standalone";
15
15
  import sharp, { Sharp } from "sharp";
16
16
  import { dedent } from "ts-dedent";
17
17
  import formatXml, { XMLFormatterOptions } from "xml-formatter";
@@ -165,12 +165,12 @@ export const readHtml = (file: string) => {
165
165
  return { root: parseHtml(html), formatOptions };
166
166
  };
167
167
 
168
- export const writeHtml = (
168
+ export const writeHtml = async (
169
169
  file: string,
170
170
  html: string,
171
171
  options?: Omit<PrettierOptions, "parser" | "plugins">,
172
172
  ) => {
173
- const formatted = prettier.format(html, {
173
+ const formatted = await prettier.format(html, {
174
174
  parser: "html",
175
175
  plugins: [htmlPlugin, cssPlugin],
176
176
  tabWidth: 2,
@@ -684,7 +684,7 @@ export const generate: CommandFunction<{
684
684
  root.querySelector("body")?.appendChild(nextDiv);
685
685
  }
686
686
 
687
- writeHtml(htmlTemplatePath, root.toString(), formatOptions);
687
+ await writeHtml(htmlTemplatePath, root.toString(), formatOptions);
688
688
  }
689
689
 
690
690
  if (assetsOutputPath != null) {
package/src/index.ts CHANGED
@@ -31,7 +31,7 @@ export type Manifest = {
31
31
  export type UseHideAnimationConfig = {
32
32
  manifest: Manifest;
33
33
 
34
- logo: ImageRequireSource;
34
+ logo?: ImageRequireSource;
35
35
  darkLogo?: ImageRequireSource;
36
36
  brand?: ImageRequireSource;
37
37
  darkBrand?: ImageRequireSource;
@@ -45,7 +45,7 @@ export type UseHideAnimationConfig = {
45
45
  export type UseHideAnimation = {
46
46
  container: ViewProps;
47
47
  logo: ImageProps;
48
- brand?: ImageProps;
48
+ brand: ImageProps;
49
49
  };
50
50
 
51
51
  export function hide(config: Config = {}): Promise<void> {
@@ -72,7 +72,9 @@ export function useHideAnimation(config: UseHideAnimationConfig) {
72
72
  navigationBarTranslucent = false,
73
73
  } = config;
74
74
 
75
- const hasBrand = manifest.brand != null && brandSrc != null;
75
+ const skipLogo = logoSrc == null;
76
+ const skipBrand = manifest.brand == null || brandSrc == null;
77
+
76
78
  const logoWidth = manifest.logo.width;
77
79
  const logoHeight = manifest.logo.height;
78
80
  const brandBottom = manifest.brand?.bottom;
@@ -86,19 +88,22 @@ export function useHideAnimation(config: UseHideAnimationConfig) {
86
88
  ? manifest.darkBackground
87
89
  : manifest.background;
88
90
 
89
- const logoFinalSrc: ImageRequireSource =
90
- colorScheme === "dark" && darkLogoSrc != null ? darkLogoSrc : logoSrc;
91
+ const logoFinalSrc: ImageRequireSource | undefined = skipLogo
92
+ ? undefined
93
+ : colorScheme === "dark" && darkLogoSrc != null
94
+ ? darkLogoSrc
95
+ : logoSrc;
91
96
 
92
- const brandFinalSrc: ImageRequireSource | undefined = hasBrand
93
- ? colorScheme === "dark" && darkBrandSrc != null
94
- ? darkBrandSrc
95
- : brandSrc
96
- : undefined;
97
+ const brandFinalSrc: ImageRequireSource | undefined = skipBrand
98
+ ? undefined
99
+ : colorScheme === "dark" && darkBrandSrc != null
100
+ ? darkBrandSrc
101
+ : brandSrc;
97
102
 
98
103
  const animateFn = useRef(animate);
99
104
  const layoutReady = useRef(false);
100
- const logoReady = useRef(false);
101
- const brandReady = useRef(!hasBrand);
105
+ const logoReady = useRef(skipLogo);
106
+ const brandReady = useRef(skipBrand);
102
107
  const animateHasBeenCalled = useRef(false);
103
108
 
104
109
  useEffect(() => {
@@ -136,23 +141,27 @@ export function useHideAnimation(config: UseHideAnimationConfig) {
136
141
  },
137
142
  };
138
143
 
139
- const logo: ImageProps = {
140
- fadeDuration: 0,
141
- resizeMode: "contain",
142
- source: logoFinalSrc,
143
- style: {
144
- width: logoWidth,
145
- height: logoHeight,
146
- },
147
- onLoadEnd: () => {
148
- logoReady.current = true;
149
- maybeRunAnimate();
150
- },
151
- };
144
+ const logo: ImageProps =
145
+ logoFinalSrc == null
146
+ ? { source: -1 }
147
+ : {
148
+ fadeDuration: 0,
149
+ resizeMode: "contain",
150
+ source: logoFinalSrc,
151
+ style: {
152
+ width: logoWidth,
153
+ height: logoHeight,
154
+ },
155
+ onLoadEnd: () => {
156
+ logoReady.current = true;
157
+ maybeRunAnimate();
158
+ },
159
+ };
152
160
 
153
- const brand: ImageProps | undefined =
154
- brandFinalSrc != null
155
- ? {
161
+ const brand: ImageProps =
162
+ brandFinalSrc == null
163
+ ? { source: -1 }
164
+ : {
156
165
  fadeDuration: 0,
157
166
  resizeMode: "contain",
158
167
  source: brandFinalSrc,
@@ -166,14 +175,13 @@ export function useHideAnimation(config: UseHideAnimationConfig) {
166
175
  brandReady.current = true;
167
176
  maybeRunAnimate();
168
177
  },
169
- }
170
- : undefined;
178
+ };
171
179
 
172
180
  if (Platform.OS !== "android") {
173
181
  return { container, logo, brand };
174
182
  }
175
183
 
176
- const { statusBarHeight, navigationBarHeight } =
184
+ const { logoSizeRatio, navigationBarHeight, statusBarHeight } =
177
185
  NativeModule.getConstants();
178
186
 
179
187
  return {
@@ -187,7 +195,13 @@ export function useHideAnimation(config: UseHideAnimationConfig) {
187
195
  : -navigationBarHeight,
188
196
  },
189
197
  },
190
- logo,
198
+ logo: {
199
+ ...logo,
200
+ style: {
201
+ width: logoWidth * logoSizeRatio,
202
+ height: logoHeight * logoSizeRatio,
203
+ },
204
+ },
191
205
  brand,
192
206
  };
193
207
  }, [
@@ -1,52 +0,0 @@
1
- package com.zoontek.rnbootsplash;
2
-
3
- import android.app.Activity;
4
- import android.app.Dialog;
5
- import android.os.Bundle;
6
- import android.view.Window;
7
- import android.view.WindowManager;
8
-
9
- import androidx.annotation.NonNull;
10
- import androidx.annotation.StyleRes;
11
-
12
- public class RNBootSplashDialog extends Dialog {
13
-
14
- public final boolean mFade;
15
-
16
- public RNBootSplashDialog(@NonNull Activity activity, @StyleRes int themeResId, boolean fade) {
17
- super(activity, themeResId);
18
-
19
- mFade = fade;
20
-
21
- setOwnerActivity(activity);
22
- setCancelable(false);
23
- setCanceledOnTouchOutside(false);
24
- }
25
-
26
- @Override
27
- public void onBackPressed() {
28
- Activity activity = getOwnerActivity();
29
-
30
- if (activity != null) {
31
- activity.moveTaskToBack(true);
32
- }
33
- }
34
-
35
- @Override
36
- protected void onCreate(Bundle savedInstanceState) {
37
- final Window window = getWindow();
38
-
39
- if (window != null) {
40
- window.setLayout(
41
- WindowManager.LayoutParams.MATCH_PARENT,
42
- WindowManager.LayoutParams.MATCH_PARENT
43
- );
44
-
45
- if (mFade) {
46
- window.setWindowAnimations(R.style.BootSplashFadeOutAnimation);
47
- }
48
- }
49
-
50
- super.onCreate(savedInstanceState);
51
- }
52
- }