Fix up tests
This commit is contained in:
parent
4c1514edc4
commit
5cbe8deb50
6 changed files with 21 additions and 13 deletions
|
@ -3318,7 +3318,7 @@ impl Render for CollabPanel {
|
||||||
.user
|
.user
|
||||||
.avatar
|
.avatar
|
||||||
.as_ref()
|
.as_ref()
|
||||||
.map(|avatar| Avatar::new(avatar.clone())),
|
.map(|avatar| Avatar::data(avatar.clone())),
|
||||||
)
|
)
|
||||||
.child(Label::new(contact.user.github_login.clone()))
|
.child(Label::new(contact.user.github_login.clone()))
|
||||||
.on_mouse_down(gpui::MouseButton::Left, {
|
.on_mouse_down(gpui::MouseButton::Left, {
|
||||||
|
|
|
@ -182,12 +182,12 @@ impl Render for CollabTitlebarItem {
|
||||||
current_user
|
current_user
|
||||||
.avatar
|
.avatar
|
||||||
.clone()
|
.clone()
|
||||||
.map(|avatar| div().child(Avatar::new(avatar.clone())))
|
.map(|avatar| div().child(Avatar::data(avatar.clone())))
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.chain(remote_participants.into_iter().flat_map(|(user, peer_id)| {
|
.chain(remote_participants.into_iter().flat_map(|(user, peer_id)| {
|
||||||
user.avatar.as_ref().map(|avatar| {
|
user.avatar.as_ref().map(|avatar| {
|
||||||
div()
|
div()
|
||||||
.child(Avatar::new(avatar.clone()).into_element())
|
.child(Avatar::data(avatar.clone()).into_element())
|
||||||
.on_mouse_down(MouseButton::Left, {
|
.on_mouse_down(MouseButton::Left, {
|
||||||
let workspace = workspace.clone();
|
let workspace = workspace.clone();
|
||||||
let id = peer_id.clone();
|
let id = peer_id.clone();
|
||||||
|
@ -235,7 +235,7 @@ impl Render for CollabTitlebarItem {
|
||||||
.map(|this| {
|
.map(|this| {
|
||||||
if let Some(user) = current_user {
|
if let Some(user) = current_user {
|
||||||
this.when_some(user.avatar.clone(), |this, avatar| {
|
this.when_some(user.avatar.clone(), |this, avatar| {
|
||||||
this.child(ui::Avatar::new(avatar))
|
this.child(ui::Avatar::data(avatar))
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
this.child(Button::new("Sign in").on_click(move |_, cx| {
|
this.child(Button::new("Sign in").on_click(move |_, cx| {
|
||||||
|
|
|
@ -129,7 +129,7 @@ impl IncomingCallNotification {
|
||||||
.calling_user
|
.calling_user
|
||||||
.avatar
|
.avatar
|
||||||
.as_ref()
|
.as_ref()
|
||||||
.map(|avatar| Avatar::new(avatar.clone())),
|
.map(|avatar| Avatar::data(avatar.clone())),
|
||||||
)
|
)
|
||||||
.child(
|
.child(
|
||||||
v_stack()
|
v_stack()
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
|
use std::sync::Arc;
|
||||||
|
|
||||||
use crate::prelude::*;
|
use crate::prelude::*;
|
||||||
use gpui::{img, ImageSource, Img, IntoElement};
|
use gpui::{img, ImageData, ImageSource, Img, IntoElement};
|
||||||
|
|
||||||
#[derive(Debug, Default, PartialEq, Clone)]
|
#[derive(Debug, Default, PartialEq, Clone)]
|
||||||
pub enum Shape {
|
pub enum Shape {
|
||||||
|
@ -34,7 +36,13 @@ impl RenderOnce for Avatar {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Avatar {
|
impl Avatar {
|
||||||
pub fn new(src: impl Into<ImageSource>) -> Self {
|
pub fn uri(src: impl Into<SharedString>) -> Self {
|
||||||
|
Self {
|
||||||
|
src: src.into().into(),
|
||||||
|
shape: Shape::Circle,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pub fn data(src: Arc<ImageData>) -> Self {
|
||||||
Self {
|
Self {
|
||||||
src: src.into(),
|
src: src.into(),
|
||||||
shape: Shape::Circle,
|
shape: Shape::Circle,
|
||||||
|
|
|
@ -323,8 +323,8 @@ impl RenderOnce for ListItem {
|
||||||
.color(Color::Muted),
|
.color(Color::Muted),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
Some(GraphicSlot::Avatar(src)) => Some(h_stack().child(Avatar::new(src))),
|
Some(GraphicSlot::Avatar(src)) => Some(h_stack().child(Avatar::uri(src))),
|
||||||
Some(GraphicSlot::PublicActor(src)) => Some(h_stack().child(Avatar::new(src))),
|
Some(GraphicSlot::PublicActor(src)) => Some(h_stack().child(Avatar::uri(src))),
|
||||||
None => None,
|
None => None,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -13,11 +13,11 @@ impl Render for AvatarStory {
|
||||||
Story::container()
|
Story::container()
|
||||||
.child(Story::title_for::<Avatar>())
|
.child(Story::title_for::<Avatar>())
|
||||||
.child(Story::label("Default"))
|
.child(Story::label("Default"))
|
||||||
.child(Avatar::new(
|
.child(Avatar::uri(
|
||||||
"https://avatars.githubusercontent.com/u/1714999?v=4".into(),
|
"https://avatars.githubusercontent.com/u/1714999?v=4",
|
||||||
))
|
))
|
||||||
.child(Avatar::new(
|
.child(Avatar::uri(
|
||||||
"https://avatars.githubusercontent.com/u/326587?v=4".into(),
|
"https://avatars.githubusercontent.com/u/326587?v=4",
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue