react-native-bootsplash 4.7.5 → 5.0.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 (54) hide show
  1. package/README.md +214 -107
  2. package/RNBootSplash.podspec +1 -2
  3. package/android/.npmignore +11 -0
  4. package/android/build.gradle +0 -1
  5. package/android/src/main/java/com/zoontek/rnbootsplash/RNBootSplash.java +3 -2
  6. package/android/src/main/java/com/zoontek/rnbootsplash/RNBootSplashDialog.java +49 -0
  7. package/android/src/main/java/com/zoontek/rnbootsplash/RNBootSplashModuleImpl.java +157 -87
  8. package/android/src/main/res/anim/bootsplash_fade_in.xml +7 -0
  9. package/android/src/main/res/anim/bootsplash_fade_out.xml +7 -0
  10. package/android/src/main/res/drawable/compat_splash_screen.xml +19 -0
  11. package/android/src/main/res/values/attrs.xml +8 -0
  12. package/android/src/main/res/values/public.xml +7 -0
  13. package/android/src/main/res/values/styles.xml +29 -0
  14. package/android/src/main/res/values-v31/styles.xml +7 -0
  15. package/android/src/newarch/com/zoontek/rnbootsplash/RNBootSplashModule.java +11 -4
  16. package/android/src/oldarch/com/zoontek/rnbootsplash/RNBootSplashModule.java +13 -4
  17. package/dist/commonjs/NativeRNBootSplash.js.map +1 -1
  18. package/dist/commonjs/addon/index.js +3 -0
  19. package/dist/commonjs/addon/index.js.map +1 -0
  20. package/dist/commonjs/generate.js +289 -194
  21. package/dist/commonjs/generate.js.map +1 -1
  22. package/dist/commonjs/index.js +115 -7
  23. package/dist/commonjs/index.js.map +1 -1
  24. package/dist/module/NativeRNBootSplash.js.map +1 -1
  25. package/dist/module/addon/index.js +3 -0
  26. package/dist/module/addon/index.js.map +1 -0
  27. package/dist/module/generate.js +287 -195
  28. package/dist/module/generate.js.map +1 -1
  29. package/dist/module/index.js +113 -6
  30. package/dist/module/index.js.map +1 -1
  31. package/dist/typescript/NativeRNBootSplash.d.ts +6 -3
  32. package/dist/typescript/NativeRNBootSplash.d.ts.map +1 -1
  33. package/dist/typescript/addon/index.d.ts +3 -0
  34. package/dist/typescript/addon/index.d.ts.map +1 -0
  35. package/dist/typescript/generate.d.ts +47 -14
  36. package/dist/typescript/generate.d.ts.map +1 -1
  37. package/dist/typescript/index.d.ts +33 -5
  38. package/dist/typescript/index.d.ts.map +1 -1
  39. package/example/android/app/debug.keystore +0 -0
  40. package/example/vendor/bundle/ruby/2.7.0/gems/ffi-1.15.5/ext/ffi_c/libffi/.travis/compile +351 -0
  41. package/example/vendor/bundle/ruby/2.7.0/gems/ffi-1.15.5/ext/ffi_c/libffi/testsuite/libffi.bhaible/Makefile +28 -0
  42. package/ios/.DS_Store +0 -0
  43. package/ios/.npmignore +8 -0
  44. package/ios/RNBootSplash.mm +101 -95
  45. package/package.json +20 -13
  46. package/react-native.config.js +74 -76
  47. package/src/.DS_Store +0 -0
  48. package/src/.npmignore +1 -0
  49. package/src/NativeRNBootSplash.ts +3 -4
  50. package/src/addon/index.ts +788 -0
  51. package/src/generate.ts +457 -232
  52. package/src/index.ts +205 -8
  53. package/RNBootSplash.res +0 -29
  54. package/bsconfig.json +0 -14
package/README.md CHANGED
@@ -1,7 +1,7 @@
1
1
  # 🚀 react-native-bootsplash
2
2
 
3
3
  Show a splash screen during app startup. Hide it when you are ready.<br>
4
- **For migration from the v3, check the [`MIGRATION.md` guide](https://github.com/zoontek/react-native-bootsplash/blob/master/MIGRATION.md).**
4
+ **For migration from the v4, check the [`MIGRATION.md` guide](./MIGRATION.md).**
5
5
 
6
6
  [![mit licence](https://img.shields.io/dub/l/vibe-d.svg?style=for-the-badge)](https://github.com/zoontek/react-native-bootsplash/blob/main/LICENSE)
7
7
  [![npm version](https://img.shields.io/npm/v/react-native-bootsplash?style=for-the-badge)](https://www.npmjs.org/package/react-native-bootsplash)
@@ -11,14 +11,14 @@ Show a splash screen during app startup. Hide it when you are ready.<br>
11
11
  [![platform - ios](https://img.shields.io/badge/platform-iOS-000.svg?logo=apple&style=for-the-badge)](https://developer.apple.com/ios)
12
12
 
13
13
  <p>
14
- <img height="520" width="256" src="https://raw.githubusercontent.com/zoontek/react-native-bootsplash/HEAD/docs/ios_demo.gif?raw=true" alt="iOS demo"></img>
15
- <img height="500" width="259" src="https://raw.githubusercontent.com/zoontek/react-native-bootsplash/HEAD/docs/android_demo.gif?raw=true" alt="android demo"></img>
14
+ <img width="393" height="490" src="./docs/demo_static.png" alt="Demo">
15
+ <img width="255" height="500" src="./docs/demo.gif" alt="Demo">
16
16
  </p>
17
17
 
18
18
  ## Support
19
19
 
20
20
  This library follows the React Native [releases support policy](https://github.com/reactwg/react-native-releases#releases-support-policy).<br>
21
- It is supporting the **latest version**, and the **two previous minor series**.
21
+ It is supporting the **latest version** and the **two previous minor series**.
22
22
 
23
23
  ## Installation
24
24
 
@@ -105,62 +105,97 @@ $ yarn react-native generate-bootsplash --help
105
105
  The command can take multiple arguments:
106
106
 
107
107
  ```bash
108
- yarn react-native generate-bootsplash <logoPath>
108
+ Usage: react-native generate-bootsplash [options] <logo>
109
109
 
110
- Generate a launch screen using an original logo file (PNG or SVG)
110
+ Generate a launch screen using a logo file path (PNG or SVG)
111
111
 
112
112
  Options:
113
- --background-color <color> color used as launch screen background (in hexadecimal format) (default: "#fff")
114
- --logo-width <width> logo width at @1x (in dp - we recommend approximately ~100) (default: 100)
115
- --assets-path [path] path to your static assets directory (useful to require the logo file in JS)
116
- --flavor <flavor> [android only] flavor build variant (outputs in an android resource directory other than "main")
117
- --platforms <platforms> platforms to generate assets for (comma separated) (default: "android,ios")
118
- -h, --help output usage information
113
+ --background <string> Background color (in hexadecimal format) (default: "#fff")
114
+ --logo-width <number> Logo width at @1x (in dp - we recommend approximately ~100) (default: 100)
115
+ --assets-output <string> Assets output directory path
116
+ --platforms <list> Platforms to generate for, separated by a comma (default: "android,ios")
117
+ --flavor <string> Android flavor build variant (where your resource directory is) (default: "main")
118
+ --license-key <string> License key to enable brand and dark mode assets generation
119
+ --brand <string> Brand file path (PNG or SVG)
120
+ --brand-width <number> Brand width at @1x (in dp - we recommend approximately ~80) (default: 80)
121
+ --dark-background <string> [dark mode] Background color (in hexadecimal format)
122
+ --dark-logo <string> [dark mode] Logo file path (PNG or SVG)
123
+ --dark-brand <string> [dark mode] Brand file path (PNG or SVG)
124
+ -h, --help display help for command
119
125
  ```
120
126
 
127
+ #### 💪 Unlock the CLI full potential
128
+
129
+ In order to use the `--brand`, `--brand-width` and `--dark-*` options, you must specify a `--license-key`.
130
+
131
+ With it, the generator is able to output over **50 files** (logo and brand images generated in all pixel densities, dark mode versions, etc.), saving you (and your company!) a massive amount of time not only at creation, but also at each adjustment ⏱️
132
+
133
+ <a href="https://zoontek.gumroad.com/l/bootsplash-generator">
134
+ <img width="280" height="52" src="./docs/gumroad_button.png" alt="Gumroad button">
135
+ </a>
136
+
121
137
  #### Full command usage example
122
138
 
123
139
  ```bash
124
- yarn react-native generate-bootsplash assets/bootsplash_logo_original.png \
125
- --background-color=F5FCFF \
140
+ # Without license key
141
+ yarn react-native generate-bootsplash svgs/light_logo.svg \
142
+ --background=F5FCFF \
126
143
  --logo-width=100 \
127
- --assets-path=assets \
144
+ --assets-output=assets \
145
+ --platforms=android,ios \
146
+ --flavor=main
147
+
148
+ # With license key 🔑
149
+ yarn react-native generate-bootsplash svgs/light_logo.svg \
150
+ --background=F5FCFF \
151
+ --logo-width=100 \
152
+ --assets-output=assets \
153
+ --platforms=android,ios \
128
154
  --flavor=main \
129
- --platforms=android,ios
155
+ --license-key=xxxxx \
156
+ --brand=svgs/light_brand.svg \
157
+ --brand-width=80 \
158
+ --dark-background=00090A \
159
+ --dark-logo=svgs/dark_logo.svg \
160
+ --dark-brand=svgs/dark_brand.svg
130
161
  ```
131
162
 
132
- ![](https://raw.githubusercontent.com/zoontek/react-native-bootsplash/master/docs/cli_tool.png?raw=true)
133
-
134
163
  This tool relies on the naming conventions that are used in the `/example` project and will therefore create the following files:
135
164
 
136
165
  ```bash
137
- # Only if --assets-path was specified
166
+ # Without license key
167
+ android/app/src/main/res/values/colors.xml
168
+ android/app/src/main/res/drawable-hdpi/bootsplash_logo.png
169
+ android/app/src/main/res/drawable-mdpi/bootsplash_logo.png
170
+ android/app/src/main/res/drawable-xhdpi/bootsplash_logo.png
171
+ android/app/src/main/res/drawable-xxhdpi/bootsplash_logo.png
172
+ android/app/src/main/res/drawable-xxxhdpi/bootsplash_logo.png
173
+
174
+ ios/RNBootSplashExample/BootSplash.storyboard
175
+ ios/RNBootSplashExample/Images.xcassets/BootSplashLogo.imageset/bootsplash_logo.png
176
+ ios/RNBootSplashExample/Images.xcassets/BootSplashLogo.imageset/bootsplash_logo@2x.png
177
+ ios/RNBootSplashExample/Images.xcassets/BootSplashLogo.imageset/bootsplash_logo@3x.png
178
+
179
+ # Only if --assets-output was specified
180
+ assets/bootsplash_manifest.json
138
181
  assets/bootsplash_logo.png
139
182
  assets/bootsplash_logo@1,5x.png
140
183
  assets/bootsplash_logo@2x.png
141
184
  assets/bootsplash_logo@3x.png
142
185
  assets/bootsplash_logo@4x.png
143
186
 
144
- android/app/src/main/res/values/colors.xml (creation and edition)
145
- android/app/src/main/res/mipmap-hdpi/bootsplash_logo.png
146
- android/app/src/main/res/mipmap-mdpi/bootsplash_logo.png
147
- android/app/src/main/res/mipmap-xhdpi/bootsplash_logo.png
148
- android/app/src/main/res/mipmap-xxhdpi/bootsplash_logo.png
149
- android/app/src/main/res/mipmap-xxxhdpi/bootsplash_logo.png
150
-
151
- ios/YourProjectName/BootSplash.storyboard
152
- ios/YourProjectName/Images.xcassets/BootSplashLogo.imageset/bootsplash_logo.png
153
- ios/YourProjectName/Images.xcassets/BootSplashLogo.imageset/bootsplash_logo@2x.png
154
- ios/YourProjectName/Images.xcassets/BootSplashLogo.imageset/bootsplash_logo@3x.png
187
+ # + 31 files with license key 🔑 (brand images, dark mode versions…)
155
188
  ```
156
189
 
190
+ ![](./docs/cli_generator.png)
191
+
157
192
  ### iOS
158
193
 
159
194
  _ℹ️ For `react-native` < `0.71` setup, follow the [`v4.4.0 README.md`](https://github.com/zoontek/react-native-bootsplash/blob/4.4.0/README.md)._
160
195
 
161
196
  ---
162
197
 
163
- Edit the `ios/YourProjectName/AppDelegate.mm` file:
198
+ 1. Edit the `ios/YourProjectName/AppDelegate.mm` file:
164
199
 
165
200
  ```obj-c
166
201
  #import "AppDelegate.h"
@@ -188,33 +223,21 @@ Edit the `ios/YourProjectName/AppDelegate.mm` file:
188
223
  @end
189
224
  ```
190
225
 
191
- Set the `BootSplash.storyboard` as launch screen file:
226
+ 2. Drag and drop the generated `BootSplash.storyboard` (and `Colors.xcassets`, when using dark mode):
192
227
 
193
- | Drag and drop the file | Create folder reference | Set as Launch Screen File |
194
- | ------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------- |
195
- | ![](https://raw.githubusercontent.com/zoontek/react-native-bootsplash/master/docs/xcode-1.png?raw=true) | ![](https://raw.githubusercontent.com/zoontek/react-native-bootsplash/master/docs/xcode-2.png?raw=true) | ![](https://raw.githubusercontent.com/zoontek/react-native-bootsplash/master/docs/xcode-3.png?raw=true) |
228
+ ![](./docs/xcode_1.png)
196
229
 
197
- ### Android
198
-
199
- _⚠️  On Android >= 12, the splash screen will not appear if you start your app from the terminal / Android Studio. To see it, kill your app and restart it in normal conditions (tap on your app icon in the app launcher)._
200
-
201
- ---
230
+ 3. Create folder references:
202
231
 
203
- 1. Edit your `android/app/build.gradle` file:
204
-
205
- ```gradle
206
- dependencies {
207
- // …
232
+ ![](./docs/xcode_2.png)
208
233
 
209
- implementation("androidx.swiperefreshlayout:swiperefreshlayout:1.0.0")
210
- implementation("androidx.core:core-splashscreen:1.0.0") // add this line
234
+ 4. Set `BootSplash.storyboard` as Launch Screen File:
211
235
 
212
- // …
213
- ```
236
+ ![](./docs/xcode_3.png)
214
237
 
215
- _⚠️  Don't forget going into the `android` directory to execute a `./gradlew clean && ./gradlew build` (or perform a Gradle sync in Android Studio)._
238
+ ### Android
216
239
 
217
- 2. Edit your `android/app/src/main/res/values/styles.xml` file:
240
+ 1. Edit your `android/app/src/main/res/values/styles.xml` file:
218
241
 
219
242
  ```xml
220
243
  <resources>
@@ -223,17 +246,18 @@ _⚠️  Don't forget going into the `android` directory to execute a `./gradl
223
246
  <!-- Your base theme customization -->
224
247
  </style>
225
248
 
226
- <!-- BootTheme should inherit from Theme.SplashScreen -->
227
- <style name="BootTheme" parent="Theme.SplashScreen">
228
- <item name="windowSplashScreenBackground">@color/bootsplash_background</item>
229
- <item name="windowSplashScreenAnimatedIcon">@mipmap/bootsplash_logo</item>
230
- <item name="postSplashScreenTheme">@style/AppTheme</item>
249
+ <!-- BootTheme should inherit from Theme.BootSplash -->
250
+ <style name="BootTheme" parent="Theme.BootSplash">
251
+ <item name="bootSplashBackground">@color/bootsplash_background</item>
252
+ <item name="bootSplashLogo">@drawable/bootsplash_logo</item>
253
+ <item name="bootSplashBrand">@drawable/bootsplash_brand</item> <!-- Only if you have a brand image -->
254
+ <item name="postBootSplashTheme">@style/AppTheme</item>
231
255
  </style>
232
256
 
233
257
  </resources>
234
258
  ```
235
259
 
236
- 3. Edit your `android/app/src/main/AndroidManifest.xml` file:
260
+ 2. Edit your `android/app/src/main/AndroidManifest.xml` file:
237
261
 
238
262
  ```xml
239
263
  <manifest xmlns:android="http://schemas.android.com/apk/res/android"
@@ -254,7 +278,7 @@ _⚠️  Don't forget going into the `android` directory to execute a `./gradl
254
278
 
255
279
  ```
256
280
 
257
- 4. Finally edit your `android/app/src/main/java/com/yourprojectname/MainActivity.java` file:
281
+ 3. Finally edit your `android/app/src/main/java/com/yourprojectname/MainActivity.java` file:
258
282
 
259
283
  ```java
260
284
  // …
@@ -269,7 +293,7 @@ public class MainActivity extends ReactActivity {
269
293
 
270
294
  @Override
271
295
  protected void onCreate(Bundle savedInstanceState) {
272
- RNBootSplash.init(this); // ⬅️ initialize the splash screen
296
+ RNBootSplash.init(this, R.style.BootTheme); // ⬅️ initialize the splash screen
273
297
  super.onCreate(savedInstanceState); // or super.onCreate(null) with react-native-screens
274
298
  }
275
299
  }
@@ -279,87 +303,170 @@ public class MainActivity extends ReactActivity {
279
303
 
280
304
  ### hide()
281
305
 
306
+ Hide the splash screen (immediately, or with a fade out).
307
+
282
308
  #### Method type
283
309
 
284
310
  ```ts
285
- type hide = (config?: { fade?: boolean; duration?: number }) => Promise<void>;
311
+ type hide = (config?: { fade?: boolean }) => Promise<void>;
286
312
  ```
287
313
 
288
- Note: Only durations above 220ms are visually noticeable. Smaller values will be ignored and the default duration will be used.
289
-
290
314
  #### Usage
291
315
 
292
- ```js
293
- import RNBootSplash from "react-native-bootsplash";
316
+ ```tsx
317
+ import { useEffect } from "react";
318
+ import { Text } from "react-native";
319
+ import BootSplash from "react-native-bootsplash";
320
+
321
+ const App = () => {
322
+ useEffect(() => {
323
+ const init = async () => {
324
+ // …do multiple sync or async tasks
325
+ };
326
+
327
+ init().finally(async () => {
328
+ await BootSplash.hide({ fade: true });
329
+ console.log("BootSplash has been hidden successfully");
330
+ });
331
+ }, []);
294
332
 
295
- RNBootSplash.hide(); // immediate
296
- RNBootSplash.hide({ fade: true }); // fade with 220ms default duration
297
- RNBootSplash.hide({ fade: true, duration: 500 }); // fade with custom duration
333
+ return <Text>My awesome app</Text>;
334
+ };
298
335
  ```
299
336
 
300
- ### getVisibilityStatus()
337
+ ### isVisible()
338
+
339
+ Return the current visibility status of the native splash screen.
301
340
 
302
341
  #### Method type
303
342
 
304
343
  ```ts
305
- type VisibilityStatus = "visible" | "hidden" | "transitioning";
306
- type getVisibilityStatus = () => Promise<VisibilityStatus>;
344
+ type isVisible = () => Promise<boolean>;
307
345
  ```
308
346
 
309
347
  #### Usage
310
348
 
311
- ```js
312
- import RNBootSplash from "react-native-bootsplash";
349
+ ```ts
350
+ import BootSplash from "react-native-bootsplash";
313
351
 
314
- RNBootSplash.getVisibilityStatus().then((status) => console.log(status));
352
+ RNBootSplash.isVisible().then((value) => console.log(value));
315
353
  ```
316
354
 
317
- ## Real world example
318
-
319
- ```js
320
- import React, { useEffect } from "react";
321
- import { Text } from "react-native";
322
- import RNBootSplash from "react-native-bootsplash";
355
+ ### useHideAnimation()
323
356
 
324
- function App() {
325
- useEffect(() => {
326
- const init = async () => {
327
- // …do multiple sync or async tasks
328
- };
357
+ A hook to easily creation a hide custom hide animation, by animating all splash screen elements using `Animated`, `react-native-reanimated` or else (similar as the video on top of this documentation).<br>
358
+ To use it, don't forget to set the `--assets-output` option of the generator as it requires the manifest and assets images files.
329
359
 
330
- init().finally(async () => {
331
- await RNBootSplash.hide({ fade: true, duration: 500 });
332
- console.log("BootSplash has been hidden successfully");
333
- });
334
- }, []);
360
+ #### Method type
335
361
 
336
- return <Text>My awesome app</Text>;
337
- }
362
+ ```ts
363
+ type useHideAnimation = (config: {
364
+ manifest: Manifest; // the manifest file is generated when --assets-output is specified
365
+
366
+ // the required generated assets
367
+ logo: ImageRequireSource;
368
+ darkLogo?: ImageRequireSource;
369
+ brand?: ImageRequireSource;
370
+ darkBrand?: ImageRequireSource;
371
+
372
+ // specify if you are using translucent status / navigation bars
373
+ // in order to avoid a shift between the native and JS splash screen
374
+ statusBarTranslucent?: boolean;
375
+ navigationBarTranslucent?: boolean;
376
+
377
+ animate: () => void;
378
+ }) => {
379
+ container: ViewProps;
380
+ logo: ImageProps;
381
+ brand?: ImageProps;
382
+ };
338
383
  ```
339
384
 
340
- **🤙 A more complex example is available in the [`/example` folder](example).**
385
+ #### Usage
341
386
 
342
- ## With React Navigation
387
+ ```tsx
388
+ import { useState } from "react";
389
+ import { Animated, Image } from "react-native";
390
+ import BootSplash from "react-native-bootsplash";
391
+
392
+ type Props = {
393
+ onAnimationEnd: () => void;
394
+ };
395
+
396
+ const AnimatedBootSplash = ({ onAnimationEnd }: Props) => {
397
+ const [opacity] = useState(() => new Animated.Value(1));
398
+
399
+ const { container, logo /*, brand */ } = BootSplash.useHideAnimation({
400
+ manifest: require("../assets/bootsplash_manifest.json"),
401
+
402
+ logo: require("../assets/bootsplash_logo.png"),
403
+ // darkLogo: require("../assets/bootsplash_dark_logo.png"),
404
+ // brand: require("../assets/bootsplash_brand.png"),
405
+ // darkBrand: require("../assets/bootsplash_dark_brand.png"),
406
+
407
+ statusBarTranslucent: true,
408
+ navigationBarTranslucent: false,
409
+
410
+ animate: () => {
411
+ // Perform animations and call onAnimationEnd
412
+ Animated.timing(opacity, {
413
+ useNativeDriver: true,
414
+ toValue: 0,
415
+ duration: 500,
416
+ }).start(() => {
417
+ onAnimationEnd();
418
+ });
419
+ },
420
+ });
343
421
 
344
- If you are using React Navigation, you can hide the splash screen once the navigation container and all children have finished mounting by using the `onReady` function.
422
+ return (
423
+ <Animated.View {...container} style={[container.style, { opacity }]}>
424
+ <Image {...logo} style={logo.style} />
425
+ {/* {brand && <Image {...brand} style={brand.style} />} */}
426
+ </Animated.View>
427
+ );
428
+ };
345
429
 
346
- ```js
347
- import React from "react";
348
- import { NavigationContainer } from "@react-navigation/native";
349
- import RNBootSplash from "react-native-bootsplash";
430
+ const App = () => {
431
+ const [visible, setVisible] = useState(true);
350
432
 
351
- function App() {
352
433
  return (
353
- <NavigationContainer onReady={() => RNBootSplash.hide()}>
434
+ <View style={{ flex: 1 }}>
354
435
  {/* content */}
355
- </NavigationContainer>
436
+
437
+ {visible && (
438
+ <AnimatedBootSplash
439
+ onAnimationEnd={() => {
440
+ setVisible(false);
441
+ }}
442
+ />
443
+ )}
444
+ </View>
356
445
  );
357
- }
446
+ };
358
447
  ```
359
448
 
360
- ## With react-native-bars
449
+ **This example is simple for documentation purpose (we only animate the container).**<br>
450
+ **🤙 A more complex example is available in the [`/example` folder](./example/src/AnimatedBootSplash.tsx).**
451
+
452
+ ## With React Navigation
453
+
454
+ If you are using React Navigation, you can hide the splash screen once the navigation container and all children have finished mounting by using the `onReady` function.
361
455
 
362
- In order to keep fully transparent status and navigation bars on Android once the splash screen is hidden (and control them), this library play nicely with [react-native-bars](https://github.com/zoontek/react-native-bars). Check its [README](https://github.com/zoontek/react-native-bars/blob/main/README.md#with-react-native-bootsplash) for more informations.
456
+ ```tsx
457
+ import { NavigationContainer } from "@react-navigation/native";
458
+ import BootSplash from "react-native-bootsplash";
459
+
460
+ const App = () => (
461
+ <NavigationContainer
462
+ onReady={() => {
463
+ BootSplash.hide();
464
+ }}
465
+ >
466
+ {/* content */}
467
+ </NavigationContainer>
468
+ );
469
+ ```
363
470
 
364
471
  ## Testing with Jest
365
472
 
@@ -367,11 +474,11 @@ Testing code which uses this library requires some setup since we need to mock t
367
474
 
368
475
  To add the mocks, create a file _jest/setup.js_ (or any other file name) containing the following code:
369
476
 
370
- ```js
477
+ ```ts
371
478
  jest.mock("react-native-bootsplash", () => {
372
479
  return {
373
- hide: jest.fn().mockResolvedValueOnce(),
374
- getVisibilityStatus: jest.fn().mockResolvedValue("hidden"),
480
+ hide: jest.fn().mockResolvedValue(),
481
+ isVisible: jest.fn().mockResolvedValue(false),
375
482
  };
376
483
  });
377
484
  ```
@@ -11,6 +11,7 @@ Pod::Spec.new do |s|
11
11
  s.author = package["author"]
12
12
  s.homepage = package["homepage"]
13
13
 
14
+ s.platforms = { :ios => "12.4", :tvos => "12.4" }
14
15
  s.requires_arc = true
15
16
 
16
17
  s.source = { :git => package["repository"]["url"], :tag => s.version }
@@ -18,9 +19,7 @@ Pod::Spec.new do |s|
18
19
 
19
20
  if ENV['RCT_NEW_ARCH_ENABLED'] == '1' then
20
21
  install_modules_dependencies(s)
21
- s.platforms = { :ios => "12.4", :tvos => "12.4" }
22
22
  else
23
23
  s.dependency "React-Core"
24
- s.platforms = { :ios => "11.0", :tvos => "11.0" }
25
24
  end
26
25
  end
@@ -0,0 +1,11 @@
1
+ .gradle/
2
+ .idea/
3
+ build/
4
+ gradle/
5
+
6
+ .DS_Store
7
+ .npmignore
8
+ gradlew
9
+ gradlew.bat
10
+ *.iml
11
+ local.properties
@@ -59,5 +59,4 @@ repositories {
59
59
  dependencies {
60
60
  //noinspection GradleDynamicVersion
61
61
  implementation "com.facebook.react:react-native:+" // From node_modules
62
- implementation "androidx.core:core-splashscreen:${safeExtGet("androidXSplashScreenVersion", "1.0.0")}"
63
62
  }
@@ -3,10 +3,11 @@ package com.zoontek.rnbootsplash;
3
3
  import android.app.Activity;
4
4
 
5
5
  import androidx.annotation.NonNull;
6
+ import androidx.annotation.StyleRes;
6
7
 
7
8
  public class RNBootSplash {
8
9
 
9
- public static void init(@NonNull final Activity activity) {
10
- RNBootSplashModuleImpl.init(activity);
10
+ public static void init(@NonNull final Activity activity, @StyleRes int themeResId) {
11
+ RNBootSplashModuleImpl.init(activity, themeResId);
11
12
  }
12
13
  }
@@ -0,0 +1,49 @@
1
+ package com.zoontek.rnbootsplash;
2
+
3
+ import android.app.Dialog;
4
+ import android.content.Context;
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
+ @StyleRes
15
+ private int mWindowAnimationsResId = -1;
16
+
17
+ public RNBootSplashDialog(@NonNull Context context, @StyleRes int themeResId) {
18
+ super(context, themeResId);
19
+ setCancelable(false);
20
+ setCanceledOnTouchOutside(false);
21
+ }
22
+
23
+ @Override
24
+ public void onBackPressed() {
25
+ // Prevent default behavior
26
+ }
27
+
28
+ @Override
29
+ protected void onCreate(Bundle savedInstanceState) {
30
+ final Window window = this.getWindow();
31
+
32
+ if (window != null) {
33
+ window.setLayout(
34
+ WindowManager.LayoutParams.MATCH_PARENT,
35
+ WindowManager.LayoutParams.MATCH_PARENT
36
+ );
37
+
38
+ if (mWindowAnimationsResId != -1) {
39
+ window.setWindowAnimations(mWindowAnimationsResId);
40
+ }
41
+ }
42
+
43
+ super.onCreate(savedInstanceState);
44
+ }
45
+
46
+ public void setWindowAnimations(@StyleRes int windowAnimationsResId) {
47
+ mWindowAnimationsResId = windowAnimationsResId;
48
+ }
49
+ }