react-native-bootsplash 3.2.3 → 3.2.7
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 +3 -3
- package/android/build.gradle +1 -1
- package/ios/RNBootSplash.m +70 -26
- package/package.json +10 -10
package/README.md
CHANGED
|
@@ -212,8 +212,8 @@ public class MainActivity extends ReactActivity {
|
|
|
212
212
|
|
|
213
213
|
@Override
|
|
214
214
|
protected void onCreate(Bundle savedInstanceState) {
|
|
215
|
-
super.onCreate(savedInstanceState);
|
|
216
|
-
RNBootSplash.init(R.drawable.bootsplash, MainActivity.this); //
|
|
215
|
+
super.onCreate(savedInstanceState); // or super.onCreate(null) with react-native-screens
|
|
216
|
+
RNBootSplash.init(R.drawable.bootsplash, MainActivity.this); // display the generated bootsplash.xml drawable over our MainActivity
|
|
217
217
|
}
|
|
218
218
|
```
|
|
219
219
|
|
|
@@ -225,7 +225,7 @@ As Android will not create our main activity before launching the app, we need t
|
|
|
225
225
|
<resources>
|
|
226
226
|
|
|
227
227
|
<!-- Base application theme -->
|
|
228
|
-
<style name="AppTheme" parent="Theme.AppCompat.
|
|
228
|
+
<style name="AppTheme" parent="Theme.AppCompat.DayNight.NoActionBar">
|
|
229
229
|
<!-- Your base theme customization -->
|
|
230
230
|
</style>
|
|
231
231
|
|
package/android/build.gradle
CHANGED
package/ios/RNBootSplash.m
CHANGED
|
@@ -8,6 +8,7 @@ static NSString *_storyboardName = @"BootSplash";
|
|
|
8
8
|
static RCTRootView *_rootView = nil;
|
|
9
9
|
static RNBootSplashStatus _status = RNBootSplashStatusHidden;
|
|
10
10
|
static UIViewController *_splashVC = nil;
|
|
11
|
+
static bool _preventInitialization = false;
|
|
11
12
|
|
|
12
13
|
@implementation RNBootSplashTask
|
|
13
14
|
|
|
@@ -39,8 +40,36 @@ RCT_EXPORT_MODULE();
|
|
|
39
40
|
return dispatch_get_main_queue();
|
|
40
41
|
}
|
|
41
42
|
|
|
43
|
+
- (id)init {
|
|
44
|
+
if (self = [super init]) {
|
|
45
|
+
[[NSNotificationCenter defaultCenter] addObserver:self
|
|
46
|
+
selector:@selector(onContentDidAppear)
|
|
47
|
+
name:RCTContentDidAppearNotification
|
|
48
|
+
object:nil];
|
|
49
|
+
|
|
50
|
+
[[NSNotificationCenter defaultCenter] addObserver:self
|
|
51
|
+
selector:@selector(onJavaScriptDidFailToLoad)
|
|
52
|
+
name:RCTJavaScriptDidFailToLoadNotification
|
|
53
|
+
object:nil];
|
|
54
|
+
|
|
55
|
+
[[NSNotificationCenter defaultCenter] addObserver:self
|
|
56
|
+
selector:@selector(onApplicationDidBecomeActive)
|
|
57
|
+
name:UIApplicationDidBecomeActiveNotification
|
|
58
|
+
object:nil];
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
return self;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
- (void)dealloc {
|
|
65
|
+
[[NSNotificationCenter defaultCenter] removeObserver:self];
|
|
66
|
+
}
|
|
67
|
+
|
|
42
68
|
+ (void)initWithStoryboard:(NSString * _Nonnull)storyboardName
|
|
43
69
|
rootView:(RCTRootView * _Nonnull)rootView {
|
|
70
|
+
if (_preventInitialization)
|
|
71
|
+
return; // initWithStoryboard has been called too late
|
|
72
|
+
|
|
44
73
|
_rootView = rootView;
|
|
45
74
|
_status = RNBootSplashStatusVisible;
|
|
46
75
|
_storyboardName = storyboardName;
|
|
@@ -65,26 +94,13 @@ RCT_EXPORT_MODULE();
|
|
|
65
94
|
|
|
66
95
|
[self shiftNextTask]; // JS thread might started pushing tasks
|
|
67
96
|
}];
|
|
68
|
-
|
|
69
|
-
[[NSNotificationCenter defaultCenter] addObserver:self
|
|
70
|
-
selector:@selector(onJavaScriptDidLoad:)
|
|
71
|
-
name:RCTJavaScriptDidLoadNotification
|
|
72
|
-
object:nil];
|
|
73
|
-
|
|
74
|
-
[[NSNotificationCenter defaultCenter] addObserver:self
|
|
75
|
-
selector:@selector(onJavaScriptDidFailToLoad)
|
|
76
|
-
name:RCTJavaScriptDidFailToLoadNotification
|
|
77
|
-
object:nil];
|
|
78
|
-
|
|
79
|
-
[[NSNotificationCenter defaultCenter] addObserver:self
|
|
80
|
-
selector:@selector(shiftNextTask)
|
|
81
|
-
name:UIApplicationDidBecomeActiveNotification
|
|
82
|
-
object:nil];
|
|
83
97
|
}
|
|
84
98
|
|
|
85
|
-
|
|
99
|
+
- (void)onContentDidAppear {
|
|
100
|
+
_preventInitialization = true;
|
|
101
|
+
|
|
86
102
|
[[NSNotificationCenter defaultCenter] removeObserver:self
|
|
87
|
-
name:
|
|
103
|
+
name:RCTContentDidAppearNotification
|
|
88
104
|
object:nil];
|
|
89
105
|
|
|
90
106
|
[[NSNotificationCenter defaultCenter] removeObserver:self
|
|
@@ -92,7 +108,9 @@ RCT_EXPORT_MODULE();
|
|
|
92
108
|
object:nil];
|
|
93
109
|
}
|
|
94
110
|
|
|
95
|
-
|
|
111
|
+
- (void)onJavaScriptDidFailToLoad {
|
|
112
|
+
_preventInitialization = true;
|
|
113
|
+
|
|
96
114
|
if (_splashVC != nil) {
|
|
97
115
|
[_splashVC dismissViewControllerAnimated:false
|
|
98
116
|
completion:^{
|
|
@@ -103,14 +121,36 @@ RCT_EXPORT_MODULE();
|
|
|
103
121
|
[[NSNotificationCenter defaultCenter] removeObserver:self];
|
|
104
122
|
}
|
|
105
123
|
|
|
124
|
+
- (void)onApplicationDidBecomeActive {
|
|
125
|
+
[RNBootSplash shiftNextTask];
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
+ (void)retryShiftNextTask:(NSTimer *)timer {
|
|
129
|
+
[timer invalidate];
|
|
130
|
+
[self shiftNextTask];
|
|
131
|
+
}
|
|
132
|
+
|
|
106
133
|
+ (void)shiftNextTask {
|
|
134
|
+
bool hasTasks = [_taskQueue count] > 0;
|
|
135
|
+
bool isActive = [[UIApplication sharedApplication] applicationState] == UIApplicationStateActive;
|
|
136
|
+
|
|
107
137
|
bool shouldSkipTick = _rootView.loadingView != nil
|
|
108
138
|
|| _status == RNBootSplashStatusTransitioningToVisible
|
|
109
139
|
|| _status == RNBootSplashStatusTransitioningToHidden
|
|
110
|
-
||
|
|
111
|
-
||
|
|
112
|
-
|
|
113
|
-
if (shouldSkipTick)
|
|
140
|
+
|| !hasTasks
|
|
141
|
+
|| !isActive;
|
|
142
|
+
|
|
143
|
+
if (shouldSkipTick) {
|
|
144
|
+
if (hasTasks && isActive) {
|
|
145
|
+
[NSTimer scheduledTimerWithTimeInterval:0.1
|
|
146
|
+
target:self
|
|
147
|
+
selector:@selector(retryShiftNextTask:)
|
|
148
|
+
userInfo:nil
|
|
149
|
+
repeats:false];
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
return;
|
|
153
|
+
}
|
|
114
154
|
|
|
115
155
|
RNBootSplashTask *task = [_taskQueue objectAtIndex:0];
|
|
116
156
|
[_taskQueue removeObjectAtIndex:0];
|
|
@@ -167,8 +207,10 @@ RCT_REMAP_METHOD(show,
|
|
|
167
207
|
showWithFade:(BOOL)fade
|
|
168
208
|
resolver:(RCTPromiseResolveBlock)resolve
|
|
169
209
|
rejecter:(RCTPromiseRejectBlock)reject) {
|
|
170
|
-
if (_rootView == nil)
|
|
171
|
-
|
|
210
|
+
if (_rootView == nil) {
|
|
211
|
+
_preventInitialization = true;
|
|
212
|
+
return reject(@"uninitialized_module", @"react-native-bootsplash has not been initialized, or has been too early", nil);
|
|
213
|
+
}
|
|
172
214
|
|
|
173
215
|
RNBootSplashTask *task = [[RNBootSplashTask alloc] initWithType:RNBootSplashTaskTypeShow
|
|
174
216
|
fade:fade
|
|
@@ -183,8 +225,10 @@ RCT_REMAP_METHOD(hide,
|
|
|
183
225
|
hideWithFade:(BOOL)fade
|
|
184
226
|
resolver:(RCTPromiseResolveBlock)resolve
|
|
185
227
|
rejecter:(RCTPromiseRejectBlock)reject) {
|
|
186
|
-
if (_rootView == nil)
|
|
187
|
-
|
|
228
|
+
if (_rootView == nil) {
|
|
229
|
+
_preventInitialization = true;
|
|
230
|
+
return reject(@"uninitialized_module", @"react-native-bootsplash has not been initialized, or has been too early", nil);
|
|
231
|
+
}
|
|
188
232
|
|
|
189
233
|
RNBootSplashTask *task = [[RNBootSplashTask alloc] initWithType:RNBootSplashTaskTypeHide
|
|
190
234
|
fade:fade
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-bootsplash",
|
|
3
|
-
"version": "3.2.
|
|
3
|
+
"version": "3.2.7",
|
|
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>",
|
|
@@ -60,21 +60,21 @@
|
|
|
60
60
|
"react-native": ">=0.60.0"
|
|
61
61
|
},
|
|
62
62
|
"dependencies": {
|
|
63
|
-
"chalk": "^4.1.
|
|
64
|
-
"fs-extra": "^
|
|
63
|
+
"chalk": "^4.1.2",
|
|
64
|
+
"fs-extra": "^10.0.0",
|
|
65
65
|
"jimp": "^0.16.1"
|
|
66
66
|
},
|
|
67
67
|
"devDependencies": {
|
|
68
|
-
"@babel/core": "^7.
|
|
68
|
+
"@babel/core": "^7.15.0",
|
|
69
69
|
"@react-native-community/bob": "^0.17.1",
|
|
70
|
-
"@types/fs-extra": "^9.0.
|
|
71
|
-
"@types/react-native": "^0.
|
|
70
|
+
"@types/fs-extra": "^9.0.12",
|
|
71
|
+
"@types/react-native": "^0.64.13",
|
|
72
72
|
"bs-platform": "^9.0.2",
|
|
73
73
|
"husky": "^4.3.8",
|
|
74
|
-
"lint-staged": "^
|
|
75
|
-
"prettier": "^2.2
|
|
76
|
-
"react": "17.0.
|
|
74
|
+
"lint-staged": "^11.1.2",
|
|
75
|
+
"prettier": "^2.3.2",
|
|
76
|
+
"react": "17.0.2",
|
|
77
77
|
"react-native": "^0.63.4",
|
|
78
|
-
"typescript": "^4.
|
|
78
|
+
"typescript": "^4.3.5"
|
|
79
79
|
}
|
|
80
80
|
}
|