Merge branch 'main' into collab-panel2

This commit is contained in:
Conrad Irwin 2023-11-29 16:32:25 -07:00
commit 4c27f4453c
25 changed files with 338 additions and 688 deletions

View file

@ -178,6 +178,7 @@ use gpui::{
use project::{Fs, Project};
use serde_derive::{Deserialize, Serialize};
use settings::{Settings, SettingsStore};
use ui::prelude::*;
use ui::{
h_stack, v_stack, Avatar, Button, Color, ContextMenu, Icon, IconButton, IconElement, IconSize,
Label, List, ListHeader, ListItem, Tooltip,
@ -2333,18 +2334,20 @@ impl CollabPanel {
}
fn render_signed_out(&mut self, cx: &mut ViewContext<Self>) -> Div {
v_stack().child(Button::new("Sign in to collaborate").on_click(cx.listener(
|this, _, cx| {
let client = this.client.clone();
cx.spawn(|_, mut cx| async move {
client
.authenticate_and_connect(true, &cx)
.await
.notify_async_err(&mut cx);
})
.detach()
},
)))
v_stack().child(
Button::new("sign_in", "Sign in to collaborate").on_click(cx.listener(
|this, _, cx| {
let client = this.client.clone();
cx.spawn(|_, mut cx| async move {
client
.authenticate_and_connect(true, &cx)
.await
.notify_async_err(&mut cx);
})
.detach()
},
)),
)
}
fn render_signed_in(&mut self, cx: &mut ViewContext<Self>) -> List {
@ -2559,7 +2562,7 @@ impl CollabPanel {
.group_hover("", |style| style.visible())
.child(
IconButton::new("remove_contact", Icon::Close)
.color(Color::Muted)
.icon_color(Color::Muted)
.tooltip(|cx| Tooltip::text("Remove Contact", cx))
.on_click(cx.listener({
let github_login = github_login.clone();
@ -2623,13 +2626,13 @@ impl CollabPanel {
.on_click(cx.listener(move |this, _, cx| {
this.respond_to_contact_request(user_id, false, cx);
}))
.color(color)
.icon_color(color)
.tooltip(|cx| Tooltip::text("Decline invite", cx)),
IconButton::new("remove_contact", Icon::Check)
.on_click(cx.listener(move |this, _, cx| {
this.respond_to_contact_request(user_id, true, cx);
}))
.color(color)
.icon_color(color)
.tooltip(|cx| Tooltip::text("Accept invite", cx)),
]
} else {
@ -2638,7 +2641,7 @@ impl CollabPanel {
.on_click(cx.listener(move |this, _, cx| {
this.remove_contact(user_id, &github_login, cx);
}))
.color(color)
.icon_color(color)
.tooltip(|cx| Tooltip::text("Cancel invite", cx))]
};
@ -2780,7 +2783,7 @@ impl CollabPanel {
"channel_chat",
Icon::MessageBubbles,
)
.color(if has_messages_notification {
.icon_color(if has_messages_notification {
Color::Default
} else {
Color::Muted
@ -2795,7 +2798,7 @@ impl CollabPanel {
.group_hover("", |style| style.visible())
.child(
IconButton::new("channel_notes", Icon::File)
.color(if has_notes_notification {
.icon_color(if has_notes_notification {
Color::Default
} else {
Color::Muted

View file

@ -37,10 +37,7 @@ use gpui::{
};
use project::Project;
use theme::ActiveTheme;
use ui::{
h_stack, Avatar, Button, ButtonCommon, ButtonLike, ButtonVariant, Clickable, Color, IconButton,
IconElement, IconSize, KeyBinding, Tooltip,
};
use ui::{h_stack, prelude::*, Avatar, Button, ButtonStyle2, IconButton, KeyBinding, Tooltip};
use util::ResultExt;
use workspace::{notifications::NotifyResultExt, Workspace};
@ -156,8 +153,8 @@ impl Render for CollabTitlebarItem {
.border_color(gpui::red())
.id("project_owner_indicator")
.child(
Button::new("player")
.variant(ButtonVariant::Ghost)
Button::new("player", "player")
.style(ButtonStyle2::Subtle)
.color(Some(Color::Player(0))),
)
.tooltip(move |cx| Tooltip::text("Toggle following", cx)),
@ -168,7 +165,10 @@ impl Render for CollabTitlebarItem {
.border()
.border_color(gpui::red())
.id("titlebar_project_menu_button")
.child(Button::new("project_name").variant(ButtonVariant::Ghost))
.child(
Button::new("project_name", "project_name")
.style(ButtonStyle2::Subtle),
)
.tooltip(move |cx| Tooltip::text("Recent Projects", cx)),
)
// TODO - Add git menu
@ -178,8 +178,8 @@ impl Render for CollabTitlebarItem {
.border_color(gpui::red())
.id("titlebar_git_menu_button")
.child(
Button::new("branch_name")
.variant(ButtonVariant::Ghost)
Button::new("branch_name", "branch_name")
.style(ButtonStyle2::Subtle)
.color(Some(Color::Muted)),
)
.tooltip(move |cx| {
@ -238,7 +238,10 @@ impl Render for CollabTitlebarItem {
h_stack()
.child(
h_stack()
.child(Button::new(if is_shared { "Unshare" } else { "Share" }))
.child(Button::new(
"toggle_sharing",
if is_shared { "Unshare" } else { "Share" },
))
.child(IconButton::new("leave-call", ui::Icon::Exit).on_click({
let workspace = workspace.clone();
move |_, cx| {
@ -291,7 +294,7 @@ impl Render for CollabTitlebarItem {
this.child(ui::Avatar::data(avatar))
})
} else {
this.child(Button::new("Sign in").on_click(move |_, cx| {
this.child(Button::new("sign_in", "Sign in").on_click(move |_, cx| {
let client = client.clone();
cx.spawn(move |mut cx| async move {
client
@ -301,27 +304,6 @@ impl Render for CollabTitlebarItem {
})
.detach();
}))
// Temporary, will be removed when the last part of button2 is merged
.child(
div().border().border_color(gpui::blue()).child(
ButtonLike::new("test-button")
.children([
Avatar::uri(
"https://avatars.githubusercontent.com/u/1714999?v=4",
)
.into_element()
.into_any(),
IconElement::new(ui::Icon::ChevronDown)
.size(IconSize::Small)
.into_element()
.into_any(),
])
.on_click(move |event, _cx| {
dbg!(format!("clicked: {:?}", event.down.position));
})
.tooltip(|cx| Tooltip::text("Test tooltip", cx)),
),
)
}
})
}

View file

@ -2,10 +2,11 @@ use crate::notification_window_options;
use call::{ActiveCall, IncomingCall};
use futures::StreamExt;
use gpui::{
div, green, px, red, AppContext, Div, Element, ParentElement, Render, RenderOnce,
StatefulInteractiveElement, Styled, ViewContext, VisualContext as _, WindowHandle,
div, px, red, AppContext, Div, Element, ParentElement, Render, RenderOnce, Styled, ViewContext,
VisualContext as _, WindowHandle,
};
use std::sync::{Arc, Weak};
use ui::prelude::*;
use ui::{h_stack, v_stack, Avatar, Button, Label};
use util::ResultExt;
use workspace::AppState;
@ -199,14 +200,24 @@ impl IncomingCallNotification {
fn render_buttons(&self, cx: &mut ViewContext<Self>) -> impl Element {
h_stack()
.child(Button::new("Accept").render(cx).bg(green()).on_click({
let state = self.state.clone();
move |_, cx| state.respond(true, cx)
}))
.child(Button::new("Decline").render(cx).bg(red()).on_click({
let state = self.state.clone();
move |_, cx| state.respond(false, cx)
}))
.child(
Button::new("accept", "Accept")
.render(cx)
// .bg(green())
.on_click({
let state = self.state.clone();
move |_, cx| state.respond(true, cx)
}),
)
.child(
Button::new("decline", "Decline")
.render(cx)
// .bg(red())
.on_click({
let state = self.state.clone();
move |_, cx| state.respond(false, cx)
}),
)
// enum Accept {}
// enum Decline {}