Files
VoelinClient/crates/voelin-ui/ui/shells/mobile.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

332 lines
13 KiB
Plaintext

// The narrow (phone) frame: a top bar, one page at a time (@children), and
// the bottom navigation (Home, Servers, Chats, Activity, You). Used while
// the window is narrower than `Nav.narrow-breakpoint`.
import { Theme } from "../theme.slint";
import { Icons } from "../icons.slint";
import { Bridge } from "../bridge.slint";
import { Nav, Page, MobileTab, SettingsSection } from "../nav.slint";
import { Icon, IconButton, CountBadge, PopupMenu, MenuEntry, BannerPicture } from "../components/index.slint";
import { PhoneVoice } from "../screens/mobile-voice.slint";
// One entry of the bottom navigation.
component NavTab inherits Rectangle {
in property <image> icon;
in property <string> text;
in property <bool> selected;
in property <int> badge;
in property <bool> dot;
callback clicked();
horizontal-stretch: 1;
accessible-role: AccessibleRole.tab;
accessible-label: text;
accessible-item-selectable: true;
accessible-item-selected: selected;
accessible-action-default => { clicked(); }
touch := TouchArea {
clicked => { root.clicked(); }
}
if selected: Rectangle {
width: 56px;
height: 32px;
y: 6px;
border-radius: 16px;
background: Theme.accent-soft;
border-width: 1px;
border-color: Theme.glow;
}
VerticalLayout {
alignment: center;
spacing: 3px;
HorizontalLayout {
alignment: center;
Icon {
source: root.icon;
size: 22px;
tint: root.selected ? Theme.accent-text : Theme.icon;
}
}
Text {
text: root.text;
color: root.selected ? Theme.accent-text : Theme.text-secondary;
font-size: Theme.font-xs;
font-weight: root.selected ? Theme.weight-semibold : Theme.weight-regular;
horizontal-alignment: center;
}
}
if badge > 0: CountBadge {
x: parent.width / 2 + 4px;
y: 2px;
count: root.badge;
}
if dot && badge == 0: Rectangle {
x: parent.width / 2 + 8px;
y: 6px;
width: 9px;
height: 9px;
border-radius: 4.5px;
background: Theme.success;
}
}
// The people in our channel, as a pill (the voice channel screen's top bar).
component PeoplePill inherits Rectangle {
callback clicked();
width: row.preferred-width;
height: 40px;
border-radius: 20px;
background: touch.pressed ? Theme.surface-4 : Theme.surface-2;
border-width: 1px;
border-color: Theme.border;
accessible-role: AccessibleRole.button;
accessible-label: @tr("{} in voice", Bridge.members.length);
accessible-action-default => { root.clicked(); }
touch := TouchArea {
clicked => { root.clicked(); }
}
row := HorizontalLayout {
padding-left: Theme.space-4;
padding-right: Theme.space-4;
spacing: Theme.space-2;
Icon {
source: Icons.users;
size: 18px;
tint: Theme.icon;
y: (parent.height - self.height) / 2;
}
Text {
text: Bridge.members.length;
color: Theme.text;
font-size: Theme.font-md;
vertical-alignment: center;
}
}
}
export component MobileShell inherits Rectangle {
in property <string> title;
in property <string> subtitle;
in property <image> banner;
// Unread messages in the server's chats (the Chat tab's badge).
in property <int> unread;
// Show a back arrow (sub-pages such as the settings, and the voice
// channel screen).
in property <bool> back;
// The bottom navigation; pages with their own controls there (the
// voice channel, the Stream Studio) go without.
in property <bool> navigation: true;
// The voice channel screen's buttons in the top bar: the people, the
// chats and a menu (pinned messages, topics, the Stream Studio, the
// voice settings, activity).
in property <bool> voice;
callback go-back();
// VOELIN_OPEN=more opens the menu (a screenshot cannot tap).
property <int> more-requests: Nav.more-requests;
changed more-requests => {
if root.voice {
root.open-more();
}
}
// Under the More button, at the right of the top bar.
function open-more() {
more.show(root.width - Theme.space-3 - more.menu-width, (60px + Theme.control-height) / 2 + 4px);
}
background: Theme.backdrop;
VerticalLayout {
// Top bar.
Rectangle {
height: 60px;
accessible-role: AccessibleRole.banner;
clip: true;
if root.banner.width > 0: BannerPicture { source: root.banner; }
HorizontalLayout {
padding-left: Theme.space-4;
padding-right: Theme.space-3;
spacing: Theme.space-3;
if root.back: IconButton {
icon: Icons.arrow-left;
label: @tr("Back");
round: true;
filled: true;
y: (parent.height - self.height) / 2;
clicked => { root.go-back(); }
}
if !root.back: Image {
width: 34px;
height: 34px;
y: (parent.height - self.height) / 2;
source: Icons.logo;
}
VerticalLayout {
alignment: center;
horizontal-stretch: 1;
Text {
text: root.title;
color: Theme.text;
font-size: Theme.font-xl;
font-weight: Theme.weight-semibold;
overflow: elide;
}
if root.subtitle != "": Text {
text: root.subtitle;
color: root.banner.width > 0 ? Theme.text : Theme.accent-text;
font-size: Theme.font-sm;
overflow: elide;
}
}
if !root.voice: IconButton {
icon: Icons.search;
label: @tr("Search");
round: true;
filled: true;
y: (parent.height - self.height) / 2;
clicked => { Nav.open-search(""); }
}
// The voice channel we are in, from any page.
if !root.voice && Bridge.voice-connected: IconButton {
icon: Icons.channel;
label: @tr("Voice channel");
round: true;
filled: true;
dot: true;
dot-color: Theme.success;
y: (parent.height - self.height) / 2;
clicked => {
Nav.show(Page.server);
Nav.show-voice(true);
}
}
if !root.voice: IconButton {
icon: Icons.bell;
label: @tr("Notifications");
round: true;
filled: true;
checked: Nav.notifications-open;
dot: Bridge.notifications-unread > 0 || Bridge.share-requests > 0 || Bridge.crash-notice != "";
y: (parent.height - self.height) / 2;
clicked => { Nav.notifications-open = !Nav.notifications-open; }
}
if root.voice: PeoplePill {
y: (parent.height - self.height) / 2;
// In front of the pins or the topics, which show first.
clicked => {
Nav.pins-open = false;
Nav.topics-open = false;
Nav.members-open = true;
}
}
if root.voice: Rectangle {
width: 40px;
height: 40px;
y: (parent.height - self.height) / 2;
IconButton {
icon: Icons.message-square;
label: @tr("Chats");
round: true;
filled: true;
size: 40px;
clicked => {
PhoneVoice.close();
Nav.mobile-tab = MobileTab.chat;
}
}
if root.unread > 0: CountBadge {
x: parent.width - self.width / 2 - 4px;
y: -4px;
count: root.unread;
}
}
if root.voice: IconButton {
icon: Icons.more-horizontal;
label: @tr("More");
round: true;
filled: true;
y: (parent.height - self.height) / 2;
clicked => { root.open-more(); }
}
}
// Not in a layout, so Slint would centre it in the bar: `show`
// is relative to its corner.
more := PopupMenu {
x: 0;
y: 0;
entries: [
{ text: @tr("Pinned Messages"), icon: Icons.pin, enabled: Bridge.has-pins },
{ text: @tr("Topics"), icon: Icons.book-open, enabled: Bridge.has-topics },
{ text: @tr("Stream Studio"), icon: Icons.radio, enabled: Bridge.streams-available, separator: true },
{ text: @tr("Voice Settings"), icon: Icons.settings, enabled: true },
{ text: @tr("Activity"), icon: Icons.activity, enabled: true },
];
activated(i) => {
if i == 0 {
Nav.members-open = false;
Nav.show-pins(true);
} else if i == 1 {
Nav.members-open = false;
Nav.show-topics(true);
} else if i == 2 {
Nav.open-studio();
} else if i == 3 {
Nav.open-settings(SettingsSection.voice);
} else {
PhoneVoice.close();
Nav.mobile-tab = MobileTab.activity;
}
}
}
}
Rectangle {
vertical-stretch: 1;
@children
}
// Bottom navigation.
if root.navigation: Rectangle {
height: 64px;
background: Theme.surface;
border-width: 1px;
border-color: Theme.border;
accessible-role: AccessibleRole.tab-list;
accessible-label: @tr("Navigation");
HorizontalLayout {
padding-left: Theme.space-2;
padding-right: Theme.space-2;
// The direct messages are on Home: their unread count.
NavTab {
icon: Icons.home;
text: @tr("Home");
selected: Nav.page == Page.home || Nav.page == Page.friends || Nav.page == Page.messages || Nav.page == Page.library || (Nav.mobile-tab == MobileTab.home && Nav.page == Page.server);
badge: Bridge.dm-unread + Bridge.inbox-unread;
clicked => { Nav.show-tab(MobileTab.home); }
}
NavTab {
icon: Icons.server;
text: @tr("Servers");
selected: (Nav.mobile-tab == MobileTab.servers && Nav.page == Page.server) || Nav.page == Page.events;
dot: Bridge.voice-connected;
clicked => { Nav.show-tab(MobileTab.servers); }
}
NavTab {
icon: Icons.message-circle;
text: @tr("Chats");
selected: Nav.mobile-tab == MobileTab.chat && Nav.page == Page.server;
badge: root.unread;
clicked => { Nav.show-tab(MobileTab.chat); }
}
NavTab {
icon: Icons.activity;
text: @tr("Activity");
selected: Nav.mobile-tab == MobileTab.activity && Nav.page == Page.server;
badge: Bridge.share-requests;
clicked => { Nav.show-tab(MobileTab.activity); }
}
NavTab {
icon: Icons.user;
text: @tr("You");
selected: (Nav.mobile-tab == MobileTab.you && Nav.page == Page.server) || Nav.page == Page.settings;
clicked => { Nav.show-tab(MobileTab.you); }
}
}
}
}
}