react-native-bootsplash 4.0.0-alpha.1 → 4.0.0-beta.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.
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
@@ -22,10 +22,8 @@ Show a bootsplash during app startup. Hide it when you are ready.
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
 
@@ -39,7 +37,7 @@ 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 will probably don't need to link it manually. Otherwise if it's not the case, follow this additional instructions:
43
41
 
44
42
  <details>
45
43
  <summary><b>👀 See manual linking instructions</b></summary>
@@ -139,7 +137,6 @@ 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
143
140
  android/app/src/main/res/values/colors.xml (creation and edition)
144
141
  android/app/src/main/res/mipmap-hdpi/bootsplash_logo.png
145
142
  android/app/src/main/res/mipmap-mdpi/bootsplash_logo.png
@@ -198,42 +195,34 @@ 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:
202
-
203
- ```java
204
- import android.os.Bundle; // <- add this necessary import
205
-
206
- import com.facebook.react.ReactActivity;
207
- import com.zoontek.rnbootsplash.RNBootSplash; // <- add this necessary import
208
-
209
- public class MainActivity extends ReactActivity {
198
+ 1. As this library only support Android 6+, you probably have to edit your `android/build.gradle` file:
210
199
 
211
- // …
200
+ ```gradle
201
+ buildscript {
202
+ ext {
203
+ buildToolsVersion = "30.0.2"
204
+ minSdkVersion = 23 // <- set at least 23
205
+ compileSdkVersion = 31 // <- set at least 31
206
+ targetSdkVersion = 31 // <- set at least 31
212
207
 
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
- }
208
+ // …
218
209
  ```
219
210
 
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
211
  2. Edit the `android/app/src/main/res/values/styles.xml` file:
223
212
 
224
213
  ```xml
225
214
  <resources>
226
215
 
227
- <!-- Base application theme -->
228
- <style name="AppTheme" parent="Theme.AppCompat.DayNight.NoActionBar">
229
- <!-- Your base theme customization -->
230
- </style>
216
+ <style name="AppTheme" parent="Theme.AppCompat.DayNight.NoActionBar">
217
+ <!-- Your base theme customization -->
218
+ </style>
231
219
 
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>
236
- </style>
220
+ <!-- BootTheme should inherit from Theme.SplashScreen -->
221
+ <style name="BootTheme" parent="Theme.SplashScreen">
222
+ <item name="windowSplashScreenBackground">@color/bootsplash_background</item>
223
+ <item name="windowSplashScreenAnimatedIcon">@mipmap/bootsplash_logo</item>
224
+ <item name="postSplashScreenTheme">@style/AppTheme</item>
225
+ </style>
237
226
 
238
227
  </resources>
239
228
  ```
@@ -244,72 +233,65 @@ As Android will not create our main activity before launching the app, we need t
244
233
  <manifest xmlns:android="http://schemas.android.com/apk/res/android"
245
234
  package="com.rnbootsplashexample">
246
235
 
247
- <!-- … -->
248
-
249
- <application
250
- android:name=".MainApplication"
251
- android:label="@string/app_name"
252
- android:icon="@mipmap/ic_launcher"
253
- android:roundIcon="@mipmap/ic_launcher_round"
254
- android:allowBackup="false"
255
- android:theme="@style/AppTheme">
256
-
257
- <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 -->
266
- </activity>
267
-
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
-
279
236
  <!-- … -->
280
237
 
281
- </application>
282
-
238
+ <application
239
+ android:name=".MainApplication"
240
+ android:label="@string/app_name"
241
+ android:icon="@mipmap/ic_launcher"
242
+ android:roundIcon="@mipmap/ic_launcher_round"
243
+ android:allowBackup="false"
244
+ android:theme="@style/BootTheme"> <!-- Replace @style/AppTheme with @style/BootTheme -->
245
+ <activity
246
+ android:name=".MainActivity"
247
+ android:label="@string/app_name"
248
+ android:configChanges="keyboard|keyboardHidden|orientation|screenSize|uiMode"
249
+ android:launchMode="singleTask"
250
+ android:windowSoftInputMode="adjustResize"
251
+ android:exported="true"> <!-- Add android:exported="true" -->
252
+ <intent-filter>
253
+ <action android:name="android.intent.action.MAIN" />
254
+ <category android:name="android.intent.category.LAUNCHER" />
255
+ </intent-filter>
256
+ </activity>
257
+ </application>
283
258
  </manifest>
284
- ```
285
-
286
- ## API
287
259
 
288
- ### hide()
260
+ ```
289
261
 
290
- #### Method type
262
+ 4. Finally edit your `android/app/src/main/java/com/yourprojectname/MainActivity.java` file:
291
263
 
292
- ```ts
293
- type hide = (config?: { fade?: boolean }) => Promise<void>;
294
- ```
264
+ ```java
265
+ import com.facebook.react.ReactActivity;
266
+ import com.facebook.react.ReactActivityDelegate; // <- add this necessary import
267
+ import com.zoontek.rnbootsplash.RNBootSplash; // <- add this necessary import
295
268
 
296
- #### Usage
269
+ public class MainActivity extends ReactActivity {
297
270
 
298
- ```js
299
- import RNBootSplash from "react-native-bootsplash";
271
+ // …
300
272
 
301
- RNBootSplash.hide(); // immediate
302
- RNBootSplash.hide({ fade: true }); // fade
273
+ @Override
274
+ protected ReactActivityDelegate createReactActivityDelegate() {
275
+ return new ReactActivityDelegate(this, getMainComponentName()) {
276
+
277
+ @Override
278
+ protected void loadApp(String appKey) {
279
+ RNBootSplash.init(R.drawable.bootsplash, MainActivity.this); // <- initialize the splash screen
280
+ super.loadApp(appKey);
281
+ }
282
+ };
283
+ }
284
+ }
303
285
  ```
304
286
 
305
- ---
287
+ ## API
306
288
 
307
- ### show()
289
+ ### hide()
308
290
 
309
291
  #### Method type
310
292
 
311
293
  ```ts
312
- type show = (config?: { fade?: boolean }) => Promise<void>;
294
+ type hide = (config?: { fade?: boolean }) => Promise<void>;
313
295
  ```
314
296
 
315
297
  #### Usage
@@ -317,8 +299,8 @@ type show = (config?: { fade?: boolean }) => Promise<void>;
317
299
  ```js
318
300
  import RNBootSplash from "react-native-bootsplash";
319
301
 
320
- RNBootSplash.show(); // immediate
321
- RNBootSplash.show({ fade: true }); // fade
302
+ RNBootSplash.hide(); // immediate
303
+ RNBootSplash.hide({ fade: true }); // fade
322
304
  ```
323
305
 
324
306
  ---
@@ -365,62 +347,6 @@ function App() {
365
347
 
366
348
  **🤙 A more complex example is available in the [`/example` folder](example).**
367
349
 
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
350
  ### Testing with Jest
425
351
 
426
352
  Testing code which uses this library required some setup since we need to mock the native methods.
@@ -430,7 +356,6 @@ To add the mocks, create a file _jest/setup.js_ (or any other file name) contain
430
356
  ```js
431
357
  jest.mock("react-native-bootsplash", () => {
432
358
  return {
433
- hide: jest.fn().mockResolvedValueOnce(),
434
359
  show: jest.fn().mockResolvedValueOnce(),
435
360
  getVisibilityStatus: jest.fn().mockResolvedValue("hidden"),
436
361
  };
@@ -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,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
  }