diff --git a/splash-screen/README.md b/splash-screen/README.md index b44be8bd9..36a239ce9 100644 --- a/splash-screen/README.md +++ b/splash-screen/README.md @@ -98,7 +98,7 @@ These config values are available: | ------------------------------- | ----------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------- | ----- | | **`launchShowDuration`** | number | How long to show the launch splash screen when autoHide is enabled (in ms) | 500 | 1.0.0 | | **`launchAutoHide`** | boolean | Whether to auto hide the splash after launchShowDuration. | true | 1.0.0 | -| **`launchFadeOutDuration`** | number | Duration for the fade out animation of the launch splash screen (in ms) Only available for Android, when using the Android 12 Splash Screen API. | 200 | 4.2.0 | +| **`launchFadeOutDuration`** | number | Duration for the fade out animation of the launch splash screen (in ms) On Android, only available when using the Android 12 Splash Screen API. | 0 | 4.2.0 | | **`backgroundColor`** | string | Color of the background of the Splash Screen in hex format, #RRGGBB or #RRGGBBAA. Doesn't work if `useDialog` is true or on launch when using the Android 12 API. | | 1.0.0 | | **`androidSplashResourceName`** | string | Name of the resource to be used as Splash Screen. Doesn't work on launch when using the Android 12 API. Only available on Android. | splash | 1.0.0 | | **`androidScaleType`** | 'CENTER' \| 'CENTER_CROP' \| 'CENTER_INSIDE' \| 'FIT_CENTER' \| 'FIT_END' \| 'FIT_START' \| 'FIT_XY' \| 'MATRIX' | The [ImageView.ScaleType](https://developer.android.com/reference/android/widget/ImageView.ScaleType) used to scale the Splash Screen image. Doesn't work if `useDialog` is true or on launch when using the Android 12 API. Only available on Android. | FIT_XY | 1.0.0 | diff --git a/splash-screen/android/src/main/java/com/capacitorjs/plugins/splashscreen/SplashScreenConfig.java b/splash-screen/android/src/main/java/com/capacitorjs/plugins/splashscreen/SplashScreenConfig.java index a8dd69ddd..8523c0762 100644 --- a/splash-screen/android/src/main/java/com/capacitorjs/plugins/splashscreen/SplashScreenConfig.java +++ b/splash-screen/android/src/main/java/com/capacitorjs/plugins/splashscreen/SplashScreenConfig.java @@ -11,7 +11,7 @@ public class SplashScreenConfig { private Integer launchShowDuration = 500; private boolean launchAutoHide = true; private Integer launchFadeInDuration = 0; - private Integer launchFadeOutDuration = 200; + private Integer launchFadeOutDuration = 0; private String resourceName = "splash"; private boolean immersive = false; private boolean fullScreen = false; diff --git a/splash-screen/ios/Sources/SplashScreenPlugin/SplashScreen.swift b/splash-screen/ios/Sources/SplashScreenPlugin/SplashScreen.swift index 4a00ed628..b4020f06b 100644 --- a/splash-screen/ios/Sources/SplashScreenPlugin/SplashScreen.swift +++ b/splash-screen/ios/Sources/SplashScreenPlugin/SplashScreen.swift @@ -9,6 +9,7 @@ import Capacitor var config: SplashScreenConfig = SplashScreenConfig() var hideTask: Any? var isVisible: Bool = false + var isLaunchSplash: Bool = false init(parentView: UIView, config: SplashScreenConfig) { self.parentView = parentView @@ -16,6 +17,7 @@ import Capacitor } public func showOnLaunch() { + isLaunchSplash = true buildViews() if self.config.launchShowDuration == 0 { return @@ -23,6 +25,7 @@ import Capacitor var settings = SplashScreenSettings() settings.showDuration = config.launchShowDuration settings.fadeInDuration = config.launchFadeInDuration + settings.fadeOutDuration = config.launchFadeOutDuration settings.autoHide = config.launchAutoHide showSplash(settings: settings, completion: {}, isLaunchSplash: true) } @@ -32,7 +35,9 @@ import Capacitor } public func hide(settings: SplashScreenSettings) { - hideSplash(fadeOutDuration: settings.fadeOutDuration, isLaunchSplash: false) + let fadeOutDuration = self.isLaunchSplash ? config.launchFadeOutDuration : settings.fadeOutDuration + self.isLaunchSplash = false + hideSplash(fadeOutDuration: fadeOutDuration, isLaunchSplash: false) } private func showSplash(settings: SplashScreenSettings, completion: @escaping () -> Void, isLaunchSplash: Bool) { diff --git a/splash-screen/ios/Sources/SplashScreenPlugin/SplashScreenConfig.swift b/splash-screen/ios/Sources/SplashScreenPlugin/SplashScreenConfig.swift index 6a5d5f578..1c8b5a1ff 100644 --- a/splash-screen/ios/Sources/SplashScreenPlugin/SplashScreenConfig.swift +++ b/splash-screen/ios/Sources/SplashScreenPlugin/SplashScreenConfig.swift @@ -8,4 +8,5 @@ public struct SplashScreenConfig { var launchShowDuration = 500 var launchAutoHide = true let launchFadeInDuration = 0 + var launchFadeOutDuration = 0 } diff --git a/splash-screen/ios/Sources/SplashScreenPlugin/SplashScreenPlugin.swift b/splash-screen/ios/Sources/SplashScreenPlugin/SplashScreenPlugin.swift index 535ff4b79..96caf5351 100644 --- a/splash-screen/ios/Sources/SplashScreenPlugin/SplashScreenPlugin.swift +++ b/splash-screen/ios/Sources/SplashScreenPlugin/SplashScreenPlugin.swift @@ -82,6 +82,7 @@ public class SplashScreenPlugin: CAPPlugin, CAPBridgedPlugin { config.launchShowDuration = getConfig().getInt("launchShowDuration", config.launchShowDuration) config.launchAutoHide = getConfig().getBoolean("launchAutoHide", config.launchAutoHide) + config.launchFadeOutDuration = getConfig().getInt("launchFadeOutDuration", config.launchFadeOutDuration) return config } diff --git a/splash-screen/src/definitions.ts b/splash-screen/src/definitions.ts index bb7a738b0..f06dcc9da 100644 --- a/splash-screen/src/definitions.ts +++ b/splash-screen/src/definitions.ts @@ -27,10 +27,10 @@ declare module '@capacitor/cli' { /** * Duration for the fade out animation of the launch splash screen (in ms) * - * Only available for Android, when using the Android 12 Splash Screen API. + * On Android, only available when using the Android 12 Splash Screen API. * * @since 4.2.0 - * @default 200 + * @default 0 * @example 3000 */ launchFadeOutDuration?: number;