CB-10079 Splashscreen plugin does not honor SplashScreenDelay on iOS

Github: close #64
This commit is contained in:
Thejaswi Puthraya 2015-11-26 15:42:25 +05:30 committed by daserge
parent cfc6d74506
commit ccb3c2f453

View File

@ -331,6 +331,9 @@
float fadeDuration = fadeSplashScreenDuration == nil ? kSplashScreenDurationDefault : [fadeSplashScreenDuration floatValue]; float fadeDuration = fadeSplashScreenDuration == nil ? kSplashScreenDurationDefault : [fadeSplashScreenDuration floatValue];
id splashDurationString = [self.commandDelegate.settings objectForKey: [@"SplashScreenDelay" lowercaseString]];
float splashDuration = splashDurationString == nil ? kSplashScreenDurationDefault : [splashDurationString floatValue];
if (fadeSplashScreenValue == nil) if (fadeSplashScreenValue == nil)
{ {
fadeSplashScreenValue = @"true"; fadeSplashScreenValue = @"true";
@ -340,7 +343,7 @@
{ {
fadeDuration = 0; fadeDuration = 0;
} }
else if(fadeDuration < 30) else if (fadeDuration < 30)
{ {
// [CB-9750] This value used to be in decimal seconds, so we will assume that if someone specifies 10 // [CB-9750] This value used to be in decimal seconds, so we will assume that if someone specifies 10
// they mean 10 seconds, and not the meaningless 10ms // they mean 10 seconds, and not the meaningless 10ms
@ -354,26 +357,29 @@
[self createViews]; [self createViews];
} }
} }
else if (fadeDuration == 0) else if (fadeDuration == 0 && splashDuration == 0)
{ {
[self destroyViews]; [self destroyViews];
} }
else else
{ {
__weak __typeof(self) weakSelf = self; __weak __typeof(self) weakSelf = self;
[UIView transitionWithView:self.viewController.view float effectiveSplashDuration = (splashDuration - fadeDuration) / 1000;
duration:(fadeDuration / 1000) dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (uint64_t) effectiveSplashDuration * NSEC_PER_SEC), dispatch_get_main_queue(), CFBridgingRelease(CFBridgingRetain(^(void) {
options:UIViewAnimationOptionTransitionNone [UIView transitionWithView:self.viewController.view
animations:^(void) { duration:(fadeDuration / 1000)
[weakSelf hideViews]; options:UIViewAnimationOptionTransitionNone
} animations:^(void) {
completion:^(BOOL finished) { [weakSelf hideViews];
if (finished) { }
[weakSelf destroyViews]; completion:^(BOOL finished) {
// TODO: It might also be nice to have a js event happen here -jm if (finished) {
} [weakSelf destroyViews];
} // TODO: It might also be nice to have a js event happen here -jm
]; }
}
];
})));
} }
} }
} }