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 +1 -1
- package/README.md +75 -134
- package/RNBootSplash.podspec +1 -1
- package/ReactNativeBootsplash.res +2 -6
- package/android/build.gradle +13 -11
- package/android/src/main/java/com/zoontek/rnbootsplash/RNBootSplash.java +2 -3
- package/android/src/main/java/com/zoontek/rnbootsplash/RNBootSplashModule.java +82 -155
- 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/dist/commonjs/generate.js +118 -110
- package/dist/commonjs/generate.js.map +1 -1
- package/dist/commonjs/index.js +4 -12
- package/dist/commonjs/index.js.map +1 -1
- package/dist/module/generate.js +114 -107
- package/dist/module/generate.js.map +1 -1
- package/dist/module/index.js +2 -8
- package/dist/module/index.js.map +1 -1
- package/dist/typescript/generate.d.ts +4 -4
- package/dist/typescript/index.d.ts +0 -2
- package/ios/RNBootSplash.h +3 -13
- package/ios/RNBootSplash.m +44 -93
- package/ios/RNBootSplash.xcodeproj/project.pbxproj +2 -2
- package/package.json +17 -19
- package/react-native.config.js +21 -8
- package/src/generate.ts +98 -139
- package/src/index.ts +4 -6
- package/android/src/main/java/com/zoontek/rnbootsplash/RNBootSplashActivity.java +0 -55
- package/android/src/main/res/values/ids.xml +0 -3
package/ios/RNBootSplash.m
CHANGED
|
@@ -4,22 +4,16 @@
|
|
|
4
4
|
#import <React/RCTUtils.h>
|
|
5
5
|
|
|
6
6
|
static NSMutableArray<RNBootSplashTask *> *_taskQueue = nil;
|
|
7
|
-
static NSString *_storyboardName = @"BootSplash";
|
|
8
7
|
static RCTRootView *_rootView = nil;
|
|
9
8
|
static RNBootSplashStatus _status = RNBootSplashStatusHidden;
|
|
10
|
-
static UIViewController *_splashVC = nil;
|
|
11
9
|
|
|
12
10
|
@implementation RNBootSplashTask
|
|
13
11
|
|
|
14
|
-
- (instancetype)
|
|
15
|
-
|
|
16
|
-
resolver:(RCTPromiseResolveBlock _Nonnull)resolve
|
|
17
|
-
rejecter:(RCTPromiseRejectBlock _Nonnull)reject {
|
|
12
|
+
- (instancetype)initWithFade:(BOOL)fade
|
|
13
|
+
resolver:(RCTPromiseResolveBlock _Nonnull)resolve {
|
|
18
14
|
if (self = [super init]) {
|
|
19
|
-
_type = type;
|
|
20
15
|
_fade = fade;
|
|
21
16
|
_resolve = resolve;
|
|
22
|
-
_reject = reject;
|
|
23
17
|
}
|
|
24
18
|
|
|
25
19
|
return self;
|
|
@@ -43,29 +37,15 @@ RCT_EXPORT_MODULE();
|
|
|
43
37
|
rootView:(RCTRootView * _Nonnull)rootView {
|
|
44
38
|
_rootView = rootView;
|
|
45
39
|
_status = RNBootSplashStatusVisible;
|
|
46
|
-
_storyboardName = storyboardName;
|
|
47
40
|
_taskQueue = [[NSMutableArray alloc] init];
|
|
48
41
|
|
|
49
|
-
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:
|
|
42
|
+
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:storyboardName bundle:nil];
|
|
50
43
|
[_rootView setLoadingView:[[storyboard instantiateInitialViewController] view]];
|
|
51
44
|
|
|
52
45
|
[[NSNotificationCenter defaultCenter] removeObserver:rootView
|
|
53
46
|
name:RCTContentDidAppearNotification
|
|
54
47
|
object:rootView];
|
|
55
48
|
|
|
56
|
-
_splashVC = [storyboard instantiateInitialViewController];
|
|
57
|
-
[_splashVC setModalPresentationStyle:UIModalPresentationOverFullScreen];
|
|
58
|
-
[_splashVC setModalTransitionStyle:UIModalTransitionStyleCrossDissolve];
|
|
59
|
-
|
|
60
|
-
[RCTPresentedViewController() presentViewController:_splashVC
|
|
61
|
-
animated:false
|
|
62
|
-
completion:^{
|
|
63
|
-
[_rootView.loadingView removeFromSuperview];
|
|
64
|
-
_rootView.loadingView = nil;
|
|
65
|
-
|
|
66
|
-
[self shiftNextTask]; // JS thread might started pushing tasks
|
|
67
|
-
}];
|
|
68
|
-
|
|
69
49
|
[[NSNotificationCenter defaultCenter] addObserver:self
|
|
70
50
|
selector:@selector(onJavaScriptDidLoad:)
|
|
71
51
|
name:RCTJavaScriptDidLoadNotification
|
|
@@ -93,20 +73,19 @@ RCT_EXPORT_MODULE();
|
|
|
93
73
|
}
|
|
94
74
|
|
|
95
75
|
+ (void)onJavaScriptDidFailToLoad {
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
76
|
+
_status = RNBootSplashStatusHidden;
|
|
77
|
+
|
|
78
|
+
if (_rootView != nil) {
|
|
79
|
+
_rootView.loadingView.hidden = YES;
|
|
80
|
+
[_rootView.loadingView removeFromSuperview];
|
|
81
|
+
_rootView.loadingView = nil;
|
|
101
82
|
}
|
|
102
83
|
|
|
103
84
|
[[NSNotificationCenter defaultCenter] removeObserver:self];
|
|
104
85
|
}
|
|
105
86
|
|
|
106
87
|
+ (void)shiftNextTask {
|
|
107
|
-
bool shouldSkipTick =
|
|
108
|
-
|| _status == RNBootSplashStatusTransitioningToVisible
|
|
109
|
-
|| _status == RNBootSplashStatusTransitioningToHidden
|
|
88
|
+
bool shouldSkipTick = _status == RNBootSplashStatusTransitioning
|
|
110
89
|
|| [_taskQueue count] == 0
|
|
111
90
|
|| [[UIApplication sharedApplication] applicationState] == UIApplicationStateBackground;
|
|
112
91
|
|
|
@@ -115,81 +94,54 @@ RCT_EXPORT_MODULE();
|
|
|
115
94
|
RNBootSplashTask *task = [_taskQueue objectAtIndex:0];
|
|
116
95
|
[_taskQueue removeObjectAtIndex:0];
|
|
117
96
|
|
|
118
|
-
|
|
119
|
-
case RNBootSplashTaskTypeShow:
|
|
120
|
-
return [self showWithTask:task];
|
|
121
|
-
case RNBootSplashTaskTypeHide:
|
|
122
|
-
return [self hideWithTask:task];
|
|
123
|
-
}
|
|
97
|
+
return [self hideWithTask:task];
|
|
124
98
|
}
|
|
125
99
|
|
|
126
|
-
+ (void)
|
|
127
|
-
if (
|
|
128
|
-
task.resolve(@(true));
|
|
129
|
-
[self shiftNextTask];
|
|
130
|
-
} else {
|
|
131
|
-
_status = RNBootSplashStatusTransitioningToVisible;
|
|
132
|
-
|
|
133
|
-
_splashVC = [[UIStoryboard storyboardWithName:_storyboardName bundle:nil] instantiateInitialViewController];
|
|
134
|
-
[_splashVC setModalPresentationStyle:UIModalPresentationOverFullScreen];
|
|
135
|
-
[_splashVC setModalTransitionStyle:UIModalTransitionStyleCrossDissolve];
|
|
136
|
-
|
|
137
|
-
[RCTPresentedViewController() presentViewController:_splashVC
|
|
138
|
-
animated:task.fade
|
|
139
|
-
completion:^{
|
|
140
|
-
_status = RNBootSplashStatusVisible;
|
|
141
|
-
|
|
142
|
-
task.resolve(@(true));
|
|
143
|
-
[self shiftNextTask];
|
|
144
|
-
}];
|
|
100
|
+
+ (void)hideWithTask:(RNBootSplashTask *)task {
|
|
101
|
+
if (_status == RNBootSplashStatusHidden) {
|
|
102
|
+
task.resolve(@(true));
|
|
103
|
+
return [self shiftNextTask];
|
|
145
104
|
}
|
|
146
|
-
}
|
|
147
105
|
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
_splashVC = nil;
|
|
158
|
-
_status = RNBootSplashStatusHidden;
|
|
159
|
-
|
|
160
|
-
task.resolve(@(true));
|
|
161
|
-
[self shiftNextTask];
|
|
162
|
-
}];
|
|
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];
|
|
163
115
|
}
|
|
164
|
-
}
|
|
165
116
|
|
|
166
|
-
|
|
167
|
-
showWithFade:(BOOL)fade
|
|
168
|
-
resolver:(RCTPromiseResolveBlock)resolve
|
|
169
|
-
rejecter:(RCTPromiseRejectBlock)reject) {
|
|
170
|
-
if (_rootView == nil)
|
|
171
|
-
return reject(@"uninitialized_module", @"react-native-bootsplash has not been initialized, or has been too early", nil);
|
|
117
|
+
_status = RNBootSplashStatusTransitioning;
|
|
172
118
|
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
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;
|
|
177
127
|
|
|
178
|
-
|
|
179
|
-
|
|
128
|
+
[_rootView.loadingView removeFromSuperview];
|
|
129
|
+
_rootView.loadingView = nil;
|
|
130
|
+
|
|
131
|
+
task.resolve(@(true));
|
|
132
|
+
return [self shiftNextTask];
|
|
133
|
+
}];
|
|
180
134
|
}
|
|
181
135
|
|
|
182
136
|
RCT_REMAP_METHOD(hide,
|
|
183
137
|
hideWithFade:(BOOL)fade
|
|
184
138
|
resolver:(RCTPromiseResolveBlock)resolve
|
|
185
139
|
rejecter:(RCTPromiseRejectBlock)reject) {
|
|
186
|
-
if (_rootView == nil)
|
|
187
|
-
return
|
|
140
|
+
if (_rootView == nil || _status == RNBootSplashStatusHidden)
|
|
141
|
+
return resolve(@(true));
|
|
188
142
|
|
|
189
|
-
RNBootSplashTask *task = [[RNBootSplashTask alloc]
|
|
190
|
-
|
|
191
|
-
resolver:resolve
|
|
192
|
-
rejecter:reject];
|
|
143
|
+
RNBootSplashTask *task = [[RNBootSplashTask alloc] initWithFade:fade
|
|
144
|
+
resolver:resolve];
|
|
193
145
|
|
|
194
146
|
[_taskQueue addObject:task];
|
|
195
147
|
[RNBootSplash shiftNextTask];
|
|
@@ -203,8 +155,7 @@ RCT_REMAP_METHOD(getVisibilityStatus,
|
|
|
203
155
|
return resolve(@"visible");
|
|
204
156
|
case RNBootSplashStatusHidden:
|
|
205
157
|
return resolve(@"hidden");
|
|
206
|
-
case
|
|
207
|
-
case RNBootSplashStatusTransitioningToHidden:
|
|
158
|
+
case RNBootSplashStatusTransitioning:
|
|
208
159
|
return resolve(@"transitioning");
|
|
209
160
|
}
|
|
210
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,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-bootsplash",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.0.0-beta.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>",
|
|
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",
|
|
@@ -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
|
-
"@types/fs-extra": "^9.0.12",
|
|
71
|
-
"@types/react-native": "^0.64.13",
|
|
67
|
+
"@types/fs-extra": "^9.0.13",
|
|
68
|
+
"@types/react-native": "^0.66.4",
|
|
72
69
|
"bs-platform": "^9.0.2",
|
|
73
|
-
"
|
|
74
|
-
"
|
|
75
|
-
"prettier": "^2.3.
|
|
76
|
-
"react": "17.0.2",
|
|
77
|
-
"react-native": "^0.
|
|
78
|
-
"
|
|
70
|
+
"lint-staged": "^11.2.6",
|
|
71
|
+
"prettier": "^2.4.1",
|
|
72
|
+
"prettier-plugin-organize-imports": "^2.3.4",
|
|
73
|
+
"react": "^17.0.2",
|
|
74
|
+
"react-native": "^0.66.3",
|
|
75
|
+
"react-native-builder-bob": "^0.18.2",
|
|
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
|
});
|