WIP: Start on showing window for authenticating with copilot

Co-Authored-By: Mikayla Maki <mikayla@zed.dev>
This commit is contained in:
Antonio Scandurra 2023-03-24 16:50:27 +01:00 committed by Mikayla Maki
parent 9713d1bb31
commit b16e2169ce

View file

@ -2,7 +2,7 @@ use crate::{request::PromptUserDeviceFlow, Copilot};
use gpui::{ use gpui::{
elements::*, elements::*,
geometry::{rect::RectF, vector::vec2f}, geometry::{rect::RectF, vector::vec2f},
Axis, Element, Entity, MutableAppContext, View, ViewContext, WindowKind, WindowOptions, Axis, Element, Entity, MutableAppContext, View, WindowKind, WindowOptions,
}; };
use settings::Settings; use settings::Settings;
@ -19,19 +19,18 @@ pub fn init(cx: &mut MutableAppContext) {
cx.remove_window(window_id); cx.remove_window(window_id);
} }
let screen = cx.platform().screens().pop();
let (window_id, _) = cx.add_window( let (window_id, _) = cx.add_window(
WindowOptions { WindowOptions {
bounds: gpui::WindowBounds::Fixed(RectF::new( bounds: gpui::WindowBounds::Fixed(RectF::new(
vec2f(100., 100.), Default::default(),
vec2f(300., 300.), vec2f(600., 400.),
)), )),
titlebar: None, titlebar: None,
center: false, center: true,
focus: false, focus: false,
kind: WindowKind::Normal, kind: WindowKind::Normal,
is_movable: true, is_movable: true,
screen, screen: None,
}, },
|_| CopilotCodeVerification::new(prompt), |_| CopilotCodeVerification::new(prompt),
); );
@ -47,16 +46,12 @@ pub fn init(cx: &mut MutableAppContext) {
.detach(); .detach();
} }
pub enum Event {
Dismiss,
}
pub struct CopilotCodeVerification { pub struct CopilotCodeVerification {
prompt: PromptUserDeviceFlow, prompt: PromptUserDeviceFlow,
} }
impl Entity for CopilotCodeVerification { impl Entity for CopilotCodeVerification {
type Event = Event; type Event = ();
} }
impl View for CopilotCodeVerification { impl View for CopilotCodeVerification {
@ -85,10 +80,6 @@ impl View for CopilotCodeVerification {
.with_style(style.auth_modal) .with_style(style.auth_modal)
.named("Copilot Authentication status modal") .named("Copilot Authentication status modal")
} }
fn focus_out(&mut self, _: gpui::AnyViewHandle, cx: &mut ViewContext<Self>) {
cx.emit(Event::Dismiss)
}
} }
impl CopilotCodeVerification { impl CopilotCodeVerification {