From 8cf926db6c481ea727f38b1dee9d9d970a84e820 Mon Sep 17 00:00:00 2001 From: Airyzz <36567925+Airyzz@users.noreply.github.com> Date: Fri, 27 Feb 2026 20:11:09 +1030 Subject: [PATCH] improve navigation --- commet/lib/config/preferences.dart | 3 +++ commet/lib/ui/pages/main/main_page.dart | 10 +++++---- .../ui/pages/main/main_page_view_mobile.dart | 21 ++++++++++++++++++- .../categories/app/boolean_toggle.dart | 4 ++-- .../categories/app/general_settings_page.dart | 6 ++++++ 5 files changed, 37 insertions(+), 7 deletions(-) diff --git a/commet/lib/config/preferences.dart b/commet/lib/config/preferences.dart index c12603f1b..d64c67307 100644 --- a/commet/lib/config/preferences.dart +++ b/commet/lib/config/preferences.dart @@ -306,6 +306,9 @@ class Preferences { defaultGetter: () => Layout.mobile ? false : true, defaultValue: false); + BoolPreference automaticallyOpenSpace = + BoolPreference("open_space_on_room_navigation", defaultValue: true); + DoublePreference textScale = DoublePreference("text_scale", defaultValue: 1.0); diff --git a/commet/lib/ui/pages/main/main_page.dart b/commet/lib/ui/pages/main/main_page.dart index 466683994..56b6acd01 100644 --- a/commet/lib/ui/pages/main/main_page.dart +++ b/commet/lib/ui/pages/main/main_page.dart @@ -320,11 +320,13 @@ class MainPageState extends State { } if (room != null) { - var spacesWithRoom = - client.spaces.where((element) => element.containsRoom(roomId)); + if (preferences.automaticallyOpenSpace.value) { + var spacesWithRoom = + client.spaces.where((element) => element.containsRoom(roomId)); - if (spacesWithRoom.isNotEmpty) { - selectSpace(spacesWithRoom.first); + if (spacesWithRoom.isNotEmpty) { + selectSpace(spacesWithRoom.first); + } } selectRoom(room); diff --git a/commet/lib/ui/pages/main/main_page_view_mobile.dart b/commet/lib/ui/pages/main/main_page_view_mobile.dart index f3923ea2b..1d793ee36 100644 --- a/commet/lib/ui/pages/main/main_page_view_mobile.dart +++ b/commet/lib/ui/pages/main/main_page_view_mobile.dart @@ -1,3 +1,4 @@ +import 'package:commet/client/components/direct_messages/direct_message_component.dart'; import 'package:commet/client/room.dart'; import 'package:commet/config/layout_config.dart'; import 'package:commet/ui/atoms/room_header.dart'; @@ -90,6 +91,22 @@ class _MainPageViewMobileState extends State { return; } + if (widget.state.currentView == MainPageSubView.home && + widget.state.currentRoom != null) { + if (widget.state.currentRoom != null) { + var dm = widget.state.currentRoom!.client + .getComponent(); + if (dm?.isRoomDirectMessage(widget.state.currentRoom!) == true) { + panelsKey.currentState?.reveal(RevealSide.left); + return; + } + } + + widget.state.selectHome(); + + return; + } + switch (panelsKey.currentState?.currentSide) { case RevealSide.right: panelsKey.currentState?.reveal(RevealSide.main); @@ -102,7 +119,9 @@ class _MainPageViewMobileState extends State { child: Foundation( child: OverlappingPanels( key: panelsKey, - onDragStart: () {}, + onDragStart: () { + FocusManager.instance.primaryFocus?.unfocus(); + }, onSideChange: (side) { setState(() { shouldMainIgnoreInput = side != RevealSide.main; diff --git a/commet/lib/ui/pages/settings/categories/app/boolean_toggle.dart b/commet/lib/ui/pages/settings/categories/app/boolean_toggle.dart index de62efabd..f98d41878 100644 --- a/commet/lib/ui/pages/settings/categories/app/boolean_toggle.dart +++ b/commet/lib/ui/pages/settings/categories/app/boolean_toggle.dart @@ -45,7 +45,7 @@ class _BooleanPreferenceToggleState extends State { ), ), Padding( - padding: const EdgeInsets.all(8.0), + padding: const EdgeInsets.fromLTRB(8, 8, 0, 8), child: tiamat.Switch( state: widget.preference.value, onChanged: (value) async { @@ -100,7 +100,7 @@ class _NullableBooleanPreferenceToggleState ), ), Padding( - padding: const EdgeInsets.all(8.0), + padding: const EdgeInsets.fromLTRB(8, 8, 0, 8), child: tiamat.Switch( state: widget.preference.value ?? false, onChanged: (value) async { diff --git a/commet/lib/ui/pages/settings/categories/app/general_settings_page.dart b/commet/lib/ui/pages/settings/categories/app/general_settings_page.dart index 537da54d0..d475ac5d8 100644 --- a/commet/lib/ui/pages/settings/categories/app/general_settings_page.dart +++ b/commet/lib/ui/pages/settings/categories/app/general_settings_page.dart @@ -147,6 +147,12 @@ class GeneralSettingsPageState extends State { title: "Autofocus Message Input", description: "Automatically focus on the message input text field when opening a chat", + ), + BooleanPreferenceToggle( + preference: preferences.automaticallyOpenSpace, + title: "Always open space", + description: + "When navigating to a room from outside of a space, also open the space the room is in, if any", ) ]), ),