Skip to main content

euv_ui/chrome_policy/
struct.rs

1use super::*;
2
3/// Immutable input snapshot describing live viewport dimensions, safe-area insets, and shell visibility flags.
4#[derive(Clone, Copy, Data, Debug, Default, New, PartialEq)]
5pub struct ShellViewportMetrics {
6    /// Logical viewport width in dp.
7    #[get(type(copy))]
8    pub(crate) viewport_width: f32,
9    /// Logical viewport height in dp.
10    #[get(type(copy))]
11    pub(crate) viewport_height: f32,
12    /// Hardware safe-area insets reported by the active OS host.
13    #[get(type(copy))]
14    pub(crate) safe_area: SafeAreaInsets,
15    /// Whether the shell was configured with an adaptive `EuvBottomNav` dock.
16    #[get(type(copy))]
17    pub(crate) has_bottom_nav: bool,
18    /// Whether an immersive fullscreen portal is currently active.
19    #[get(type(copy))]
20    pub(crate) is_fullscreen: bool,
21    /// Whether scroll-driven chrome auto-hide is currently requesting chrome hide.
22    #[get(type(copy))]
23    pub(crate) is_chrome_hidden: bool,
24    /// Whether the active breakpoint is compact (`< 640dp`).
25    #[get(type(copy))]
26    pub(crate) is_compact_bp: bool,
27}
28
29/// Compact reactive presentation contract consumed by `EuvBottomNav` to mirror `EuvAppShell`'s active dock orientation.
30#[derive(Clone, Copy, Data, Debug, Default, Eq, PartialEq)]
31pub struct NavDockPresentation {
32    /// Selected dock placement edge.
33    #[get(type(copy))]
34    pub(crate) placement: NavDockPlacement,
35    /// Axis orientation (`Horizontal` vs `Vertical`).
36    #[get(type(copy))]
37    pub(crate) orientation: NavDockOrientation,
38    /// When `true`, renders crisp icon-only tabs without overflowing text labels (watches or tight vertical rails).
39    #[get(type(copy))]
40    pub(crate) icon_only: bool,
41}
42
43/// Shared floating horizontal bottom-dock box geometry computed for standard mobile and top-safe postures.
44#[derive(Clone, Copy, Data, Debug, Default, PartialEq)]
45pub(crate) struct BottomFloatingDockBox {
46    /// Logical X offset of the floating bottom dock (`Position::Fixed` `left`).
47    #[get(type(copy))]
48    pub(crate) dock_left: f32,
49    /// Logical bottom offset above the viewport bottom edge (`Position::Fixed` `bottom`).
50    #[get(type(copy))]
51    pub(crate) dock_bottom: f32,
52    /// Logical dock width in dp.
53    #[get(type(copy))]
54    pub(crate) dock_width: f32,
55    /// Logical dock height in dp.
56    #[get(type(copy))]
57    pub(crate) dock_height: f32,
58    /// Additional bottom content scroll padding clearing the bottom dock.
59    #[get(type(copy))]
60    pub(crate) content_extra_bottom_pad: f32,
61}
62
63/// Complete, deterministic chrome geometry resolved by `EuvChromeLayoutPolicy` for `EuvAppShell` and `EuvRouterOutlet`.
64#[derive(Clone, Copy, Data, Debug, Default, PartialEq)]
65pub struct ResolvedChromeLayout {
66    /// Detected device posture driving layout decisions.
67    #[get(type(copy))]
68    pub(crate) posture: ChromePosture,
69    /// Selected navigation dock placement.
70    #[get(type(copy))]
71    pub(crate) dock_placement: NavDockPlacement,
72    /// Active navigation dock axis orientation.
73    #[get(type(copy))]
74    pub(crate) dock_orientation: NavDockOrientation,
75    /// Whether the navigation dock uses icon-only compact tabs.
76    #[get(type(copy))]
77    pub(crate) dock_icon_only: bool,
78    /// Whether the navigation dock renders frameless (no outer card border, background fill, or drop shadow) directly inside a safe-area rail.
79    #[get(type(copy))]
80    pub(crate) dock_frameless: bool,
81    /// Whether scroll-driven auto-hide is permitted to hide the navigation dock (`false` inside dedicated hardware safe areas).
82    #[get(type(copy))]
83    pub(crate) dock_allow_auto_hide: bool,
84    /// Whether the page top bar is hosted directly inside a tall top hardware safe-area strip (avoiding top-right cutout/signal icons).
85    #[get(type(copy))]
86    pub(crate) top_bar_in_safe_area: bool,
87    /// Whether scroll-driven auto-hide is permitted to hide the page top bar (`false` when hosted inside the top safe area).
88    #[get(type(copy))]
89    pub(crate) top_bar_allow_auto_hide: bool,
90    /// Whether the floating/rail navigation dock is visible in this frame.
91    #[get(type(copy))]
92    pub(crate) show_dock: bool,
93    /// Logical X offset of the navigation dock (`Position::Fixed` `left`).
94    #[get(type(copy))]
95    pub(crate) dock_left: f32,
96    /// Optional logical Y offset from viewport top (`Position::Fixed` `top`) for side safe-area rails.
97    #[get(type(copy))]
98    pub(crate) dock_top: Option<f32>,
99    /// Optional logical Y offset from viewport bottom (`Position::Fixed` `bottom`) for bottom docks.
100    #[get(type(copy))]
101    pub(crate) dock_bottom: Option<f32>,
102    /// Logical width of the navigation dock in dp.
103    #[get(type(copy))]
104    pub(crate) dock_width: f32,
105    /// Logical height of the navigation dock in dp.
106    #[get(type(copy))]
107    pub(crate) dock_height: f32,
108    /// Horizontal slide-out delta applied when auto-hiding a side rail.
109    #[get(type(copy))]
110    pub(crate) dock_hide_dx: f32,
111    /// Vertical slide-out delta applied when auto-hiding a bottom horizontal dock.
112    #[get(type(copy))]
113    pub(crate) dock_hide_dy: f32,
114    /// Effective top inset applied to the mobile top header bar (compact on watches, full safe strip on top-safe postures).
115    #[get(type(copy))]
116    pub(crate) mobile_header_top_inset: f32,
117    /// Total logical height of the mobile top bar in dp.
118    #[get(type(copy))]
119    pub(crate) mobile_header_height: f32,
120    /// Exact `(top, right, bottom, left)` padding applied inside the mobile top bar, avoiding side and top-right hardware safe areas.
121    #[get(type(copy))]
122    pub(crate) mobile_header_padding: Edges,
123    /// 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.
124    #[get(type(copy))]
125    pub(crate) route_stage_insets: Edges,
126    /// Additional bottom content scroll padding inside pages so scrolling clears bottom docks cleanly.
127    #[get(type(copy))]
128    pub(crate) content_extra_bottom_pad: f32,
129    /// Horizontal left divider inset keeping topbar borders out of left hardware safe areas.
130    #[get(type(copy))]
131    pub(crate) top_divider_left_inset: f32,
132    /// Horizontal right divider inset keeping topbar borders out of right signal safe-area rails.
133    #[get(type(copy))]
134    pub(crate) top_divider_right_inset: f32,
135}
136
137/// Unified safe-area and display corner-radius padding plan consumed by every fullscreen component and portal.
138#[derive(Clone, Copy, Data, Debug, Default, PartialEq)]
139pub struct FullscreenSafeLayout {
140    /// Safe header/toolbar padding keeping close buttons, titles, and action pills cleanly inside large curved corners and cutouts.
141    #[get(type(copy))]
142    pub(crate) header_padding: Edges,
143    /// Safe bottom overlay/action-bar padding clearing home indicators and bottom display corners.
144    #[get(type(copy))]
145    pub(crate) footer_padding: Edges,
146    /// Minimal safe content padding for scrollable fullscreen bodies (tables, code, diagrams) while keeping outer canvases edge-to-edge.
147    #[get(type(copy))]
148    pub(crate) body_padding: Edges,
149    /// Computed display corner-radius clearance floor in logical dp (`0.0` on rectangular desktops).
150    #[get(type(copy))]
151    pub(crate) corner_clearance: f32,
152}
153
154/// Facade entrypoint coordinating all stateless `ChromeLayoutStrategy` implementations.
155#[derive(Clone, Copy, Debug, Default)]
156pub struct EuvChromeLayoutPolicy;
157
158/// Strategy resolving Desktop / PC / wide landscape tablet layouts (`>= 960dp`).
159#[derive(Clone, Copy, Debug, Default)]
160pub(crate) struct DesktopSidebarStrategy;
161
162/// Strategy resolving compact smartwatch layouts (`< 300dp`).
163#[derive(Clone, Copy, Debug, Default)]
164pub(crate) struct WatchCompactStrategy;
165
166/// Strategy docking borderless persistent vertical navigation inside an asymmetric left or right hardware safe-area strip (iPhone Duo folded/unfolded/rotated/split).
167#[derive(Clone, Copy, Debug, Default)]
168pub(crate) struct SideSafeRailStrategy;
169
170/// Strategy hosting the page top bar directly inside a tall top hardware safe-area strip (avoiding the top-right signal zone) while keeping tab navigation docked at the bottom.
171#[derive(Clone, Copy, Debug, Default)]
172pub(crate) struct TopSafeHeaderStrategy;
173
174/// Default mobile/tablet/MiniApp/QuickApp/left-safe landscape strategy preserving the canonical floating bottom dock.
175#[derive(Clone, Copy, Debug, Default)]
176pub(crate) struct BottomFloatingDockStrategy;