#[cfg(any(feature = "ios", feature = "android"))]
use crate::{prelude::*, extern_functions::*};
use serde::{Deserialize, Serialize};
use typed_builder::TypedBuilder;
pub struct SplashScreen;
impl SplashScreen {
#[cfg(any(feature = "ios", feature = "android"))]
pub async fn show(options: impl Into<ShowOptions>) -> Result<(), Error> {
run_value_unit(options, splash_show).await
}
#[cfg(any(feature = "ios", feature = "android"))]
pub async fn hide(options: impl Into<HideOptions>) -> Result<(), Error> {
run_value_unit(options, splash_hide).await
}
}
#[derive(Debug, Serialize, Deserialize, TypedBuilder)]
#[serde(rename_all = "camelCase", default)]
pub struct HideOptions {
pub fade_out_duration: f64,
}
impl From<f64> for HideOptions {
fn from(fade_out_duration: f64) -> Self {
Self { fade_out_duration }
}
}
impl Default for HideOptions {
fn default() -> Self {
Self {
fade_out_duration: 200.0,
}
}
}
#[derive(Debug, Serialize, Deserialize, TypedBuilder)]
#[serde(rename_all = "camelCase", default)]
pub struct ShowOptions {
pub auto_hide: bool,
pub fade_in_duration: f64,
pub fade_out_duration: f64,
pub show_duration: f64,
}
impl Default for ShowOptions {
fn default() -> Self {
Self {
auto_hide: true,
fade_in_duration: 200.0,
fade_out_duration: 200.0,
show_duration: 3000.0,
}
}
}