Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -202,14 +202,22 @@ public struct _NavigationDestinationViewModifier<
content
.environment(\.navigationDestinationType, State.self)
.navigationDestination(for: StackState<State>.Component.self) { component in
navigationDestination(component: component)
destination(store.scope(component: component, fileID: fileID, filePath: filePath, line: line, column: column))
.environment(\.navigationDestinationType, State.self)
}
}
}

@MainActor
private func navigationDestination(component: StackState<State>.Component) -> Destination {
let id = store.id(
@_spi(Internals)
public extension Store {
func scope<ChildState, ChildAction>(
component: StackState<ChildState>.Component,
fileID: StaticString = #fileID,
filePath: StaticString = #filePath,
line: UInt = #line,
column: UInt = #column
) -> Store<ChildState, ChildAction> where State == StackState<ChildState>, Action == StackAction<ChildState, ChildAction> {
let id = self.id(
state:
\.[
id: component.id,
Expand All @@ -222,8 +230,8 @@ public struct _NavigationDestinationViewModifier<
)
@MainActor
func open(
_ core: some Core<StackState<State>, StackAction<State, Action>>
) -> any Core<State, Action> {
_ core: some Core<StackState<ChildState>, StackAction<ChildState, ChildAction>>
) -> any Core<ChildState, ChildAction> {
IfLetCore(
base: core,
cachedState: component.element,
Expand All @@ -238,7 +246,7 @@ public struct _NavigationDestinationViewModifier<
actionKeyPath: \.[id: component.id]
)
}
return destination(store.scope(id: id, childCore: open(store.core)))
return self.scope(id: id, childCore: open(self.core))
}
}

Expand Down
Loading