Como posso ocultar o fundo de um NavigationLink animado enquanto uso o gesto de deslizar para voltar? Aqui está o que eu tenho atualmente:
e como eu quero que fique:
semelhante ao app Fotos do iOS. Não tenho problema em cobrir o fundo com uma cor sólida ou um desfoque forte, mas não quero que ele fique visível durante a transição.
struct ContentView: View {
@Namespace private var transitionNamespace
var body: some View {
NavigationStack {
VStack {
Text("Should not be visible while swiping")
let value = "details"
NavigationLink(value: value) {
Text("Link")
.frame(width: 200, height: 50)
.background(Color.green.opacity(0.5))
.clipShape(RoundedRectangle(cornerRadius: 32))
.matchedTransitionSource(id: value, in: transitionNamespace)
}
}
.navigationDestination(for: String.self) { value in
ZStack {
Color.yellow.ignoresSafeArea(.all)
Text(value)
}
.navigationTransition(.zoom(sourceID: value, in: transitionNamespace))
.navigationBarBackButtonHidden(true)
}
}
}
}
Outro pequeno problema relacionado: por que essa borda branca aparece enquanto o gesto está em andamento? Como posso corrigir a cor?
struct ContentView: View {
@Namespace private var transitionNamespace
var body: some View {
NavigationStack {
ZStack {
Color.purple.ignoresSafeArea(.all)
// .padding(-200) // this is a solution?
VStack {
Text("Should not be visible while swiping")
let value = "details"
NavigationLink(value: value) {
Text("Link")
.frame(width: 200, height: 50)
.background(Color.green.opacity(0.5))
.clipShape(RoundedRectangle(cornerRadius: 32))
.matchedTransitionSource(id: value, in: transitionNamespace)
}
}
}
.navigationDestination(for: String.self) { value in
ZStack {
Color.yellow.ignoresSafeArea(.all)
Text(value)
}
.navigationTransition(.zoom(sourceID: value, in: transitionNamespace))
.navigationBarBackButtonHidden(true)
}
}
}
}