On the phone's Servers tab the top bar showed the server's name and counts,
which the server card right below it shows too, and the voice card named
the server again ("Chill Zone / Nightfall Guild"). The top bar now says
Servers, as the Activity and You tabs say their names; the server card
stays the one place for the name, the counts, the banner and its Edit
server / Add a server menu. The voice card shows only the channel, on
desktop too; while connecting, before there is a channel, it shows
Connecting… alone.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AVRENKftQqGoEeswiR9TDQ
266 lines
11 KiB
Plaintext
266 lines
11 KiB
Plaintext
// Pieces both shells use: the voice controls and the user card.
|
||
|
||
import { Theme } from "../theme.slint";
|
||
import { Icons } from "../icons.slint";
|
||
import { Bridge } from "../bridge.slint";
|
||
import { Nav, SettingsSection } from "../nav.slint";
|
||
import { StudioBridge } from "../studio-bridge.slint";
|
||
import { ShareMenu } from "../share-menu.slint";
|
||
import { Icon, IconButton, FocusRing, Avatar, Status } from "../components/index.slint";
|
||
|
||
// A rounded panel of the frame (sidebar, main area, right panel).
|
||
export component Panel inherits Rectangle {
|
||
background: Theme.surface.transparentize(0.08);
|
||
border-radius: Theme.radius-xl;
|
||
border-width: 1px;
|
||
border-color: Theme.border;
|
||
clip: true;
|
||
}
|
||
|
||
// Push-to-talk in the window: talks while held.
|
||
export component HoldToTalk inherits Rectangle {
|
||
height: Theme.control-height;
|
||
border-radius: Theme.radius-md;
|
||
background: Bridge.transmitting ? Theme.success.transparentize(0.2) : ptt-area.has-hover ? Theme.surface-3 : Theme.surface-2;
|
||
border-width: 1px;
|
||
border-color: Bridge.transmitting ? Theme.success : Theme.border;
|
||
opacity: Bridge.voice-connected ? 1.0 : 0.4;
|
||
accessible-role: AccessibleRole.button;
|
||
accessible-label: @tr("Hold to talk");
|
||
accessible-enabled: Bridge.voice-connected;
|
||
accessible-checkable: true;
|
||
accessible-checked: Bridge.transmitting;
|
||
accessible-action-default => { Bridge.push-to-talk(!Bridge.transmitting); }
|
||
HorizontalLayout {
|
||
alignment: center;
|
||
spacing: Theme.space-2;
|
||
Icon {
|
||
source: Icons.mic;
|
||
size: Theme.icon-sm;
|
||
tint: Bridge.transmitting ? Theme.on-accent : Theme.text-secondary;
|
||
y: (parent.height - self.height) / 2;
|
||
}
|
||
Text {
|
||
text: Bridge.transmitting ? @tr("Talking…") : @tr("Hold to talk");
|
||
color: Bridge.transmitting ? Theme.on-accent : Theme.text-secondary;
|
||
font-size: Theme.font-sm;
|
||
font-weight: Theme.weight-medium;
|
||
vertical-alignment: center;
|
||
}
|
||
}
|
||
ptt-area := TouchArea {
|
||
enabled: Bridge.voice-connected;
|
||
pointer-event(e) => {
|
||
if e.kind == PointerEventKind.down {
|
||
Bridge.push-to-talk(true);
|
||
} else if e.kind == PointerEventKind.up || e.kind == PointerEventKind.cancel {
|
||
Bridge.push-to-talk(false);
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
// "Voice Connected" and our channel, disconnect, and hold-to-talk with
|
||
// push-to-talk.
|
||
export component VoiceCard inherits Rectangle {
|
||
border-radius: Theme.radius-lg;
|
||
background: Theme.surface-2;
|
||
border-width: 1px;
|
||
border-color: Theme.border;
|
||
accessible-role: AccessibleRole.groupbox;
|
||
accessible-label: @tr("Voice");
|
||
// The phone: a tap opens the voice channel screen.
|
||
if Nav.narrow && Bridge.voice-connected: TouchArea {
|
||
clicked => { Nav.show-voice(true); }
|
||
}
|
||
VerticalLayout {
|
||
padding: Theme.space-3;
|
||
spacing: Theme.space-3;
|
||
HorizontalLayout {
|
||
spacing: Theme.space-3;
|
||
Rectangle {
|
||
width: 10px;
|
||
height: 10px;
|
||
y: (parent.height - self.height) / 2;
|
||
border-radius: 5px;
|
||
background: Bridge.voice-connected ? Theme.success : Theme.warning;
|
||
}
|
||
VerticalLayout {
|
||
horizontal-stretch: 1;
|
||
alignment: center;
|
||
Text {
|
||
text: Bridge.voice-connected ? @tr("Voice Connected") : @tr("Connecting…");
|
||
color: Bridge.voice-connected ? Theme.success : Theme.warning;
|
||
font-size: Theme.font-sm;
|
||
font-weight: Theme.weight-semibold;
|
||
}
|
||
// Our channel; none yet while connecting.
|
||
if Bridge.own-channel != "": Text {
|
||
text: Bridge.own-channel;
|
||
color: Theme.text-muted;
|
||
font-size: Theme.font-xs;
|
||
overflow: elide;
|
||
}
|
||
}
|
||
if Nav.narrow && Bridge.voice-connected: IconButton {
|
||
icon: Icons.chevron-right;
|
||
label: @tr("Open the voice channel");
|
||
size: 32px;
|
||
icon-size: Theme.icon-sm;
|
||
y: (parent.height - self.height) / 2;
|
||
clicked => { Nav.show-voice(true); }
|
||
}
|
||
IconButton {
|
||
icon: Icons.phone-off;
|
||
label: @tr("Disconnect");
|
||
size: 32px;
|
||
icon-size: Theme.icon-sm;
|
||
tint: Theme.danger;
|
||
y: (parent.height - self.height) / 2;
|
||
clicked => { Bridge.disconnect-voice(); }
|
||
}
|
||
}
|
||
if Bridge.voice-connected && Bridge.audio.transmit == 0: HoldToTalk { }
|
||
}
|
||
}
|
||
|
||
// Mute, deafen, share, and with `gear` the voice settings. `round` and
|
||
// `filled` are the voice view's call bar.
|
||
export component VoiceButtons inherits HorizontalLayout {
|
||
in property <length> size: 34px;
|
||
// The rail has the settings; the user card leaves them out.
|
||
in property <bool> gear: false;
|
||
in property <bool> round;
|
||
in property <bool> filled;
|
||
spacing: Theme.space-1;
|
||
IconButton {
|
||
icon: Bridge.input-muted ? Icons.mic-off : Icons.mic;
|
||
label: Bridge.input-muted ? @tr("Microphone off") : @tr("Microphone on");
|
||
checked: Bridge.input-muted;
|
||
danger: true;
|
||
size: root.size;
|
||
round: root.round;
|
||
filled: root.filled;
|
||
enabled: Bridge.voice-connected;
|
||
clicked => { Bridge.set-input-muted(!Bridge.input-muted); }
|
||
}
|
||
IconButton {
|
||
icon: Bridge.output-muted ? Icons.headphone-off : Icons.headphones;
|
||
label: Bridge.output-muted ? @tr("Sound off") : @tr("Sound on");
|
||
checked: Bridge.output-muted;
|
||
danger: true;
|
||
size: root.size;
|
||
round: root.round;
|
||
filled: root.filled;
|
||
enabled: Bridge.voice-connected;
|
||
clicked => { Bridge.set-output-muted(!Bridge.output-muted); }
|
||
}
|
||
// A screen or window, or the Stream Studio (ShareMenu).
|
||
if Bridge.streams-available && Bridge.can-share: VerticalLayout {
|
||
IconButton {
|
||
icon: Icons.monitor-up;
|
||
label: Bridge.share-state == "live" ? @tr("Sharing") : StudioBridge.status.live ? @tr("Live in the Stream Studio") : @tr("Share or go live");
|
||
checked: Bridge.share-state == "live" || StudioBridge.status.live;
|
||
size: root.size;
|
||
round: root.round;
|
||
filled: root.filled;
|
||
clicked => { share-menu.open(0, - root.size - share-menu.menu-height - 4px); }
|
||
}
|
||
share-menu := ShareMenu { }
|
||
}
|
||
if root.gear: IconButton {
|
||
icon: Icons.settings;
|
||
label: @tr("Voice Settings");
|
||
size: root.size;
|
||
round: root.round;
|
||
filled: root.filled;
|
||
clicked => { Nav.open-settings(SettingsSection.voice); }
|
||
}
|
||
}
|
||
|
||
// The primary app profile, with current server voice status and controls.
|
||
// The avatar and the name open Settings › Account.
|
||
export component UserCard inherits Rectangle {
|
||
min-height: 60px;
|
||
border-radius: Theme.radius-lg;
|
||
background: Theme.surface-2.transparentize(0.3);
|
||
accessible-role: AccessibleRole.groupbox;
|
||
accessible-label: @tr("You");
|
||
HorizontalLayout {
|
||
padding: Theme.space-2;
|
||
spacing: Theme.space-2;
|
||
profile := Rectangle {
|
||
horizontal-stretch: 1;
|
||
border-radius: Theme.radius-md;
|
||
background: profile-touch.pressed ? Theme.surface-4 : profile-touch.has-hover ? Theme.surface-3 : transparent;
|
||
accessible-role: AccessibleRole.button;
|
||
accessible-label: @tr("Your profile");
|
||
accessible-description: Bridge.primary-name;
|
||
accessible-action-default => { Nav.open-settings(SettingsSection.account); }
|
||
FocusRing {
|
||
shown: profile-focus.has-focus;
|
||
w: profile.width;
|
||
h: profile.height;
|
||
}
|
||
profile-focus := FocusScope {
|
||
key-pressed(event) => {
|
||
if event.text == " " || event.text == "\n" {
|
||
Nav.open-settings(SettingsSection.account);
|
||
return accept;
|
||
}
|
||
reject
|
||
}
|
||
profile-touch := TouchArea {
|
||
mouse-cursor: MouseCursor.pointer;
|
||
clicked => {
|
||
profile-focus.focus();
|
||
Nav.open-settings(SettingsSection.account);
|
||
}
|
||
}
|
||
}
|
||
HorizontalLayout {
|
||
padding-left: Theme.space-2;
|
||
padding-right: Theme.space-2;
|
||
spacing: Theme.space-3;
|
||
VerticalLayout {
|
||
alignment: center;
|
||
Avatar {
|
||
size: 38px;
|
||
initials: Bridge.myts.signed-in || Bridge.nickname != "" ? "" : "?";
|
||
// The server's avatar for us, else the account's.
|
||
image: Bridge.own-avatar.width > 0 ? Bridge.own-avatar : Bridge.myts.avatar;
|
||
tint: Theme.accent;
|
||
label: Bridge.primary-name;
|
||
// Green ring while our voice goes out.
|
||
speaking: Bridge.transmitting;
|
||
status: Bridge.voice-connected ? Status.online : Bridge.observing ? Status.info : Status.offline;
|
||
Icon {
|
||
source: Icons.user;
|
||
size: 20px;
|
||
tint: #ffffff;
|
||
visible: (Bridge.myts.signed-in || Bridge.nickname != "") && Bridge.own-avatar.width == 0 && Bridge.myts.avatar.width == 0;
|
||
}
|
||
}
|
||
}
|
||
VerticalLayout {
|
||
alignment: center;
|
||
horizontal-stretch: 1;
|
||
Text {
|
||
text: Bridge.primary-name;
|
||
color: Theme.text;
|
||
font-weight: Theme.weight-semibold;
|
||
overflow: elide;
|
||
}
|
||
Text {
|
||
text: Bridge.voice-connected ? @tr("Online") : Bridge.observing ? @tr("Observing") : @tr("Offline");
|
||
color: Theme.text-muted;
|
||
font-size: Theme.font-xs;
|
||
overflow: elide;
|
||
}
|
||
}
|
||
}
|
||
}
|
||
VoiceButtons { }
|
||
}
|
||
}
|