mirror of
https://github.com/zed-industries/zed.git
synced 2025-01-24 02:46:43 +00:00
WIP
This commit is contained in:
parent
300ce61bd0
commit
60e190e500
2 changed files with 11 additions and 12 deletions
|
@ -4,7 +4,7 @@ use gpui::{
|
||||||
geometry::rect::RectF,
|
geometry::rect::RectF,
|
||||||
platform::{WindowBounds, WindowKind, WindowOptions},
|
platform::{WindowBounds, WindowKind, WindowOptions},
|
||||||
AnyElement, AnyViewHandle, AppContext, ClipboardItem, Element, Entity, View, ViewContext,
|
AnyElement, AnyViewHandle, AppContext, ClipboardItem, Element, Entity, View, ViewContext,
|
||||||
ViewHandle,
|
WindowHandle,
|
||||||
};
|
};
|
||||||
use theme::ui::modal;
|
use theme::ui::modal;
|
||||||
|
|
||||||
|
@ -18,14 +18,14 @@ const COPILOT_SIGN_UP_URL: &'static str = "https://github.com/features/copilot";
|
||||||
|
|
||||||
pub fn init(cx: &mut AppContext) {
|
pub fn init(cx: &mut AppContext) {
|
||||||
if let Some(copilot) = Copilot::global(cx) {
|
if let Some(copilot) = Copilot::global(cx) {
|
||||||
let mut code_verification: Option<ViewHandle<CopilotCodeVerification>> = None;
|
let mut code_verification: Option<WindowHandle<CopilotCodeVerification>> = None;
|
||||||
cx.observe(&copilot, move |copilot, cx| {
|
cx.observe(&copilot, move |copilot, cx| {
|
||||||
let status = copilot.read(cx).status();
|
let status = copilot.read(cx).status();
|
||||||
|
|
||||||
match &status {
|
match &status {
|
||||||
crate::Status::SigningIn { prompt } => {
|
crate::Status::SigningIn { prompt } => {
|
||||||
if let Some(code_verification_handle) = code_verification.as_mut() {
|
if let Some(code_verification_handle) = code_verification.as_mut() {
|
||||||
let window_id = code_verification_handle.window_id();
|
let window_id = code_verification_handle.id();
|
||||||
let updated = cx.update_window(window_id, |cx| {
|
let updated = cx.update_window(window_id, |cx| {
|
||||||
code_verification_handle.update(cx, |code_verification, cx| {
|
code_verification_handle.update(cx, |code_verification, cx| {
|
||||||
code_verification.set_status(status.clone(), cx)
|
code_verification.set_status(status.clone(), cx)
|
||||||
|
@ -66,7 +66,7 @@ pub fn init(cx: &mut AppContext) {
|
||||||
fn create_copilot_auth_window(
|
fn create_copilot_auth_window(
|
||||||
cx: &mut AppContext,
|
cx: &mut AppContext,
|
||||||
status: &Status,
|
status: &Status,
|
||||||
) -> ViewHandle<CopilotCodeVerification> {
|
) -> WindowHandle<CopilotCodeVerification> {
|
||||||
let window_size = theme::current(cx).copilot.modal.dimensions();
|
let window_size = theme::current(cx).copilot.modal.dimensions();
|
||||||
let window_options = WindowOptions {
|
let window_options = WindowOptions {
|
||||||
bounds: WindowBounds::Fixed(RectF::new(Default::default(), window_size)),
|
bounds: WindowBounds::Fixed(RectF::new(Default::default(), window_size)),
|
||||||
|
@ -78,10 +78,9 @@ fn create_copilot_auth_window(
|
||||||
is_movable: true,
|
is_movable: true,
|
||||||
screen: None,
|
screen: None,
|
||||||
};
|
};
|
||||||
let (_, view) = cx.add_window(window_options, |_cx| {
|
cx.add_window(window_options, |_cx| {
|
||||||
CopilotCodeVerification::new(status.clone())
|
CopilotCodeVerification::new(status.clone())
|
||||||
});
|
})
|
||||||
view
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct CopilotCodeVerification {
|
pub struct CopilotCodeVerification {
|
||||||
|
|
|
@ -3811,10 +3811,6 @@ pub struct WindowHandle<T> {
|
||||||
|
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
impl<V: View> WindowHandle<V> {
|
impl<V: View> WindowHandle<V> {
|
||||||
fn id(&self) -> usize {
|
|
||||||
self.any_handle.id()
|
|
||||||
}
|
|
||||||
|
|
||||||
fn new(window_id: usize, ref_counts: Arc<Mutex<RefCounts>>) -> Self {
|
fn new(window_id: usize, ref_counts: Arc<Mutex<RefCounts>>) -> Self {
|
||||||
WindowHandle {
|
WindowHandle {
|
||||||
any_handle: AnyWindowHandle::new::<V>(window_id, ref_counts),
|
any_handle: AnyWindowHandle::new::<V>(window_id, ref_counts),
|
||||||
|
@ -3822,7 +3818,11 @@ impl<V: View> WindowHandle<V> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn root(&self, cx: &impl BorrowAppContext) -> ViewHandle<V> {
|
pub fn id(&self) -> usize {
|
||||||
|
self.any_handle.id()
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn root(&self, cx: &impl BorrowAppContext) -> ViewHandle<V> {
|
||||||
self.read_with(cx, |cx| cx.root_view().clone().downcast().unwrap())
|
self.read_with(cx, |cx| cx.root_view().clone().downcast().unwrap())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue