Skip to main content

slint_ui_templates/shell/
platform.rs

1/// Target platform for AppShell rendering and token routing.
2#[derive(Debug, Clone, PartialEq, Default)]
3/// P la tf or m enum.
4pub enum Platform {
5    #[default]
6    Windows,
7    Android,
8    /// Steam Deck — 1280×800 touchscreen + gamepad primary, small tier.
9    SteamDeck,
10    /// Steam Linux — GamepadUI fullscreen, desktop-class hardware, small tier.
11    SteamLinux,
12    /// macOS — Apple HIG sidebar shell, SF Pro fonts, AppKit control sizing.
13    MacOS,
14}
15
16impl Platform {
17    /// Returns the platform identifier string that matches `Variants.*` in Slint.
18    pub fn as_str(&self) -> &'static str {
19        match self {
20            Platform::Windows    => "windows",
21            Platform::Android    => "android",
22            Platform::SteamDeck  => "steam-deck",
23            Platform::SteamLinux => "steam-linux",
24            Platform::MacOS      => "macos",
25        }
26    }
27
28    /// Returns `true` if the platform is a mobile target (portrait touch-first).
29    pub fn is_mobile(&self) -> bool {
30        matches!(self, Platform::Android)
31    }
32
33    /// Returns `true` if the platform is the small tier (1280×800 touchscreen + gamepad).
34    /// Small tier: gamepad-safe 56px touch targets, bottom/rail nav, max 5 nav items.
35    pub fn is_small(&self) -> bool {
36        matches!(self, Platform::SteamDeck)
37    }
38
39    /// Returns `true` if the platform is a desktop target (mouse+keyboard or gamepad fullscreen).
40    /// Desktop tier includes SteamLinux — fullscreen but with desktop nav limits.
41    pub fn is_desktop(&self) -> bool {
42        !self.is_mobile() && !self.is_small()
43    }
44}