You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by dp...@apache.org on 2020/10/10 20:59:01 UTC

[cordova-ios] branch master updated: Hide splash sceen immediately on .hide() (#1006)

This is an automated email from the ASF dual-hosted git repository.

dpogue pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/cordova-ios.git


The following commit(s) were added to refs/heads/master by this push:
     new cb20c9b  Hide splash sceen immediately on .hide() (#1006)
cb20c9b is described below

commit cb20c9bba970136c98571cc6f1a4c97501c4aff7
Author: Dimitri B <Be...@users.noreply.github.com>
AuthorDate: Sat Oct 10 22:58:51 2020 +0200

    Hide splash sceen immediately on .hide() (#1006)
    
    Make hiding of splash screen a race between `SplashScreenDelay` setting
    and navigator.splashscreen.hide().
    
    Related issue: https://github.com/apache/cordova-ios/issues/991
---
 CordovaLib/Classes/Public/CDVViewController.m | 25 +++++++++++++++----------
 1 file changed, 15 insertions(+), 10 deletions(-)

diff --git a/CordovaLib/Classes/Public/CDVViewController.m b/CordovaLib/Classes/Public/CDVViewController.m
index 0d7eb8b..9318d46 100644
--- a/CordovaLib/Classes/Public/CDVViewController.m
+++ b/CordovaLib/Classes/Public/CDVViewController.m
@@ -767,7 +767,18 @@
     self.webView.hidden = NO;
 
     if ([self.settings cordovaBoolSettingForKey:@"AutoHideSplashScreen" defaultValue:YES]) {
-       [self showLaunchScreen:NO];
+        CGFloat splashScreenDelaySetting = [self.settings cordovaFloatSettingForKey:@"SplashScreenDelay" defaultValue:0];
+
+        if (splashScreenDelaySetting == 0) {
+            [self showLaunchScreen:NO];
+        } else {
+            // Divide by 1000 because config returns milliseconds and NSTimer takes seconds
+            CGFloat splashScreenDelay = splashScreenDelaySetting / 1000;
+
+            [NSTimer scheduledTimerWithTimeInterval:splashScreenDelay repeats:NO block:^(NSTimer * _Nonnull timer) {
+                [self showLaunchScreen:NO];
+            }];
+        }
     }
 }
 
@@ -776,22 +787,16 @@
  */
 - (void)showLaunchScreen:(BOOL)visible
 {
-    CGFloat splashScreenDelay = [self.settings cordovaFloatSettingForKey:@"SplashScreenDelay" defaultValue:0];
-
-    // AnimateWithDuration takes seconds but cordova documentation specifies milliseconds
     CGFloat fadeSplashScreenDuration = [self.settings cordovaFloatSettingForKey:@"FadeSplashScreenDuration" defaultValue:250];
 
     // Setting minimum value for fade to 0.25 seconds
     fadeSplashScreenDuration = fadeSplashScreenDuration < 250 ? 250 : fadeSplashScreenDuration;
 
-    // Divide by 1000 because config returns milliseconds and NSTimer takes seconds
-    CGFloat delayToFade = (MAX(splashScreenDelay, fadeSplashScreenDuration) - fadeSplashScreenDuration)/1000;
+    // AnimateWithDuration takes seconds but cordova documentation specifies milliseconds
     CGFloat fadeDuration = fadeSplashScreenDuration/1000;
 
-    [NSTimer scheduledTimerWithTimeInterval:delayToFade repeats:NO block:^(NSTimer * _Nonnull timer) {
-        [UIView animateWithDuration:fadeDuration animations:^{
-            [self.launchView setAlpha:(visible ? 1 : 0)];
-        }];
+    [UIView animateWithDuration:fadeDuration animations:^{
+        [self.launchView setAlpha:(visible ? 1 : 0)];
     }];
 }
 


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org