Files
novem/src/screen/setup_wizard/mod.rs

73 lines
2.1 KiB
Rust
Raw Normal View History

2026-04-22 22:12:39 +01:00
mod github_step;
mod screen;
2026-04-26 00:58:38 +01:00
mod setup_complete_step;
2026-04-25 00:49:50 +01:00
mod storage;
2026-04-22 22:12:39 +01:00
mod welcome_step;
2026-04-26 00:01:57 +01:00
use gpui::{AppContext, BorrowAppContext, point, px, size};
pub(crate) use screen::{from_saved, new};
2026-04-25 00:49:50 +01:00
use serde::{Deserialize, Serialize};
2026-04-26 00:01:57 +01:00
pub(crate) use crate::screen::setup_wizard::storage::{SetupStatus, StoredSetupState};
use crate::{app, screen::setup_wizard::screen::Screen};
#[derive(Debug, PartialEq, Serialize, Deserialize)]
pub(crate) enum Step {
2026-04-25 00:49:50 +01:00
Welcome,
ConnectToGithub,
2026-04-26 00:58:38 +01:00
SetupComplete,
2026-04-25 00:49:50 +01:00
}
2026-04-26 00:58:38 +01:00
const ALL_SETUP_STEPS: [Step; 3] = [Step::Welcome, Step::ConnectToGithub, Step::SetupComplete];
2026-04-26 00:01:57 +01:00
pub fn read_setup_status() -> SetupStatus {
storage::read_setup_state()
}
pub fn open_window(screen: Screen, cx: &mut gpui::App) -> anyhow::Result<()> {
let (top_left, window_bounds) = cx.read_global::<app::Global, _>(|global, cx| {
(
global.safe_area.origin,
gpui::Bounds::centered(None, size(px(800.), px(600.0)), cx),
)
});
cx.open_window(
gpui::WindowOptions {
window_bounds: Some(gpui::WindowBounds::Windowed(window_bounds)),
titlebar: Some(gpui::TitlebarOptions {
appears_transparent: true,
traffic_light_position: Some(top_left + point(px(12.), px(12.))),
..Default::default()
}),
is_resizable: false,
..Default::default()
},
|window, cx| {
cx.new(|cx| {
cx.observe_window_appearance(window, |_, window, cx| {
cx.update_global::<app::Global, ()>(|global, cx| {
2026-04-26 00:46:11 +01:00
global.current_theme = global
.theme_family
.theme_for_appearance(window.appearance());
2026-04-26 00:01:57 +01:00
cx.notify();
});
})
.detach();
screen
})
},
)
.map(|_| ())
}
impl Step {
pub const fn order(&self) -> usize {
match self {
Step::Welcome => 0,
Step::ConnectToGithub => 1,
2026-04-26 00:58:38 +01:00
Step::SetupComplete => 2,
2026-04-26 00:01:57 +01:00
}
}
}