rework basically everything

This commit is contained in:
jfmonty2 committed 2026-11-12 11:28:18 -05:00
1 parent 2bd81a66a4
commit a1e5daba59
12 files changed
+450 -157

No files matched your search

+45 -26
View File
@@ -1,48 +1,67 @@
use gpui_kit::{
AppContext, Context, Entity, IntoElement, ParentElement, Render, Styled, Window, WindowOptions,
AppContext, Context, IntoElement, ParentElement, Render, Styled, Window, WindowOptions, div,
};
use gpui_omarchy::{ActiveTheme, ButtonVariant, button, focus_scope, panel};
use gpui_omarchy::ActiveTheme;
mod components;
mod config;
mod db;
mod error;
mod screens;
mod session;
use config::AppConfig;
use session::AppSession;
use screens::WelcomeScreen;
use screens::{HomeScreen, WelcomeScreen};
enum AppScreen {
Welcome(Entity<WelcomeScreen>),
}
struct CreddyApp {
session: Entity<AppSession>,
screen: AppScreen,
}
struct CreddyApp {}
impl Render for CreddyApp {
fn render(&mut self, _: &mut Window, _: &mut Context<Self>) -> impl IntoElement {
match &self.screen {
AppScreen::Welcome(s) => s.clone().into_any_element(),
}
fn render(&mut self, window: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
let session = cx.global::<AppSession>();
let screen = match session {
AppSession::Empty => window
.use_keyed_state("welcome", cx, |window, cx| {
WelcomeScreen::new(window, cx)
})
.into_any_element(),
// todo: unlock screen
AppSession::Locked => div().child("Creddy is locked").into_any_element(),
AppSession::Unlocked { .. } => window
.use_keyed_state("home", cx, |_, _| HomeScreen {})
.into_any_element(),
};
let theme = cx.omarchy();
div()
.size_full()
.bg(theme.background)
.text_color(theme.foreground)
.font_family(theme.font.clone())
.child(screen)
}
}
fn main() {
// todo: replace this with proper error handling
let app_config = AppConfig::load().expect("failed to load config");
let app_session = AppSession::load(&app_config);
dbg!(&app_session);
// Icons are read through the asset source, so register the bundle.
gpui_kit::application()
.with_assets(gpui_kit::assets::Assets)
.run(|cx| {
gpui_omarchy::init(cx);
let session = cx.new(|_| AppSession::Empty);
cx.open_window(WindowOptions::default(), |window, cx| {
let screen = AppScreen::Welcome(
cx.new(|cx| WelcomeScreen::new(session.clone(), window, cx)),
);
cx.new(|_| CreddyApp { session, screen })
})
.expect("open window");
cx.activate(true);
.run(|app| {
gpui_omarchy::init(app);
app.set_global(app_config);
app.set_global(app_session);
// refresh_windows() forces everything to re-render, which is kind of a nuclear solution,
// but these values aren't expected to change very frequently, so it shouldn't be a problem
app.observe_global::<AppConfig>(|app| app.refresh_windows()).detach();
app.observe_global::<AppSession>(|app| app.refresh_windows()).detach();
app.open_window(WindowOptions::default(), |_, cx| cx.new(|_| CreddyApp {}))
.expect("open window");
app.activate(true);
});
}