wip: connect to github step
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
use gpui::{bounds, point, prelude::*, px, size};
|
use gpui::{bounds, point, prelude::*, px, size};
|
||||||
|
|
||||||
use crate::screen::welcome;
|
use crate::screen::setup_wizard;
|
||||||
|
|
||||||
mod api;
|
mod api;
|
||||||
mod app;
|
mod app;
|
||||||
@@ -61,7 +61,7 @@ fn setup_application(cx: &mut gpui::App) {
|
|||||||
is_resizable: false,
|
is_resizable: false,
|
||||||
..Default::default()
|
..Default::default()
|
||||||
},
|
},
|
||||||
|window, cx| cx.new(|cx| welcome::Screen::new(cx)),
|
|_window, cx| cx.new(|cx| setup_wizard::new(cx)),
|
||||||
)
|
)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1 +0,0 @@
|
|||||||
pub(crate) mod welcome;
|
|
||||||
1
src/screen/mod.rs
Normal file
1
src/screen/mod.rs
Normal file
@@ -0,0 +1 @@
|
|||||||
|
pub(crate) mod setup_wizard;
|
||||||
39
src/screen/setup_wizard/github_step.rs
Normal file
39
src/screen/setup_wizard/github_step.rs
Normal file
@@ -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<api::auth::CreateDeviceCode>,
|
||||||
|
}
|
||||||
|
|
||||||
|
pub(crate) fn new(cx: &mut gpui::Context<GithubStepView>) -> 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<Self>,
|
||||||
|
) -> impl gpui::IntoElement {
|
||||||
|
div().flex().flex_col().size_full().child(header(cx))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn header(cx: &gpui::Context<GithubStepView>) -> 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))
|
||||||
|
}
|
||||||
5
src/screen/setup_wizard/mod.rs
Normal file
5
src/screen/setup_wizard/mod.rs
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
mod github_step;
|
||||||
|
mod screen;
|
||||||
|
mod welcome_step;
|
||||||
|
|
||||||
|
pub(crate) use screen::new;
|
||||||
@@ -1,33 +1,40 @@
|
|||||||
use gpui::{FontWeight, ParentElement, Styled, div, px};
|
use gpui::{AppContext, FontWeight, IntoElement, ParentElement, Styled, div};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
api, app,
|
api, app,
|
||||||
component::{
|
component::text::text,
|
||||||
font_icon::{FontIcon, font_icon},
|
query::{self, use_lazy_query},
|
||||||
text::text,
|
screen::setup_wizard::{github_step, welcome_step},
|
||||||
},
|
|
||||||
query::{self, use_lazy_query, use_query},
|
|
||||||
};
|
};
|
||||||
|
|
||||||
pub(crate) struct Screen {
|
pub(crate) struct Screen {
|
||||||
create_device_code_query: query::Entity<api::auth::CreateDeviceCode>,
|
current_step: Step,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Screen {
|
enum Step {
|
||||||
pub fn new(cx: &mut gpui::Context<Self>) -> Self {
|
Welcome,
|
||||||
Self {
|
ConnectToGithub,
|
||||||
create_device_code_query: use_lazy_query(api::auth::CreateDeviceCode, cx),
|
}
|
||||||
}
|
|
||||||
|
pub(crate) fn new(cx: &mut gpui::Context<Screen>) -> Screen {
|
||||||
|
Screen {
|
||||||
|
current_step: Step::Welcome,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl gpui::Render for Screen {
|
impl gpui::Render for Screen {
|
||||||
fn render(
|
fn render(
|
||||||
&mut self,
|
&mut self,
|
||||||
window: &mut gpui::Window,
|
_window: &mut gpui::Window,
|
||||||
cx: &mut gpui::Context<Self>,
|
cx: &mut gpui::Context<Self>,
|
||||||
) -> impl gpui::IntoElement {
|
) -> 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);
|
let theme = app::current_theme(cx);
|
||||||
|
|
||||||
div()
|
div()
|
||||||
.flex()
|
.flex()
|
||||||
.flex_row()
|
.flex_row()
|
||||||
@@ -55,21 +62,12 @@ impl gpui::Render for Screen {
|
|||||||
.child(
|
.child(
|
||||||
div()
|
div()
|
||||||
.flex()
|
.flex()
|
||||||
.flex_col()
|
.items_center()
|
||||||
|
.justify_center()
|
||||||
.w_2_3()
|
.w_2_3()
|
||||||
.px_8()
|
|
||||||
.h_full()
|
.h_full()
|
||||||
.bg(theme.colors.background)
|
.bg(theme.colors.background)
|
||||||
.items_start()
|
.child(step_view),
|
||||||
.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.)))
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -83,6 +81,7 @@ fn step_list(cx: &gpui::Context<impl gpui::Render>) -> impl gpui::IntoElement {
|
|||||||
.px_8()
|
.px_8()
|
||||||
.justify_center()
|
.justify_center()
|
||||||
.gap_3()
|
.gap_3()
|
||||||
|
.text_sm()
|
||||||
.children(vec![
|
.children(vec![
|
||||||
text("Welcome!", cx),
|
text("Welcome!", cx),
|
||||||
text("Connect to GitHub", cx),
|
text("Connect to GitHub", cx),
|
||||||
47
src/screen/setup_wizard/welcome_step.rs
Normal file
47
src/screen/setup_wizard/welcome_step.rs
Normal file
@@ -0,0 +1,47 @@
|
|||||||
|
use gpui::{FontWeight, ParentElement, Styled, div};
|
||||||
|
|
||||||
|
use crate::{
|
||||||
|
app,
|
||||||
|
component::{button::button, text::text},
|
||||||
|
};
|
||||||
|
|
||||||
|
struct WelcomeStep {
|
||||||
|
on_next: Option<FnOnce>,
|
||||||
|
}
|
||||||
|
|
||||||
|
pub(crate) fn new<E>(cx: &gpui::Context<E>) -> 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")),
|
||||||
|
)
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user