feat: impl setup restoration

This commit is contained in:
2026-04-26 00:01:57 +01:00
parent a54cc84660
commit 8b28f3d67f
11 changed files with 397 additions and 130 deletions

View File

@@ -3,14 +3,67 @@ mod screen;
mod storage;
mod welcome_step;
pub(crate) use screen::new;
use gpui::{AppContext, BorrowAppContext, point, px, size};
pub(crate) use screen::{from_saved, new};
use serde::{Deserialize, Serialize};
#[derive(PartialEq, Serialize, Deserialize)]
enum Step {
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 {
Welcome,
ConnectToGithub,
Customization,
}
const ALL_SETUP_STEPS: [Step; 3] = [Step::Welcome, Step::ConnectToGithub, Step::Customization];
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| {
global.current_theme = window.appearance().into();
cx.notify();
});
})
.detach();
screen
})
},
)
.map(|_| ())
}
impl Step {
pub const fn order(&self) -> usize {
match self {
Step::Welcome => 0,
Step::ConnectToGithub => 1,
Step::Customization => 2,
}
}
}