react-native-bootsplash 3.2.6 → 4.0.0-beta.2

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/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
@@ -15,31 +15,34 @@ Show a bootsplash during app startup. Hide it when you are ready.
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
+ **⚠️ You are currently reading the 4.x version documentation, which is still in beta.**<br>
22
+ **For the stable version, check the [`3.2.6` tag `README.md`](https://github.com/zoontek/react-native-bootsplash/tree/3.2.6).**
23
+
24
+ **For migration from the v3, check the [`MIGRATION.md` file](https://github.com/zoontek/react-native-bootsplash/blob/master/MIGRATION.md).**
25
+
21
26
  ## Support
22
27
 
23
28
  | version | react-native version |
24
29
  | ------- | -------------------- |
30
+ | 4.0.0+ | 0.65.0+ |
25
31
  | 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
32
 
30
33
  ## Installation
31
34
 
32
35
  ```bash
33
- $ npm install --save react-native-bootsplash
36
+ $ npm install --save react-native-bootsplash@next
34
37
  # --- or ---
35
- $ yarn add react-native-bootsplash
38
+ $ yarn add react-native-bootsplash@next
36
39
  ```
37
40
 
38
41
  Don't forget going into the `ios` directory to execute a `pod install`.
39
42
 
40
43
  ## 🆘 Manual linking
41
44
 
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:
45
+ 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
46
 
44
47
  <details>
45
48
  <summary><b>👀 See manual linking instructions</b></summary>
@@ -118,7 +121,7 @@ Generate a launch screen using an original logo file
118
121
 
119
122
  Options:
120
123
  --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)
124
+ --logo-width <width> logo width at @1x (in dp - we recommend approximately ~100) (default: 100)
122
125
  --assets-path [path] path to your static assets directory (useful to require the logo file in JS)
123
126
  --flavor <flavor> [android only] flavor build variant (outputs in an android resource directory other than "main")
124
127
  -h, --help output usage information
@@ -139,7 +142,6 @@ yarn react-native generate-bootsplash assets/bootsplash_logo_original.png \
139
142
  This tool relies on the naming conventions that are used in the `/example` project and will therefore create the following files:
140
143
 
141
144
  ```bash
142
- android/app/src/main/res/drawable/bootsplash.xml
143
145
  android/app/src/main/res/values/colors.xml (creation and edition)
144
146
  android/app/src/main/res/mipmap-hdpi/bootsplash_logo.png
145
147
  android/app/src/main/res/mipmap-mdpi/bootsplash_logo.png
@@ -198,47 +200,52 @@ Set the `BootSplash.storyboard` as launch screen file:
198
200
 
199
201
  ### Android
200
202
 
201
- 1. Edit the `android/app/src/main/java/com/yourprojectname/MainActivity.java` file:
203
+ 1. As this library only support Android 6+, you probably have to edit your `android/build.gradle` file:
202
204
 
203
- ```java
204
- import android.os.Bundle; // <- add this necessary import
205
+ ```gradle
206
+ buildscript {
207
+ ext {
208
+ buildToolsVersion = "30.0.2"
209
+ minSdkVersion = 23 // <- AndroidX splashscreen has basic support for 21 (only the background color), so 23 is best
210
+ compileSdkVersion = 31 // <- set at least 31
211
+ targetSdkVersion = 31 // <- set at least 31
205
212
 
206
- import com.facebook.react.ReactActivity;
207
- import com.zoontek.rnbootsplash.RNBootSplash; // <- add this necessary import
213
+ //
214
+ ```
208
215
 
209
- public class MainActivity extends ReactActivity {
216
+ 2. Then edit your `android/app/build.gradle` file:
210
217
 
211
- // …
218
+ ```gradle
219
+ dependencies {
220
+ implementation fileTree(dir: "libs", include: ["*.jar"])
221
+ //noinspection GradleDynamicVersion
222
+ implementation "com.facebook.react:react-native:+" // From node_modules
212
223
 
213
- @Override
214
- protected void onCreate(Bundle savedInstanceState) {
215
- super.onCreate(savedInstanceState); // or super.onCreate(null) with react-native-screens
216
- RNBootSplash.init(R.drawable.bootsplash, MainActivity.this); // display the generated bootsplash.xml drawable over our MainActivity
217
- }
218
- ```
224
+ implementation "androidx.core:core-splashscreen:1.0.0-alpha02" // Add this line
219
225
 
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.
226
+ //
227
+ ```
221
228
 
222
- 2. Edit the `android/app/src/main/res/values/styles.xml` file:
229
+ 3. Edit your `android/app/src/main/res/values/styles.xml` file:
223
230
 
224
231
  ```xml
225
232
  <resources>
226
233
 
227
- <!-- Base application theme -->
228
234
  <style name="AppTheme" parent="Theme.AppCompat.DayNight.NoActionBar">
229
- <!-- Your base theme customization -->
235
+ <!-- Your base theme customization -->
230
236
  </style>
231
237
 
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>
238
+ <!-- BootTheme should inherit from Theme.SplashScreen -->
239
+ <style name="BootTheme" parent="Theme.SplashScreen">
240
+ <item name="windowSplashScreenBackground">@color/bootsplash_background</item>
241
+ <item name="windowSplashScreenAnimatedIcon">@mipmap/bootsplash_logo</item>
242
+ <item name="postSplashScreenTheme">@style/AppTheme</item>
236
243
  </style>
237
244
 
238
245
  </resources>
239
246
  ```
240
247
 
241
- 3. Edit the `android/app/src/main/AndroidManifest.xml` file:
248
+ 4. Edit your `android/app/src/main/AndroidManifest.xml` file:
242
249
 
243
250
  ```xml
244
251
  <manifest xmlns:android="http://schemas.android.com/apk/res/android"
@@ -252,35 +259,47 @@ As Android will not create our main activity before launching the app, we need t
252
259
  android:icon="@mipmap/ic_launcher"
253
260
  android:roundIcon="@mipmap/ic_launcher_round"
254
261
  android:allowBackup="false"
255
- android:theme="@style/AppTheme">
256
-
262
+ android:theme="@style/BootTheme"> <!-- Replace @style/AppTheme with @style/BootTheme -->
257
263
  <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 -->
264
+ android:name=".MainActivity"
265
+ android:label="@string/app_name"
266
+ android:configChanges="keyboard|keyboardHidden|orientation|screenSize|uiMode"
267
+ android:launchMode="singleTask"
268
+ android:windowSoftInputMode="adjustResize"
269
+ android:exported="true"> <!-- Add android:exported="true" -->
270
+ <intent-filter>
271
+ <action android:name="android.intent.action.MAIN" />
272
+ <category android:name="android.intent.category.LAUNCHER" />
273
+ </intent-filter>
266
274
  </activity>
275
+ </application>
276
+ </manifest>
267
277
 
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>
278
+ ```
278
279
 
279
- <!-- -->
280
+ 5. Finally edit your `android/app/src/main/java/com/yourprojectname/MainActivity.java` file:
280
281
 
281
- </application>
282
+ ```java
283
+ import com.facebook.react.ReactActivity;
284
+ import com.facebook.react.ReactActivityDelegate; // <- add this necessary import
285
+ import com.zoontek.rnbootsplash.RNBootSplash; // <- add this necessary import
282
286
 
283
- </manifest>
287
+ public class MainActivity extends ReactActivity {
288
+
289
+ // …
290
+
291
+ @Override
292
+ protected ReactActivityDelegate createReactActivityDelegate() {
293
+ return new ReactActivityDelegate(this, getMainComponentName()) {
294
+
295
+ @Override
296
+ protected void loadApp(String appKey) {
297
+ RNBootSplash.init(R.drawable.bootsplash, MainActivity.this); // <- initialize the splash screen
298
+ super.loadApp(appKey);
299
+ }
300
+ };
301
+ }
302
+ }
284
303
  ```
285
304
 
286
305
  ## API
@@ -304,25 +323,6 @@ RNBootSplash.hide({ fade: true }); // fade
304
323
 
305
324
  ---
306
325
 
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
326
  ### getVisibilityStatus()
327
327
 
328
328
  #### Method type
@@ -365,72 +365,15 @@ function App() {
365
365
 
366
366
  **🤙 A more complex example is available in the [`/example` folder](example).**
367
367
 
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
368
  ### Testing with Jest
425
369
 
426
- Testing code which uses this library required some setup since we need to mock the native methods.
370
+ Testing code which uses this library requires some setup since we need to mock the native methods.
427
371
 
428
372
  To add the mocks, create a file _jest/setup.js_ (or any other file name) containing the following code:
429
373
 
430
374
  ```js
431
375
  jest.mock("react-native-bootsplash", () => {
432
376
  return {
433
- hide: jest.fn().mockResolvedValueOnce(),
434
377
  show: jest.fn().mockResolvedValueOnce(),
435
378
  getVisibilityStatus: jest.fn().mockResolvedValue("hidden"),
436
379
  };
@@ -465,8 +408,6 @@ function App() {
465
408
 
466
409
  ## 🕵️‍♂️ Comparison with [react-native-splash-screen](https://github.com/crazycodeboy/react-native-splash-screen)
467
410
 
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
-
411
+ - 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
412
  - It should not prevent you from seeing red screen errors.
471
-
472
413
  - 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!).
@@ -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,22 +1,18 @@
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
15
  ReactNativeBootsplash.hide({fade: true})->ignore
19
- ReactNativeBootSplash.show({fade: false})->ignore
20
16
  ```
21
17
 
22
18
  Or
@@ -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,12 +2,11 @@ package com.zoontek.rnbootsplash;
2
2
 
3
3
  import android.app.Activity;
4
4
 
5
- import androidx.annotation.DrawableRes;
6
5
  import androidx.annotation.NonNull;
7
6
 
8
7
  public class RNBootSplash {
9
8
 
10
- public static void init(final @DrawableRes int drawableResId, @NonNull final Activity activity) {
11
- RNBootSplashModule.init(drawableResId, activity);
9
+ public static void init(@NonNull final Activity activity) {
10
+ RNBootSplashModule.init(activity);
12
11
  }
13
12
  }