Skip to content
Permalink
Browse files
CB-10562 hide() not working in latest splashscreen plug in 3.1.0 in iOS
  • Loading branch information
daserge committed Mar 24, 2016
1 parent 9ca15db commit 41d9ae94ffe4e6d70f941f176045ceff45c69d4f
Showing 2 changed files with 26 additions and 15 deletions.
@@ -36,6 +36,7 @@ typedef struct {
UIImageView* _imageView;
NSString* _curImageName;
BOOL _visible;
BOOL _destroyed;
}

- (void)show:(CDVInvokedUrlCommand*)command;
@@ -41,7 +41,7 @@ - (void)show:(CDVInvokedUrlCommand*)command

- (void)hide:(CDVInvokedUrlCommand*)command
{
[self setVisible:NO];
[self setVisible:NO andForce:YES];
}

- (void)pageDidLoad
@@ -120,6 +120,7 @@ - (void)createViews
[parentView addObserver:self forKeyPath:@"bounds" options:0 context:nil];

[self updateImage];
_destroyed = NO;
}

- (void)hideViews
@@ -130,6 +131,7 @@ - (void)hideViews

- (void)destroyViews
{
_destroyed = YES;
[(CDVViewController *)self.viewController setEnabledAutorotation:[(CDVViewController *)self.viewController shouldAutorotateDefaultValue]];

[_imageView removeFromSuperview];
@@ -376,7 +378,12 @@ - (void)updateBounds

- (void)setVisible:(BOOL)visible
{
if (visible != _visible)
[self setVisible:visible andForce:NO];
}

- (void)setVisible:(BOOL)visible andForce:(BOOL)force
{
if (visible != _visible || force)
{
_visible = visible;

@@ -433,26 +440,29 @@ - (void)setVisible:(BOOL)visible
__weak __typeof(self) weakSelf = self;
float effectiveSplashDuration;

if (!autoHideSplashScreen) {
// [CB-10562] AutoHideSplashScreen may be "true" but we should still be able to hide the splashscreen manually.
if (!autoHideSplashScreen || force) {
effectiveSplashDuration = (fadeDuration) / 1000;
} else {
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 (!_destroyed) {
[UIView transitionWithView:self.viewController.view
duration:(fadeDuration / 1000)
options:UIViewAnimationOptionTransitionNone
animations:^(void) {
[weakSelf hideViews];
}
completion:^(BOOL finished) {
if (finished && !_destroyed) {
[weakSelf destroyViews];
// TODO: It might also be nice to have a js event happen here -jm
}
}
];
}
})));
}
}

0 comments on commit 41d9ae9

Please sign in to comment.