From 95f021672e025f540368204e733f57891b2d1a8c Mon Sep 17 00:00:00 2001 From: Ybrin <11356621+koraykoska@users.noreply.github.com> Date: Tue, 28 Sep 2021 12:00:58 +0200 Subject: [PATCH] fix: make replace in Navigate customizable --- Sources/Navigate.swift | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/Sources/Navigate.swift b/Sources/Navigate.swift index 091286c..1c03fc8 100644 --- a/Sources/Navigate.swift +++ b/Sources/Navigate.swift @@ -28,10 +28,13 @@ 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 { @@ -39,7 +42,7 @@ public struct Navigate: View { .hidden() .onAppear { if navigator.path != path { - navigator.navigate(resolvePaths(relativePath, path), replace: true) + navigator.navigate(resolvePaths(relativePath, path), replace: replace) } } }