react-native-bootsplash 4.0.0-alpha.1 → 4.0.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 (31) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +80 -144
  3. package/RNBootSplash.podspec +1 -1
  4. package/{ReactNativeBootsplash.res → RNBootsplash.res} +4 -8
  5. package/android/build.gradle +13 -11
  6. package/android/src/main/java/com/zoontek/rnbootsplash/RNBootSplash.java +2 -11
  7. package/android/src/main/java/com/zoontek/rnbootsplash/RNBootSplashModule.java +79 -198
  8. package/android/src/main/java/com/zoontek/rnbootsplash/RNBootSplashPackage.java +6 -2
  9. package/android/src/main/java/com/zoontek/rnbootsplash/RNBootSplashTask.java +1 -15
  10. package/bsconfig.json +0 -1
  11. package/dist/commonjs/generate.js +128 -110
  12. package/dist/commonjs/generate.js.map +1 -1
  13. package/dist/commonjs/index.js +5 -21
  14. package/dist/commonjs/index.js.map +1 -1
  15. package/dist/module/generate.js +124 -107
  16. package/dist/module/generate.js.map +1 -1
  17. package/dist/module/index.js +3 -15
  18. package/dist/module/index.js.map +1 -1
  19. package/dist/typescript/generate.d.ts +4 -4
  20. package/dist/typescript/index.d.ts +0 -6
  21. package/ios/RNBootSplash.h +3 -13
  22. package/ios/RNBootSplash.m +44 -99
  23. package/ios/RNBootSplash.xcodeproj/project.pbxproj +2 -2
  24. package/package.json +19 -21
  25. package/react-native.config.js +21 -8
  26. package/src/generate.ts +116 -138
  27. package/src/index.ts +0 -14
  28. package/android/src/main/java/com/zoontek/rnbootsplash/RNBootSplashDialog.java +0 -36
  29. package/android/src/main/res/anim/bootsplash_fade_in.xml +0 -7
  30. package/android/src/main/res/anim/bootsplash_fade_out.xml +0 -7
  31. package/android/src/main/res/values/styles.xml +0 -13
package/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2020 Mathieu Acthernoene
3
+ Copyright (c) 2021 Mathieu Acthernoene
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
package/README.md CHANGED
@@ -4,42 +4,40 @@
4
4
  <img align="right" width="160" alt="This library helped you? Consider sponsoring!" src=".github/funding-octocat.svg">
5
5
  </a>
6
6
 
7
- Show a bootsplash during app startup. Hide it when you are ready.
7
+ Show a bootsplash during app startup. Hide it when you are ready.<br>
8
+ **For migration from the v3, check the [`MIGRATION.md` guide](https://github.com/zoontek/react-native-bootsplash/blob/master/MIGRATION.md).**
8
9
 
9
10
  [![npm version](https://badge.fury.io/js/react-native-bootsplash.svg)](https://www.npmjs.org/package/react-native-bootsplash)
10
11
  [![npm](https://img.shields.io/npm/dt/react-native-bootsplash.svg)](https://www.npmjs.org/package/react-native-bootsplash)
11
12
  [![MIT](https://img.shields.io/dub/l/vibe-d.svg)](https://opensource.org/licenses/MIT)
12
- <br>
13
13
  [![Platform - Android](https://img.shields.io/badge/platform-Android-3ddc84.svg?style=flat&logo=android)](https://www.android.com)
14
14
  [![Platform - iOS](https://img.shields.io/badge/platform-iOS-000.svg?style=flat&logo=apple)](https://developer.apple.com/ios)
15
15
 
16
16
  <p>
17
17
  <img height="520" src="https://raw.githubusercontent.com/zoontek/react-native-bootsplash/HEAD/docs/ios_demo.gif?raw=true" alt="iOS demo"></img>
18
- <img width="300" src="https://raw.githubusercontent.com/zoontek/react-native-bootsplash/HEAD/docs/android_demo.gif?raw=true" alt="android demo"></img>
18
+ <img height="500" src="https://raw.githubusercontent.com/zoontek/react-native-bootsplash/HEAD/docs/android_demo.gif?raw=true" alt="android demo"></img>
19
19
  </p>
20
20
 
21
21
  ## Support
22
22
 
23
23
  | version | react-native version |
24
24
  | ------- | -------------------- |
25
+ | 4.0.0+ | 0.65.0+ |
25
26
  | 3.0.0+ | 0.63.0+ |
26
- | 2.0.0+ | 0.60.0+ |
27
-
28
- For 0.59-, you should use [`jetify -r`](https://github.com/mikehardy/jetifier/blob/master/README.md#to-reverse-jetify--convert-node_modules-dependencies-to-support-libraries)
29
27
 
30
28
  ## Installation
31
29
 
32
30
  ```bash
33
- $ npm install --save react-native-bootsplash
31
+ $ npm install --save react-native-bootsplash@next
34
32
  # --- or ---
35
- $ yarn add react-native-bootsplash
33
+ $ yarn add react-native-bootsplash@next
36
34
  ```
37
35
 
38
36
  Don't forget going into the `ios` directory to execute a `pod install`.
39
37
 
40
38
  ## 🆘 Manual linking
41
39
 
42
- Because this package targets React Native 0.60.0+, you will probably don't need to link it manually. Otherwise if it's not the case, follow this additional instructions:
40
+ Because this package targets React Native 0.65.0+, you probably don't need to link it manually. But if you have a special case, follow these additional instructions:
43
41
 
44
42
  <details>
45
43
  <summary><b>👀 See manual linking instructions</b></summary>
@@ -118,7 +116,7 @@ Generate a launch screen using an original logo file
118
116
 
119
117
  Options:
120
118
  --background-color <color> color used as launch screen background (in hexadecimal format) (default: "#fff")
121
- --logo-width <width> logo width at @1x (in dp - we recommand approximately ~100) (default: 100)
119
+ --logo-width <width> logo width at @1x (in dp - we recommend approximately ~100) (default: 100)
122
120
  --assets-path [path] path to your static assets directory (useful to require the logo file in JS)
123
121
  --flavor <flavor> [android only] flavor build variant (outputs in an android resource directory other than "main")
124
122
  -h, --help output usage information
@@ -139,7 +137,13 @@ yarn react-native generate-bootsplash assets/bootsplash_logo_original.png \
139
137
  This tool relies on the naming conventions that are used in the `/example` project and will therefore create the following files:
140
138
 
141
139
  ```bash
142
- android/app/src/main/res/drawable/bootsplash.xml
140
+ # Only if --assets-path was specified
141
+ assets/bootsplash_logo.png
142
+ assets/bootsplash_logo@1,5x.png
143
+ assets/bootsplash_logo@2x.png
144
+ assets/bootsplash_logo@3x.png
145
+ assets/bootsplash_logo@4x.png
146
+
143
147
  android/app/src/main/res/values/colors.xml (creation and edition)
144
148
  android/app/src/main/res/mipmap-hdpi/bootsplash_logo.png
145
149
  android/app/src/main/res/mipmap-mdpi/bootsplash_logo.png
@@ -151,13 +155,6 @@ ios/YourProjectName/BootSplash.storyboard
151
155
  ios/YourProjectName/Images.xcassets/BootSplashLogo.imageset/bootsplash_logo.png
152
156
  ios/YourProjectName/Images.xcassets/BootSplashLogo.imageset/bootsplash_logo@2x.png
153
157
  ios/YourProjectName/Images.xcassets/BootSplashLogo.imageset/bootsplash_logo@3x.png
154
-
155
- # Only if --assets-path was specified
156
- assets/bootsplash_logo.png
157
- assets/bootsplash_logo@1,5x.png
158
- assets/bootsplash_logo@2x.png
159
- assets/bootsplash_logo@3x.png
160
- assets/bootsplash_logo@4x.png
161
158
  ```
162
159
 
163
160
  ### iOS
@@ -198,47 +195,52 @@ Set the `BootSplash.storyboard` as launch screen file:
198
195
 
199
196
  ### Android
200
197
 
201
- 1. Edit the `android/app/src/main/java/com/yourprojectname/MainActivity.java` file:
198
+ 1. As this library only support Android 6+, you probably have to edit your `android/build.gradle` file:
202
199
 
203
- ```java
204
- import android.os.Bundle; // <- add this necessary import
200
+ ```gradle
201
+ buildscript {
202
+ ext {
203
+ buildToolsVersion = "30.0.2"
204
+ minSdkVersion = 23 // <- AndroidX splashscreen has basic support for 21 (only the background color), so 23 is best
205
+ compileSdkVersion = 31 // <- set at least 31
206
+ targetSdkVersion = 31 // <- set at least 31
205
207
 
206
- import com.facebook.react.ReactActivity;
207
- import com.zoontek.rnbootsplash.RNBootSplash; // <- add this necessary import
208
+ //
209
+ ```
208
210
 
209
- public class MainActivity extends ReactActivity {
211
+ 2. Then edit your `android/app/build.gradle` file:
210
212
 
211
- // …
213
+ ```gradle
214
+ dependencies {
215
+ implementation fileTree(dir: "libs", include: ["*.jar"])
216
+ //noinspection GradleDynamicVersion
217
+ implementation "com.facebook.react:react-native:+" // From node_modules
212
218
 
213
- @Override
214
- protected void onCreate(Bundle savedInstanceState) {
215
- super.onCreate(savedInstanceState);
216
- RNBootSplash.init(R.drawable.bootsplash, MainActivity.this); // <- display the generated bootsplash.xml drawable over our MainActivity
217
- }
218
- ```
219
+ implementation "androidx.core:core-splashscreen:1.0.0-alpha02" // Add this line
219
220
 
220
- As Android will not create our main activity before launching the app, we need to display a different activity at start, then switch to our main one.
221
+ //
222
+ ```
221
223
 
222
- 2. Edit the `android/app/src/main/res/values/styles.xml` file:
224
+ 3. Edit your `android/app/src/main/res/values/styles.xml` file:
223
225
 
224
226
  ```xml
225
227
  <resources>
226
228
 
227
- <!-- Base application theme -->
228
229
  <style name="AppTheme" parent="Theme.AppCompat.DayNight.NoActionBar">
229
- <!-- Your base theme customization -->
230
+ <!-- Your base theme customization -->
230
231
  </style>
231
232
 
232
- <!-- Add the following lines (BootTheme should inherit from AppTheme) -->
233
- <style name="BootTheme" parent="AppTheme">
234
- <!-- set the generated bootsplash.xml drawable as activity background -->
235
- <item name="android:background">@drawable/bootsplash</item>
233
+ <!-- BootTheme should inherit from Theme.SplashScreen -->
234
+ <style name="BootTheme" parent="Theme.SplashScreen">
235
+ <item name="windowSplashScreenBackground">@color/bootsplash_background</item>
236
+ <item name="windowSplashScreenAnimatedIcon">@mipmap/bootsplash_logo</item>
237
+ <item name="postSplashScreenTheme">@style/AppTheme</item>
236
238
  </style>
237
239
 
238
240
  </resources>
239
241
  ```
240
242
 
241
- 3. Edit the `android/app/src/main/AndroidManifest.xml` file:
243
+ 4. Edit your `android/app/src/main/AndroidManifest.xml` file:
242
244
 
243
245
  ```xml
244
246
  <manifest xmlns:android="http://schemas.android.com/apk/res/android"
@@ -252,35 +254,47 @@ As Android will not create our main activity before launching the app, we need t
252
254
  android:icon="@mipmap/ic_launcher"
253
255
  android:roundIcon="@mipmap/ic_launcher_round"
254
256
  android:allowBackup="false"
255
- android:theme="@style/AppTheme">
256
-
257
+ android:theme="@style/BootTheme"> <!-- Replace @style/AppTheme with @style/BootTheme -->
257
258
  <activity
258
- android:name=".MainActivity"
259
- android:configChanges="keyboard|keyboardHidden|orientation|screenSize|uiMode"
260
- android:label="@string/app_name"
261
- android:windowSoftInputMode="adjustResize"
262
- android:exported="true"
263
- android:launchMode="singleTask">
264
- <!-- ⚠️ add android:exported="true" and android:launchMode="singleTask" above -->
265
- <!-- remove the <intent-filter> from .MainActivity -->
259
+ android:name=".MainActivity"
260
+ android:label="@string/app_name"
261
+ android:configChanges="keyboard|keyboardHidden|orientation|screenSize|uiMode"
262
+ android:launchMode="singleTask"
263
+ android:windowSoftInputMode="adjustResize"
264
+ android:exported="true"> <!-- Add android:exported="true" -->
265
+ <intent-filter>
266
+ <action android:name="android.intent.action.MAIN" />
267
+ <category android:name="android.intent.category.LAUNCHER" />
268
+ </intent-filter>
266
269
  </activity>
270
+ </application>
271
+ </manifest>
267
272
 
268
- <!-- add the following lines (use the theme you created at step 2) -->
269
- <activity
270
- android:name="com.zoontek.rnbootsplash.RNBootSplashActivity"
271
- android:theme="@style/BootTheme"
272
- android:launchMode="singleTask">
273
- <intent-filter>
274
- <action android:name="android.intent.action.MAIN" />
275
- <category android:name="android.intent.category.LAUNCHER" />
276
- </intent-filter>
277
- </activity>
273
+ ```
278
274
 
279
- <!-- -->
275
+ 5. Finally edit your `android/app/src/main/java/com/yourprojectname/MainActivity.java` file:
280
276
 
281
- </application>
277
+ ```java
278
+ import com.facebook.react.ReactActivity;
279
+ import com.facebook.react.ReactActivityDelegate; // <- add this necessary import
280
+ import com.zoontek.rnbootsplash.RNBootSplash; // <- add this necessary import
282
281
 
283
- </manifest>
282
+ public class MainActivity extends ReactActivity {
283
+
284
+ // …
285
+
286
+ @Override
287
+ protected ReactActivityDelegate createReactActivityDelegate() {
288
+ return new ReactActivityDelegate(this, getMainComponentName()) {
289
+
290
+ @Override
291
+ protected void loadApp(String appKey) {
292
+ RNBootSplash.init(MainActivity.this); // <- initialize the splash screen
293
+ super.loadApp(appKey);
294
+ }
295
+ };
296
+ }
297
+ }
284
298
  ```
285
299
 
286
300
  ## API
@@ -304,25 +318,6 @@ RNBootSplash.hide({ fade: true }); // fade
304
318
 
305
319
  ---
306
320
 
307
- ### show()
308
-
309
- #### Method type
310
-
311
- ```ts
312
- type show = (config?: { fade?: boolean }) => Promise<void>;
313
- ```
314
-
315
- #### Usage
316
-
317
- ```js
318
- import RNBootSplash from "react-native-bootsplash";
319
-
320
- RNBootSplash.show(); // immediate
321
- RNBootSplash.show({ fade: true }); // fade
322
- ```
323
-
324
- ---
325
-
326
321
  ### getVisibilityStatus()
327
322
 
328
323
  #### Method type
@@ -365,72 +360,15 @@ function App() {
365
360
 
366
361
  **🤙 A more complex example is available in the [`/example` folder](example).**
367
362
 
368
- ## Guides
369
-
370
- ### Handle deep linking (on Android)
371
-
372
- If you want to correctly handle [deep linking](https://developer.android.com/training/app-links/deep-linking) with this package, you should edit the `android/app/src/main/AndroidManifest.xml` file like this:
373
-
374
- ```xml
375
- <manifest xmlns:android="http://schemas.android.com/apk/res/android"
376
- package="com.rnbootsplashexample">
377
-
378
- <!-- … -->
379
-
380
- <application
381
- android:name=".MainApplication"
382
- android:label="@string/app_name"
383
- android:icon="@mipmap/ic_launcher"
384
- android:roundIcon="@mipmap/ic_launcher_round"
385
- android:allowBackup="false"
386
- android:theme="@style/AppTheme">
387
-
388
- <activity
389
- android:name=".MainActivity"
390
- android:configChanges="keyboard|keyboardHidden|orientation|screenSize|uiMode"
391
- android:label="@string/app_name"
392
- android:windowSoftInputMode="adjustResize"
393
- android:exported="true"
394
- android:launchMode="singleTask">
395
- <!-- ⚠️ add android:exported="true" and android:launchMode="singleTask" above -->
396
- <!-- remove the <intent-filter> from .MainActivity -->
397
- </activity>
398
-
399
- <activity
400
- android:name="com.zoontek.rnbootsplash.RNBootSplashActivity"
401
- android:theme="@style/BootTheme"
402
- android:launchMode="singleTask">
403
- <intent-filter>
404
- <action android:name="android.intent.action.MAIN" />
405
- <category android:name="android.intent.category.LAUNCHER" />
406
- </intent-filter>
407
-
408
- <!-- add your deep linking instructions inside the RNBootSplashActivity declaration -->
409
- <intent-filter>
410
- <action android:name="android.intent.action.VIEW" />
411
- <category android:name="android.intent.category.DEFAULT" />
412
- <category android:name="android.intent.category.BROWSABLE" />
413
- <data android:scheme="YOUR APP SCHEME" /> <!-- replace this with your custom scheme -->
414
- </intent-filter>
415
- </activity>
416
-
417
- <!-- … -->
418
-
419
- </application>
420
-
421
- </manifest>
422
- ```
423
-
424
363
  ### Testing with Jest
425
364
 
426
- Testing code which uses this library required some setup since we need to mock the native methods.
365
+ Testing code which uses this library requires some setup since we need to mock the native methods.
427
366
 
428
367
  To add the mocks, create a file _jest/setup.js_ (or any other file name) containing the following code:
429
368
 
430
369
  ```js
431
370
  jest.mock("react-native-bootsplash", () => {
432
371
  return {
433
- hide: jest.fn().mockResolvedValueOnce(),
434
372
  show: jest.fn().mockResolvedValueOnce(),
435
373
  getVisibilityStatus: jest.fn().mockResolvedValue("hidden"),
436
374
  };
@@ -465,8 +403,6 @@ function App() {
465
403
 
466
404
  ## 🕵️‍♂️ Comparison with [react-native-splash-screen](https://github.com/crazycodeboy/react-native-splash-screen)
467
405
 
468
- - If `react-native-splash-screen` encourages you to display an image over your application, `react-native-bootsplash` way-to-go is to design your launch screen using platforms tools ([Xcode layout editor](https://developer.apple.com/library/archive/documentation/UserExperience/Conceptual/AutolayoutPG/) and [Android drawable resource](https://developer.android.com/guide/topics/resources/drawable-resource)).
469
-
406
+ - If `react-native-splash-screen` encourages you to display an image over your application, `react-native-bootsplash` way-to-go is to design your launch screen using platforms tools.
470
407
  - It should not prevent you from seeing red screen errors.
471
-
472
- - Hiding the launch screen is configurable: fade it out or hide it without any animation at all (no fade needed if you want to animate it out!).
408
+ - Hiding the launch screen is configurable: fade it out or hide it without any animation.
@@ -11,7 +11,7 @@ Pod::Spec.new do |s|
11
11
  s.authors = package["author"]
12
12
  s.homepage = package["homepage"]
13
13
 
14
- s.platforms = { :ios => "9.0", :tvos => "11.0" }
14
+ s.platforms = { :ios => "11.0" }
15
15
  s.requires_arc = true
16
16
 
17
17
  s.source = { :git => package["repository"]["url"], :tag => s.version }
@@ -1,28 +1,24 @@
1
1
  type config = {fade: bool}
2
2
 
3
- @bs.module("react-native-bootsplash") @bs.scope("default")
3
+ @module("react-native-bootsplash") @scope("default")
4
4
  external hide: config => Js.Promise.t<unit> = "hide"
5
5
 
6
- @bs.module("react-native-bootsplash") @bs.scope("default")
7
- external show: config => Js.Promise.t<unit> = "show"
8
-
9
6
  // Note that this binding requires BuckleScript >= 8.2.0
10
7
  type visibilityStatus = [#visible | #hidden | #transitioning]
11
8
 
12
- @bs.module("react-native-bootsplash") @bs.scope("default")
9
+ @module("react-native-bootsplash") @scope("default")
13
10
  external getVisibilityStatus: unit => Js.Promise.t<visibilityStatus> = "getVisibilityStatus"
14
11
  /*
15
12
  ## Usage
16
13
 
17
14
  ```rescript
18
- ReactNativeBootsplash.hide({fade: true})->ignore
19
- ReactNativeBootSplash.show({fade: false})->ignore
15
+ RNBootsplash.hide({fade: true})->ignore
20
16
  ```
21
17
 
22
18
  Or
23
19
 
24
20
  ```rescript
25
- ReactNativeBootsplash.hide({fade: true})->Js.Promise.then_(() => {
21
+ RNBootsplash.hide({fade: true})->Js.Promise.then_(() => {
26
22
  Js.log("RN BootSplash: fading is over")
27
23
  Js.Promise.resolve()
28
24
  }, _)->Js.Promise.catch(error => {
@@ -8,23 +8,23 @@ buildscript {
8
8
  // module dependency in an application project.
9
9
  if (project == rootProject) {
10
10
  repositories {
11
- mavenCentral()
12
11
  google()
12
+ mavenCentral()
13
13
  }
14
14
  dependencies {
15
- classpath 'com.android.tools.build:gradle:4.1.0'
15
+ classpath("com.android.tools.build:gradle:4.2.2")
16
16
  }
17
17
  }
18
18
  }
19
19
 
20
- apply plugin: 'com.android.library'
20
+ apply plugin: "com.android.library"
21
21
 
22
22
  android {
23
- compileSdkVersion safeExtGet('compileSdkVersion', 29)
24
- buildToolsVersion safeExtGet('buildToolsVersion', '29.0.3')
23
+ compileSdkVersion safeExtGet("compileSdkVersion", 31)
24
+ buildToolsVersion safeExtGet("buildToolsVersion", "30.0.2")
25
25
  defaultConfig {
26
- minSdkVersion safeExtGet('minSdkVersion', 16)
27
- targetSdkVersion safeExtGet('targetSdkVersion', 29)
26
+ minSdkVersion safeExtGet("minSdkVersion", 23)
27
+ targetSdkVersion safeExtGet("targetSdkVersion", 31)
28
28
  }
29
29
  lintOptions {
30
30
  abortOnError false
@@ -32,20 +32,22 @@ android {
32
32
  }
33
33
 
34
34
  repositories {
35
- mavenLocal()
36
35
  mavenCentral()
36
+ mavenLocal()
37
37
  maven {
38
38
  // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
39
- url "$rootDir/../node_modules/react-native/android"
39
+ url("$rootDir/../node_modules/react-native/android")
40
40
  }
41
41
  maven {
42
42
  // Android JSC is installed from npm
43
- url "$rootDir/../node_modules/jsc-android/dist"
43
+ url("$rootDir/../node_modules/jsc-android/dist")
44
44
  }
45
45
  google()
46
+ maven { url "https://www.jitpack.io" }
46
47
  }
47
48
 
48
49
  dependencies {
49
50
  //noinspection GradleDynamicVersion
50
- implementation 'com.facebook.react:react-native:+' // From node_modules
51
+ implementation "com.facebook.react:react-native:+" // From node_modules
52
+ implementation "androidx.core:core-splashscreen:${safeExtGet("androidXSplashScreenVersion", "1.0.0-alpha02")}"
51
53
  }
@@ -2,20 +2,11 @@ package com.zoontek.rnbootsplash;
2
2
 
3
3
  import android.app.Activity;
4
4
 
5
- import androidx.annotation.ColorRes;
6
5
  import androidx.annotation.NonNull;
7
- import androidx.annotation.StyleRes;
8
6
 
9
7
  public class RNBootSplash {
10
8
 
11
- public static void init(@NonNull final Activity activity,
12
- @StyleRes final int bootThemeResId) {
13
- RNBootSplashModule.init(activity, bootThemeResId, android.R.color.white);
14
- }
15
-
16
- public static void init(@NonNull final Activity activity,
17
- @StyleRes final int bootThemeResId,
18
- @ColorRes final int backgroundColorResId) {
19
- RNBootSplashModule.init(activity, bootThemeResId, backgroundColorResId);
9
+ public static void init(@NonNull final Activity activity) {
10
+ RNBootSplashModule.init(activity);
20
11
  }
21
12
  }