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); } } } }