import { Theme, ActionButton } from "theme.slint"; export struct VoiceMemberItem { user_id: string, nickname: string, speaking: bool, avatar_text: string } 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-out property push-to-talk; callback preview-screen(); callback ptt-held(bool); callback toggle-mic(); callback toggle-deafen(); callback leave-voice(); background: Theme.bg-base; VerticalLayout { spacing: 0; Rectangle { height: 56px; border-width: 1px; border-color: Theme.border; HorizontalLayout { padding-left: 22px; spacing: 12px; Text { text: "◖"; color: Theme.text-muted; font-size: Math.max(11px, Theme.font-size * 1.4375); width: 20px; vertical-alignment: center; } 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; } Rectangle { horizontal-stretch: 1; } ActionButton { text: @tr("Screen preview"); clicked => { root.preview-screen(); } } } } VerticalLayout { padding: 24px; spacing: 16px; Text { text: @tr("{n} participant" | "{n} participants" % root.members.length); color: Theme.text-muted; font-size: Math.max(11px, Theme.font-size * 0.8125); } Flickable { content-width: self.width; VerticalLayout { spacing: 12px; for member in root.members: Rectangle { height: 120px; border-radius: 12px; background: Theme.bg-interactive; border-width: member.speaking ? 2px : 1px; border-color: member.speaking ? Theme.success : Theme.border; HorizontalLayout { padding: 24px; spacing: 18px; Rectangle { width: 58px; height: 58px; border-radius: 20px; background: Theme.avatar-bg; Text { text: member.avatar_text; color: Theme.accent; font-size: Math.max(11px, Theme.font-size * 1.625); horizontal-alignment: center; vertical-alignment: center; } } VerticalLayout { spacing: 5px; Text { text: member.nickname; color: Theme.text-primary; font-size: Math.max(11px, Theme.font-size * 1.0625); } Text { text: member.speaking ? @tr("Speaking") : @tr("In voice"); color: member.speaking ? Theme.success : Theme.text-muted; font-size: Math.max(11px, Theme.font-size * 0.75); } } Rectangle { horizontal-stretch: 1; } } } if root.members.length == 0 : Text { text: @tr("Joining voice…"); color: Theme.text-muted; font-size: Math.max(11px, Theme.font-size * 0.875); } Rectangle { vertical-stretch: 1; } } } if root.push-to-talk : Rectangle { height: 46px; background: ptt-area.pressed ? Theme.voice-bg : Theme.bg-interactive; border-radius: 8px; border-width: ptt-focus.has-focus ? 1px : 0px; border-color: Theme.accent; accessible-role: button; accessible-label: @tr("Push to talk"); 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); horizontal-alignment: center; vertical-alignment: center; } ptt-area := TouchArea { clicked => { ptt-focus.focus(); } changed pressed => { root.ptt-held(self.pressed); } } ptt-focus := FocusScope { 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.activity-banner; color: Theme.success; font-size: Math.max(11px, Theme.font-size * 0.8125); height: 22px; } HorizontalLayout { spacing: 10px; Rectangle { horizontal-stretch: 1; } ActionButton { text: root.mic-enabled ? @tr("Mute microphone") : @tr("Unmute microphone"); danger: !root.mic-enabled; clicked => { root.toggle-mic(); } } ActionButton { text: root.deafened ? @tr("Undeafen") : @tr("Deafen"); danger: root.deafened; clicked => { root.toggle-deafen(); } } ActionButton { text: @tr("Leave room"); danger: true; clicked => { root.leave-voice(); } } Rectangle { horizontal-stretch: 1; } } } } }