WIP - Start on Copilot Modal

This commit is contained in:
Nate Butler 2024-01-05 00:51:03 -05:00
parent bca900a5d3
commit f7a036e952

View file

@ -1,11 +1,10 @@
use crate::{request::PromptUserDeviceFlow, Copilot, Status}; use crate::{request::PromptUserDeviceFlow, Copilot, Status};
use gpui::{ use gpui::{
div, size, AppContext, Bounds, ClipboardItem, Element, GlobalPixels, InteractiveElement, div, size, svg, AppContext, Bounds, ClipboardItem, Element, GlobalPixels, InteractiveElement,
IntoElement, ParentElement, Point, Render, Styled, ViewContext, VisualContext, WindowBounds, IntoElement, ParentElement, Point, Render, Styled, ViewContext, VisualContext, WindowBounds,
WindowHandle, WindowKind, WindowOptions, WindowHandle, WindowKind, WindowOptions,
}; };
use theme::ActiveTheme; use ui::{prelude::*, Button, Icon, Label};
use ui::{prelude::*, Button, Icon, IconElement, Label};
const COPILOT_SIGN_UP_URL: &'static str = "https://github.com/features/copilot"; const COPILOT_SIGN_UP_URL: &'static str = "https://github.com/features/copilot";
@ -59,7 +58,7 @@ fn create_copilot_auth_window(
cx: &mut AppContext, cx: &mut AppContext,
status: &Status, status: &Status,
) -> WindowHandle<CopilotCodeVerification> { ) -> WindowHandle<CopilotCodeVerification> {
let window_size = size(GlobalPixels::from(280.), GlobalPixels::from(280.)); let window_size = size(GlobalPixels::from(400.), GlobalPixels::from(480.));
let window_options = WindowOptions { let window_options = WindowOptions {
bounds: WindowBounds::Fixed(Bounds::new(Point::default(), window_size)), bounds: WindowBounds::Fixed(Bounds::new(Point::default(), window_size)),
titlebar: None, titlebar: None,
@ -129,8 +128,8 @@ impl CopilotCodeVerification {
}; };
v_stack() v_stack()
.flex_1() .flex_1()
.gap_2()
.items_center() .items_center()
.justify_between()
.w_full() .w_full()
.child(Label::new( .child(Label::new(
"Enable Copilot by connecting your existing license", "Enable Copilot by connecting your existing license",
@ -141,13 +140,16 @@ impl CopilotCodeVerification {
.size(ui::LabelSize::Small), .size(ui::LabelSize::Small),
) )
.child( .child(
Button::new("connect-button", connect_button_label).on_click({ Button::new("connect-button", connect_button_label)
.on_click({
let verification_uri = data.verification_uri.clone(); let verification_uri = data.verification_uri.clone();
cx.listener(move |this, _, cx| { cx.listener(move |this, _, cx| {
cx.open_url(&verification_uri); cx.open_url(&verification_uri);
this.connect_clicked = true; this.connect_clicked = true;
}) })
}), })
.full_width()
.style(ButtonStyle::Filled),
) )
} }
fn render_enabled_modal() -> impl Element { fn render_enabled_modal() -> impl Element {
@ -196,16 +198,23 @@ impl Render for CopilotCodeVerification {
} }
_ => div().into_any_element(), _ => div().into_any_element(),
}; };
div()
v_stack()
.id("copilot code verification") .id("copilot code verification")
.flex() .elevation_3(cx)
.flex_col()
.size_full() .size_full()
.items_center() .items_center()
.p_10() .p_4()
.bg(cx.theme().colors().element_background) .gap_4()
.child(ui::Label::new("Connect Copilot to Zed")) .child(Headline::new("Connect Copilot to Zed").size(HeadlineSize::Large))
.child(IconElement::new(Icon::ZedXCopilot)) .child(
svg()
.w_32()
.h_16()
.flex_none()
.path(Icon::ZedXCopilot.path())
.text_color(cx.theme().colors().icon),
)
.child(prompt) .child(prompt)
} }
} }