react-native-bootsplash 4.4.0 → 4.4.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/README.md CHANGED
@@ -40,7 +40,7 @@ $ npm install --save react-native-bootsplash
40
40
  $ yarn add react-native-bootsplash
41
41
  ```
42
42
 
43
- Don't forget going into the `ios` directory to execute a `pod install`.
43
+ _⚠️  Don't forget going into the `ios` directory to execute a `pod install`._
44
44
 
45
45
  ## 🆘 Manual linking
46
46
 
@@ -104,6 +104,8 @@ public class MainApplication extends Application implements ReactApplication {
104
104
 
105
105
  ## Setup
106
106
 
107
+ ℹ️ 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).
108
+
107
109
  ### Assets generation
108
110
 
109
111
  In order to speed up the setup, we provide a **CLI** to generate assets, create the Android Drawable XML file and the iOS Storyboard file automatically ✨.
@@ -181,7 +183,7 @@ _⚠️  Only `.storyboard` files are supported ([Apple has deprecated other m
181
183
 
182
184
  ---
183
185
 
184
- Edit the `ios/YourProjectName/AppDelegate.m(m)` file:
186
+ Edit the `ios/YourProjectName/AppDelegate.mm` file:
185
187
 
186
188
  ```obj-c
187
189
  #import "AppDelegate.h"
@@ -193,13 +195,11 @@ Edit the `ios/YourProjectName/AppDelegate.m(m)` file:
193
195
 
194
196
  - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
195
197
  {
196
- //
197
-
198
- rootViewController.view = rootView;
199
- self.window.rootViewController = rootViewController;
200
- [self.window makeKeyAndVisible];
198
+ self.moduleName = @"RNBootSplashExample";
199
+ self.initialProps = @{};
200
+ [super application:application didFinishLaunchingWithOptions:launchOptions];
201
201
 
202
- [RNBootSplash initWithStoryboard:@"BootSplash" rootView:rootView]; // <- initialization using the storyboard file name
202
+ [RNBootSplash initWithStoryboard:@"BootSplash" rootView:self.window.rootViewController.view]; // <- initialization using the storyboard file name
203
203
 
204
204
  return YES;
205
205
  }
@@ -217,32 +217,21 @@ _⚠️  On Android >= 12, the splash screen will not appear if you start your
217
217
 
218
218
  ---
219
219
 
220
- 1. As this library only support Android 6+, you probably have to edit your `android/build.gradle` file:
221
-
222
- ```gradle
223
- buildscript {
224
- ext {
225
- buildToolsVersion = "31.0.0"
226
- minSdkVersion = 23 // <- AndroidX splashscreen has basic support for 21 (only the background color), so 23 is best
227
- compileSdkVersion = 31 // <- set at least 31
228
- targetSdkVersion = 31 // <- set at least 31
229
-
230
- // …
231
- ```
232
-
233
- 2. Then edit your `android/app/build.gradle` file:
220
+ 1. Edit your `android/app/build.gradle` file:
234
221
 
235
222
  ```gradle
236
223
  dependencies {
237
224
  // …
238
225
 
239
- implementation "androidx.swiperefreshlayout:swiperefreshlayout:1.0.0"
240
- implementation "androidx.core:core-splashscreen:1.0.0" // Add this line
226
+ implementation("androidx.swiperefreshlayout:swiperefreshlayout:1.0.0")
227
+ implementation("androidx.core:core-splashscreen:1.0.0") // Add this line
241
228
 
242
229
  // …
243
230
  ```
244
231
 
245
- 3. Edit your `android/app/src/main/res/values/styles.xml` file:
232
+ _⚠️  Don't forget going into the `android` directory to execute a `./gradlew clean && ./gradlew build` (or perform a Gradle sync in Android Studio)._
233
+
234
+ 2. Edit your `android/app/src/main/res/values/styles.xml` file:
246
235
 
247
236
  ```xml
248
237
  <resources>
@@ -261,7 +250,7 @@ dependencies {
261
250
  </resources>
262
251
  ```
263
252
 
264
- 4. Edit your `android/app/src/main/AndroidManifest.xml` file:
253
+ 3. Edit your `android/app/src/main/AndroidManifest.xml` file:
265
254
 
266
255
  ```xml
267
256
  <manifest xmlns:android="http://schemas.android.com/apk/res/android"
@@ -282,7 +271,7 @@ dependencies {
282
271
 
283
272
  ```
284
273
 
285
- 5. Finally edit your `android/app/src/main/java/com/yourprojectname/MainActivity.java` file:
274
+ 4. Finally edit your `android/app/src/main/java/com/yourprojectname/MainActivity.java` file:
286
275
 
287
276
  ```java
288
277
  // …
@@ -310,7 +299,7 @@ public class MainActivity extends ReactActivity {
310
299
  #### Method type
311
300
 
312
301
  ```ts
313
- type hide = (config?: { fade?: boolean, duration?: boolean }) => Promise<void>;
302
+ type hide = (config?: { fade?: boolean; duration?: number }) => Promise<void>;
314
303
  ```
315
304
 
316
305
  Note: Only durations above 220ms are visually noticeable. Smaller values will be ignored and the default duration will be used.
@@ -387,7 +376,7 @@ function App() {
387
376
 
388
377
  ## With react-native-bars
389
378
 
390
- 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 the [README](https://github.com/zoontek/react-native-bars/blob/main/README.md#with-react-native-bootsplash) for more informations.
379
+ 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.
391
380
 
392
381
  ## Testing with Jest
393
382
 
@@ -12,7 +12,7 @@ buildscript {
12
12
  mavenCentral()
13
13
  }
14
14
  dependencies {
15
- classpath("com.android.tools.build:gradle:7.2.1")
15
+ classpath("com.android.tools.build:gradle:7.3.1")
16
16
  }
17
17
  }
18
18
  }
@@ -20,11 +20,11 @@ buildscript {
20
20
  apply plugin: "com.android.library"
21
21
 
22
22
  android {
23
- compileSdkVersion safeExtGet("compileSdkVersion", 31)
24
- buildToolsVersion safeExtGet("buildToolsVersion", "31.0.0")
23
+ compileSdkVersion safeExtGet("compileSdkVersion", 33)
24
+ buildToolsVersion safeExtGet("buildToolsVersion", "33.0.0")
25
25
  defaultConfig {
26
26
  minSdkVersion safeExtGet("minSdkVersion", 23)
27
- targetSdkVersion safeExtGet("targetSdkVersion", 31)
27
+ targetSdkVersion safeExtGet("targetSdkVersion", 33)
28
28
  }
29
29
  lintOptions {
30
30
  abortOnError false
@@ -41,9 +41,8 @@ public class RNBootSplashModule extends ReactContextBaseJavaModule {
41
41
 
42
42
  private static final RNBootSplashQueue<Promise> mPromiseQueue = new RNBootSplashQueue<>();
43
43
  private static Status mStatus = Status.HIDDEN;
44
- private static boolean mShouldFade = false;
44
+ private static int mFadeDuration = 0;
45
45
  private static boolean mShouldKeepOnScreen = true;
46
- private static int mAnimationDuration;
47
46
 
48
47
  public RNBootSplashModule(ReactApplicationContext reactContext) {
49
48
  super(reactContext);
@@ -79,9 +78,9 @@ public class RNBootSplashModule extends ReactContextBaseJavaModule {
79
78
 
80
79
  splashScreenView
81
80
  .animate()
81
+ .setDuration(mFadeDuration)
82
82
  // Crappy hack to avoid automatic layout transitions
83
- .setDuration(mShouldFade ? mAnimationDuration: 0)
84
- .setStartDelay(mShouldFade ? 0 : mAnimationDuration)
83
+ .setStartDelay(Math.min(0, mFadeDuration))
85
84
  .alpha(0.0f)
86
85
  .setInterpolator(new AccelerateInterpolator())
87
86
  .setListener(new AnimatorListenerAdapter() {
@@ -110,7 +109,7 @@ public class RNBootSplashModule extends ReactContextBaseJavaModule {
110
109
  }
111
110
  }
112
111
 
113
- private void hideAndResolveAll(final boolean fade) {
112
+ private void hideAndResolveAll() {
114
113
  if (mSplashScreen == null || mStatus == Status.HIDDEN) {
115
114
  clearPromiseQueue();
116
115
  return;
@@ -128,16 +127,15 @@ public class RNBootSplashModule extends ReactContextBaseJavaModule {
128
127
  timer.schedule(new TimerTask() {
129
128
  @Override
130
129
  public void run() {
131
- hideAndResolveAll(fade);
130
+ hideAndResolveAll();
132
131
  timer.cancel();
133
132
  }
134
133
  }, 250);
135
134
  } else {
136
- if (fade) {
135
+ if (mFadeDuration > 0) {
137
136
  mStatus = Status.TRANSITIONING;
138
137
  }
139
138
 
140
- mShouldFade = fade;
141
139
  mShouldKeepOnScreen = false;
142
140
 
143
141
  final Timer timer = new Timer();
@@ -151,17 +149,17 @@ public class RNBootSplashModule extends ReactContextBaseJavaModule {
151
149
  timer.cancel();
152
150
  clearPromiseQueue();
153
151
  }
154
- }, mAnimationDuration);
152
+ }, mFadeDuration);
155
153
  }
156
154
  }
157
155
  });
158
156
  }
159
157
 
160
158
  @ReactMethod
161
- public void hide(final boolean fade, final int fadeDuration, final Promise promise) {
162
- mAnimationDuration = fadeDuration;
159
+ public void hide(final double duration, final Promise promise) {
160
+ mFadeDuration = (int) Math.round(duration);
163
161
  mPromiseQueue.push(promise);
164
- hideAndResolveAll(fade);
162
+ hideAndResolveAll();
165
163
  }
166
164
 
167
165
  @ReactMethod
@@ -8,14 +8,13 @@ exports.getVisibilityStatus = getVisibilityStatus;
8
8
  exports.hide = hide;
9
9
  var _reactNative = require("react-native");
10
10
  const NativeModule = _reactNative.NativeModules.RNBootSplash;
11
- const DEFAULT_DURATION = 220;
12
11
  function hide() {
13
12
  let config = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
14
13
  const {
15
14
  fade = false,
16
- duration = DEFAULT_DURATION
15
+ duration = 0
17
16
  } = config;
18
- return NativeModule.hide(fade, Math.max(duration, DEFAULT_DURATION)).then(() => {});
17
+ return NativeModule.hide(fade ? Math.max(duration, 220) : 0).then(() => {});
19
18
  }
20
19
  function getVisibilityStatus() {
21
20
  return NativeModule.getVisibilityStatus();
@@ -1 +1 @@
1
- {"version":3,"names":["NativeModule","NativeModules","RNBootSplash","DEFAULT_DURATION","hide","config","fade","duration","Math","max","then","getVisibilityStatus"],"sourceRoot":"../../src","sources":["index.ts"],"mappings":";;;;;;;;AAAA;AAKA,MAAMA,YAGL,GAAGC,0BAAa,CAACC,YAAY;AAE9B,MAAMC,gBAAgB,GAAG,GAAG;AAErB,SAASC,IAAI,GAAqC;EAAA,IAApCC,MAAc,uEAAG,CAAC,CAAC;EACtC,MAAM;IAAEC,IAAI,GAAG,KAAK;IAAEC,QAAQ,GAAGJ;EAAiB,CAAC,GAAGE,MAAM;EAC5D,OAAOL,YAAY,CAACI,IAAI,CAACE,IAAI,EAAEE,IAAI,CAACC,GAAG,CAACF,QAAQ,EAAEJ,gBAAgB,CAAC,CAAC,CAACO,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC;AACrF;AAEO,SAASC,mBAAmB,GAA8B;EAC/D,OAAOX,YAAY,CAACW,mBAAmB,EAAE;AAC3C;AAAC,eAEc;EACbP,IAAI;EACJO;AACF,CAAC;AAAA"}
1
+ {"version":3,"names":["NativeModule","NativeModules","RNBootSplash","hide","config","fade","duration","Math","max","then","getVisibilityStatus"],"sourceRoot":"../../src","sources":["index.ts"],"mappings":";;;;;;;;AAAA;AAKA,MAAMA,YAGL,GAAGC,0BAAa,CAACC,YAAY;AAEvB,SAASC,IAAI,GAAqC;EAAA,IAApCC,MAAc,uEAAG,CAAC,CAAC;EACtC,MAAM;IAAEC,IAAI,GAAG,KAAK;IAAEC,QAAQ,GAAG;EAAE,CAAC,GAAGF,MAAM;EAC7C,OAAOJ,YAAY,CAACG,IAAI,CAACE,IAAI,GAAGE,IAAI,CAACC,GAAG,CAACF,QAAQ,EAAE,GAAG,CAAC,GAAG,CAAC,CAAC,CAACG,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC;AAC7E;AAEO,SAASC,mBAAmB,GAA8B;EAC/D,OAAOV,YAAY,CAACU,mBAAmB,EAAE;AAC3C;AAAC,eAEc;EACbP,IAAI;EACJO;AACF,CAAC;AAAA"}
@@ -1,13 +1,12 @@
1
1
  import { NativeModules } from "react-native";
2
2
  const NativeModule = NativeModules.RNBootSplash;
3
- const DEFAULT_DURATION = 220;
4
3
  export function hide() {
5
4
  let config = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
6
5
  const {
7
6
  fade = false,
8
- duration = DEFAULT_DURATION
7
+ duration = 0
9
8
  } = config;
10
- return NativeModule.hide(fade, Math.max(duration, DEFAULT_DURATION)).then(() => {});
9
+ return NativeModule.hide(fade ? Math.max(duration, 220) : 0).then(() => {});
11
10
  }
12
11
  export function getVisibilityStatus() {
13
12
  return NativeModule.getVisibilityStatus();
@@ -1 +1 @@
1
- {"version":3,"names":["NativeModules","NativeModule","RNBootSplash","DEFAULT_DURATION","hide","config","fade","duration","Math","max","then","getVisibilityStatus"],"sourceRoot":"../../src","sources":["index.ts"],"mappings":"AAAA,SAASA,aAAa,QAAQ,cAAc;AAK5C,MAAMC,YAGL,GAAGD,aAAa,CAACE,YAAY;AAE9B,MAAMC,gBAAgB,GAAG,GAAG;AAE5B,OAAO,SAASC,IAAI,GAAqC;EAAA,IAApCC,MAAc,uEAAG,CAAC,CAAC;EACtC,MAAM;IAAEC,IAAI,GAAG,KAAK;IAAEC,QAAQ,GAAGJ;EAAiB,CAAC,GAAGE,MAAM;EAC5D,OAAOJ,YAAY,CAACG,IAAI,CAACE,IAAI,EAAEE,IAAI,CAACC,GAAG,CAACF,QAAQ,EAAEJ,gBAAgB,CAAC,CAAC,CAACO,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC;AACrF;AAEA,OAAO,SAASC,mBAAmB,GAA8B;EAC/D,OAAOV,YAAY,CAACU,mBAAmB,EAAE;AAC3C;AAEA,eAAe;EACbP,IAAI;EACJO;AACF,CAAC"}
1
+ {"version":3,"names":["NativeModules","NativeModule","RNBootSplash","hide","config","fade","duration","Math","max","then","getVisibilityStatus"],"sourceRoot":"../../src","sources":["index.ts"],"mappings":"AAAA,SAASA,aAAa,QAAQ,cAAc;AAK5C,MAAMC,YAGL,GAAGD,aAAa,CAACE,YAAY;AAE9B,OAAO,SAASC,IAAI,GAAqC;EAAA,IAApCC,MAAc,uEAAG,CAAC,CAAC;EACtC,MAAM;IAAEC,IAAI,GAAG,KAAK;IAAEC,QAAQ,GAAG;EAAE,CAAC,GAAGF,MAAM;EAC7C,OAAOH,YAAY,CAACE,IAAI,CAACE,IAAI,GAAGE,IAAI,CAACC,GAAG,CAACF,QAAQ,EAAE,GAAG,CAAC,GAAG,CAAC,CAAC,CAACG,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC;AAC7E;AAEA,OAAO,SAASC,mBAAmB,GAA8B;EAC/D,OAAOT,YAAY,CAACS,mBAAmB,EAAE;AAC3C;AAEA,eAAe;EACbP,IAAI;EACJO;AACF,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,gBAAgB,GAAG,SAAS,GAAG,QAAQ,GAAG,eAAe,CAAC;AACtE,MAAM,MAAM,MAAM,GAAG;IAAE,IAAI,CAAC,EAAE,OAAO,CAAC;IAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC;AAS3D,wBAAgB,IAAI,CAAC,MAAM,GAAE,MAAW,GAAG,OAAO,CAAC,IAAI,CAAC,CAGvD;AAED,wBAAgB,mBAAmB,IAAI,OAAO,CAAC,gBAAgB,CAAC,CAE/D;;;;;AAED,wBAGE"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,gBAAgB,GAAG,SAAS,GAAG,QAAQ,GAAG,eAAe,CAAC;AACtE,MAAM,MAAM,MAAM,GAAG;IAAE,IAAI,CAAC,EAAE,OAAO,CAAC;IAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC;AAO3D,wBAAgB,IAAI,CAAC,MAAM,GAAE,MAAW,GAAG,OAAO,CAAC,IAAI,CAAC,CAGvD;AAED,wBAAgB,mBAAmB,IAAI,OAAO,CAAC,gBAAgB,CAAC,CAE/D;;;;;AAED,wBAGE"}
@@ -84,8 +84,7 @@ RCT_EXPORT_MODULE();
84
84
  }
85
85
 
86
86
  RCT_REMAP_METHOD(hide,
87
- hideWithFade:(BOOL)fade
88
- duration:(NSInteger)duration
87
+ hideWithDuration:(double)duration
89
88
  resolver:(RCTPromiseResolveBlock)resolve
90
89
  rejecter:(RCTPromiseRejectBlock)reject) {
91
90
  if (_resolverQueue == nil)
@@ -96,7 +95,9 @@ RCT_REMAP_METHOD(hide,
96
95
  if ([RNBootSplash isHidden] || RCTRunningInAppExtension())
97
96
  return [self clearResolverQueue];
98
97
 
99
- if (!fade) {
98
+ float roundedDuration = lroundf((float)duration);
99
+
100
+ if (roundedDuration <= 0) {
100
101
  [RNBootSplash removeLoadingView];
101
102
  return [self clearResolverQueue];
102
103
  }
@@ -105,7 +106,7 @@ RCT_REMAP_METHOD(hide,
105
106
  _isTransitioning = true;
106
107
 
107
108
  [UIView transitionWithView:_rootView
108
- duration:duration / 1000.0
109
+ duration:roundedDuration / 1000.0
109
110
  options:UIViewAnimationOptionTransitionCrossDissolve
110
111
  animations:^{
111
112
  _rootView.loadingView.hidden = YES;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-bootsplash",
3
- "version": "4.4.0",
3
+ "version": "4.4.2",
4
4
  "license": "MIT",
5
5
  "description": "Display a bootsplash on your app starts. Hide it when you want.",
6
6
  "author": "Mathieu Acthernoene <zoontek@gmail.com>",
@@ -64,15 +64,14 @@
64
64
  "picocolors": "^1.0.0"
65
65
  },
66
66
  "devDependencies": {
67
- "@types/fs-extra": "^9.0.13",
68
- "@types/react-native": "^0.70.7",
69
- "lint-staged": "^13.0.4",
70
- "prettier": "^2.8.0",
71
- "prettier-plugin-organize-imports": "^3.2.1",
72
- "react": "18.1.0",
73
- "react-native": "0.70.6",
74
- "react-native-builder-bob": "^0.20.2",
75
- "rescript": "^10.0.1",
76
- "typescript": "^4.9.3"
67
+ "@types/fs-extra": "^11.0.1",
68
+ "lint-staged": "^13.1.0",
69
+ "prettier": "^2.8.3",
70
+ "prettier-plugin-organize-imports": "^3.2.2",
71
+ "react": "18.2.0",
72
+ "react-native": "0.71.1",
73
+ "react-native-builder-bob": "^0.20.3",
74
+ "rescript": "^10.1.2",
75
+ "typescript": "^4.9.5"
77
76
  }
78
77
  }
package/src/index.ts CHANGED
@@ -1,18 +1,16 @@
1
1
  import { NativeModules } from "react-native";
2
2
 
3
3
  export type VisibilityStatus = "visible" | "hidden" | "transitioning";
4
- export type Config = { fade?: boolean, duration?: number };
4
+ export type Config = { fade?: boolean; duration?: number };
5
5
 
6
6
  const NativeModule: {
7
- hide: (fade: boolean, duration: number) => Promise<true>;
7
+ hide: (duration: number) => Promise<true>;
8
8
  getVisibilityStatus: () => Promise<VisibilityStatus>;
9
9
  } = NativeModules.RNBootSplash;
10
10
 
11
- const DEFAULT_DURATION = 220;
12
-
13
11
  export function hide(config: Config = {}): Promise<void> {
14
- const { fade = false, duration = DEFAULT_DURATION } = config;
15
- return NativeModule.hide(fade, Math.max(duration, DEFAULT_DURATION)).then(() => {});
12
+ const { fade = false, duration = 0 } = config;
13
+ return NativeModule.hide(fade ? Math.max(duration, 220) : 0).then(() => {});
16
14
  }
17
15
 
18
16
  export function getVisibilityStatus(): Promise<VisibilityStatus> {
@@ -1,11 +0,0 @@
1
- .gradle/
2
- .idea/
3
- build/
4
- gradle/
5
-
6
- .DS_Store
7
- .npmignore
8
- gradlew
9
- gradlew.bat
10
- *.iml
11
- local.properties
Binary file
package/ios/.DS_Store DELETED
Binary file
package/ios/.npmignore DELETED
@@ -1,8 +0,0 @@
1
- Pods/
2
- build/
3
-
4
- */project.xcworkspace/
5
- */xcuserdata/
6
-
7
- .DS_Store
8
- .npmignore