aok_manyatta/src/app.rs
2025-01-31 17:30:57 +03:00

101 lines
2.9 KiB
Rust

use makepad_widgets::*;
use std::path::Path;
use crate::data::state::State;
live_design!(
use link::widgets::*;
use link::theme::*;
use link::shaders::*;
use crate::shared::styles::*;
use crate::shared::widgets::*;
use crate::shared::widgets::SidebarMenuButton;
use crate::home::home_screen::HomeScreen;
App = {{App}} {
ui: <Window> {
window: {inner_size: vec2(1280, 800)},
pass: {clear_color: #2A}
body = {
// A wrapper view for showing top-level app modals/dialogs/popups
<View> {
width: Fill, height: Fill,
flow: Overlay,
home_screen_view = <View> {
// visible: true
home_screen = <HomeScreen> {}
}
}
} // end of body
}
}
);
#[derive(Live, LiveHook)]
struct App {
#[live]
ui: WidgetRef,
#[rust]
state: State,
}
impl MatchEvent for App {
fn handle_startup(&mut self, _cx: &mut Cx) {
// self.stack_navigation(id!(view_stack))
// .show_view(id!(main_content_view));
// let home = std::env::var("HOME")
// .or_else(|_| std::env::var("USERPROFILE"))
// .expect("home not found");
// self.state.load_images(&Path::new(&home).join("Downloads"));
self.state.new();
}
fn handle_actions(&mut self, cx: &mut Cx, actions: &Actions) {
// for action in actions {
// // match action.as_widget_action().cast() {
// let widget_uid = self.ui.widget_uid();
// // Navigate to the main content view
// cx.widget_action(
// widget_uid,
// &Scope::default().path,
// StackNavigationAction::NavigateTo(live_id!(main_content_view)),
// );
// // }
// }
}
}
impl AppMain for App {
fn handle_event(&mut self, cx: &mut Cx, event: &Event) {
// self.ui
// .handle_event(cx, event, &mut Scope::with_data(&mut self.state));
// self.match_event(cx, event);
if let Event::WindowGeomChange(window_geom_change_event) = event {
self.state.window_geom = Some(window_geom_change_event.new_geom.clone());
}
// Forward events to the MatchEvent trait implementation.
self.match_event(cx, event);
let scope = &mut Scope::with_data(&mut self.state);
self.ui.handle_event(cx, event, scope);
// self.match_event(cx, event);
}
}
impl LiveRegister for App {
fn live_register(cx: &mut Cx) {
makepad_widgets::live_design(cx);
crate::shared::live_design(cx);
crate::home::live_design(cx);
crate::services::live_design(cx);
crate::howitworks::live_design(cx);
crate::footer::live_design(cx);
}
}
app_main!(App);