0

I have the following model in place for navigating to various pages:

enum Destination: Hashable {
  case today
  case activity
  case settings(path: SettingsPath? = nil)
  case project(project: ProjectItem? = nil)
  
  enum SettingsPath: Hashable {
    case cycles
    case donations

  }
}

In an ObservableObject, I'm using

@Published var sidebarDestination: Destination? = .today

And then in various NavigationLink buttons, I'm using the following initializer - NavigationLink(value: NavigationModel.Destination.activity...

In the detail section of my NavigationSplitView I'm using a switch like so

detail: {
      if let destination = navigationModel.sidebarDestination {

        switch destination {

        case .today:
            TodayView()

        case .project(let project):
          // FIXME: Why is the detail view not updating
            if let selectedProject = project {
              IOSProjectDetailView(project: selectedProject)
            } else {
              EmptyView()
            }
...

I've noticed that the pages with an enum case with an associated value are not updating correctly - the title on the page will update, but none of the other content. The pages with an enum case without an associated type seem to work just fine.

All of this is using an iPad - the larger screen sizes

I have tried with iOS 16.0.1 as well as iOS 16.1 and it is not working there either.

Joey Slomowitz
  • 179
  • 1
  • 12

1 Answers1

1

I would need to see your code in greater detail.

The 'selected' variable apparently is @Published var sidebarDestination: Destination? = .today.

That needs to be specified as such in the List definition (e.g. List(selection: $navigationModel.sidebarDestination) ). It is also very important that the types match = they appear to here.

mdecaro
  • 11
  • 2
  • As it’s currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Feb 01 '23 at 10:29