mod pages;
mod routes;
use gpui::prelude::*;
use gpui::{App, Application, Context, Entity, Window, WindowOptions, div};
use rooter::{NavLink, Router};
struct AppView {
router: Entity<Router>,
}
impl AppView {
fn new(window: &mut Window, cx: &mut Context<Self>) -> Self {
Self {
router: Router::attach(window, cx, routes::routes()),
}
}
}
impl Render for AppView {
fn render(&mut self, _window: &mut Window, _cx: &mut Context<Self>) -> impl IntoElement {
div()
.size_full()
.flex()
.flex_col()
.gap_4()
.p_4()
.bg(gpui::white())
.text_color(gpui::black())
.child(
div()
.flex()
.gap_4()
.child(
NavLink::to("/")
.when_active(None, |link| link.underline())
.child("Home"),
)
.child(
NavLink::to("/about")
.when_active(None, |link| link.underline())
.child("About"),
),
)
.child(self.router.clone())
}
}
fn main() {
Application::new().run(|cx: &mut App| {
cx.activate(true);
cx.open_window(WindowOptions::default(), |window, cx| {
cx.new(|cx| AppView::new(window, cx))
})
.unwrap();
});
}