use crate::event::Event;
use crate::theme::Theme;
#[derive(Debug)]
pub struct AppState {
pub running: bool,
pub show_about: bool,
pub theme: Theme,
pub theme_picker_open: bool,
pub builtin_items: Vec<(super::BuiltinId, String, String)>,
pub home_selected: Option<usize>,
}
impl AppState {
pub fn new(theme: Theme) -> Self {
let builtin_items = super::all_builtins()
.into_iter()
.map(|(id, cat, label)| (id, cat.to_string(), label.to_string()))
.collect();
AppState {
running: true,
show_about: false,
theme,
theme_picker_open: false,
builtin_items,
home_selected: None,
}
}
pub fn process_events(&mut self, events: &[Event]) {
for event in events {
if let Event::ThemeChanged(theme) = event {
self.theme = theme.clone();
}
}
}
}