diff --git a/src/main.rs b/src/main.rs index b10dae4..9cb0c23 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,6 +1,6 @@ use gpui::{bounds, point, prelude::*, px, size}; -use crate::screen::welcome; +use crate::screen::setup_wizard; mod api; mod app; @@ -61,7 +61,7 @@ fn setup_application(cx: &mut gpui::App) { is_resizable: false, ..Default::default() }, - |window, cx| cx.new(|cx| welcome::Screen::new(cx)), + |_window, cx| cx.new(|cx| setup_wizard::new(cx)), ) .unwrap(); } diff --git a/src/screen.rs b/src/screen.rs deleted file mode 100644 index 58219c9..0000000 --- a/src/screen.rs +++ /dev/null @@ -1 +0,0 @@ -pub(crate) mod welcome; diff --git a/src/screen/mod.rs b/src/screen/mod.rs new file mode 100644 index 0000000..1411cc0 --- /dev/null +++ b/src/screen/mod.rs @@ -0,0 +1 @@ +pub(crate) mod setup_wizard; diff --git a/src/screen/setup_wizard/github_step.rs b/src/screen/setup_wizard/github_step.rs new file mode 100644 index 0000000..e952c01 --- /dev/null +++ b/src/screen/setup_wizard/github_step.rs @@ -0,0 +1,39 @@ +use gpui::{FontWeight, ParentElement, Styled, div}; + +use crate::{ + api, + component::text::text, + query::{self, use_lazy_query}, +}; + +pub(crate) struct GithubStepView { + create_device_code_query: query::Entity, +} + +pub(crate) fn new(cx: &mut gpui::Context) -> GithubStepView { + GithubStepView { + create_device_code_query: use_lazy_query(api::auth::CreateDeviceCode, cx), + } +} + +impl gpui::Render for GithubStepView { + fn render( + &mut self, + _window: &mut gpui::Window, + cx: &mut gpui::Context, + ) -> impl gpui::IntoElement { + div().flex().flex_col().size_full().child(header(cx)) + } +} + +fn header(cx: &gpui::Context) -> impl gpui::IntoElement { + div() + .flex() + .flex_col() + .items_center() + .child(text("Connect to GitHub", cx).font_weight(FontWeight(700.))) + .child(text( + "You will be redirected to GitHub to authorize access. Copy the device code below into GitHub.", + cx + ).opacity(0.8)) +} diff --git a/src/screen/setup_wizard/mod.rs b/src/screen/setup_wizard/mod.rs new file mode 100644 index 0000000..3ea0382 --- /dev/null +++ b/src/screen/setup_wizard/mod.rs @@ -0,0 +1,5 @@ +mod github_step; +mod screen; +mod welcome_step; + +pub(crate) use screen::new; diff --git a/src/screen/welcome.rs b/src/screen/setup_wizard/screen.rs similarity index 63% rename from src/screen/welcome.rs rename to src/screen/setup_wizard/screen.rs index 3aedbc9..2f53b44 100644 --- a/src/screen/welcome.rs +++ b/src/screen/setup_wizard/screen.rs @@ -1,33 +1,40 @@ -use gpui::{FontWeight, ParentElement, Styled, div, px}; +use gpui::{AppContext, FontWeight, IntoElement, ParentElement, Styled, div}; use crate::{ api, app, - component::{ - font_icon::{FontIcon, font_icon}, - text::text, - }, - query::{self, use_lazy_query, use_query}, + component::text::text, + query::{self, use_lazy_query}, + screen::setup_wizard::{github_step, welcome_step}, }; pub(crate) struct Screen { - create_device_code_query: query::Entity, + current_step: Step, } -impl Screen { - pub fn new(cx: &mut gpui::Context) -> Self { - Self { - create_device_code_query: use_lazy_query(api::auth::CreateDeviceCode, cx), - } +enum Step { + Welcome, + ConnectToGithub, +} + +pub(crate) fn new(cx: &mut gpui::Context) -> Screen { + Screen { + current_step: Step::Welcome, } } impl gpui::Render for Screen { fn render( &mut self, - window: &mut gpui::Window, + _window: &mut gpui::Window, cx: &mut gpui::Context, ) -> impl gpui::IntoElement { + let step_view = match self.current_step { + Step::Welcome => welcome_step::new(cx).into_any_element(), + Step::ConnectToGithub => cx.new(|cx| github_step::new(cx)).into_any_element(), + }; + let theme = app::current_theme(cx); + div() .flex() .flex_row() @@ -55,21 +62,12 @@ impl gpui::Render for Screen { .child( div() .flex() - .flex_col() + .items_center() + .justify_center() .w_2_3() - .px_8() .h_full() .bg(theme.colors.background) - .items_start() - .justify_center() - .child( - text( - "Welcome to Novem!\nThis wizard will guide you through setting up Novem.\n", - cx, - ) - .opacity(0.8), - ) - .child(text("Press 'Next' to begin setup.", cx).font_weight(FontWeight(500.))) + .child(step_view), ) } } @@ -83,6 +81,7 @@ fn step_list(cx: &gpui::Context) -> impl gpui::IntoElement { .px_8() .justify_center() .gap_3() + .text_sm() .children(vec![ text("Welcome!", cx), text("Connect to GitHub", cx), diff --git a/src/screen/setup_wizard/welcome_step.rs b/src/screen/setup_wizard/welcome_step.rs new file mode 100644 index 0000000..9d1313a --- /dev/null +++ b/src/screen/setup_wizard/welcome_step.rs @@ -0,0 +1,47 @@ +use gpui::{FontWeight, ParentElement, Styled, div}; + +use crate::{ + app, + component::{button::button, text::text}, +}; + +struct WelcomeStep { + on_next: Option, +} + +pub(crate) fn new(cx: &gpui::Context) -> impl gpui::IntoElement { + let theme = app::current_theme(cx); + div() + .flex() + .flex_col() + .size_full() + .items_start() + .justify_center() + .child( + div() + .flex() + .flex_col() + .flex_1() + .justify_center() + .w_full() + .p_8() + .child( + text( + "Welcome to Novem!\nThis wizard will guide you through setting up Novem.\n", + cx, + ) + .opacity(0.8), + ) + .child(text("Press 'Next' to begin setup.", cx).font_weight(FontWeight(500.))), + ) + .child( + div() + .flex() + .flex_row() + .justify_end() + .w_full() + .p_4() + .pt_0() + .child(button("next", cx).label("Next")), + ) +}