diff --git a/src/screen/setup_wizard/mod.rs b/src/screen/setup_wizard/mod.rs index ad77b95..743bf27 100644 --- a/src/screen/setup_wizard/mod.rs +++ b/src/screen/setup_wizard/mod.rs @@ -1,5 +1,6 @@ mod github_step; mod screen; +mod setup_complete_step; mod storage; mod welcome_step; @@ -14,10 +15,10 @@ use crate::{app, screen::setup_wizard::screen::Screen}; pub(crate) enum Step { Welcome, ConnectToGithub, - Customization, + SetupComplete, } -const ALL_SETUP_STEPS: [Step; 3] = [Step::Welcome, Step::ConnectToGithub, Step::Customization]; +const ALL_SETUP_STEPS: [Step; 3] = [Step::Welcome, Step::ConnectToGithub, Step::SetupComplete]; pub fn read_setup_status() -> SetupStatus { storage::read_setup_state() @@ -65,7 +66,7 @@ impl Step { match self { Step::Welcome => 0, Step::ConnectToGithub => 1, - Step::Customization => 2, + Step::SetupComplete => 2, } } } diff --git a/src/screen/setup_wizard/screen.rs b/src/screen/setup_wizard/screen.rs index fab0079..af994e1 100644 --- a/src/screen/setup_wizard/screen.rs +++ b/src/screen/setup_wizard/screen.rs @@ -7,8 +7,9 @@ use crate::{ text::text, }, screen::setup_wizard::{ - ALL_SETUP_STEPS, Step, github_step, - storage::{StoredSetupState, store_setup_state}, + ALL_SETUP_STEPS, SetupStatus, Step, github_step, + setup_complete_step::setup_complete_step, + storage::{StoredSetupState, store_setup_status}, welcome_step::welcome_step, }, storage, @@ -38,29 +39,24 @@ impl Screen { fn advance_to_next_step(&mut self, cx: &mut gpui::Context) { let next_step = match self.current_step { Step::Welcome => Step::ConnectToGithub, - Step::ConnectToGithub => Step::Customization, + Step::ConnectToGithub => Step::SetupComplete, _ => panic!(), }; self.current_step = next_step; cx.notify(); } - fn save_setup_state(&mut self, state: StoredSetupState, cx: &mut gpui::Context) { - _ = cx.background_executor().block(store_setup_state(state)); + fn save_setup_state(&mut self, state: SetupStatus, cx: &mut gpui::Context) { + _ = cx.background_executor().block(store_setup_status(state)); } fn on_github_connected(&mut self, user_id: api::user::Id, cx: &mut gpui::Context) { - let state = StoredSetupState { - step: Step::Customization, - connected_user_id: Some(user_id), - }; - self.save_setup_state(state, cx); - // TODO: handle state write error _ = storage::update_persisted_state(|state| { state.selected_account = user_id; }); + self.save_setup_state(SetupStatus::Completed, cx); self.advance_to_next_step(cx); cx.notify(); @@ -96,7 +92,7 @@ impl Screen { let label = match step { Step::Welcome => "Welcome!", Step::ConnectToGithub => "Connect to GitHub", - Step::Customization => "Customize Novem", + Step::SetupComplete => "Complete!", }; let is_completed = i < self.current_step.order(); let is_current = self.current_step == *step; @@ -148,7 +144,7 @@ impl gpui::Render for Screen { None => self.init_github_step_view(cx).clone().into_any_element(), }, - Step::Customization => text("customization").into_any_element(), + Step::SetupComplete => setup_complete_step().into_any_element(), }; let theme = app::current_theme(cx); diff --git a/src/screen/setup_wizard/setup_complete_step.rs b/src/screen/setup_wizard/setup_complete_step.rs new file mode 100644 index 0000000..0d60c54 --- /dev/null +++ b/src/screen/setup_wizard/setup_complete_step.rs @@ -0,0 +1,33 @@ +use gpui::{ParentElement, Styled, div}; + +use crate::component::{button::button, text::text}; + +pub(crate) fn setup_complete_step() -> impl gpui::IntoElement { + div() + .flex() + .flex_col() + .size_full() + .items_center() + .justify_center() + .child( + div() + .flex_1() + .flex() + .flex_col() + .items_center() + .justify_center() + .child(text("ദ്ദി/ᐠ - ⩊ -マ.ᐟ").text_2xl().styled(|it| it.mb_4())) + .child(text("Setup complete!").bold().text_2xl()) + .child(text("You can now start using Novem.").opacity(0.8)), + ) + .child( + div() + .flex() + .flex_row() + .justify_end() + .w_full() + .p_4() + .pt_0() + .child(button("setup-done").label("Start")), + ) +} diff --git a/src/screen/setup_wizard/storage.rs b/src/screen/setup_wizard/storage.rs index f1577d0..4618225 100644 --- a/src/screen/setup_wizard/storage.rs +++ b/src/screen/setup_wizard/storage.rs @@ -15,9 +15,9 @@ pub(crate) enum SetupStatus { Completed, } -pub(crate) async fn store_setup_state(state: StoredSetupState) -> anyhow::Result<()> { +pub(crate) async fn store_setup_status(state: SetupStatus) -> anyhow::Result<()> { let path = storage::data_dir_path().join("setup.json"); - let content = serde_json::to_string(&SetupStatus::InProgress(state))?; + let content = serde_json::to_string(&state)?; tokio::fs::write(path, content).await?; Ok(()) }