use gpui_kit::component::{
Sizable as _, Size,
avatar::{Avatar, AvatarGroup},
};
use gpui_kit::prelude::FluentBuilder as _;
use gpui_kit::{RenderImage, SharedString, Styled as _, px};
use crate::Tokens;
use std::sync::Arc;
mod agent;
mod crew;
mod external;
mod icons;
pub use agent::{AgentAvatar, AgentRank, MARK_SIZE_PX, agent, agent_icon};
pub use crew::{CrewMeter, MAX_DOTS as CREW_METER_MAX_DOTS, activity_dot, crew_meter};
pub use external::{ExternalAvatar, external};
pub(crate) use icons::initialize as initialize_icons;
pub use icons::{AgentIcons, DEFAULT_AGENT_ICONS, PREFERENCE_KEY as AGENT_ICONS_KEY};
const AVATAR_SIZE_PX: f32 = 24.0;
pub const SENDER_SIZE_PX: f32 = 32.0;
pub const MEMBER_SIZE_PX: f32 = 16.0;
const GROUP_AVATAR_LIMIT: usize = 2;
pub fn person(name: impl Into<SharedString>, photo: Option<Arc<RenderImage>>) -> Avatar {
let name = name.into();
Avatar::new()
.name(name)
.small()
.when_some(photo, |avatar, image| avatar.src(image))
}
pub fn sender(name: impl Into<SharedString>, tokens: &Tokens) -> Avatar {
Avatar::new()
.name(name)
.with_size(Size::Size(px(SENDER_SIZE_PX)))
.text_size(tokens.secondary_size())
.rounded(tokens.surface_radius)
}
pub fn member(name: impl Into<SharedString>, tokens: &Tokens) -> Avatar {
Avatar::new()
.name(name)
.xsmall()
.rounded(tokens.control_radius)
}
pub fn group(people: impl IntoIterator<Item = Avatar>) -> AvatarGroup {
let people: Vec<_> = people.into_iter().take(GROUP_AVATAR_LIMIT).collect();
AvatarGroup::new()
.small()
.limit(GROUP_AVATAR_LIMIT)
.flex_shrink_0()
.w(px(AVATAR_SIZE_PX * GROUP_AVATAR_LIMIT as f32))
.children(people)
}