Github user daserge commented on the pull request:
https://github.com/apache/cordova-plugin-splashscreen/pull/64#issuecomment-165813016
@theju, thanks for this fix!
A few notes on this:
- Could you please add the fallback to default value for `splashDuration`
(like the way it is done for `fadeSplashScreenDuration`)?
```objective-c
id splashDurationString = [self.commandDelegate.settings objectForKey: [@
"SplashScreenDelay"lowercaseString]];
float splashDuration = splashDurationString == nil ?
kSplashScreenDurationDefault : [splashDurationString floatValue];
```
- If we have `<preference name="FadeSplashScreen" value="false" />` there
will be no delay at all - to fix this we should change this line:
```objective-c
else if (fadeDuration == 0 && splashDuration == 0) {
[self destroyViews];
}
```
- Could you also please rename the PR title and the commit title to
`CB-10079 Splashscreen plugin does not honor SplashScreenDelay on iOS`?
The updated function:
```objective-c
-(void) setVisible: (BOOL) visible {
if (visible != _visible) {
_visible = visible;
id fadeSplashScreenValue = [self.commandDelegate.settings
objectForKey: [@ "FadeSplashScreen"lowercaseString]];
id fadeSplashScreenDuration = [self.commandDelegate.settings
objectForKey: [@ "FadeSplashScreenDuration"lowercaseString]];
float fadeDuration = fadeSplashScreenDuration == nil ?
kSplashScreenDurationDefault : [fadeSplashScreenDuration floatValue];
id splashDurationString = [self.commandDelegate.settings
objectForKey: [@ "SplashScreenDelay"lowercaseString]];
float splashDuration = splashDurationString == nil ?
kSplashScreenDurationDefault : [splashDurationString floatValue];
// Changes from
https://github.com/apache/cordova-plugin-splashscreen/pull/65
if (fadeSplashScreenValue == nil) {
fadeSplashScreenValue = @ "true";
}
if (![fadeSplashScreenValue boolValue]) {
fadeDuration = 0;
} else if (fadeDuration < 30) {
// [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
fadeDuration *= 1000;
}
if (_visible) {
if (_imageView == nil) {
[self createViews];
}
} else if (fadeDuration == 0 && splashDuration == 0) {
[self destroyViews];
} else {
__weak __typeof(self) weakSelf = self;
float effectiveSplashDuration = (splashDuration - fadeDuration)
/ 1000;
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (uint64_t)
effectiveSplashDuration * NSEC_PER_SEC), dispatch_get_main_queue(),
CFBridgingRelease(CFBridgingRetain( ^ (void) {
[UIView transitionWithView: self.viewController.view
duration: (fadeDuration / 1000)
options: UIViewAnimationOptionTransitionNone
animations: ^ (void) {
[weakSelf hideViews];
}
completion: ^ (BOOL finished) {
if (finished) {
[weakSelf destroyViews];
// TODO: It might also be nice to have a js
event happen here -jm
}
}
];
})));
}
}
}
```
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]