Files
VoelinClient/crates/voelin-ui/ui/components/badge.slint
T
Claude b452ccb236 ui: other people's badges, named on the member card and drawn after their name
Clients only send badge GUIDs. voelin-model names them from tsclientlib's
table plus the newer entries of TeamSpeak's own list, and the engine fetches
the first three pictures of each client from TeamSpeak's badge server
(<guid>/<filename>.svg, checked to answer) with the banners, under
cache.fetch_images.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AVRENKftQqGoEeswiR9TDQ
2026-10-06 20:16:37 +00:00

138 lines
4.1 KiB
Plaintext

import { Theme } from "../theme.slint";
import { Icon } from "icon.slint";
// A count bubble (unread, requests), red unless `fill` says otherwise.
export component CountBadge inherits Rectangle {
in property <int> count;
in property <color> fill: Theme.live;
// The number's colour.
in property <color> ink: Theme.on-accent;
width: max(18px, label.preferred-width + 10px);
height: 18px;
border-radius: 9px;
background: fill;
accessible-role: AccessibleRole.text;
accessible-label: count;
HorizontalLayout {
padding-left: 5px;
padding-right: 5px;
label := Text {
text: root.count > 99 ? "99+" : root.count;
color: root.ink;
font-size: Theme.font-xs;
font-weight: Theme.weight-bold;
horizontal-alignment: center;
vertical-alignment: center;
}
}
}
// The red LIVE tag.
export component LiveBadge inherits Rectangle {
in property <string> text: @tr("LIVE");
in property <bool> large;
height: large ? 26px : 18px;
width: label.preferred-width + (large ? 16px : 10px);
horizontal-stretch: 0;
vertical-stretch: 0;
border-radius: Theme.radius-xs;
background: Theme.live;
accessible-role: AccessibleRole.text;
accessible-label: text;
label := Text {
text: root.text;
color: #ffffff;
font-size: root.large ? Theme.font-body : Theme.font-xs;
font-weight: Theme.weight-bold;
horizontal-alignment: center;
vertical-alignment: center;
}
}
// A small rounded label: tags, stream facts ("1080p"), roles ("Moderator").
export component Chip inherits Rectangle {
in property <string> text;
in property <image> icon;
// A picture in its own colours (a badge's), instead of a tinted icon.
in property <image> picture;
in property <color> tint: Theme.text-secondary;
in property <brush> fill: Theme.surface-3;
in property <bool> outlined;
height: 22px;
width: row.preferred-width;
horizontal-stretch: 0;
vertical-stretch: 0;
border-radius: Theme.radius-pill;
background: fill;
border-width: outlined ? 1px : 0px;
border-color: Theme.border-strong;
accessible-role: AccessibleRole.text;
accessible-label: text;
row := HorizontalLayout {
padding-left: Theme.space-3;
padding-right: Theme.space-3;
spacing: Theme.space-2;
if root.icon.width > 0: Icon {
source: root.icon;
size: 12px;
tint: root.tint;
y: (parent.height - self.height) / 2;
}
if root.picture.width > 0: Image {
source: root.picture;
width: 14px;
height: 14px;
image-fit: contain;
y: (parent.height - self.height) / 2;
accessible-role: AccessibleRole.none;
}
Text {
text: root.text;
color: root.tint;
font-size: Theme.font-xs;
font-weight: Theme.weight-medium;
vertical-alignment: center;
}
}
}
// Up to three badge pictures in their own colours, 14 px high, after a
// name; empty ones take no room.
export component BadgeIcons inherits HorizontalLayout {
in property <image> first;
in property <image> second;
in property <image> third;
spacing: 2px;
cross-axis-alignment: center;
Image {
source: root.first;
width: root.first.width > 0 ? 14px : 0px;
height: 14px;
image-fit: contain;
accessible-role: AccessibleRole.none;
}
Image {
source: root.second;
width: root.second.width > 0 ? 14px : 0px;
height: 14px;
image-fit: contain;
accessible-role: AccessibleRole.none;
}
Image {
source: root.third;
width: root.third.width > 0 ? 14px : 0px;
height: 14px;
image-fit: contain;
accessible-role: AccessibleRole.none;
}
}
// A coloured dot (online, connection state).
export component Dot inherits Rectangle {
in property <length> size: 8px;
width: size;
height: size;
border-radius: size / 2;
background: Theme.success;
}