Start changing Avatar to use URI

Co-Authored-By: Antonio Scandurra <antonio@zed.dev>
This commit is contained in:
Julia
2023-12-12 11:27:40 -05:00
co-authored by Antonio Scandurra
parent 376716254f
commit 44d40625fe
19 changed files with 190 additions and 203 deletions
+2 -10
View File
@@ -58,16 +58,8 @@ impl RenderOnce for Avatar {
}
impl Avatar {
pub fn uri(src: impl Into<SharedString>) -> Self {
Self::source(src.into().into())
}
pub fn data(src: Arc<ImageData>) -> Self {
Self::source(src.into())
}
pub fn source(src: ImageSource) -> Self {
Self {
pub fn new(src: impl Into<ImageSource>) -> Self {
Avatar {
image: img(src),
is_available: None,
border_color: None,
+1 -1
View File
@@ -107,7 +107,7 @@ impl ListItem {
}
pub fn left_avatar(mut self, left_avatar: impl Into<ImageSource>) -> Self {
self.left_slot = Some(Avatar::source(left_avatar.into()).into_any_element());
self.left_slot = Some(Avatar::new(left_avatar).into_any_element());
self
}
}
+4 -4
View File
@@ -13,18 +13,18 @@ impl Render for AvatarStory {
Story::container()
.child(Story::title_for::<Avatar>())
.child(Story::label("Default"))
.child(Avatar::uri(
.child(Avatar::new(
"https://avatars.githubusercontent.com/u/1714999?v=4",
))
.child(Avatar::uri(
.child(Avatar::new(
"https://avatars.githubusercontent.com/u/326587?v=4",
))
.child(
Avatar::uri("https://avatars.githubusercontent.com/u/326587?v=4")
Avatar::new("https://avatars.githubusercontent.com/u/326587?v=4")
.availability_indicator(true),
)
.child(
Avatar::uri("https://avatars.githubusercontent.com/u/326587?v=4")
Avatar::new("https://avatars.githubusercontent.com/u/326587?v=4")
.availability_indicator(false),
)
}