Skip to content

Commit

Permalink
Merge pull request #27 from koraykoska/main
Browse files Browse the repository at this point in the history
fix: make replace in Navigate customizable
  • Loading branch information
frzi committed Sep 28, 2021
2 parents fe08575 + 95f0216 commit edd6728
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions Sources/Navigate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,21 @@ public struct Navigate: View {
@Environment(\.relativePath) private var relativePath

private let path: String


private let replace: Bool

/// - Parameter path: New path to navigate to once the View is rendered.
public init(to path: String) {
public init(to path: String, replace: Bool = true) {
self.path = path
self.replace = replace
}

public var body: some View {
Text("Navigating...")
.hidden()
.onAppear {
if navigator.path != path {
navigator.navigate(resolvePaths(relativePath, path), replace: true)
navigator.navigate(resolvePaths(relativePath, path), replace: replace)
}
}
}
Expand Down

0 comments on commit edd6728

Please sign in to comment.