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.
- package/LICENSE +1 -1
- package/README.md +80 -144
- package/RNBootSplash.podspec +1 -1
- package/{ReactNativeBootsplash.res → RNBootsplash.res} +4 -8
- package/android/build.gradle +13 -11
- package/android/src/main/java/com/zoontek/rnbootsplash/RNBootSplash.java +2 -11
- package/android/src/main/java/com/zoontek/rnbootsplash/RNBootSplashModule.java +79 -198
- package/android/src/main/java/com/zoontek/rnbootsplash/RNBootSplashPackage.java +6 -2
- package/android/src/main/java/com/zoontek/rnbootsplash/RNBootSplashTask.java +1 -15
- package/bsconfig.json +0 -1
- package/dist/commonjs/generate.js +128 -110
- package/dist/commonjs/generate.js.map +1 -1
- package/dist/commonjs/index.js +5 -21
- package/dist/commonjs/index.js.map +1 -1
- package/dist/module/generate.js +124 -107
- package/dist/module/generate.js.map +1 -1
- package/dist/module/index.js +3 -15
- package/dist/module/index.js.map +1 -1
- package/dist/typescript/generate.d.ts +4 -4
- package/dist/typescript/index.d.ts +0 -6
- package/ios/RNBootSplash.h +3 -13
- package/ios/RNBootSplash.m +44 -99
- package/ios/RNBootSplash.xcodeproj/project.pbxproj +2 -2
- package/package.json +19 -21
- package/react-native.config.js +21 -8
- package/src/generate.ts +116 -138
- package/src/index.ts +0 -14
- package/android/src/main/java/com/zoontek/rnbootsplash/RNBootSplashDialog.java +0 -36
- package/android/src/main/res/anim/bootsplash_fade_in.xml +0 -7
- package/android/src/main/res/anim/bootsplash_fade_out.xml +0 -7
- package/android/src/main/res/values/styles.xml +0 -13
package/ios/RNBootSplash.m
CHANGED
|
@@ -1,26 +1,19 @@
|
|
|
1
1
|
#import "RNBootSplash.h"
|
|
2
2
|
|
|
3
3
|
#import <React/RCTBridge.h>
|
|
4
|
-
#import <React/RCTLog.h>
|
|
5
4
|
#import <React/RCTUtils.h>
|
|
6
5
|
|
|
7
6
|
static NSMutableArray<RNBootSplashTask *> *_taskQueue = nil;
|
|
8
|
-
static NSString *_storyboardName = @"BootSplash";
|
|
9
7
|
static RCTRootView *_rootView = nil;
|
|
10
8
|
static RNBootSplashStatus _status = RNBootSplashStatusHidden;
|
|
11
|
-
static UIViewController *_splashVC = nil;
|
|
12
9
|
|
|
13
10
|
@implementation RNBootSplashTask
|
|
14
11
|
|
|
15
|
-
- (instancetype)
|
|
16
|
-
|
|
17
|
-
resolver:(RCTPromiseResolveBlock _Nonnull)resolve
|
|
18
|
-
rejecter:(RCTPromiseRejectBlock _Nonnull)reject {
|
|
12
|
+
- (instancetype)initWithFade:(BOOL)fade
|
|
13
|
+
resolver:(RCTPromiseResolveBlock _Nonnull)resolve {
|
|
19
14
|
if (self = [super init]) {
|
|
20
|
-
_type = type;
|
|
21
15
|
_fade = fade;
|
|
22
16
|
_resolve = resolve;
|
|
23
|
-
_reject = reject;
|
|
24
17
|
}
|
|
25
18
|
|
|
26
19
|
return self;
|
|
@@ -42,36 +35,17 @@ RCT_EXPORT_MODULE();
|
|
|
42
35
|
|
|
43
36
|
+ (void)initWithStoryboard:(NSString * _Nonnull)storyboardName
|
|
44
37
|
rootView:(RCTRootView * _Nonnull)rootView {
|
|
45
|
-
UIViewController *rootVC = RCTPresentedViewController();
|
|
46
|
-
|
|
47
|
-
if (!rootVC) {
|
|
48
|
-
RCTLogWarn(@"react-native-bootsplash has been initialized too early: rootViewController must be set");
|
|
49
|
-
return;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
38
|
_rootView = rootView;
|
|
53
39
|
_status = RNBootSplashStatusVisible;
|
|
54
|
-
_storyboardName = storyboardName;
|
|
55
40
|
_taskQueue = [[NSMutableArray alloc] init];
|
|
56
41
|
|
|
57
|
-
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:
|
|
42
|
+
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:storyboardName bundle:nil];
|
|
58
43
|
[_rootView setLoadingView:[[storyboard instantiateInitialViewController] view]];
|
|
59
44
|
|
|
60
45
|
[[NSNotificationCenter defaultCenter] removeObserver:rootView
|
|
61
46
|
name:RCTContentDidAppearNotification
|
|
62
47
|
object:rootView];
|
|
63
48
|
|
|
64
|
-
_splashVC = [storyboard instantiateInitialViewController];
|
|
65
|
-
[_splashVC setModalPresentationStyle:UIModalPresentationOverFullScreen];
|
|
66
|
-
[_splashVC setModalTransitionStyle:UIModalTransitionStyleCrossDissolve];
|
|
67
|
-
|
|
68
|
-
[rootVC presentViewController:_splashVC animated:false completion:^{
|
|
69
|
-
[_rootView.loadingView removeFromSuperview];
|
|
70
|
-
_rootView.loadingView = nil;
|
|
71
|
-
|
|
72
|
-
[self shiftNextTask]; // JS thread might started pushing tasks
|
|
73
|
-
}];
|
|
74
|
-
|
|
75
49
|
[[NSNotificationCenter defaultCenter] addObserver:self
|
|
76
50
|
selector:@selector(onJavaScriptDidLoad:)
|
|
77
51
|
name:RCTJavaScriptDidLoadNotification
|
|
@@ -99,20 +73,19 @@ RCT_EXPORT_MODULE();
|
|
|
99
73
|
}
|
|
100
74
|
|
|
101
75
|
+ (void)onJavaScriptDidFailToLoad {
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
76
|
+
_status = RNBootSplashStatusHidden;
|
|
77
|
+
|
|
78
|
+
if (_rootView != nil) {
|
|
79
|
+
_rootView.loadingView.hidden = YES;
|
|
80
|
+
[_rootView.loadingView removeFromSuperview];
|
|
81
|
+
_rootView.loadingView = nil;
|
|
107
82
|
}
|
|
108
83
|
|
|
109
84
|
[[NSNotificationCenter defaultCenter] removeObserver:self];
|
|
110
85
|
}
|
|
111
86
|
|
|
112
87
|
+ (void)shiftNextTask {
|
|
113
|
-
bool shouldSkipTick =
|
|
114
|
-
|| _status == RNBootSplashStatusTransitioningToVisible
|
|
115
|
-
|| _status == RNBootSplashStatusTransitioningToHidden
|
|
88
|
+
bool shouldSkipTick = _status == RNBootSplashStatusTransitioning
|
|
116
89
|
|| [_taskQueue count] == 0
|
|
117
90
|
|| [[UIApplication sharedApplication] applicationState] == UIApplicationStateBackground;
|
|
118
91
|
|
|
@@ -121,81 +94,54 @@ RCT_EXPORT_MODULE();
|
|
|
121
94
|
RNBootSplashTask *task = [_taskQueue objectAtIndex:0];
|
|
122
95
|
[_taskQueue removeObjectAtIndex:0];
|
|
123
96
|
|
|
124
|
-
|
|
125
|
-
case RNBootSplashTaskTypeShow:
|
|
126
|
-
return [self showWithTask:task];
|
|
127
|
-
case RNBootSplashTaskTypeHide:
|
|
128
|
-
return [self hideWithTask:task];
|
|
129
|
-
}
|
|
97
|
+
return [self hideWithTask:task];
|
|
130
98
|
}
|
|
131
99
|
|
|
132
|
-
+ (void)
|
|
133
|
-
if (
|
|
134
|
-
task.resolve(@(true));
|
|
135
|
-
[self shiftNextTask];
|
|
136
|
-
} else {
|
|
137
|
-
_status = RNBootSplashStatusTransitioningToVisible;
|
|
138
|
-
|
|
139
|
-
_splashVC = [[UIStoryboard storyboardWithName:_storyboardName bundle:nil] instantiateInitialViewController];
|
|
140
|
-
[_splashVC setModalPresentationStyle:UIModalPresentationOverFullScreen];
|
|
141
|
-
[_splashVC setModalTransitionStyle:UIModalTransitionStyleCrossDissolve];
|
|
142
|
-
|
|
143
|
-
[RCTPresentedViewController() presentViewController:_splashVC
|
|
144
|
-
animated:task.fade
|
|
145
|
-
completion:^{
|
|
146
|
-
_status = RNBootSplashStatusVisible;
|
|
147
|
-
|
|
148
|
-
task.resolve(@(true));
|
|
149
|
-
[self shiftNextTask];
|
|
150
|
-
}];
|
|
100
|
+
+ (void)hideWithTask:(RNBootSplashTask *)task {
|
|
101
|
+
if (_status == RNBootSplashStatusHidden) {
|
|
102
|
+
task.resolve(@(true));
|
|
103
|
+
return [self shiftNextTask];
|
|
151
104
|
}
|
|
152
|
-
}
|
|
153
105
|
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
_splashVC = nil;
|
|
164
|
-
_status = RNBootSplashStatusHidden;
|
|
165
|
-
|
|
166
|
-
task.resolve(@(true));
|
|
167
|
-
[self shiftNextTask];
|
|
168
|
-
}];
|
|
106
|
+
if (!task.fade) {
|
|
107
|
+
_status = RNBootSplashStatusHidden;
|
|
108
|
+
|
|
109
|
+
_rootView.loadingView.hidden = YES;
|
|
110
|
+
[_rootView.loadingView removeFromSuperview];
|
|
111
|
+
_rootView.loadingView = nil;
|
|
112
|
+
|
|
113
|
+
task.resolve(@(true));
|
|
114
|
+
return [self shiftNextTask];
|
|
169
115
|
}
|
|
170
|
-
}
|
|
171
116
|
|
|
172
|
-
|
|
173
|
-
showWithFade:(BOOL)fade
|
|
174
|
-
resolver:(RCTPromiseResolveBlock)resolve
|
|
175
|
-
rejecter:(RCTPromiseRejectBlock)reject) {
|
|
176
|
-
if (_rootView == nil)
|
|
177
|
-
return reject(@"uninitialized_module", @"react-native-bootsplash has not been initialized, or has been too early", nil);
|
|
117
|
+
_status = RNBootSplashStatusTransitioning;
|
|
178
118
|
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
119
|
+
[UIView transitionWithView:_rootView
|
|
120
|
+
duration:0.220
|
|
121
|
+
options:UIViewAnimationOptionTransitionCrossDissolve
|
|
122
|
+
animations:^{
|
|
123
|
+
_rootView.loadingView.hidden = YES;
|
|
124
|
+
}
|
|
125
|
+
completion:^(__unused BOOL finished) {
|
|
126
|
+
_status = RNBootSplashStatusHidden;
|
|
183
127
|
|
|
184
|
-
|
|
185
|
-
|
|
128
|
+
[_rootView.loadingView removeFromSuperview];
|
|
129
|
+
_rootView.loadingView = nil;
|
|
130
|
+
|
|
131
|
+
task.resolve(@(true));
|
|
132
|
+
return [self shiftNextTask];
|
|
133
|
+
}];
|
|
186
134
|
}
|
|
187
135
|
|
|
188
136
|
RCT_REMAP_METHOD(hide,
|
|
189
137
|
hideWithFade:(BOOL)fade
|
|
190
138
|
resolver:(RCTPromiseResolveBlock)resolve
|
|
191
139
|
rejecter:(RCTPromiseRejectBlock)reject) {
|
|
192
|
-
if (_rootView == nil)
|
|
193
|
-
return
|
|
140
|
+
if (_rootView == nil || _status == RNBootSplashStatusHidden)
|
|
141
|
+
return resolve(@(true));
|
|
194
142
|
|
|
195
|
-
RNBootSplashTask *task = [[RNBootSplashTask alloc]
|
|
196
|
-
|
|
197
|
-
resolver:resolve
|
|
198
|
-
rejecter:reject];
|
|
143
|
+
RNBootSplashTask *task = [[RNBootSplashTask alloc] initWithFade:fade
|
|
144
|
+
resolver:resolve];
|
|
199
145
|
|
|
200
146
|
[_taskQueue addObject:task];
|
|
201
147
|
[RNBootSplash shiftNextTask];
|
|
@@ -209,8 +155,7 @@ RCT_REMAP_METHOD(getVisibilityStatus,
|
|
|
209
155
|
return resolve(@"visible");
|
|
210
156
|
case RNBootSplashStatusHidden:
|
|
211
157
|
return resolve(@"hidden");
|
|
212
|
-
case
|
|
213
|
-
case RNBootSplashStatusTransitioningToHidden:
|
|
158
|
+
case RNBootSplashStatusTransitioning:
|
|
214
159
|
return resolve(@"transitioning");
|
|
215
160
|
}
|
|
216
161
|
}
|
|
@@ -133,7 +133,7 @@
|
|
|
133
133
|
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
|
|
134
134
|
GCC_WARN_UNUSED_FUNCTION = YES;
|
|
135
135
|
GCC_WARN_UNUSED_VARIABLE = YES;
|
|
136
|
-
IPHONEOS_DEPLOYMENT_TARGET =
|
|
136
|
+
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
|
|
137
137
|
MTL_ENABLE_DEBUG_INFO = YES;
|
|
138
138
|
ONLY_ACTIVE_ARCH = YES;
|
|
139
139
|
SDKROOT = iphoneos;
|
|
@@ -174,7 +174,7 @@
|
|
|
174
174
|
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
|
|
175
175
|
GCC_WARN_UNUSED_FUNCTION = YES;
|
|
176
176
|
GCC_WARN_UNUSED_VARIABLE = YES;
|
|
177
|
-
IPHONEOS_DEPLOYMENT_TARGET =
|
|
177
|
+
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
|
|
178
178
|
MTL_ENABLE_DEBUG_INFO = NO;
|
|
179
179
|
SDKROOT = iphoneos;
|
|
180
180
|
SKIP_INSTALL = YES;
|
package/package.json
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-bootsplash",
|
|
3
|
-
"version": "4.0.0
|
|
3
|
+
"version": "4.0.0",
|
|
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>",
|
|
7
7
|
"homepage": "https://github.com/zoontek/react-native-bootsplash",
|
|
8
|
-
"types": "dist/typescript/index.d.ts",
|
|
9
8
|
"main": "dist/commonjs/index.js",
|
|
10
9
|
"module": "dist/module/index.js",
|
|
10
|
+
"types": "dist/typescript/index.d.ts",
|
|
11
11
|
"files": [
|
|
12
12
|
"/android",
|
|
13
13
|
"/dist",
|
|
14
14
|
"/ios",
|
|
15
15
|
"/src",
|
|
16
16
|
"RNBootSplash.podspec",
|
|
17
|
-
"
|
|
17
|
+
"RNBootSplash.res",
|
|
18
18
|
"bsconfig.json",
|
|
19
19
|
"package.json",
|
|
20
20
|
"react-native.config.js"
|
|
@@ -37,9 +37,10 @@
|
|
|
37
37
|
],
|
|
38
38
|
"scripts": {
|
|
39
39
|
"format": "prettier '**/*.{js,json,md,ts,tsx}' --write",
|
|
40
|
-
"
|
|
40
|
+
"setup-hooks": "git config --local core.hooksPath .hooks",
|
|
41
|
+
"prepare": "yarn setup-hooks && bob build"
|
|
41
42
|
},
|
|
42
|
-
"
|
|
43
|
+
"react-native-builder-bob": {
|
|
43
44
|
"source": "src",
|
|
44
45
|
"output": "dist",
|
|
45
46
|
"targets": [
|
|
@@ -48,16 +49,14 @@
|
|
|
48
49
|
"typescript"
|
|
49
50
|
]
|
|
50
51
|
},
|
|
51
|
-
"
|
|
52
|
-
"
|
|
53
|
-
"pre-commit": "lint-staged"
|
|
54
|
-
}
|
|
52
|
+
"prettier": {
|
|
53
|
+
"trailingComma": "all"
|
|
55
54
|
},
|
|
56
55
|
"lint-staged": {
|
|
57
56
|
"**/*.{js,json,md,ts,tsx}": "prettier --write"
|
|
58
57
|
},
|
|
59
58
|
"peerDependencies": {
|
|
60
|
-
"react-native": ">=0.
|
|
59
|
+
"react-native": ">=0.65.0"
|
|
61
60
|
},
|
|
62
61
|
"dependencies": {
|
|
63
62
|
"chalk": "^4.1.2",
|
|
@@ -65,16 +64,15 @@
|
|
|
65
64
|
"jimp": "^0.16.1"
|
|
66
65
|
},
|
|
67
66
|
"devDependencies": {
|
|
68
|
-
"@
|
|
69
|
-
"@react-native
|
|
70
|
-
"
|
|
71
|
-
"
|
|
72
|
-
"
|
|
73
|
-
"
|
|
74
|
-
"
|
|
75
|
-
"
|
|
76
|
-
"
|
|
77
|
-
"
|
|
78
|
-
"typescript": "^4.3.5"
|
|
67
|
+
"@types/fs-extra": "^9.0.13",
|
|
68
|
+
"@types/react-native": "^0.66.4",
|
|
69
|
+
"lint-staged": "^12.0.2",
|
|
70
|
+
"prettier": "^2.4.1",
|
|
71
|
+
"prettier-plugin-organize-imports": "^2.3.4",
|
|
72
|
+
"react": "^17.0.2",
|
|
73
|
+
"react-native": "^0.66.3",
|
|
74
|
+
"react-native-builder-bob": "^0.18.2",
|
|
75
|
+
"rescript": "^9.1.4",
|
|
76
|
+
"typescript": "^4.4.4"
|
|
79
77
|
}
|
|
80
78
|
}
|
package/react-native.config.js
CHANGED
|
@@ -16,7 +16,7 @@ module.exports = {
|
|
|
16
16
|
{
|
|
17
17
|
name: "--logo-width <width>",
|
|
18
18
|
description:
|
|
19
|
-
"logo width at @1x (in dp - we
|
|
19
|
+
"logo width at @1x (in dp - we recommend approximately ~100)",
|
|
20
20
|
default: 100,
|
|
21
21
|
parse: (value) => parseInt(value, 10),
|
|
22
22
|
},
|
|
@@ -37,21 +37,34 @@ module.exports = {
|
|
|
37
37
|
{ project: { android, ios } },
|
|
38
38
|
{ backgroundColor, logoWidth, assetsPath, flavor },
|
|
39
39
|
) => {
|
|
40
|
-
const
|
|
40
|
+
const workingPath =
|
|
41
41
|
process.env.INIT_CWD || process.env.PWD || process.cwd();
|
|
42
42
|
|
|
43
|
+
if (logoWidth > 288) {
|
|
44
|
+
console.log(
|
|
45
|
+
"❌ Logo width can't be superior to 288dp as it will be cropped on Android. Exiting…\n",
|
|
46
|
+
);
|
|
47
|
+
|
|
48
|
+
process.exit(1);
|
|
49
|
+
} else if (logoWidth > 192) {
|
|
50
|
+
console.log(
|
|
51
|
+
"⚠️ As logo width is superior to 192dp, it might be cropped on Android.\n",
|
|
52
|
+
);
|
|
53
|
+
}
|
|
54
|
+
|
|
43
55
|
return generate({
|
|
44
56
|
android,
|
|
45
57
|
ios,
|
|
46
58
|
|
|
47
|
-
|
|
48
|
-
logoPath: path.resolve(
|
|
49
|
-
backgroundColor,
|
|
50
|
-
logoWidth,
|
|
51
|
-
flavor,
|
|
59
|
+
workingPath,
|
|
60
|
+
logoPath: path.resolve(workingPath, logoPath),
|
|
52
61
|
assetsPath: assetsPath
|
|
53
|
-
? path.resolve(
|
|
62
|
+
? path.resolve(workingPath, assetsPath)
|
|
54
63
|
: undefined,
|
|
64
|
+
|
|
65
|
+
backgroundColor,
|
|
66
|
+
flavor,
|
|
67
|
+
logoWidth,
|
|
55
68
|
}).catch((error) => {
|
|
56
69
|
console.error(error);
|
|
57
70
|
});
|