initial function management refactoring

This commit is contained in:
Simon Gardling
2022-04-23 15:39:40 -04:00
parent 22d1be59f5
commit 2172f3da61
11 changed files with 173 additions and 122 deletions

View File

@@ -71,3 +71,20 @@ pub const COLORS: &[Color32; 13] = &[
Color32::DARK_GREEN,
Color32::DARK_BLUE,
];
#[cfg(target_arch = "wasm32")]
lazy_static::lazy_static! {
pub static IS_MOBILE: bool = {
fn is_mobile() -> Option<bool> {
const MOBILE_DEVICE: [&str; 6] = ["Android", "iPhone", "iPad", "iPod", "webOS", "BlackBerry"];
let user_agent = web_sys::window()?.navigator().user_agent().ok()?;
Some(MOBILE_DEVICE.iter().any(|&name| user_agent.contains(name)))
}
is_mobile().unwrap_or_default()
}
}
#[cfg(not(target_arch = "wasm32"))]
pub const IS_MOBILE: bool = false;