From 5da3f94479788bdbda60e9efd45832500368dcfe Mon Sep 17 00:00:00 2001 From: selikhov Date: Sat, 3 Oct 2026 17:59:27 +0300 Subject: [PATCH] voelin-ui: the phone's bottom navigation shows where you are Home could be on screen while the bar marked Chats and the top bar named the server: opening Home other than by its tab (the desktop's logo before the window narrowed, VOELIN_OPEN=home) left the phone's tab where it was. Nav.show now keeps the tab and the page together, also while the window is wide, so the tab is right when it narrows. The tabs go through Nav.show-tab, which also closes the pins, topics or members page that was over the last tab, instead of leaving it over the next one. Co-Authored-By: Claude Opus 5.5 --- crates/voelin-ui/ui/nav.slint | 19 +++++++++++++++++-- crates/voelin-ui/ui/shells/mobile.slint | 10 +++++----- 2 files changed, 22 insertions(+), 7 deletions(-) diff --git a/crates/voelin-ui/ui/nav.slint b/crates/voelin-ui/ui/nav.slint index d6af3f2..de0ed93 100644 --- a/crates/voelin-ui/ui/nav.slint +++ b/crates/voelin-ui/ui/nav.slint @@ -85,13 +85,28 @@ export global Nav { settings-active = false; Bridge.close-settings(); } - // The phone shows Home on its own tab: a server goes to Servers. - if narrow && p == Page.server && mobile-tab == MobileTab.home { + // The phone shows Home on its own tab: a server goes to Servers, + // and Home from anywhere (the desktop's logo, a switch) is that tab. + // Also while wide, so the tab is right when the window narrows. + if p == Page.server && mobile-tab == MobileTab.home { mobile-tab = MobileTab.servers; } + if p == Page.home { + mobile-tab = MobileTab.home; + } page = p; } + // A tab of the phone's bottom navigation, without the pages that were + // over the last one (pins, topics, members). + public function show-tab(tab: MobileTab) { + pins-open = false; + topics-open = false; + members-open = false; + show(tab == MobileTab.home ? Page.home : Page.server); + mobile-tab = tab; + } + public function open-settings(section: SettingsSection) { if !settings-active { settings-active = true; diff --git a/crates/voelin-ui/ui/shells/mobile.slint b/crates/voelin-ui/ui/shells/mobile.slint index ea021ae..50aebb7 100644 --- a/crates/voelin-ui/ui/shells/mobile.slint +++ b/crates/voelin-ui/ui/shells/mobile.slint @@ -265,34 +265,34 @@ export component MobileShell inherits Rectangle { icon: Icons.home; text: @tr("Home"); selected: Nav.mobile-tab == MobileTab.home && Nav.page != Page.settings; - clicked => { Nav.show(Page.home); Nav.mobile-tab = MobileTab.home; } + clicked => { Nav.show-tab(MobileTab.home); } } NavTab { icon: Icons.server; text: @tr("Servers"); selected: Nav.mobile-tab == MobileTab.servers && Nav.page != Page.settings; dot: Bridge.voice-connected; - clicked => { Nav.show(Page.server); Nav.mobile-tab = MobileTab.servers; } + clicked => { Nav.show-tab(MobileTab.servers); } } NavTab { icon: Icons.message-circle; text: @tr("Chats"); selected: Nav.mobile-tab == MobileTab.chat && Nav.page != Page.settings; badge: root.unread; - clicked => { Nav.show(Page.server); Nav.mobile-tab = MobileTab.chat; } + clicked => { Nav.show-tab(MobileTab.chat); } } NavTab { icon: Icons.activity; text: @tr("Activity"); selected: Nav.mobile-tab == MobileTab.activity && Nav.page != Page.settings; badge: Bridge.share-requests; - clicked => { Nav.show(Page.server); Nav.mobile-tab = MobileTab.activity; } + clicked => { Nav.show-tab(MobileTab.activity); } } NavTab { icon: Icons.user; text: @tr("You"); selected: Nav.mobile-tab == MobileTab.you || Nav.page == Page.settings; - clicked => { Nav.show(Page.server); Nav.mobile-tab = MobileTab.you; } + clicked => { Nav.show-tab(MobileTab.you); } } } }