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
This commit is contained in:
13 files changed
+337
-267
No files matched your search
@@ -903,6 +903,7 @@ pub fn run(options: RunOptions) -> Result<()> {
|
||||
app.apply_srtp();
|
||||
app.refresh_all();
|
||||
app.refresh_settings_flags();
|
||||
app.refresh_transmit();
|
||||
app.refresh_crash_notice();
|
||||
app.load_recent_chats();
|
||||
app.refresh_people();
|
||||
@@ -1071,6 +1072,8 @@ impl App {
|
||||
fn setting_changed(&mut self, key: &str) {
|
||||
if key == AUDIO.name() && !self.audio_dirty {
|
||||
self.audio = self.prefs.get(&AUDIO);
|
||||
// The voice controls follow the transmit mode.
|
||||
self.refresh_transmit();
|
||||
} else if key == CRASH_REPORTS.name() {
|
||||
let enabled = self.prefs.get(&CRASH_REPORTS);
|
||||
if enabled != self.settings.crash_reports {
|
||||
|
||||
+39
-15
@@ -20,6 +20,8 @@
|
||||
//! client once connected), `panel` / `no-panel` (the members panel),
|
||||
//! `voice` (the voice channel view; on the phone its own screen;
|
||||
//! `voice:compact` with the smaller stage, not stored),
|
||||
//! `more` (after `voice` on the phone: the voice screen's More menu,
|
||||
//! opened once the screen is laid out),
|
||||
//! `members` (the phone's members page), `notification` (a tapped voice
|
||||
//! notification), `shared:<text>` (text shared to the app on Android),
|
||||
//! `pins`, `topics` (the drawers),
|
||||
@@ -167,6 +169,7 @@ pub(crate) struct Running {
|
||||
_screenshot: Option<slint::Timer>,
|
||||
_resize: Option<slint::Timer>,
|
||||
_scroll: Option<slint::Timer>,
|
||||
_more: Option<slint::Timer>,
|
||||
}
|
||||
|
||||
/// Apply the switches once the app is set up.
|
||||
@@ -279,6 +282,8 @@ pub(crate) fn start(ui: &MainWindow, switches: &Switches) -> Running {
|
||||
}
|
||||
}
|
||||
"pins" => nav.invoke_show_pins(true),
|
||||
// Opened once laid out (below).
|
||||
"more" => {}
|
||||
// The phone's members page.
|
||||
"members" => nav.set_members_open(true),
|
||||
// What Android hands over: a tapped voice notification, text
|
||||
@@ -410,20 +415,18 @@ pub(crate) fn start(ui: &MainWindow, switches: &Switches) -> Running {
|
||||
// `unread`: up to the divider once the list is laid out (after the
|
||||
// resize above).
|
||||
let scroll = switches.open.iter().any(|o| o == "unread").then(|| {
|
||||
let weak = ui.as_weak();
|
||||
let timer = slint::Timer::default();
|
||||
timer.start(
|
||||
slint::TimerMode::SingleShot,
|
||||
Duration::from_millis(switches.screenshot_delay * 1000 * 3 / 4),
|
||||
move || {
|
||||
if let Some(ui) = weak.upgrade() {
|
||||
let bridge = ui.global::<Bridge>();
|
||||
bridge.set_jump_index(bridge.get_unread_index());
|
||||
bridge.set_jump_requests(bridge.get_jump_requests().wrapping_add(1));
|
||||
}
|
||||
},
|
||||
);
|
||||
timer
|
||||
late(ui, switches, |ui| {
|
||||
let bridge = ui.global::<Bridge>();
|
||||
bridge.set_jump_index(bridge.get_unread_index());
|
||||
bridge.set_jump_requests(bridge.get_jump_requests().wrapping_add(1));
|
||||
})
|
||||
});
|
||||
// `more`: the phone voice screen's More menu (a screenshot cannot tap).
|
||||
let more = switches.open.iter().any(|o| o == "more").then(|| {
|
||||
late(ui, switches, |ui| {
|
||||
let nav = ui.global::<Nav>();
|
||||
nav.set_more_requests(nav.get_more_requests().wrapping_add(1));
|
||||
})
|
||||
});
|
||||
let screenshot = switches.screenshot.clone().map(|path| {
|
||||
let weak = ui.as_weak();
|
||||
@@ -445,7 +448,28 @@ pub(crate) fn start(ui: &MainWindow, switches: &Switches) -> Running {
|
||||
);
|
||||
timer
|
||||
});
|
||||
Running { _screenshot: screenshot, _resize: resize, _scroll: scroll }
|
||||
Running { _screenshot: screenshot, _resize: resize, _scroll: scroll, _more: more }
|
||||
}
|
||||
|
||||
/// A timer that runs `action` at three quarters of the screenshot delay, once
|
||||
/// the window has its size and the screens are laid out.
|
||||
fn late(
|
||||
ui: &MainWindow,
|
||||
switches: &Switches,
|
||||
action: impl Fn(&MainWindow) + 'static,
|
||||
) -> slint::Timer {
|
||||
let weak = ui.as_weak();
|
||||
let timer = slint::Timer::default();
|
||||
timer.start(
|
||||
slint::TimerMode::SingleShot,
|
||||
Duration::from_millis(switches.screenshot_delay * 1000 * 3 / 4),
|
||||
move || {
|
||||
if let Some(ui) = weak.upgrade() {
|
||||
action(&ui);
|
||||
}
|
||||
},
|
||||
);
|
||||
timer
|
||||
}
|
||||
|
||||
/// The current chat's read marker `back` messages before its end, as if
|
||||
|
||||
@@ -418,6 +418,23 @@ fn noise_level(index: i32) -> NoiseLevel {
|
||||
}
|
||||
}
|
||||
|
||||
/// The form's number for a transmit mode (`AudioForm.transmit`).
|
||||
pub fn transmit_index(mode: TransmitMode) -> i32 {
|
||||
match mode {
|
||||
TransmitMode::PushToTalk => 0,
|
||||
TransmitMode::VoiceActivation => 1,
|
||||
TransmitMode::Continuous => 2,
|
||||
}
|
||||
}
|
||||
|
||||
fn transmit_mode(index: i32) -> TransmitMode {
|
||||
match index {
|
||||
1 => TransmitMode::VoiceActivation,
|
||||
2 => TransmitMode::Continuous,
|
||||
_ => TransmitMode::PushToTalk,
|
||||
}
|
||||
}
|
||||
|
||||
/// The settings page's form for `settings`.
|
||||
pub fn audio_form(
|
||||
settings: &AudioSettings,
|
||||
@@ -428,11 +445,7 @@ pub fn audio_form(
|
||||
AudioForm {
|
||||
input_index: inputs.index_of(settings.input_device.as_deref()) as i32,
|
||||
output_index: outputs.index_of(settings.output_device.as_deref()) as i32,
|
||||
transmit: match settings.transmit {
|
||||
TransmitMode::PushToTalk => 0,
|
||||
TransmitMode::VoiceActivation => 1,
|
||||
TransmitMode::Continuous => 2,
|
||||
},
|
||||
transmit: transmit_index(settings.transmit),
|
||||
vad_threshold: settings.vad.threshold_db,
|
||||
echo_cancellation: p.echo_cancellation,
|
||||
noise_suppression: p.noise_suppression,
|
||||
@@ -454,11 +467,7 @@ pub fn apply_audio_form(
|
||||
let mut s = settings.clone();
|
||||
s.input_device = inputs.id_at(form.input_index);
|
||||
s.output_device = outputs.id_at(form.output_index);
|
||||
s.transmit = match form.transmit {
|
||||
1 => TransmitMode::VoiceActivation,
|
||||
2 => TransmitMode::Continuous,
|
||||
_ => TransmitMode::PushToTalk,
|
||||
};
|
||||
s.transmit = transmit_mode(form.transmit);
|
||||
s.vad.threshold_db = form.vad_threshold;
|
||||
s.processing.echo_cancellation = form.echo_cancellation;
|
||||
s.processing.noise_suppression = form.noise_suppression;
|
||||
@@ -522,6 +531,22 @@ mod tests {
|
||||
assert_eq!(changed.playback_buffer_ms, 180);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn transmit_modes() {
|
||||
for (mode, index) in [
|
||||
(TransmitMode::PushToTalk, 0),
|
||||
(TransmitMode::VoiceActivation, 1),
|
||||
(TransmitMode::Continuous, 2),
|
||||
] {
|
||||
assert_eq!(transmit_index(mode), index);
|
||||
assert_eq!(transmit_mode(index), mode);
|
||||
}
|
||||
// Any other number is the default, push-to-talk (Hold to talk shows).
|
||||
assert_eq!(transmit_mode(7), TransmitMode::PushToTalk);
|
||||
assert_eq!(transmit_mode(-1), TransmitMode::PushToTalk);
|
||||
assert_eq!(transmit_index(AudioSettings::default().transmit), 0);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn free_values() {
|
||||
assert_eq!(nearest_choice(&FPS_CHOICES, 60), 2);
|
||||
|
||||
@@ -136,6 +136,17 @@ impl App {
|
||||
bridge.set_crash_reports(self.settings.crash_reports);
|
||||
}
|
||||
|
||||
/// The transmit mode for the voice controls (Hold to talk shows for
|
||||
/// push-to-talk) before the settings page fills the whole form: only
|
||||
/// `transmit` changes, as the device lists are not read yet.
|
||||
pub(crate) fn refresh_transmit(&self) {
|
||||
let Some(ui) = self.ui.upgrade() else { return };
|
||||
let bridge = ui.global::<Bridge>();
|
||||
let mut form = bridge.get_audio();
|
||||
form.transmit = settings::transmit_index(self.audio.transmit);
|
||||
bridge.set_audio(form);
|
||||
}
|
||||
|
||||
pub(crate) fn set_crash_reports(&mut self, enabled: bool) {
|
||||
self.settings.crash_reports = enabled;
|
||||
// Also in the blob, for older versions.
|
||||
|
||||
@@ -31,7 +31,7 @@ import { MessagesPage, ConversationList, Conversation, DmProfile, OfflineDialog
|
||||
import { ServerLinks, EventsPage, EventDialog } from "screens/events.slint";
|
||||
import { NotificationsPanel, SearchPalette, Lightbox } from "screens/overlays.slint";
|
||||
import { MobileServers, ActivityPage, YouPage, PhoneSheet } from "screens/mobile.slint";
|
||||
import { MobileVoice } from "screens/mobile-voice.slint";
|
||||
import { MobileVoice, PhoneVoice } from "screens/mobile-voice.slint";
|
||||
import { BookmarkDialog, ShareDialog, ClientAudioDialog, ChannelPasswordDialog, PokeDialog, LinkDialog, AboutDialog } from "screens/dialogs.slint";
|
||||
import { StudioBridge } from "studio-bridge.slint";
|
||||
import { StudioPage, MobileStudio } from "screens/studio.slint";
|
||||
@@ -266,13 +266,13 @@ export component MainWindow inherits Window {
|
||||
&& Nav.mobile-tab == MobileTab.chat && !Bridge.viewer-open
|
||||
&& Bridge.current-tab >= 0 && Bridge.current-tab < Bridge.tabs.length
|
||||
&& Bridge.tabs[Bridge.current-tab].kind == 1;
|
||||
banner: self.channel-chat ? Bridge.tabs[Bridge.current-tab].banner : @image-url("");
|
||||
banner: Nav.phone-voice ? Bridge.own-channel-banner : self.channel-chat ? Bridge.tabs[Bridge.current-tab].banner : @image-url("");
|
||||
title: Nav.page == Page.settings ? @tr("Settings")
|
||||
: Nav.page == Page.friends ? @tr("Friends")
|
||||
: Nav.page == Page.messages ? @tr("Messages")
|
||||
: Nav.page == Page.library ? @tr("Library")
|
||||
: Nav.page == Page.events ? @tr("Events")
|
||||
: Nav.phone-voice ? Bridge.app-name
|
||||
: Nav.phone-voice ? Bridge.own-channel
|
||||
: Nav.page == Page.home || Nav.mobile-tab == MobileTab.home ? Bridge.app-name
|
||||
: Nav.mobile-tab == MobileTab.you ? @tr("You")
|
||||
: Nav.mobile-tab == MobileTab.activity ? @tr("Activity")
|
||||
@@ -282,13 +282,15 @@ export component MainWindow inherits Window {
|
||||
: Nav.page == Page.home || Nav.mobile-tab == MobileTab.home ? ""
|
||||
: Nav.mobile-tab == MobileTab.chat && Bridge.current-tab >= 0 && Bridge.current-tab < Bridge.tabs.length ? Bridge.tabs[Bridge.current-tab].title
|
||||
: Nav.mobile-tab == MobileTab.servers ? Bridge.server-stats : "";
|
||||
back: Nav.page == Page.settings || Nav.page == Page.friends || Nav.page == Page.messages || Nav.page == Page.library || Nav.page == Page.events;
|
||||
back: Nav.phone-voice || Nav.page == Page.settings || Nav.page == Page.friends || Nav.page == Page.messages || Nav.page == Page.library || Nav.page == Page.events;
|
||||
unread: Bridge.unread-total;
|
||||
voice: Nav.phone-voice;
|
||||
// The voice channel and the studio bring their own controls.
|
||||
navigation: !Nav.phone-voice && Nav.page != Page.studio;
|
||||
go-back => {
|
||||
if Nav.page == Page.messages && Bridge.dm.open {
|
||||
if Nav.phone-voice {
|
||||
PhoneVoice.back();
|
||||
} else if Nav.page == Page.messages && Bridge.dm.open {
|
||||
Bridge.open-conversation(-1);
|
||||
} else if Nav.page == Page.events || Nav.page == Page.settings {
|
||||
Nav.show(Page.server);
|
||||
|
||||
@@ -138,6 +138,9 @@ export global Nav {
|
||||
// The server's members as a page of their own (the desktop shows them
|
||||
// beside the chat).
|
||||
in-out property <bool> members-open;
|
||||
// Counts requests to open the voice screen's More menu, which MobileShell
|
||||
// opens (VOELIN_OPEN=more: a screenshot cannot tap).
|
||||
in-out property <int> more-requests;
|
||||
// The voice channel screen (design mockup 02) instead of a tab: the
|
||||
// voice channel view, or a stream we watch.
|
||||
out property <bool> phone-voice: narrow && page == Page.server && Bridge.voice-connected && (voice-view || Bridge.viewer-open);
|
||||
|
||||
@@ -1,82 +1,41 @@
|
||||
// The voice channel on the phone (design mockup 02): the channel's name
|
||||
// and Leave, the stream we watch (or a card to watch one), the people in
|
||||
// the channel, the channel's chat, and the voice controls at the bottom in
|
||||
// place of the navigation.
|
||||
// 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, Button, ButtonKind, ActionButton, LiveBadge, Select, Slider, ScrollView, BannerPicture } from "../components/index.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";
|
||||
|
||||
// Back to the navigation; a stream we watch goes on behind it.
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
// Channel background behind its name, topic, Back and Leave.
|
||||
component ChannelBar inherits Rectangle {
|
||||
height: 56px;
|
||||
clip: true;
|
||||
if Bridge.own-channel-banner.width > 0: BannerPicture {
|
||||
y: 0;
|
||||
source: Bridge.own-channel-banner;
|
||||
}
|
||||
HorizontalLayout {
|
||||
height: 56px;
|
||||
padding-left: Theme.space-3;
|
||||
padding-right: Theme.space-3;
|
||||
spacing: Theme.space-3;
|
||||
IconButton {
|
||||
icon: Icons.arrow-left;
|
||||
label: @tr("Back");
|
||||
round: true;
|
||||
filled: true;
|
||||
size: 40px;
|
||||
y: (parent.height - self.height) / 2;
|
||||
clicked => { PhoneVoice.close(); }
|
||||
}
|
||||
Icon {
|
||||
source: Icons.volume-2;
|
||||
size: 28px;
|
||||
tint: Theme.text-secondary;
|
||||
y: (parent.height - self.height) / 2;
|
||||
}
|
||||
VerticalLayout {
|
||||
alignment: center;
|
||||
horizontal-stretch: 1;
|
||||
Text {
|
||||
text: Bridge.own-channel;
|
||||
color: Theme.text;
|
||||
font-size: Theme.font-lg;
|
||||
font-weight: Theme.weight-semibold;
|
||||
overflow: elide;
|
||||
}
|
||||
if Bridge.own-channel-topic != "": Text {
|
||||
text: Bridge.own-channel-topic;
|
||||
color: Bridge.own-channel-banner.width > 0 ? Theme.text : Theme.text-secondary;
|
||||
font-size: Theme.font-sm;
|
||||
overflow: elide;
|
||||
}
|
||||
}
|
||||
Button {
|
||||
kind: ButtonKind.danger;
|
||||
icon: Icons.log-out;
|
||||
text: @tr("Leave");
|
||||
y: (parent.height - self.height) / 2;
|
||||
clicked => {
|
||||
PhoneVoice.close();
|
||||
Bridge.disconnect-voice();
|
||||
}
|
||||
}
|
||||
function close-pages() {
|
||||
Nav.pins-open = false;
|
||||
Nav.topics-open = false;
|
||||
Nav.members-open = false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -263,72 +222,6 @@ component PhonePlayer inherits Rectangle {
|
||||
}
|
||||
}
|
||||
|
||||
// "# Chill Zone Chat · Linked to this voice channel", with the pins, the
|
||||
// topics and the members.
|
||||
component ChatHeader inherits Rectangle {
|
||||
height: 56px;
|
||||
border-radius: Theme.radius-lg;
|
||||
background: Theme.surface-2;
|
||||
border-width: 1px;
|
||||
border-color: Theme.border;
|
||||
HorizontalLayout {
|
||||
padding-left: Theme.space-4;
|
||||
padding-right: Theme.space-3;
|
||||
spacing: Theme.space-3;
|
||||
Icon {
|
||||
source: Icons.hash;
|
||||
size: 24px;
|
||||
tint: Theme.text-secondary;
|
||||
y: (parent.height - self.height) / 2;
|
||||
}
|
||||
VerticalLayout {
|
||||
alignment: center;
|
||||
horizontal-stretch: 1;
|
||||
Text {
|
||||
text: @tr("{} Chat", Bridge.own-channel);
|
||||
color: Theme.text;
|
||||
font-size: Theme.font-md;
|
||||
font-weight: Theme.weight-semibold;
|
||||
overflow: elide;
|
||||
}
|
||||
Text {
|
||||
text: @tr("Linked to this voice channel");
|
||||
color: Theme.text-secondary;
|
||||
font-size: Theme.font-xs;
|
||||
overflow: elide;
|
||||
}
|
||||
}
|
||||
if Bridge.has-pins: IconButton {
|
||||
icon: Icons.pin;
|
||||
label: @tr("Pinned Messages");
|
||||
filled: true;
|
||||
size: 36px;
|
||||
icon-size: 18px;
|
||||
tint: Theme.accent-text;
|
||||
y: (parent.height - self.height) / 2;
|
||||
clicked => { Nav.show-pins(true); }
|
||||
}
|
||||
if Bridge.has-topics: IconButton {
|
||||
icon: Icons.book-open;
|
||||
label: @tr("Topics");
|
||||
filled: true;
|
||||
size: 36px;
|
||||
icon-size: 18px;
|
||||
y: (parent.height - self.height) / 2;
|
||||
clicked => { Nav.show-topics(true); }
|
||||
}
|
||||
IconButton {
|
||||
icon: Icons.users;
|
||||
label: @tr("Members");
|
||||
filled: true;
|
||||
size: 36px;
|
||||
icon-size: 18px;
|
||||
y: (parent.height - self.height) / 2;
|
||||
clicked => { Nav.members-open = true; }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// The voice bar's controls: larger, on a stronger edge, sharing the width.
|
||||
component BarButton inherits ActionButton {
|
||||
size: 48px;
|
||||
@@ -338,8 +231,110 @@ component BarButton inherits ActionButton {
|
||||
horizontal-stretch: 1;
|
||||
}
|
||||
|
||||
// Mute, Deafen, Go Live (the Stream Studio; "Live" while it or a share
|
||||
// is), Share (the screen, at once) and Leave.
|
||||
// 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;
|
||||
@@ -352,9 +347,10 @@ component VoiceBar inherits Rectangle {
|
||||
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("Unmute") : @tr("Mute");
|
||||
text: Bridge.input-muted ? @tr("Mic off") : @tr("Mic on");
|
||||
checked: Bridge.input-muted;
|
||||
danger: true;
|
||||
clicked => { Bridge.set-input-muted(!Bridge.input-muted); }
|
||||
@@ -366,42 +362,18 @@ component VoiceBar inherits Rectangle {
|
||||
danger: true;
|
||||
clicked => { Bridge.set-output-muted(!Bridge.output-muted); }
|
||||
}
|
||||
// The big one: the Stream Studio, or live there.
|
||||
if Bridge.streams-available && Bridge.can-share: VerticalLayout {
|
||||
// Push-to-talk is the transmit mode: talks while held.
|
||||
if Bridge.audio.transmit == 0: BarPill {
|
||||
horizontal-stretch: 1.6;
|
||||
spacing: Theme.space-1;
|
||||
alignment: center;
|
||||
accessible-role: AccessibleRole.button;
|
||||
accessible-label: @tr("Go Live");
|
||||
accessible-action-default => { Nav.open-studio(); }
|
||||
Rectangle {
|
||||
height: 48px;
|
||||
border-radius: 24px;
|
||||
background: live.pressed ? Theme.accent-pressed : Theme.accent;
|
||||
border-width: 2px;
|
||||
border-color: Theme.glow;
|
||||
Icon {
|
||||
source: Icons.radio;
|
||||
size: 26px;
|
||||
tint: Theme.on-accent;
|
||||
}
|
||||
live := TouchArea {
|
||||
clicked => { Nav.open-studio(); }
|
||||
}
|
||||
}
|
||||
Text {
|
||||
text: Bridge.share-state == "live" || StudioBridge.status.live ? @tr("Live") : @tr("Go Live");
|
||||
color: Theme.text;
|
||||
font-size: Theme.font-xs;
|
||||
font-weight: Theme.weight-semibold;
|
||||
horizontal-alignment: center;
|
||||
}
|
||||
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: BarButton {
|
||||
icon: Icons.screen-share;
|
||||
text: Bridge.share-state == "live" ? @tr("Sharing") : @tr("Share");
|
||||
checked: Bridge.share-state == "live";
|
||||
clicked => { Nav.open-share(); }
|
||||
if Bridge.streams-available && Bridge.can-share: ShareControl {
|
||||
wide: Bridge.audio.transmit != 0;
|
||||
}
|
||||
BarButton {
|
||||
icon: Icons.phone-off;
|
||||
@@ -415,35 +387,6 @@ component VoiceBar inherits Rectangle {
|
||||
}
|
||||
}
|
||||
|
||||
// Push-to-talk at the end of the composer: talks while held.
|
||||
component TalkButton inherits Rectangle {
|
||||
width: 48px;
|
||||
height: 48px;
|
||||
border-radius: 24px;
|
||||
background: Bridge.transmitting ? Theme.success : touch.pressed ? Theme.accent-pressed : Theme.accent;
|
||||
border-width: 2px;
|
||||
border-color: Bridge.transmitting ? Theme.success.transparentize(0.4) : Theme.glow;
|
||||
accessible-role: AccessibleRole.button;
|
||||
accessible-label: @tr("Hold to talk");
|
||||
accessible-checkable: true;
|
||||
accessible-checked: Bridge.transmitting;
|
||||
accessible-action-default => { Bridge.push-to-talk(!Bridge.transmitting); }
|
||||
Icon {
|
||||
source: Icons.mic;
|
||||
size: 22px;
|
||||
tint: Theme.on-accent;
|
||||
}
|
||||
touch := TouchArea {
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// The whole screen.
|
||||
export component MobileVoice inherits VerticalLayout {
|
||||
// A topic opened from the drawer shows in the chat page.
|
||||
@@ -454,12 +397,12 @@ export component MobileVoice inherits VerticalLayout {
|
||||
Nav.mobile-tab = MobileTab.chat;
|
||||
}
|
||||
}
|
||||
ChannelBar { }
|
||||
sv := ScrollView {
|
||||
// The stream, the people and the chat header scroll away together
|
||||
// when the window is short; the messages always keep some room.
|
||||
// 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.55);
|
||||
height: min(content.preferred-height, root.height * 0.45);
|
||||
content := VerticalLayout {
|
||||
width: sv.visible-width;
|
||||
padding-left: Theme.space-3;
|
||||
@@ -475,29 +418,36 @@ export component MobileVoice inherits VerticalLayout {
|
||||
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: 112px;
|
||||
HorizontalLayout {
|
||||
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: 62px;
|
||||
icon-size: 24px;
|
||||
size: 44px;
|
||||
icon-size: 20px;
|
||||
clicked => { Nav.copy(Bridge.invite()); }
|
||||
}
|
||||
}
|
||||
@@ -510,7 +460,6 @@ export component MobileVoice inherits VerticalLayout {
|
||||
}
|
||||
}
|
||||
}
|
||||
ChatHeader { }
|
||||
}
|
||||
}
|
||||
MessageList {
|
||||
@@ -519,17 +468,9 @@ export component MobileVoice inherits VerticalLayout {
|
||||
model: Bridge.messages;
|
||||
older: true;
|
||||
}
|
||||
HorizontalLayout {
|
||||
padding-right: Bridge.audio.transmit == 0 ? Theme.space-4 : 0px;
|
||||
Composer {
|
||||
placeholder: @tr("Message #{}…", Bridge.own-channel);
|
||||
padding: Theme.space-3;
|
||||
padding-right: Bridge.audio.transmit == 0 ? Theme.space-3 : Theme.space-5;
|
||||
}
|
||||
// Push-to-talk is the transmit mode: talking is at hand.
|
||||
if Bridge.audio.transmit == 0: TalkButton {
|
||||
y: (parent.height - self.height) / 2;
|
||||
}
|
||||
Composer {
|
||||
placeholder: @tr("Message {}", Bridge.own-channel);
|
||||
padding: Theme.space-3;
|
||||
}
|
||||
VoiceBar { }
|
||||
}
|
||||
@@ -236,7 +236,8 @@ export component PhoneSheet inherits Rectangle {
|
||||
if Nav.pins-open: PinsDrawer { }
|
||||
if Nav.topics-open && !Nav.pins-open: TopicsDrawer { }
|
||||
if Nav.members-open && !Nav.pins-open && !Nav.topics-open: VerticalLayout {
|
||||
HorizontalLayout {
|
||||
// The voice screen's top bar has Back.
|
||||
if !Nav.phone-voice: HorizontalLayout {
|
||||
padding-left: Theme.space-3;
|
||||
padding-top: Theme.space-3;
|
||||
spacing: Theme.space-2;
|
||||
|
||||
@@ -10,7 +10,8 @@ import { StudioBridge } from "studio-bridge.slint";
|
||||
import { Nav } from "nav.slint";
|
||||
|
||||
export component ShareMenu inherits Rectangle {
|
||||
// The menu's height, to open it above a button.
|
||||
// The menu's size, to open it above a button.
|
||||
out property <length> menu-width: 220px;
|
||||
out property <length> menu-height: 2 * Theme.control-height + 2 * Theme.space-2 + 2px;
|
||||
width: 0;
|
||||
height: 0;
|
||||
@@ -25,7 +26,7 @@ export component ShareMenu inherits Rectangle {
|
||||
}
|
||||
|
||||
menu := PopupMenu {
|
||||
menu-width: 220px;
|
||||
menu-width: root.menu-width;
|
||||
entries: [
|
||||
// The studio's stream takes the place of a simple share.
|
||||
{ text: @tr("Share screen"), icon: Icons.monitor-up, enabled: !StudioBridge.status.live },
|
||||
|
||||
@@ -109,15 +109,28 @@ export component MobileShell inherits Rectangle {
|
||||
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).
|
||||
// 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.
|
||||
// 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.
|
||||
@@ -195,7 +208,12 @@ export component MobileShell inherits Rectangle {
|
||||
}
|
||||
if root.voice: PeoplePill {
|
||||
y: (parent.height - self.height) / 2;
|
||||
clicked => { Nav.members-open = true; }
|
||||
// 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;
|
||||
@@ -224,27 +242,35 @@ export component MobileShell inherits Rectangle {
|
||||
round: true;
|
||||
filled: true;
|
||||
y: (parent.height - self.height) / 2;
|
||||
clicked => { more.show(self.x + self.width - 220px, self.y + self.height + 4px); }
|
||||
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("Stream Studio"), icon: Icons.radio, enabled: Bridge.streams-available },
|
||||
{ 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 },
|
||||
{ text: @tr("Leave Voice"), icon: Icons.phone-off, danger: true, enabled: true, separator: true },
|
||||
];
|
||||
activated(i) => {
|
||||
if i == 0 {
|
||||
Nav.open-studio();
|
||||
Nav.members-open = false;
|
||||
Nav.show-pins(true);
|
||||
} else if i == 1 {
|
||||
Nav.open-settings(SettingsSection.voice);
|
||||
Nav.members-open = false;
|
||||
Nav.show-topics(true);
|
||||
} else if i == 2 {
|
||||
PhoneVoice.close();
|
||||
Nav.mobile-tab = MobileTab.activity;
|
||||
Nav.open-studio();
|
||||
} else if i == 3 {
|
||||
Nav.open-settings(SettingsSection.voice);
|
||||
} else {
|
||||
PhoneVoice.close();
|
||||
Bridge.disconnect-voice();
|
||||
Nav.mobile-tab = MobileTab.activity;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user