euv-ui 0.48.8

Cross-platform UI component library and 17-scheme design system for the euv framework with pixel-consistent rendering across Web, Android, iOS, iPadOS, macOS, Windows, and Linux.
Documentation
use super::*;

/// Immutable input snapshot describing live viewport dimensions, safe-area insets, and shell visibility flags.
#[derive(Clone, Copy, Data, Debug, Default, New, PartialEq)]
pub struct ShellViewportMetrics {
    /// Logical viewport width in dp.
    #[get(type(copy))]
    pub(crate) viewport_width: f32,
    /// Logical viewport height in dp.
    #[get(type(copy))]
    pub(crate) viewport_height: f32,
    /// Hardware safe-area insets reported by the active OS host.
    #[get(type(copy))]
    pub(crate) safe_area: SafeAreaInsets,
    /// Whether the shell was configured with an adaptive `EuvBottomNav` dock.
    #[get(type(copy))]
    pub(crate) has_bottom_nav: bool,
    /// Whether an immersive fullscreen portal is currently active.
    #[get(type(copy))]
    pub(crate) is_fullscreen: bool,
    /// Whether scroll-driven chrome auto-hide is currently hiding top/bottom chrome.
    #[get(type(copy))]
    pub(crate) is_chrome_hidden: bool,
    /// Whether the active breakpoint is compact (`< 640dp`).
    #[get(type(copy))]
    pub(crate) is_compact_bp: bool,
}

/// Compact reactive presentation contract consumed by `EuvBottomNav` to mirror `EuvAppShell`'s active dock orientation.
#[derive(Clone, Copy, Data, Debug, Default, Eq, PartialEq)]
pub struct NavDockPresentation {
    /// Selected dock placement edge.
    #[get(type(copy))]
    pub(crate) placement: NavDockPlacement,
    /// Axis orientation (`Horizontal` vs `Vertical`).
    #[get(type(copy))]
    pub(crate) orientation: NavDockOrientation,
    /// When `true`, renders crisp icon-only tabs without overflowing text labels (watches or tight vertical rails).
    #[get(type(copy))]
    pub(crate) icon_only: bool,
}

/// Complete, deterministic chrome geometry resolved by `EuvChromeLayoutPolicy` for `EuvAppShell` and `EuvRouterOutlet`.
#[derive(Clone, Copy, Data, Debug, Default, PartialEq)]
pub struct ResolvedChromeLayout {
    /// Detected device posture driving layout decisions.
    #[get(type(copy))]
    pub(crate) posture: ChromePosture,
    /// Selected navigation dock placement.
    #[get(type(copy))]
    pub(crate) dock_placement: NavDockPlacement,
    /// Active navigation dock axis orientation.
    #[get(type(copy))]
    pub(crate) dock_orientation: NavDockOrientation,
    /// Whether the navigation dock uses icon-only compact tabs.
    #[get(type(copy))]
    pub(crate) dock_icon_only: bool,
    /// Whether the floating/rail navigation dock is visible in this frame.
    #[get(type(copy))]
    pub(crate) show_dock: bool,
    /// Logical X offset of the navigation dock (`Position::Fixed` `left`).
    #[get(type(copy))]
    pub(crate) dock_left: f32,
    /// Optional logical Y offset from viewport top (`Position::Fixed` `top`) for side/top safe-area docks.
    #[get(type(copy))]
    pub(crate) dock_top: Option<f32>,
    /// Optional logical Y offset from viewport bottom (`Position::Fixed` `bottom`) for bottom docks.
    #[get(type(copy))]
    pub(crate) dock_bottom: Option<f32>,
    /// Logical width of the navigation dock in dp.
    #[get(type(copy))]
    pub(crate) dock_width: f32,
    /// Logical height of the navigation dock in dp.
    #[get(type(copy))]
    pub(crate) dock_height: f32,
    /// Horizontal slide-out delta applied when auto-hiding a side vertical rail.
    #[get(type(copy))]
    pub(crate) dock_hide_dx: f32,
    /// Vertical slide-out delta applied when auto-hiding a top/bottom horizontal dock.
    #[get(type(copy))]
    pub(crate) dock_hide_dy: f32,
    /// Effective top inset applied to the mobile top header bar (compact on watches, zero when top safe strip hosts navigation).
    #[get(type(copy))]
    pub(crate) mobile_header_top_inset: f32,
    /// Safe-area exclusion insets applied around `EuvAppShell`'s content stage so route transitions clip strictly inside non-safe areas and NEVER cross cutouts, signal rails, or docked navigation.
    #[get(type(copy))]
    pub(crate) route_stage_insets: Edges,
    /// Additional bottom content scroll padding inside pages so scrolling clears bottom docks cleanly.
    #[get(type(copy))]
    pub(crate) content_extra_bottom_pad: f32,
    /// Horizontal divider inset `(left, right)` keeping topbar borders out of side signal safe-area rails.
    #[get(type(copy))]
    pub(crate) top_divider_left_inset: f32,
    /// Horizontal right divider inset keeping topbar borders out of right signal safe-area rails.
    #[get(type(copy))]
    pub(crate) top_divider_right_inset: f32,
}

/// Unified safe-area and display corner-radius padding plan consumed by every fullscreen component and portal.
#[derive(Clone, Copy, Data, Debug, Default, PartialEq)]
pub struct FullscreenSafeLayout {
    /// Safe header/toolbar padding keeping close buttons, titles, and action pills cleanly inside large curved corners and cutouts.
    #[get(type(copy))]
    pub(crate) header_padding: Edges,
    /// Safe bottom overlay/action-bar padding clearing home indicators and bottom display corners.
    #[get(type(copy))]
    pub(crate) footer_padding: Edges,
    /// Minimal safe content padding for scrollable fullscreen bodies (tables, code, diagrams) while keeping outer canvases edge-to-edge.
    #[get(type(copy))]
    pub(crate) body_padding: Edges,
    /// Computed display corner-radius clearance floor in logical dp (`0.0` on rectangular desktops).
    #[get(type(copy))]
    pub(crate) corner_clearance: f32,
}

/// Facade entrypoint coordinating all stateless `ChromeLayoutStrategy` implementations.
#[derive(Clone, Copy, Debug, Default)]
pub struct EuvChromeLayoutPolicy;

/// Strategy resolving Desktop / PC / wide landscape tablet layouts (`>= 960dp`).
#[derive(Clone, Copy, Debug, Default)]
pub(crate) struct DesktopSidebarStrategy;

/// Strategy resolving compact smartwatch layouts (`< 300dp`).
#[derive(Clone, Copy, Debug, Default)]
pub(crate) struct WatchCompactStrategy;

/// Strategy docking navigation vertically inside right or left hardware safe-area signal strips (iPhone Duo folded/unfolded/split, landscape cutouts).
#[derive(Clone, Copy, Debug, Default)]
pub(crate) struct VerticalSafeRailStrategy;

/// Strategy docking navigation horizontally inside wide rotated top or bottom hardware safe-area strips clear of signal icons.
#[derive(Clone, Copy, Debug, Default)]
pub(crate) struct EdgeSafeStripStrategy;

/// Default mobile/tablet/MiniApp/QuickApp strategy preserving the canonical floating bottom dock.
#[derive(Clone, Copy, Debug, Default)]
pub(crate) struct BottomFloatingDockStrategy;