1use std::rc::Rc;
2
3pub use mundy::{
4 AccentColor,
5 Srgba,
6};
7use torin::prelude::Size2D;
8
9use crate::{
10 accessibility::id::AccessibilityId,
11 prelude::{
12 State,
13 consume_root_context,
14 },
15 user_event::UserEvent,
16};
17
18#[derive(Clone, Copy, PartialEq, Eq, Default, Debug, Hash)]
19pub enum NavigationMode {
20 #[default]
21 NotKeyboard,
22 Keyboard,
23}
24
25#[derive(Clone, Copy, Debug, PartialEq, Eq, Default)]
26pub enum PreferredTheme {
27 #[default]
28 Light,
29 Dark,
30}
31
32#[derive(Clone)]
37pub struct Platform {
38 pub focused_accessibility_id: State<AccessibilityId>,
40 pub focused_accessibility_node: State<accesskit::Node>,
42 pub root_size: State<Size2D>,
44 pub scale_factor: State<f64>,
46 pub navigation_mode: State<NavigationMode>,
48 pub preferred_theme: State<PreferredTheme>,
50 pub is_app_focused: State<bool>,
52 pub accent_color: State<AccentColor>,
54 pub sender: Rc<dyn Fn(UserEvent)>,
56}
57
58impl Platform {
59 pub fn get() -> Self {
61 consume_root_context()
62 }
63
64 pub fn send(&self, event: UserEvent) {
66 (self.sender)(event)
67 }
68}