Improve layout and styling of contact notifications
Co-authored-by: Nathan Sobo <nathan@zed.dev>
This commit is contained in:
co-authored by
Nathan Sobo
parent
3bc9b8ec85
commit
0ba656aa0e
@@ -371,7 +371,7 @@ impl UserStore {
|
||||
response: if accept {
|
||||
proto::ContactRequestResponse::Accept
|
||||
} else {
|
||||
proto::ContactRequestResponse::Reject
|
||||
proto::ContactRequestResponse::Decline
|
||||
} as i32,
|
||||
},
|
||||
cx,
|
||||
|
||||
@@ -118,7 +118,7 @@ impl PickerDelegate for ContactFinder {
|
||||
"icons/accept.svg"
|
||||
}
|
||||
ContactRequestStatus::RequestSent | ContactRequestStatus::RequestAccepted => {
|
||||
"icons/reject.svg"
|
||||
"icons/decline.svg"
|
||||
}
|
||||
};
|
||||
let button_style = if self.user_store.read(cx).is_contact_request_pending(&user) {
|
||||
|
||||
@@ -6,6 +6,8 @@ use gpui::{
|
||||
use settings::Settings;
|
||||
use workspace::Notification;
|
||||
|
||||
use crate::render_icon_button;
|
||||
|
||||
impl_internal_actions!(contact_notifications, [Dismiss, RespondToContactRequest]);
|
||||
|
||||
pub fn init(cx: &mut MutableAppContext) {
|
||||
@@ -31,7 +33,7 @@ pub enum Event {
|
||||
Dismiss,
|
||||
}
|
||||
|
||||
enum Reject {}
|
||||
enum Decline {}
|
||||
enum Accept {}
|
||||
|
||||
impl Entity for ContactNotification {
|
||||
@@ -87,7 +89,7 @@ impl ContactNotification {
|
||||
let user_id = user.id;
|
||||
|
||||
Flex::column()
|
||||
.with_child(self.render_header("added you", theme, cx))
|
||||
.with_child(self.render_header("wants to add you as a contact.", theme, cx))
|
||||
.with_child(
|
||||
Label::new(
|
||||
"They won't know if you decline.".to_string(),
|
||||
@@ -100,13 +102,14 @@ impl ContactNotification {
|
||||
.with_child(
|
||||
Flex::row()
|
||||
.with_child(
|
||||
MouseEventHandler::new::<Reject, _, _>(
|
||||
MouseEventHandler::new::<Decline, _, _>(
|
||||
self.event.user.id as usize,
|
||||
cx,
|
||||
|_, _| {
|
||||
Label::new("Reject".to_string(), theme.button.text.clone())
|
||||
|state, _| {
|
||||
let button = theme.button.style_for(state, false);
|
||||
Label::new("Decline".to_string(), button.text.clone())
|
||||
.contained()
|
||||
.with_style(theme.button.container)
|
||||
.with_style(button.container)
|
||||
.boxed()
|
||||
},
|
||||
)
|
||||
@@ -120,10 +123,11 @@ impl ContactNotification {
|
||||
.boxed(),
|
||||
)
|
||||
.with_child(
|
||||
MouseEventHandler::new::<Accept, _, _>(user.id as usize, cx, |_, _| {
|
||||
Label::new("Accept".to_string(), theme.button.text.clone())
|
||||
MouseEventHandler::new::<Accept, _, _>(user.id as usize, cx, |state, _| {
|
||||
let button = theme.button.style_for(state, false);
|
||||
Label::new("Accept".to_string(), button.text.clone())
|
||||
.contained()
|
||||
.with_style(theme.button.container)
|
||||
.with_style(button.container)
|
||||
.boxed()
|
||||
})
|
||||
.with_cursor_style(CursorStyle::PointingHand)
|
||||
@@ -163,42 +167,51 @@ impl ContactNotification {
|
||||
Image::new(avatar)
|
||||
.with_style(theme.header_avatar)
|
||||
.aligned()
|
||||
.left()
|
||||
.constrained()
|
||||
.with_height(
|
||||
cx.font_cache()
|
||||
.line_height(theme.header_message.text.font_size),
|
||||
)
|
||||
.aligned()
|
||||
.top()
|
||||
.boxed()
|
||||
}))
|
||||
.with_child(
|
||||
Label::new(
|
||||
Text::new(
|
||||
format!("{} {}", user.github_login, message),
|
||||
theme.header_message.text.clone(),
|
||||
)
|
||||
.contained()
|
||||
.with_style(theme.header_message.container)
|
||||
.aligned()
|
||||
.top()
|
||||
.left()
|
||||
.flex(1., true)
|
||||
.boxed(),
|
||||
)
|
||||
.with_child(
|
||||
MouseEventHandler::new::<Dismiss, _, _>(user.id as usize, cx, |_, _| {
|
||||
Svg::new("icons/reject.svg")
|
||||
.with_color(theme.dismiss_button.color)
|
||||
.constrained()
|
||||
.with_width(theme.dismiss_button.icon_width)
|
||||
.aligned()
|
||||
.contained()
|
||||
.with_style(theme.dismiss_button.container)
|
||||
.constrained()
|
||||
.with_width(theme.dismiss_button.button_width)
|
||||
.with_height(theme.dismiss_button.button_width)
|
||||
.aligned()
|
||||
.boxed()
|
||||
MouseEventHandler::new::<Dismiss, _, _>(user.id as usize, cx, |state, _| {
|
||||
render_icon_button(
|
||||
theme.dismiss_button.style_for(state, false),
|
||||
"icons/decline.svg",
|
||||
)
|
||||
.boxed()
|
||||
})
|
||||
.with_cursor_style(CursorStyle::PointingHand)
|
||||
.with_padding(Padding::uniform(5.))
|
||||
.on_click(move |_, cx| cx.dispatch_action(Dismiss(user_id)))
|
||||
.aligned()
|
||||
.constrained()
|
||||
.with_height(
|
||||
cx.font_cache()
|
||||
.line_height(theme.header_message.text.font_size),
|
||||
)
|
||||
.aligned()
|
||||
.top()
|
||||
.flex_float()
|
||||
.boxed(),
|
||||
)
|
||||
.constrained()
|
||||
.with_height(theme.header_height)
|
||||
.boxed()
|
||||
.named("contact notification header")
|
||||
}
|
||||
|
||||
fn dismiss(&mut self, _: &Dismiss, cx: &mut ViewContext<Self>) {
|
||||
|
||||
@@ -344,7 +344,7 @@ impl ContactsPanel {
|
||||
is_incoming: bool,
|
||||
cx: &mut LayoutContext,
|
||||
) -> ElementBox {
|
||||
enum Reject {}
|
||||
enum Decline {}
|
||||
enum Accept {}
|
||||
enum Cancel {}
|
||||
|
||||
@@ -373,13 +373,13 @@ impl ContactsPanel {
|
||||
|
||||
if is_incoming {
|
||||
row.add_children([
|
||||
MouseEventHandler::new::<Reject, _, _>(user.id as usize, cx, |mouse_state, _| {
|
||||
MouseEventHandler::new::<Decline, _, _>(user.id as usize, cx, |mouse_state, _| {
|
||||
let button_style = if is_contact_request_pending {
|
||||
&theme.disabled_contact_button
|
||||
} else {
|
||||
&theme.contact_button.style_for(mouse_state, false)
|
||||
};
|
||||
render_icon_button(button_style, "icons/reject.svg")
|
||||
render_icon_button(button_style, "icons/decline.svg")
|
||||
.aligned()
|
||||
.flex_float()
|
||||
.boxed()
|
||||
@@ -421,7 +421,7 @@ impl ContactsPanel {
|
||||
} else {
|
||||
&theme.contact_button.style_for(mouse_state, false)
|
||||
};
|
||||
render_icon_button(button_style, "icons/reject.svg")
|
||||
render_icon_button(button_style, "icons/decline.svg")
|
||||
.aligned()
|
||||
.flex_float()
|
||||
.boxed()
|
||||
|
||||
@@ -564,7 +564,7 @@ message RespondToContactRequest {
|
||||
|
||||
enum ContactRequestResponse {
|
||||
Accept = 0;
|
||||
Reject = 1;
|
||||
Decline = 1;
|
||||
Block = 2;
|
||||
Dismiss = 3;
|
||||
}
|
||||
|
||||
@@ -362,8 +362,8 @@ pub struct ContactNotification {
|
||||
pub header_message: ContainedText,
|
||||
pub header_height: f32,
|
||||
pub body_message: ContainedText,
|
||||
pub button: ContainedText,
|
||||
pub dismiss_button: IconButton,
|
||||
pub button: Interactive<ContainedText>,
|
||||
pub dismiss_button: Interactive<IconButton>,
|
||||
}
|
||||
|
||||
#[derive(Clone, Deserialize, Default)]
|
||||
|
||||
@@ -1769,7 +1769,7 @@ impl Workspace {
|
||||
.boxed()
|
||||
}))
|
||||
.constrained()
|
||||
.with_width(250.)
|
||||
.with_width(theme.notifications.width)
|
||||
.contained()
|
||||
.with_style(theme.notifications.container)
|
||||
.aligned()
|
||||
|
||||
Reference in New Issue
Block a user