wip: connect to github step

This commit is contained in:
2026-04-22 22:12:39 +01:00
parent 02932411fb
commit 302d0d3222
7 changed files with 118 additions and 28 deletions

View File

@@ -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();
}

View File

@@ -1 +0,0 @@
pub(crate) mod welcome;

1
src/screen/mod.rs Normal file
View File

@@ -0,0 +1 @@
pub(crate) mod setup_wizard;

View 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))
}

View File

@@ -0,0 +1,5 @@
mod github_step;
mod screen;
mod welcome_step;
pub(crate) use screen::new;

View File

@@ -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<api::auth::CreateDeviceCode>,
current_step: Step,
}
impl Screen {
pub fn new(cx: &mut gpui::Context<Self>) -> 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 {
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<Self>,
) -> 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::Render>) -> impl gpui::IntoElement {
.px_8()
.justify_center()
.gap_3()
.text_sm()
.children(vec![
text("Welcome!", cx),
text("Connect to GitHub", cx),

View 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")),
)
}