Rework loading images from files (#7088)
This PR is a follow-up to #7084, where I noted that I wasn't satisfied with using `SharedUri` to represent both URIs and paths on the local filesystem: > I'm still not entirely happy with this naming, as the file paths that we can store in here are not _really_ URIs, as they are lacking a protocol. > > I want to explore changing `SharedUri` / `SharedUrl` back to alway storing a URL and treat local filepaths differently, as it seems we're conflating two different concerns under the same umbrella, at the moment. `SharedUri` has now been reverted to just containing a `SharedString` with a URI. `ImageSource` now has a new `File` variant that is used to load an image from a `PathBuf`. Release Notes: - N/A
This commit is contained in:
parent
6d4fe8098b
commit
2980f0508c
12 changed files with 163 additions and 166 deletions
|
@ -1,4 +1,4 @@
|
|||
use gpui::{Render, SharedUri};
|
||||
use gpui::Render;
|
||||
use story::{StoryContainer, StoryItem, StorySection};
|
||||
|
||||
use crate::{prelude::*, AudioStatus, Availability, AvatarAvailabilityIndicator};
|
||||
|
@ -13,66 +13,50 @@ impl Render for AvatarStory {
|
|||
StorySection::new()
|
||||
.child(StoryItem::new(
|
||||
"Default",
|
||||
Avatar::new(SharedUri::network(
|
||||
"https://avatars.githubusercontent.com/u/1714999?v=4",
|
||||
)),
|
||||
Avatar::new("https://avatars.githubusercontent.com/u/1714999?v=4"),
|
||||
))
|
||||
.child(StoryItem::new(
|
||||
"Default",
|
||||
Avatar::new(SharedUri::network(
|
||||
"https://avatars.githubusercontent.com/u/326587?v=4",
|
||||
)),
|
||||
Avatar::new("https://avatars.githubusercontent.com/u/326587?v=4"),
|
||||
)),
|
||||
)
|
||||
.child(
|
||||
StorySection::new()
|
||||
.child(StoryItem::new(
|
||||
"With free availability indicator",
|
||||
Avatar::new(SharedUri::network(
|
||||
"https://avatars.githubusercontent.com/u/326587?v=4",
|
||||
))
|
||||
.indicator(AvatarAvailabilityIndicator::new(Availability::Free)),
|
||||
Avatar::new("https://avatars.githubusercontent.com/u/326587?v=4")
|
||||
.indicator(AvatarAvailabilityIndicator::new(Availability::Free)),
|
||||
))
|
||||
.child(StoryItem::new(
|
||||
"With busy availability indicator",
|
||||
Avatar::new(SharedUri::network(
|
||||
"https://avatars.githubusercontent.com/u/326587?v=4",
|
||||
))
|
||||
.indicator(AvatarAvailabilityIndicator::new(Availability::Busy)),
|
||||
Avatar::new("https://avatars.githubusercontent.com/u/326587?v=4")
|
||||
.indicator(AvatarAvailabilityIndicator::new(Availability::Busy)),
|
||||
)),
|
||||
)
|
||||
.child(
|
||||
StorySection::new()
|
||||
.child(StoryItem::new(
|
||||
"With info border",
|
||||
Avatar::new(SharedUri::network(
|
||||
"https://avatars.githubusercontent.com/u/326587?v=4",
|
||||
))
|
||||
.border_color(cx.theme().status().info_border),
|
||||
Avatar::new("https://avatars.githubusercontent.com/u/326587?v=4")
|
||||
.border_color(cx.theme().status().info_border),
|
||||
))
|
||||
.child(StoryItem::new(
|
||||
"With error border",
|
||||
Avatar::new(SharedUri::network(
|
||||
"https://avatars.githubusercontent.com/u/326587?v=4",
|
||||
))
|
||||
.border_color(cx.theme().status().error_border),
|
||||
Avatar::new("https://avatars.githubusercontent.com/u/326587?v=4")
|
||||
.border_color(cx.theme().status().error_border),
|
||||
)),
|
||||
)
|
||||
.child(
|
||||
StorySection::new()
|
||||
.child(StoryItem::new(
|
||||
"With muted audio indicator",
|
||||
Avatar::new(SharedUri::network(
|
||||
"https://avatars.githubusercontent.com/u/326587?v=4",
|
||||
))
|
||||
.indicator(AvatarAudioStatusIndicator::new(AudioStatus::Muted)),
|
||||
Avatar::new("https://avatars.githubusercontent.com/u/326587?v=4")
|
||||
.indicator(AvatarAudioStatusIndicator::new(AudioStatus::Muted)),
|
||||
))
|
||||
.child(StoryItem::new(
|
||||
"With deafened audio indicator",
|
||||
Avatar::new(SharedUri::network(
|
||||
"https://avatars.githubusercontent.com/u/326587?v=4",
|
||||
))
|
||||
.indicator(AvatarAudioStatusIndicator::new(AudioStatus::Deafened)),
|
||||
Avatar::new("https://avatars.githubusercontent.com/u/326587?v=4")
|
||||
.indicator(AvatarAudioStatusIndicator::new(AudioStatus::Deafened)),
|
||||
)),
|
||||
)
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
use gpui::{Render, SharedUri};
|
||||
use gpui::Render;
|
||||
use story::Story;
|
||||
|
||||
use crate::{prelude::*, Avatar};
|
||||
|
@ -45,17 +45,17 @@ impl Render for ListItemStory {
|
|||
.child(
|
||||
ListItem::new("with_start slot avatar")
|
||||
.child("Hello, world!")
|
||||
.start_slot(Avatar::new(SharedUri::network(
|
||||
.start_slot(Avatar::new(
|
||||
"https://avatars.githubusercontent.com/u/1714999?v=4",
|
||||
))),
|
||||
)),
|
||||
)
|
||||
.child(Story::label("With end slot"))
|
||||
.child(
|
||||
ListItem::new("with_left_avatar")
|
||||
.child("Hello, world!")
|
||||
.end_slot(Avatar::new(SharedUri::network(
|
||||
.end_slot(Avatar::new(
|
||||
"https://avatars.githubusercontent.com/u/1714999?v=4",
|
||||
))),
|
||||
)),
|
||||
)
|
||||
.child(Story::label("With end hover slot"))
|
||||
.child(
|
||||
|
@ -64,25 +64,25 @@ impl Render for ListItemStory {
|
|||
.end_slot(
|
||||
h_flex()
|
||||
.gap_2()
|
||||
.child(Avatar::new(SharedUri::network(
|
||||
.child(Avatar::new(
|
||||
"https://avatars.githubusercontent.com/u/1789?v=4",
|
||||
)))
|
||||
.child(Avatar::new(SharedUri::network(
|
||||
))
|
||||
.child(Avatar::new(
|
||||
"https://avatars.githubusercontent.com/u/1789?v=4",
|
||||
)))
|
||||
.child(Avatar::new(SharedUri::network(
|
||||
))
|
||||
.child(Avatar::new(
|
||||
"https://avatars.githubusercontent.com/u/1789?v=4",
|
||||
)))
|
||||
.child(Avatar::new(SharedUri::network(
|
||||
))
|
||||
.child(Avatar::new(
|
||||
"https://avatars.githubusercontent.com/u/1789?v=4",
|
||||
)))
|
||||
.child(Avatar::new(SharedUri::network(
|
||||
))
|
||||
.child(Avatar::new(
|
||||
"https://avatars.githubusercontent.com/u/1789?v=4",
|
||||
))),
|
||||
)),
|
||||
)
|
||||
.end_hover_slot(Avatar::new(SharedUri::network(
|
||||
.end_hover_slot(Avatar::new(
|
||||
"https://avatars.githubusercontent.com/u/1714999?v=4",
|
||||
))),
|
||||
)),
|
||||
)
|
||||
.child(Story::label("With `on_click`"))
|
||||
.child(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue