Rename SharedUrl
to SharedUri
(#7084)
This PR renames `SharedUrl` to `SharedUri` to better reflect its intent. 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. Release Notes: - N/A
This commit is contained in:
parent
d18c0d9df0
commit
6c7893db35
14 changed files with 66 additions and 66 deletions
|
@ -4,7 +4,7 @@ use collections::{hash_map::Entry, HashMap, HashSet};
|
||||||
use feature_flags::FeatureFlagAppExt;
|
use feature_flags::FeatureFlagAppExt;
|
||||||
use futures::{channel::mpsc, Future, StreamExt};
|
use futures::{channel::mpsc, Future, StreamExt};
|
||||||
use gpui::{
|
use gpui::{
|
||||||
AppContext, AsyncAppContext, EventEmitter, Model, ModelContext, SharedString, SharedUrl, Task,
|
AppContext, AsyncAppContext, EventEmitter, Model, ModelContext, SharedString, SharedUri, Task,
|
||||||
WeakModel,
|
WeakModel,
|
||||||
};
|
};
|
||||||
use postage::{sink::Sink, watch};
|
use postage::{sink::Sink, watch};
|
||||||
|
@ -22,7 +22,7 @@ pub struct ParticipantIndex(pub u32);
|
||||||
pub struct User {
|
pub struct User {
|
||||||
pub id: UserId,
|
pub id: UserId,
|
||||||
pub github_login: String,
|
pub github_login: String,
|
||||||
pub avatar_uri: SharedUrl,
|
pub avatar_uri: SharedUri,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug, PartialEq, Eq)]
|
#[derive(Clone, Debug, PartialEq, Eq)]
|
||||||
|
@ -707,7 +707,7 @@ impl User {
|
||||||
Arc::new(User {
|
Arc::new(User {
|
||||||
id: message.id,
|
id: message.id,
|
||||||
github_login: message.github_login,
|
github_login: message.github_login,
|
||||||
avatar_uri: SharedUrl::network(message.avatar_url),
|
avatar_uri: SharedUri::network(message.avatar_url),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,7 +9,7 @@ use fs::{repository::GitFileStatus, FakeFs, Fs as _, RemoveOptions};
|
||||||
use futures::StreamExt as _;
|
use futures::StreamExt as _;
|
||||||
use gpui::{
|
use gpui::{
|
||||||
px, size, AppContext, BackgroundExecutor, Model, Modifiers, MouseButton, MouseDownEvent,
|
px, size, AppContext, BackgroundExecutor, Model, Modifiers, MouseButton, MouseDownEvent,
|
||||||
SharedUrl, TestAppContext,
|
SharedUri, TestAppContext,
|
||||||
};
|
};
|
||||||
use language::{
|
use language::{
|
||||||
language_settings::{AllLanguageSettings, Formatter},
|
language_settings::{AllLanguageSettings, Formatter},
|
||||||
|
@ -1828,7 +1828,7 @@ async fn test_active_call_events(
|
||||||
owner: Arc::new(User {
|
owner: Arc::new(User {
|
||||||
id: client_a.user_id().unwrap(),
|
id: client_a.user_id().unwrap(),
|
||||||
github_login: "user_a".to_string(),
|
github_login: "user_a".to_string(),
|
||||||
avatar_uri: SharedUrl::network("avatar_a"),
|
avatar_uri: SharedUri::network("avatar_a"),
|
||||||
}),
|
}),
|
||||||
project_id: project_a_id,
|
project_id: project_a_id,
|
||||||
worktree_root_names: vec!["a".to_string()],
|
worktree_root_names: vec!["a".to_string()],
|
||||||
|
@ -1846,7 +1846,7 @@ async fn test_active_call_events(
|
||||||
owner: Arc::new(User {
|
owner: Arc::new(User {
|
||||||
id: client_b.user_id().unwrap(),
|
id: client_b.user_id().unwrap(),
|
||||||
github_login: "user_b".to_string(),
|
github_login: "user_b".to_string(),
|
||||||
avatar_uri: SharedUrl::network("avatar_b"),
|
avatar_uri: SharedUri::network("avatar_b"),
|
||||||
}),
|
}),
|
||||||
project_id: project_b_id,
|
project_id: project_b_id,
|
||||||
worktree_root_names: vec!["b".to_string()]
|
worktree_root_names: vec!["b".to_string()]
|
||||||
|
|
|
@ -714,7 +714,7 @@ fn format_timestamp(
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
use gpui::{HighlightStyle, SharedUrl};
|
use gpui::{HighlightStyle, SharedUri};
|
||||||
use pretty_assertions::assert_eq;
|
use pretty_assertions::assert_eq;
|
||||||
use rich_text::Highlight;
|
use rich_text::Highlight;
|
||||||
use time::{Date, OffsetDateTime, Time, UtcOffset};
|
use time::{Date, OffsetDateTime, Time, UtcOffset};
|
||||||
|
@ -730,7 +730,7 @@ mod tests {
|
||||||
timestamp: OffsetDateTime::now_utc(),
|
timestamp: OffsetDateTime::now_utc(),
|
||||||
sender: Arc::new(client::User {
|
sender: Arc::new(client::User {
|
||||||
github_login: "fgh".into(),
|
github_login: "fgh".into(),
|
||||||
avatar_uri: SharedUrl::network("avatar_fgh"),
|
avatar_uri: SharedUri::network("avatar_fgh"),
|
||||||
id: 103,
|
id: 103,
|
||||||
}),
|
}),
|
||||||
nonce: 5,
|
nonce: 5,
|
||||||
|
|
|
@ -365,7 +365,7 @@ impl Render for MessageEditor {
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
use client::{Client, User, UserStore};
|
use client::{Client, User, UserStore};
|
||||||
use gpui::{SharedUrl, TestAppContext};
|
use gpui::{SharedUri, TestAppContext};
|
||||||
use language::{Language, LanguageConfig};
|
use language::{Language, LanguageConfig};
|
||||||
use rpc::proto;
|
use rpc::proto;
|
||||||
use settings::SettingsStore;
|
use settings::SettingsStore;
|
||||||
|
@ -392,7 +392,7 @@ mod tests {
|
||||||
user: Arc::new(User {
|
user: Arc::new(User {
|
||||||
github_login: "a-b".into(),
|
github_login: "a-b".into(),
|
||||||
id: 101,
|
id: 101,
|
||||||
avatar_uri: SharedUrl::network("avatar_a-b"),
|
avatar_uri: SharedUri::network("avatar_a-b"),
|
||||||
}),
|
}),
|
||||||
kind: proto::channel_member::Kind::Member,
|
kind: proto::channel_member::Kind::Member,
|
||||||
role: proto::ChannelRole::Member,
|
role: proto::ChannelRole::Member,
|
||||||
|
@ -401,7 +401,7 @@ mod tests {
|
||||||
user: Arc::new(User {
|
user: Arc::new(User {
|
||||||
github_login: "C_D".into(),
|
github_login: "C_D".into(),
|
||||||
id: 102,
|
id: 102,
|
||||||
avatar_uri: SharedUrl::network("avatar_C_D"),
|
avatar_uri: SharedUri::network("avatar_C_D"),
|
||||||
}),
|
}),
|
||||||
kind: proto::channel_member::Kind::Member,
|
kind: proto::channel_member::Kind::Member,
|
||||||
role: proto::ChannelRole::Member,
|
role: proto::ChannelRole::Member,
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
use gpui::{img, prelude::*, AnyElement, SharedUrl};
|
use gpui::{img, prelude::*, AnyElement, SharedUri};
|
||||||
use smallvec::SmallVec;
|
use smallvec::SmallVec;
|
||||||
use ui::prelude::*;
|
use ui::prelude::*;
|
||||||
|
|
||||||
#[derive(IntoElement)]
|
#[derive(IntoElement)]
|
||||||
pub struct CollabNotification {
|
pub struct CollabNotification {
|
||||||
avatar_uri: SharedUrl,
|
avatar_uri: SharedUri,
|
||||||
accept_button: Button,
|
accept_button: Button,
|
||||||
dismiss_button: Button,
|
dismiss_button: Button,
|
||||||
children: SmallVec<[AnyElement; 2]>,
|
children: SmallVec<[AnyElement; 2]>,
|
||||||
|
@ -12,7 +12,7 @@ pub struct CollabNotification {
|
||||||
|
|
||||||
impl CollabNotification {
|
impl CollabNotification {
|
||||||
pub fn new(
|
pub fn new(
|
||||||
avatar_uri: impl Into<SharedUrl>,
|
avatar_uri: impl Into<SharedUri>,
|
||||||
accept_button: Button,
|
accept_button: Button,
|
||||||
dismiss_button: Button,
|
dismiss_button: Button,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
use gpui::{prelude::*, SharedUrl};
|
use gpui::{prelude::*, SharedUri};
|
||||||
use story::{StoryContainer, StoryItem, StorySection};
|
use story::{StoryContainer, StoryItem, StorySection};
|
||||||
use ui::prelude::*;
|
use ui::prelude::*;
|
||||||
|
|
||||||
|
@ -19,7 +19,7 @@ impl Render for CollabNotificationStory {
|
||||||
"Incoming Call Notification",
|
"Incoming Call Notification",
|
||||||
window_container(400., 72.).child(
|
window_container(400., 72.).child(
|
||||||
CollabNotification::new(
|
CollabNotification::new(
|
||||||
SharedUrl::network("https://avatars.githubusercontent.com/u/1486634?v=4"),
|
SharedUri::network("https://avatars.githubusercontent.com/u/1486634?v=4"),
|
||||||
Button::new("accept", "Accept"),
|
Button::new("accept", "Accept"),
|
||||||
Button::new("decline", "Decline"),
|
Button::new("decline", "Decline"),
|
||||||
)
|
)
|
||||||
|
@ -36,7 +36,7 @@ impl Render for CollabNotificationStory {
|
||||||
"Project Shared Notification",
|
"Project Shared Notification",
|
||||||
window_container(400., 72.).child(
|
window_container(400., 72.).child(
|
||||||
CollabNotification::new(
|
CollabNotification::new(
|
||||||
SharedUrl::network("https://avatars.githubusercontent.com/u/1714999?v=4"),
|
SharedUri::network("https://avatars.githubusercontent.com/u/1714999?v=4"),
|
||||||
Button::new("open", "Open"),
|
Button::new("open", "Open"),
|
||||||
Button::new("dismiss", "Dismiss"),
|
Button::new("dismiss", "Dismiss"),
|
||||||
)
|
)
|
||||||
|
|
|
@ -3,7 +3,7 @@ use gpui::*;
|
||||||
#[derive(IntoElement)]
|
#[derive(IntoElement)]
|
||||||
struct ImageFromResource {
|
struct ImageFromResource {
|
||||||
text: SharedString,
|
text: SharedString,
|
||||||
resource: SharedUrl,
|
resource: SharedUri,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl RenderOnce for ImageFromResource {
|
impl RenderOnce for ImageFromResource {
|
||||||
|
@ -20,8 +20,8 @@ impl RenderOnce for ImageFromResource {
|
||||||
}
|
}
|
||||||
|
|
||||||
struct ImageShowcase {
|
struct ImageShowcase {
|
||||||
local_resource: SharedUrl,
|
local_resource: SharedUri,
|
||||||
remote_resource: SharedUrl,
|
remote_resource: SharedUri,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Render for ImageShowcase {
|
impl Render for ImageShowcase {
|
||||||
|
@ -51,8 +51,8 @@ fn main() {
|
||||||
App::new().run(|cx: &mut AppContext| {
|
App::new().run(|cx: &mut AppContext| {
|
||||||
cx.open_window(WindowOptions::default(), |cx| {
|
cx.open_window(WindowOptions::default(), |cx| {
|
||||||
cx.new_view(|_cx| ImageShowcase {
|
cx.new_view(|_cx| ImageShowcase {
|
||||||
local_resource: SharedUrl::file("../zed/resources/app-icon.png"),
|
local_resource: SharedUri::file("../zed/resources/app-icon.png"),
|
||||||
remote_resource: SharedUrl::network("https://picsum.photos/512/512"),
|
remote_resource: SharedUri::network("https://picsum.photos/512/512"),
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -2,7 +2,7 @@ use std::sync::Arc;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
point, size, Bounds, DevicePixels, Element, ElementContext, ImageData, InteractiveElement,
|
point, size, Bounds, DevicePixels, Element, ElementContext, ImageData, InteractiveElement,
|
||||||
InteractiveElementState, Interactivity, IntoElement, LayoutId, Pixels, SharedUrl, Size,
|
InteractiveElementState, Interactivity, IntoElement, LayoutId, Pixels, SharedUri, Size,
|
||||||
StyleRefinement, Styled,
|
StyleRefinement, Styled,
|
||||||
};
|
};
|
||||||
use futures::FutureExt;
|
use futures::FutureExt;
|
||||||
|
@ -13,7 +13,7 @@ use util::ResultExt;
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, Debug)]
|
||||||
pub enum ImageSource {
|
pub enum ImageSource {
|
||||||
/// Image content will be loaded from provided URI at render time.
|
/// Image content will be loaded from provided URI at render time.
|
||||||
Uri(SharedUrl),
|
Uri(SharedUri),
|
||||||
/// Cached image data
|
/// Cached image data
|
||||||
Data(Arc<ImageData>),
|
Data(Arc<ImageData>),
|
||||||
// TODO: move surface definitions into mac platform module
|
// TODO: move surface definitions into mac platform module
|
||||||
|
@ -21,8 +21,8 @@ pub enum ImageSource {
|
||||||
Surface(CVImageBuffer),
|
Surface(CVImageBuffer),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<SharedUrl> for ImageSource {
|
impl From<SharedUri> for ImageSource {
|
||||||
fn from(value: SharedUrl) -> Self {
|
fn from(value: SharedUri) -> Self {
|
||||||
Self::Uri(value)
|
Self::Uri(value)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -83,7 +83,7 @@ mod platform;
|
||||||
pub mod prelude;
|
pub mod prelude;
|
||||||
mod scene;
|
mod scene;
|
||||||
mod shared_string;
|
mod shared_string;
|
||||||
mod shared_url;
|
mod shared_uri;
|
||||||
mod style;
|
mod style;
|
||||||
mod styled;
|
mod styled;
|
||||||
mod subscription;
|
mod subscription;
|
||||||
|
@ -133,7 +133,7 @@ pub use refineable::*;
|
||||||
pub use scene::*;
|
pub use scene::*;
|
||||||
use seal::Sealed;
|
use seal::Sealed;
|
||||||
pub use shared_string::*;
|
pub use shared_string::*;
|
||||||
pub use shared_url::*;
|
pub use shared_uri::*;
|
||||||
pub use smol::Timer;
|
pub use smol::Timer;
|
||||||
pub use style::*;
|
pub use style::*;
|
||||||
pub use styled::*;
|
pub use styled::*;
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
use crate::{AppContext, ImageData, ImageId, SharedUrl, Task};
|
use crate::{AppContext, ImageData, ImageId, SharedUri, Task};
|
||||||
use collections::HashMap;
|
use collections::HashMap;
|
||||||
use futures::{future::Shared, AsyncReadExt, FutureExt, TryFutureExt};
|
use futures::{future::Shared, AsyncReadExt, FutureExt, TryFutureExt};
|
||||||
use image::ImageError;
|
use image::ImageError;
|
||||||
|
@ -41,7 +41,7 @@ impl From<ImageError> for Error {
|
||||||
|
|
||||||
pub(crate) struct ImageCache {
|
pub(crate) struct ImageCache {
|
||||||
client: Arc<dyn HttpClient>,
|
client: Arc<dyn HttpClient>,
|
||||||
images: Arc<Mutex<HashMap<SharedUrl, FetchImageTask>>>,
|
images: Arc<Mutex<HashMap<SharedUri, FetchImageTask>>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
type FetchImageTask = Shared<Task<Result<Arc<ImageData>, Error>>>;
|
type FetchImageTask = Shared<Task<Result<Arc<ImageData>, Error>>>;
|
||||||
|
@ -54,7 +54,7 @@ impl ImageCache {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get(&self, uri: impl Into<SharedUrl>, cx: &AppContext) -> FetchImageTask {
|
pub fn get(&self, uri: impl Into<SharedUri>, cx: &AppContext) -> FetchImageTask {
|
||||||
let uri = uri.into();
|
let uri = uri.into();
|
||||||
let mut images = self.images.lock();
|
let mut images = self.images.lock();
|
||||||
|
|
||||||
|
@ -69,11 +69,11 @@ impl ImageCache {
|
||||||
let uri = uri.clone();
|
let uri = uri.clone();
|
||||||
async move {
|
async move {
|
||||||
match uri {
|
match uri {
|
||||||
SharedUrl::File(uri) => {
|
SharedUri::File(uri) => {
|
||||||
let image = image::open(uri.as_ref())?.into_bgra8();
|
let image = image::open(uri.as_ref())?.into_bgra8();
|
||||||
Ok(Arc::new(ImageData::new(image)))
|
Ok(Arc::new(ImageData::new(image)))
|
||||||
}
|
}
|
||||||
SharedUrl::Network(uri) => {
|
SharedUri::Network(uri) => {
|
||||||
let mut response =
|
let mut response =
|
||||||
client.get(uri.as_ref(), ().into(), true).await?;
|
client.get(uri.as_ref(), ().into(), true).await?;
|
||||||
let mut body = Vec::new();
|
let mut body = Vec::new();
|
||||||
|
|
|
@ -2,34 +2,34 @@ use std::ops::{Deref, DerefMut};
|
||||||
|
|
||||||
use crate::SharedString;
|
use crate::SharedString;
|
||||||
|
|
||||||
/// A URL stored in a `SharedString` pointing to a file or a remote resource.
|
/// A URI stored in a [`SharedString`].
|
||||||
#[derive(PartialEq, Eq, Hash, Clone)]
|
#[derive(PartialEq, Eq, Hash, Clone)]
|
||||||
pub enum SharedUrl {
|
pub enum SharedUri {
|
||||||
/// A path to a local file.
|
/// A path to a local file.
|
||||||
File(SharedString),
|
File(SharedString),
|
||||||
/// A URL to a remote resource.
|
/// A URL to a remote resource.
|
||||||
Network(SharedString),
|
Network(SharedString),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl SharedUrl {
|
impl SharedUri {
|
||||||
/// Create a URL pointing to a local file.
|
/// Creates a [`SharedUri`] pointing to a local file.
|
||||||
pub fn file<S: Into<SharedString>>(s: S) -> Self {
|
pub fn file<S: Into<SharedString>>(s: S) -> Self {
|
||||||
Self::File(s.into())
|
Self::File(s.into())
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Create a URL pointing to a remote resource.
|
/// Creates a [`SharedUri`] pointing to a remote resource.
|
||||||
pub fn network<S: Into<SharedString>>(s: S) -> Self {
|
pub fn network<S: Into<SharedString>>(s: S) -> Self {
|
||||||
Self::Network(s.into())
|
Self::Network(s.into())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for SharedUrl {
|
impl Default for SharedUri {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
Self::Network(SharedString::default())
|
Self::Network(SharedString::default())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Deref for SharedUrl {
|
impl Deref for SharedUri {
|
||||||
type Target = SharedString;
|
type Target = SharedString;
|
||||||
|
|
||||||
fn deref(&self) -> &Self::Target {
|
fn deref(&self) -> &Self::Target {
|
||||||
|
@ -40,7 +40,7 @@ impl Deref for SharedUrl {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl DerefMut for SharedUrl {
|
impl DerefMut for SharedUri {
|
||||||
fn deref_mut(&mut self) -> &mut Self::Target {
|
fn deref_mut(&mut self) -> &mut Self::Target {
|
||||||
match self {
|
match self {
|
||||||
Self::File(s) => s,
|
Self::File(s) => s,
|
||||||
|
@ -49,7 +49,7 @@ impl DerefMut for SharedUrl {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl std::fmt::Debug for SharedUrl {
|
impl std::fmt::Debug for SharedUri {
|
||||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||||
match self {
|
match self {
|
||||||
Self::File(s) => write!(f, "File({:?})", s),
|
Self::File(s) => write!(f, "File({:?})", s),
|
||||||
|
@ -58,7 +58,7 @@ impl std::fmt::Debug for SharedUrl {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl std::fmt::Display for SharedUrl {
|
impl std::fmt::Display for SharedUri {
|
||||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||||
write!(f, "{}", self.as_ref())
|
write!(f, "{}", self.as_ref())
|
||||||
}
|
}
|
|
@ -1,4 +1,4 @@
|
||||||
use gpui::{div, img, px, IntoElement, ParentElement, Render, SharedUrl, Styled, ViewContext};
|
use gpui::{div, img, px, IntoElement, ParentElement, Render, SharedUri, Styled, ViewContext};
|
||||||
use story::Story;
|
use story::Story;
|
||||||
|
|
||||||
use crate::{ActiveTheme, PlayerColors};
|
use crate::{ActiveTheme, PlayerColors};
|
||||||
|
@ -53,7 +53,7 @@ impl Render for PlayerStory {
|
||||||
.border_2()
|
.border_2()
|
||||||
.border_color(player.cursor)
|
.border_color(player.cursor)
|
||||||
.child(
|
.child(
|
||||||
img(SharedUrl::network(
|
img(SharedUri::network(
|
||||||
"https://avatars.githubusercontent.com/u/1714999?v=4",
|
"https://avatars.githubusercontent.com/u/1714999?v=4",
|
||||||
))
|
))
|
||||||
.rounded_full()
|
.rounded_full()
|
||||||
|
@ -84,7 +84,7 @@ impl Render for PlayerStory {
|
||||||
.border_color(player.background)
|
.border_color(player.background)
|
||||||
.size(px(28.))
|
.size(px(28.))
|
||||||
.child(
|
.child(
|
||||||
img(SharedUrl::network(
|
img(SharedUri::network(
|
||||||
"https://avatars.githubusercontent.com/u/1714999?v=4",
|
"https://avatars.githubusercontent.com/u/1714999?v=4",
|
||||||
))
|
))
|
||||||
.rounded_full()
|
.rounded_full()
|
||||||
|
@ -102,7 +102,7 @@ impl Render for PlayerStory {
|
||||||
.border_color(player.background)
|
.border_color(player.background)
|
||||||
.size(px(28.))
|
.size(px(28.))
|
||||||
.child(
|
.child(
|
||||||
img(SharedUrl::network(
|
img(SharedUri::network(
|
||||||
"https://avatars.githubusercontent.com/u/1714999?v=4",
|
"https://avatars.githubusercontent.com/u/1714999?v=4",
|
||||||
))
|
))
|
||||||
.rounded_full()
|
.rounded_full()
|
||||||
|
@ -120,7 +120,7 @@ impl Render for PlayerStory {
|
||||||
.border_color(player.background)
|
.border_color(player.background)
|
||||||
.size(px(28.))
|
.size(px(28.))
|
||||||
.child(
|
.child(
|
||||||
img(SharedUrl::network(
|
img(SharedUri::network(
|
||||||
"https://avatars.githubusercontent.com/u/1714999?v=4",
|
"https://avatars.githubusercontent.com/u/1714999?v=4",
|
||||||
))
|
))
|
||||||
.rounded_full()
|
.rounded_full()
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
use gpui::{Render, SharedUrl};
|
use gpui::{Render, SharedUri};
|
||||||
use story::{StoryContainer, StoryItem, StorySection};
|
use story::{StoryContainer, StoryItem, StorySection};
|
||||||
|
|
||||||
use crate::{prelude::*, AudioStatus, Availability, AvatarAvailabilityIndicator};
|
use crate::{prelude::*, AudioStatus, Availability, AvatarAvailabilityIndicator};
|
||||||
|
@ -13,13 +13,13 @@ impl Render for AvatarStory {
|
||||||
StorySection::new()
|
StorySection::new()
|
||||||
.child(StoryItem::new(
|
.child(StoryItem::new(
|
||||||
"Default",
|
"Default",
|
||||||
Avatar::new(SharedUrl::network(
|
Avatar::new(SharedUri::network(
|
||||||
"https://avatars.githubusercontent.com/u/1714999?v=4",
|
"https://avatars.githubusercontent.com/u/1714999?v=4",
|
||||||
)),
|
)),
|
||||||
))
|
))
|
||||||
.child(StoryItem::new(
|
.child(StoryItem::new(
|
||||||
"Default",
|
"Default",
|
||||||
Avatar::new(SharedUrl::network(
|
Avatar::new(SharedUri::network(
|
||||||
"https://avatars.githubusercontent.com/u/326587?v=4",
|
"https://avatars.githubusercontent.com/u/326587?v=4",
|
||||||
)),
|
)),
|
||||||
)),
|
)),
|
||||||
|
@ -28,14 +28,14 @@ impl Render for AvatarStory {
|
||||||
StorySection::new()
|
StorySection::new()
|
||||||
.child(StoryItem::new(
|
.child(StoryItem::new(
|
||||||
"With free availability indicator",
|
"With free availability indicator",
|
||||||
Avatar::new(SharedUrl::network(
|
Avatar::new(SharedUri::network(
|
||||||
"https://avatars.githubusercontent.com/u/326587?v=4",
|
"https://avatars.githubusercontent.com/u/326587?v=4",
|
||||||
))
|
))
|
||||||
.indicator(AvatarAvailabilityIndicator::new(Availability::Free)),
|
.indicator(AvatarAvailabilityIndicator::new(Availability::Free)),
|
||||||
))
|
))
|
||||||
.child(StoryItem::new(
|
.child(StoryItem::new(
|
||||||
"With busy availability indicator",
|
"With busy availability indicator",
|
||||||
Avatar::new(SharedUrl::network(
|
Avatar::new(SharedUri::network(
|
||||||
"https://avatars.githubusercontent.com/u/326587?v=4",
|
"https://avatars.githubusercontent.com/u/326587?v=4",
|
||||||
))
|
))
|
||||||
.indicator(AvatarAvailabilityIndicator::new(Availability::Busy)),
|
.indicator(AvatarAvailabilityIndicator::new(Availability::Busy)),
|
||||||
|
@ -45,14 +45,14 @@ impl Render for AvatarStory {
|
||||||
StorySection::new()
|
StorySection::new()
|
||||||
.child(StoryItem::new(
|
.child(StoryItem::new(
|
||||||
"With info border",
|
"With info border",
|
||||||
Avatar::new(SharedUrl::network(
|
Avatar::new(SharedUri::network(
|
||||||
"https://avatars.githubusercontent.com/u/326587?v=4",
|
"https://avatars.githubusercontent.com/u/326587?v=4",
|
||||||
))
|
))
|
||||||
.border_color(cx.theme().status().info_border),
|
.border_color(cx.theme().status().info_border),
|
||||||
))
|
))
|
||||||
.child(StoryItem::new(
|
.child(StoryItem::new(
|
||||||
"With error border",
|
"With error border",
|
||||||
Avatar::new(SharedUrl::network(
|
Avatar::new(SharedUri::network(
|
||||||
"https://avatars.githubusercontent.com/u/326587?v=4",
|
"https://avatars.githubusercontent.com/u/326587?v=4",
|
||||||
))
|
))
|
||||||
.border_color(cx.theme().status().error_border),
|
.border_color(cx.theme().status().error_border),
|
||||||
|
@ -62,14 +62,14 @@ impl Render for AvatarStory {
|
||||||
StorySection::new()
|
StorySection::new()
|
||||||
.child(StoryItem::new(
|
.child(StoryItem::new(
|
||||||
"With muted audio indicator",
|
"With muted audio indicator",
|
||||||
Avatar::new(SharedUrl::network(
|
Avatar::new(SharedUri::network(
|
||||||
"https://avatars.githubusercontent.com/u/326587?v=4",
|
"https://avatars.githubusercontent.com/u/326587?v=4",
|
||||||
))
|
))
|
||||||
.indicator(AvatarAudioStatusIndicator::new(AudioStatus::Muted)),
|
.indicator(AvatarAudioStatusIndicator::new(AudioStatus::Muted)),
|
||||||
))
|
))
|
||||||
.child(StoryItem::new(
|
.child(StoryItem::new(
|
||||||
"With deafened audio indicator",
|
"With deafened audio indicator",
|
||||||
Avatar::new(SharedUrl::network(
|
Avatar::new(SharedUri::network(
|
||||||
"https://avatars.githubusercontent.com/u/326587?v=4",
|
"https://avatars.githubusercontent.com/u/326587?v=4",
|
||||||
))
|
))
|
||||||
.indicator(AvatarAudioStatusIndicator::new(AudioStatus::Deafened)),
|
.indicator(AvatarAudioStatusIndicator::new(AudioStatus::Deafened)),
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
use gpui::{Render, SharedUrl};
|
use gpui::{Render, SharedUri};
|
||||||
use story::Story;
|
use story::Story;
|
||||||
|
|
||||||
use crate::{prelude::*, Avatar};
|
use crate::{prelude::*, Avatar};
|
||||||
|
@ -45,7 +45,7 @@ impl Render for ListItemStory {
|
||||||
.child(
|
.child(
|
||||||
ListItem::new("with_start slot avatar")
|
ListItem::new("with_start slot avatar")
|
||||||
.child("Hello, world!")
|
.child("Hello, world!")
|
||||||
.start_slot(Avatar::new(SharedUrl::network(
|
.start_slot(Avatar::new(SharedUri::network(
|
||||||
"https://avatars.githubusercontent.com/u/1714999?v=4",
|
"https://avatars.githubusercontent.com/u/1714999?v=4",
|
||||||
))),
|
))),
|
||||||
)
|
)
|
||||||
|
@ -53,7 +53,7 @@ impl Render for ListItemStory {
|
||||||
.child(
|
.child(
|
||||||
ListItem::new("with_left_avatar")
|
ListItem::new("with_left_avatar")
|
||||||
.child("Hello, world!")
|
.child("Hello, world!")
|
||||||
.end_slot(Avatar::new(SharedUrl::network(
|
.end_slot(Avatar::new(SharedUri::network(
|
||||||
"https://avatars.githubusercontent.com/u/1714999?v=4",
|
"https://avatars.githubusercontent.com/u/1714999?v=4",
|
||||||
))),
|
))),
|
||||||
)
|
)
|
||||||
|
@ -64,23 +64,23 @@ impl Render for ListItemStory {
|
||||||
.end_slot(
|
.end_slot(
|
||||||
h_flex()
|
h_flex()
|
||||||
.gap_2()
|
.gap_2()
|
||||||
.child(Avatar::new(SharedUrl::network(
|
.child(Avatar::new(SharedUri::network(
|
||||||
"https://avatars.githubusercontent.com/u/1789?v=4",
|
"https://avatars.githubusercontent.com/u/1789?v=4",
|
||||||
)))
|
)))
|
||||||
.child(Avatar::new(SharedUrl::network(
|
.child(Avatar::new(SharedUri::network(
|
||||||
"https://avatars.githubusercontent.com/u/1789?v=4",
|
"https://avatars.githubusercontent.com/u/1789?v=4",
|
||||||
)))
|
)))
|
||||||
.child(Avatar::new(SharedUrl::network(
|
.child(Avatar::new(SharedUri::network(
|
||||||
"https://avatars.githubusercontent.com/u/1789?v=4",
|
"https://avatars.githubusercontent.com/u/1789?v=4",
|
||||||
)))
|
)))
|
||||||
.child(Avatar::new(SharedUrl::network(
|
.child(Avatar::new(SharedUri::network(
|
||||||
"https://avatars.githubusercontent.com/u/1789?v=4",
|
"https://avatars.githubusercontent.com/u/1789?v=4",
|
||||||
)))
|
)))
|
||||||
.child(Avatar::new(SharedUrl::network(
|
.child(Avatar::new(SharedUri::network(
|
||||||
"https://avatars.githubusercontent.com/u/1789?v=4",
|
"https://avatars.githubusercontent.com/u/1789?v=4",
|
||||||
))),
|
))),
|
||||||
)
|
)
|
||||||
.end_hover_slot(Avatar::new(SharedUrl::network(
|
.end_hover_slot(Avatar::new(SharedUri::network(
|
||||||
"https://avatars.githubusercontent.com/u/1714999?v=4",
|
"https://avatars.githubusercontent.com/u/1714999?v=4",
|
||||||
))),
|
))),
|
||||||
)
|
)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue