Files
VoelinClient/crates/voelin-ui/ui/screens/mobile-voice.slint
T
Claude 034ee44e60 ui: the phone's voice screen gets one header, room for chat and Hold to talk
The shell's top bar is the only header on the voice screen: Back, the
channel on its banner, the server below it. ChannelBar and ChatHeader are
gone, Pinned Messages and Topics are entries of the More menu, and Leave is
only in the bottom bar. The people strip and the scroll cap leave the chat
about 320 px at 390 x 844 (it had about 190).

With push-to-talk, Hold to talk is the bottom bar's middle control and the
composer's microphone button is gone; Go Live and Share are one Share
control that opens the share menu, as on desktop; the microphone button
reads Mic on or Mic off.

The audio form was only filled when the settings opened, so every start
showed push-to-talk controls whatever the stored mode; the transmit mode is
now set at start and when the setting changes.

VOELIN_OPEN=more opens the More menu for screenshots. The menu is not in a
layout, so Slint centred it in the bar and it opened 30 px low; it now sits
at the bar's corner.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AVRENKftQqGoEeswiR9TDQ
2026-10-08 17:34:15 +00:00

477 lines
17 KiB
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
// The voice channel on the phone (design mockup 02), under the shell's top
// bar (Back, the channel, the people, the chats and More): the stream we
// watch (or the streams to watch), the people in the channel, the channel's
// chat, and the voice controls at the bottom in place of the navigation.
import { Theme } from "../theme.slint";
import { Icons } from "../icons.slint";
import { Bridge } from "../bridge.slint";
import { Nav, MobileTab } from "../nav.slint";
import { Icon, IconButton, ActionButton, LiveBadge, Select, Slider, ScrollView } from "../components/index.slint";
import { MessageList, Composer } from "chat.slint";
import { Participant, StreamCard } from "voice-parts.slint";
import { StudioBridge } from "../studio-bridge.slint";
import { ShareMenu } from "../share-menu.slint";
export global PhoneVoice {
// The top bar's Back: a page over the screen (the pins, the topics or
// the members) first, then the screen.
public function back() {
if Nav.pins-open || Nav.topics-open || Nav.members-open {
close-pages();
} else {
close();
}
}
// Back to the navigation; a stream we watch goes on behind it. The pages
// over the screen close with it (they would show over the next tab).
public function close() {
close-pages();
if Bridge.viewer-open {
Bridge.hide-viewer();
}
Nav.show-voice(false);
}
function close-pages() {
Nav.pins-open = false;
Nav.topics-open = false;
Nav.members-open = false;
}
}
// A translucent pill over the picture.
component OverlayChip inherits Rectangle {
in property <string> text;
in property <image> icon;
height: 26px;
width: row.preferred-width;
border-radius: Theme.radius-pill;
background: #060a18b0;
border-width: 1px;
border-color: #ffffff24;
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: 14px;
tint: #ffffff;
y: (parent.height - self.height) / 2;
}
Text {
text: root.text;
color: #ffffff;
font-size: Theme.font-sm;
font-weight: Theme.weight-medium;
vertical-alignment: center;
}
}
}
// The stream we watch: the picture with LIVE, the viewers and the quality
// over its top, the title and who streams it over its bottom, and volume
// and full screen below them.
component PhonePlayer inherits Rectangle {
border-radius: Theme.radius-lg;
clip: true;
background: #000000;
border-width: 1px;
border-color: Theme.accent.transparentize(0.45);
accessible-role: AccessibleRole.groupbox;
accessible-label: Bridge.viewer-title;
Image {
width: parent.width;
height: parent.height;
source: Bridge.viewer-frame;
image-fit: contain;
visible: Bridge.viewer-has-frame;
accessible-role: AccessibleRole.image;
accessible-label: @tr("Stream picture");
}
if Bridge.viewer-status != "": Text {
width: parent.width - 48px;
text: Bridge.viewer-status;
color: #ffffff;
font-size: Theme.font-sm;
horizontal-alignment: center;
vertical-alignment: center;
wrap: word-wrap;
accessible-live-region: polite;
}
// Shades for what is drawn over the picture.
Rectangle {
y: 0;
height: 64px;
background: @linear-gradient(180deg, #000000b0 0%, #00000000 100%);
}
Rectangle {
y: parent.height - self.height;
height: 104px;
background: @linear-gradient(180deg, #00000000 0%, #000000d0 100%);
}
// LIVE, viewers; the quality and full screen.
HorizontalLayout {
y: Theme.space-3;
height: 30px;
padding-left: Theme.space-3;
padding-right: Theme.space-3;
spacing: Theme.space-2;
if !Bridge.viewer-ended: LiveBadge {
large: true;
y: (parent.height - self.height) / 2;
}
if Bridge.viewer-count > 0: OverlayChip {
icon: Icons.eye;
text: Bridge.viewer-count;
y: (parent.height - self.height) / 2;
}
Rectangle { horizontal-stretch: 1; }
// Simulcast layers the streamer offers ("Auto" follows the
// bandwidth estimate); otherwise the height of what arrives.
if Bridge.viewer-qualities.length > 1: Select {
width: 116px;
horizontal-stretch: 0;
label: @tr("Quality");
model: Bridge.viewer-qualities;
current-index <=> Bridge.viewer-quality;
selected(_) => { Bridge.set-stream-quality(Bridge.viewer-quality); }
}
if Bridge.viewer-qualities.length <= 1 && Bridge.viewer-has-frame: OverlayChip {
text: @tr("{}p", Bridge.viewer-frame.height);
y: (parent.height - self.height) / 2;
}
IconButton {
icon: Icons.maximize;
label: @tr("Full screen");
size: 30px;
icon-size: 16px;
tint: #ffffff;
y: (parent.height - self.height) / 2;
clicked => { Bridge.toggle-fullscreen(); }
}
}
// The title, who streams it, and the controls.
VerticalLayout {
height: self.preferred-height;
y: parent.height - self.height;
padding-left: Theme.space-4;
padding-right: Theme.space-3;
padding-bottom: Theme.space-1;
spacing: 1px;
Text {
text: Bridge.viewer-title;
color: #ffffff;
font-size: Theme.font-md;
font-weight: Theme.weight-semibold;
overflow: elide;
}
HorizontalLayout {
spacing: Theme.space-2;
alignment: start;
Text {
text: Bridge.viewer-streamer;
color: #ffffffd0;
font-size: Theme.font-sm;
vertical-alignment: center;
overflow: elide;
}
if Bridge.viewer-streamer-admin: Icon {
source: Icons.crown;
size: 14px;
tint: Theme.gold;
y: (parent.height - self.height) / 2;
}
if !Bridge.viewer-ended: Text {
text: "• " + Bridge.viewer-elapsed;
color: #ffffffa0;
font-size: Theme.font-sm;
vertical-alignment: center;
}
}
HorizontalLayout {
height: 40px;
spacing: Theme.space-2;
IconButton {
icon: Bridge.viewer-volume > 0 ? Icons.volume-2 : Icons.volume-x;
label: Bridge.viewer-volume > 0 ? @tr("Mute") : @tr("Unmute");
size: 34px;
tint: #ffffff;
y: (parent.height - self.height) / 2;
clicked => { Bridge.set-stream-volume(Bridge.viewer-volume > 0 ? 0 : 100); }
}
Slider {
y: (parent.height - self.height) / 2;
minimum: 0;
maximum: 200;
step: 5;
value <=> Bridge.viewer-volume;
enabled: !Bridge.viewer-ended;
label: @tr("Stream volume");
changed(v) => { Bridge.set-stream-volume(v); }
}
IconButton {
icon: Bridge.viewer-ended ? Icons.x : Icons.log-out;
label: Bridge.viewer-ended ? @tr("Close") : @tr("Stop watching");
size: 34px;
tint: #ffffff;
y: (parent.height - self.height) / 2;
clicked => { Bridge.leave-stream(); }
}
}
}
}
// The voice bar's controls: larger, on a stronger edge, sharing the width.
component BarButton inherits ActionButton {
size: 48px;
icon-size: 22px;
edge: Theme.border-strong;
checkable: !root.alarm;
horizontal-stretch: 1;
}
// The bar's wide control in the middle: a pill with an icon, its caption
// below. `hold` talks while pressed (push-to-talk), from the press to the
// release or a cancelled press, instead of `clicked`.
component BarPill inherits VerticalLayout {
in property <image> icon;
in property <string> text;
// Green: our voice goes out.
in property <bool> talking;
// Screen readers hear it as checked (talking, sharing).
in property <bool> checked;
in property <bool> hold;
callback clicked();
callback held(bool);
// Its width does not follow the caption (Hold to talk, Talking…), which
// would move the buttons beside it while it is held.
preferred-width: 80px;
spacing: Theme.space-1;
alignment: center;
accessible-role: AccessibleRole.button;
accessible-label: root.text;
accessible-checkable: true;
accessible-checked: root.checked;
accessible-action-default => {
if root.hold {
root.held(!root.checked);
} else {
root.clicked();
}
}
Rectangle {
height: 48px;
border-radius: 24px;
background: root.talking ? Theme.success : touch.pressed ? Theme.accent-pressed : Theme.accent;
border-width: 2px;
border-color: root.talking ? Theme.success.transparentize(0.4) : Theme.glow;
Icon {
source: root.icon;
size: 26px;
tint: Theme.on-accent;
}
touch := TouchArea {
mouse-cursor: MouseCursor.pointer;
pointer-event(e) => {
if root.hold && e.kind == PointerEventKind.down {
root.held(true);
} else if root.hold && (e.kind == PointerEventKind.up || e.kind == PointerEventKind.cancel) {
root.held(false);
}
}
clicked => {
if !root.hold {
root.clicked();
}
}
}
}
Text {
text: root.text;
color: Theme.text;
font-size: Theme.font-xs;
font-weight: Theme.weight-semibold;
horizontal-alignment: center;
accessible-role: AccessibleRole.none;
}
}
// Share a screen or a window, or go live in the Stream Studio: the share
// menu above the bar, as the desktop's call bar has it (while a share
// runs, the share dialog at once). Wide, in the middle, when there is no
// Hold to talk.
component ShareControl inherits Rectangle {
in property <bool> wide;
property <bool> live: Bridge.share-state == "live" || StudioBridge.status.live;
property <string> caption: Bridge.share-state == "live" ? @tr("Sharing") : StudioBridge.status.live ? @tr("Live") : @tr("Share");
horizontal-stretch: root.wide ? 1.6 : 1;
// Centred over this control, above the bar (whose padding is space-3).
function open-menu() {
share-menu.open((root.width - share-menu.menu-width) / 2, - share-menu.menu-height - Theme.space-3 - 4px);
}
VerticalLayout {
alignment: center;
if root.wide: BarPill {
icon: Icons.monitor-up;
text: root.caption;
checked: root.live;
clicked => { root.open-menu(); }
}
if !root.wide: BarButton {
icon: Icons.monitor-up;
text: root.caption;
checked: root.live;
clicked => { root.open-menu(); }
}
}
// Not in the layout: its width of 0 would stop the control growing.
share-menu := ShareMenu {
x: 0;
y: 0;
}
}
// Mic on or off and Deafen; with push-to-talk Hold to talk in the middle
// (wide) and Share, otherwise Share in the middle; and Leave, the screen's
// only one.
component VoiceBar inherits Rectangle {
height: 84px;
background: Theme.surface;
border-width: 1px;
border-color: Theme.border;
accessible-role: AccessibleRole.groupbox;
accessible-label: @tr("Voice");
HorizontalLayout {
padding-left: Theme.space-2;
padding-right: Theme.space-2;
padding-top: Theme.space-3;
padding-bottom: Theme.space-3;
// Named by its state, so it does not read as a talk button.
BarButton {
icon: Bridge.input-muted ? Icons.mic-off : Icons.mic;
text: Bridge.input-muted ? @tr("Mic off") : @tr("Mic on");
checked: Bridge.input-muted;
danger: true;
clicked => { Bridge.set-input-muted(!Bridge.input-muted); }
}
BarButton {
icon: Bridge.output-muted ? Icons.headphone-off : Icons.headphones;
text: Bridge.output-muted ? @tr("Undeafen") : @tr("Deafen");
checked: Bridge.output-muted;
danger: true;
clicked => { Bridge.set-output-muted(!Bridge.output-muted); }
}
// Push-to-talk is the transmit mode: talks while held.
if Bridge.audio.transmit == 0: BarPill {
horizontal-stretch: 1.6;
icon: Icons.mic;
text: Bridge.transmitting ? @tr("Talking…") : @tr("Hold to talk");
talking: Bridge.transmitting;
checked: Bridge.transmitting;
hold: true;
held(on) => { Bridge.push-to-talk(on); }
}
if Bridge.streams-available && Bridge.can-share: ShareControl {
wide: Bridge.audio.transmit != 0;
}
BarButton {
icon: Icons.phone-off;
text: @tr("Leave");
alarm: true;
clicked => {
PhoneVoice.close();
Bridge.disconnect-voice();
}
}
}
}
// The whole screen.
export component MobileVoice inherits VerticalLayout {
// A topic opened from the drawer shows in the chat page.
property <int> topic: Bridge.current-topic;
changed topic => {
if topic >= 0 {
PhoneVoice.close();
Nav.mobile-tab = MobileTab.chat;
}
}
sv := ScrollView {
// The stream and the people scroll away together when they would take
// more than 45 % of the screen; the messages keep the rest (about
// 320 px at 390 × 844 while watching).
vertical-stretch: 0;
height: min(content.preferred-height, root.height * 0.45);
content := VerticalLayout {
width: sv.visible-width;
padding-left: Theme.space-3;
padding-right: Theme.space-3;
spacing: Theme.space-3;
if Bridge.viewer-open: PhonePlayer {
height: (sv.visible-width - 2 * Theme.space-3) * 9 / 16;
}
if !Bridge.viewer-open: VerticalLayout {
spacing: Theme.space-2;
for stream in Bridge.streams: StreamCard {
stream: stream;
compact: true;
}
}
// At least 84 px; taller only for a LIVE mark under a name (or a
// larger text size), which a fixed height would cut, with room
// under it for the sideways scroll line.
people := ScrollView {
height: max(84px, strip.preferred-height + Theme.space-3);
strip := HorizontalLayout {
padding-top: Theme.space-2;
spacing: Theme.space-2;
alignment: start;
for member in Bridge.members: Participant {
member: member;
compact: true;
size: 44px;
}
VerticalLayout {
width: 68px;
spacing: Theme.space-1;
alignment: start;
// Where an avatar is: 44 px in its 52 px ring.
HorizontalLayout {
alignment: center;
padding-top: 4px;
padding-bottom: 4px;
IconButton {
icon: Icons.user-plus;
label: @tr("Invite: copy a link to this channel");
round: true;
filled: true;
size: 44px;
icon-size: 20px;
clicked => { Nav.copy(Bridge.invite()); }
}
}
Text {
text: @tr("Invite");
color: Theme.text-secondary;
font-size: Theme.font-sm;
horizontal-alignment: center;
}
}
}
}
}
}
MessageList {
vertical-stretch: 1;
min-height: 96px;
model: Bridge.messages;
older: true;
}
Composer {
placeholder: @tr("Message {}", Bridge.own-channel);
padding: Theme.space-3;
}
VoiceBar { }
}