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 +18 -29
- package/android/build.gradle +4 -4
- package/android/src/main/java/com/zoontek/rnbootsplash/RNBootSplashModule.java +10 -12
- package/dist/commonjs/index.js +2 -3
- package/dist/commonjs/index.js.map +1 -1
- package/dist/module/index.js +2 -3
- package/dist/module/index.js.map +1 -1
- package/dist/typescript/index.d.ts.map +1 -1
- package/ios/RNBootSplash.m +5 -4
- package/package.json +10 -11
- package/src/index.ts +4 -6
- package/android/.npmignore +0 -11
- package/example/android/app/debug.keystore +0 -0
- package/ios/.DS_Store +0 -0
- package/ios/.npmignore +0 -8
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.
|
|
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
|
-
|
|
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:
|
|
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.
|
|
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
|
|
240
|
-
implementation
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
|
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
|
|
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
|
|
package/android/build.gradle
CHANGED
|
@@ -12,7 +12,7 @@ buildscript {
|
|
|
12
12
|
mavenCentral()
|
|
13
13
|
}
|
|
14
14
|
dependencies {
|
|
15
|
-
classpath("com.android.tools.build:gradle:7.
|
|
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",
|
|
24
|
-
buildToolsVersion safeExtGet("buildToolsVersion", "
|
|
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",
|
|
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
|
|
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
|
-
.
|
|
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(
|
|
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(
|
|
130
|
+
hideAndResolveAll();
|
|
132
131
|
timer.cancel();
|
|
133
132
|
}
|
|
134
133
|
}, 250);
|
|
135
134
|
} else {
|
|
136
|
-
if (
|
|
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
|
-
},
|
|
152
|
+
}, mFadeDuration);
|
|
155
153
|
}
|
|
156
154
|
}
|
|
157
155
|
});
|
|
158
156
|
}
|
|
159
157
|
|
|
160
158
|
@ReactMethod
|
|
161
|
-
public void hide(final
|
|
162
|
-
|
|
159
|
+
public void hide(final double duration, final Promise promise) {
|
|
160
|
+
mFadeDuration = (int) Math.round(duration);
|
|
163
161
|
mPromiseQueue.push(promise);
|
|
164
|
-
hideAndResolveAll(
|
|
162
|
+
hideAndResolveAll();
|
|
165
163
|
}
|
|
166
164
|
|
|
167
165
|
@ReactMethod
|
package/dist/commonjs/index.js
CHANGED
|
@@ -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 =
|
|
15
|
+
duration = 0
|
|
17
16
|
} = config;
|
|
18
|
-
return NativeModule.hide(fade
|
|
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","
|
|
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"}
|
package/dist/module/index.js
CHANGED
|
@@ -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 =
|
|
7
|
+
duration = 0
|
|
9
8
|
} = config;
|
|
10
|
-
return NativeModule.hide(fade
|
|
9
|
+
return NativeModule.hide(fade ? Math.max(duration, 220) : 0).then(() => {});
|
|
11
10
|
}
|
|
12
11
|
export function getVisibilityStatus() {
|
|
13
12
|
return NativeModule.getVisibilityStatus();
|
package/dist/module/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["NativeModules","NativeModule","RNBootSplash","
|
|
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;
|
|
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"}
|
package/ios/RNBootSplash.m
CHANGED
|
@@ -84,8 +84,7 @@ RCT_EXPORT_MODULE();
|
|
|
84
84
|
}
|
|
85
85
|
|
|
86
86
|
RCT_REMAP_METHOD(hide,
|
|
87
|
-
|
|
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
|
-
|
|
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:
|
|
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.
|
|
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": "^
|
|
68
|
-
"
|
|
69
|
-
"
|
|
70
|
-
"prettier": "^2.
|
|
71
|
-
"
|
|
72
|
-
"react": "
|
|
73
|
-
"react-native": "0.
|
|
74
|
-
"
|
|
75
|
-
"
|
|
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
|
|
4
|
+
export type Config = { fade?: boolean; duration?: number };
|
|
5
5
|
|
|
6
6
|
const NativeModule: {
|
|
7
|
-
hide: (
|
|
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 =
|
|
15
|
-
return NativeModule.hide(fade
|
|
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> {
|
package/android/.npmignore
DELETED
|
Binary file
|
package/ios/.DS_Store
DELETED
|
Binary file
|