Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion splash-screen/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ These config values are available:
| ------------------------------- | ----------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------- | ----- |
| **`launchShowDuration`** | <code>number</code> | How long to show the launch splash screen when autoHide is enabled (in ms) | <code>500</code> | 1.0.0 |
| **`launchAutoHide`** | <code>boolean</code> | Whether to auto hide the splash after launchShowDuration. | <code>true</code> | 1.0.0 |
| **`launchFadeOutDuration`** | <code>number</code> | 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. | <code>200</code> | 4.2.0 |
| **`launchFadeOutDuration`** | <code>number</code> | 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. | <code>0</code> | 4.2.0 |
| **`backgroundColor`** | <code>string</code> | 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`** | <code>string</code> | 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. | <code>splash</code> | 1.0.0 |
| **`androidScaleType`** | <code>'CENTER' \| 'CENTER_CROP' \| 'CENTER_INSIDE' \| 'FIT_CENTER' \| 'FIT_END' \| 'FIT_START' \| 'FIT_XY' \| 'MATRIX'</code> | 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. | <code>FIT_XY</code> | 1.0.0 |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,23 @@ 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
self.config = config
}

public func showOnLaunch() {
isLaunchSplash = true
buildViews()
if self.config.launchShowDuration == 0 {
return
}
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)
}
Expand All @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@ public struct SplashScreenConfig {
var launchShowDuration = 500
var launchAutoHide = true
let launchFadeInDuration = 0
var launchFadeOutDuration = 0
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
4 changes: 2 additions & 2 deletions splash-screen/src/definitions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Loading