Instead of using a NavigationLink you could utilize a switch-statement
.
struct ContentView: View {
@State private var currentView: ShowView = .PARENT
var body: some View {
switch currentView {
case .PARENT:
NavigationStack {
Button("Show Subview") {
withAnimation {
currentView = .SUBVIEW
}
}
}
.transition(.backslide)
case .SUBVIEW:
NavigationStack {
Button("Show Parent") {
withAnimation {
currentView = .PARENT
}
}
}
.transition(.backslide)
}
}
}
For this example I used my own enum:
enum ShowView {
case PARENT, SUBVIEW
}
And for the backslide (which I guess is the transition you wanted):
extension AnyTransition {
static var backslide: AnyTransition {
AnyTransition.asymmetric(
insertion: .move(edge: .trailing),
removal: .move(edge: .leading))}
}
The result looks like this (I added black background):

Feel free to add more information if that is not what you wanted.