import { AvatarView } from "avatar-view.slint"; import { Theme, ActionButton, Symbol, TipBubble } from "theme.slint"; export struct VoiceMemberItem { avatar: image, has_avatar: bool, user_id: string, nickname: string, speaking: bool, avatar_text: string, is_own: bool } /// Round control of the voice room bar. `off` shows the muted state highlighted in red. component RoundControl inherits Rectangle { in property icon; in property tooltip; in property off: false; in property leave: false; callback clicked(); width: 52px; height: 52px; border-radius: 26px; background: root.leave ? (touch.has-hover ? Theme.danger.darker(10%) : Theme.danger) : root.off ? Theme.danger.with-alpha(touch.has-hover ? 0.32 : 0.22) : touch.has-hover ? Theme.bg-hover : Theme.bg-interactive; border-width: keyboard.has-focus ? 2px : 1px; border-color: keyboard.has-focus ? Theme.accent : root.off ? Theme.danger.with-alpha(0.5) : Theme.border; accessible-role: button; accessible-label: root.tooltip; Symbol { kind: root.icon; ink: root.leave ? Theme.on-accent : root.off ? Theme.danger : Theme.text-primary; width: 22px; height: 22px; x: (parent.width - self.width) / 2; y: (parent.height - self.height) / 2; } touch := TouchArea { clicked => { keyboard.focus(); root.clicked(); } } keyboard := FocusScope { focus-on-click: false; key-pressed(event) => { if event.text == " " || event.text == "\n" { root.clicked(); return accept; } return reject; } } if root.tooltip != "" : Tooltip { TipBubble { text: root.tooltip; } } } component ParticipantCard inherits Rectangle { in property member; in property own-avatar; in property has-own-avatar; border-radius: 16px; background: Theme.bg-elevated; border-width: root.member.speaking ? 3px : 1px; border-color: root.member.speaking ? Theme.success : Theme.border; VerticalLayout { padding: 18px; spacing: 10px; alignment: center; HorizontalLayout { alignment: center; AvatarView { width: 80px; height: 80px; source: root.member.avatar; has-source: root.member.has_avatar; initials: root.member.avatar_text; mask: Theme.bg-elevated; speaking: root.member.speaking; } } Text { text: root.member.nickname; color: Theme.text-primary; font-size: Math.max(11px, Theme.font-size * 0.9375); font-weight: 600; horizontal-alignment: center; overflow: elide; } Text { text: root.member.speaking ? @tr("Speaking") : @tr("In voice"); color: root.member.speaking ? Theme.success : Theme.text-muted; font-size: Math.max(11px, Theme.font-size * 0.75); horizontal-alignment: center; } } } export component VoicePanel inherits Rectangle { in-out property <[VoiceMemberItem]> members; in-out property mic-enabled; in-out property deafened; in-out property channel-name; in-out property activity-banner; in property joining; in-out property push-to-talk; in property own-avatar; in property has-own-avatar; private property gap: 14px; private property columns: Math.max(1, Math.floor((grid.width + root.gap) / (210px + root.gap))); private property card-width: (grid.width - (root.columns - 1) * root.gap) / root.columns; callback preview-screen(); callback ptt-held(bool); callback toggle-mic(); callback toggle-deafen(); callback leave-voice(); background: @linear-gradient(180deg, Theme.bg-base 0%, Theme.bg-surface 100%); VerticalLayout { spacing: 0; Rectangle { height: 56px; border-width: 1px; border-color: Theme.border; HorizontalLayout { padding-left: 22px; padding-right: 16px; spacing: 10px; Symbol { kind: "volume-2"; ink: Theme.text-muted; width: 20px; height: 20px; y: (parent.height - self.height) / 2; } Text { text: root.channel-name; color: Theme.text-primary; font-size: Math.max(11px, Theme.font-size * 1.0); font-weight: 600; vertical-alignment: center; } Text { text: @tr("{n} participant" | "{n} participants" % root.members.length); color: Theme.text-muted; font-size: Math.max(11px, Theme.font-size * 0.8125); vertical-alignment: center; } Rectangle { horizontal-stretch: 1; } } } VerticalLayout { padding: 24px; spacing: 16px; grid := Flickable { content-width: self.width; content-height: Math.max(self.height, Math.ceil(root.members.length / root.columns) * (170px + root.gap)); for member[index] in root.members: ParticipantCard { x: Math.mod(index, root.columns) * (root.card-width + root.gap); y: Math.floor(index / root.columns) * (170px + root.gap); width: root.card-width; height: 170px; member: member; own-avatar: root.own-avatar; has-own-avatar: root.has-own-avatar; } if root.members.length == 0 : Text { text: @tr("Joining voice…"); color: Theme.text-muted; font-size: Math.max(11px, Theme.font-size * 0.875); } } if root.push-to-talk : Rectangle { height: 46px; background: ptt-area.pressed ? Theme.voice-bg : Theme.bg-interactive; border-radius: 10px; border-width: ptt-focus.has-focus ? 1px : 0px; border-color: Theme.accent; accessible-role: button; accessible-label: @tr("Push to talk"); HorizontalLayout { alignment: center; spacing: 10px; Symbol { kind: "mic"; ink: ptt-area.pressed ? Theme.success : Theme.text-secondary; width: 18px; height: 18px; y: (parent.height - self.height) / 2; } Text { text: ptt-area.pressed ? @tr("Microphone is transmitting") : @tr("Hold here to talk"); color: Theme.text-primary; font-size: Math.max(11px, Theme.font-size * 0.875); vertical-alignment: center; } } ptt-area := TouchArea { clicked => { ptt-focus.focus(); } changed pressed => { root.ptt-held(self.pressed); } } ptt-focus := FocusScope { focus-on-click: false; key-pressed(event) => { if event.text == " " { root.ptt-held(true); return accept; } return reject; } key-released(event) => { if event.text == " " { root.ptt-held(false); return accept; } return reject; } changed has-focus => { if !self.has-focus { root.ptt-held(false); } } } } Text { text: root.joining ? @tr("Joining voice…") : root.activity-banner; color: root.joining ? Theme.text-muted : Theme.success; font-size: Math.max(11px, Theme.font-size * 0.8125); height: 22px; horizontal-alignment: center; } HorizontalLayout { alignment: center; spacing: 14px; RoundControl { icon: root.mic-enabled ? "mic" : "mic-off"; off: !root.mic-enabled; tooltip: root.mic-enabled ? @tr("Mute microphone") : @tr("Unmute microphone"); clicked => { root.toggle-mic(); } } RoundControl { icon: root.deafened ? "headphone-off" : "headphones"; off: root.deafened; tooltip: root.deafened ? @tr("Undeafen") : @tr("Deafen"); clicked => { root.toggle-deafen(); } } RoundControl { icon: "screen-share"; tooltip: @tr("Screen preview"); clicked => { root.preview-screen(); } } RoundControl { icon: "phone-off"; leave: true; tooltip: @tr("Leave room"); clicked => { root.leave-voice(); } } } } } }