Skip to content

Commit

Permalink
Fix initial navigation selection on macOS
Browse files Browse the repository at this point in the history
  • Loading branch information
LaurentTreguier committed Jul 24, 2024
1 parent 9647f94 commit ef40af5
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions Fyreplace/Views/Navigation/RegularNavigation.swift
Original file line number Diff line number Diff line change
@@ -1,8 +1,21 @@
import SwiftUI

struct RegularNavigation: View {
@SceneStorage("RegularNavigation.selectedDestination")
private var selectedDestination: Destination?
#if os(macOS)
@SceneStorage("RegularNavigation.selectedDestination")
private var selectedDestination = Destination.feed
#else
@SceneStorage("RegularNavigation.selectedDestination")
private var selectedDestination: Destination?
#endif

private var finalDestination: Destination {
#if os(macOS)
selectedDestination
#else
selectedDestination ?? .feed
#endif
}

var body: some View {
NavigationSplitView {
Expand All @@ -16,7 +29,7 @@ struct RegularNavigation: View {
#endif
} detail: {
NavigationStack {
Screen(destination: selectedDestination ?? .feed)
Screen(destination: finalDestination)
}
}
}
Expand Down

0 comments on commit ef40af5

Please sign in to comment.