Open Settings from yattee://settings

SettingsView owns its navigation stack, so pushing it onto a section's
stack rendered nothing. Select the Settings section where the layout has
one, otherwise present Home's settings sheet; open the Settings window on
macOS.
This commit is contained in:
Arkadiusz Fal
2026-10-05 23:37:14 +02:00
parent dea4f590ec
commit 498a282396
5 changed files with 66 additions and 4 deletions

View File

@@ -37,6 +37,12 @@ final class NavigationCoordinator {
/// Sheets observe it via `.dismissesOnExternalNavigation(_:)`.
var dismissPresentationsGeneration = 0
#if os(macOS)
/// Bumped to ask the main window to open the Settings window, which only a
/// view can do (`openWindow`).
var openSettingsWindowRequest = 0
#endif
/// Whether the mini player is expanded to full screen.
var isPlayerExpanded = false {
didSet {
@@ -231,10 +237,27 @@ final class NavigationCoordinator {
/// Navigate to a destination by pushing it onto the selected section's stack.
func navigate(to destination: NavigationDestination) {
// Settings has its own navigation stack, so it can't be pushed onto a
// section's stack: it is a section, a sheet, or a window instead.
if case .settings = destination {
openSettings()
return
}
router.push(destination)
handoffManager?.updateActivity(for: destination)
}
/// Shows Settings the way the current layout presents it: the Settings
/// section where the layout has one, otherwise the Home screen's sheet
/// (`NavigationRouter.ensureSelectionIsAvailable`), or on macOS its window.
func openSettings() {
#if os(macOS)
openSettingsWindowRequest += 1
#else
router.select(.settings)
#endif
}
// MARK: - Sheet Presentation
/// Dismiss the main window's sheets so external navigation lands on a

View File

@@ -32,6 +32,11 @@ final class NavigationRouter {
/// sidebar layout so it is created and loaded once.
let sidebarManager = SidebarManager()
/// Set when Settings was requested in a layout without a Settings section
/// (the iPhone tab bar, unless the user added the tab). Home presents its
/// Settings sheet and clears it.
var pendingSettingsSheet = false
@ObservationIgnored private var hasAppliedStartupTab = false
@ObservationIgnored private var isSidebarManagerConfigured = false
@@ -139,6 +144,10 @@ final class NavigationRouter {
case .sources:
host = .home
root = .mediaSources
case .settings:
host = .home
root = nil
pendingSettingsSheet = true
default:
host = .home
root = current.navigationDestination()