Im trying to put a navigationDestination(isPresented:destination:) for a button on Xcode14/iOS16, it executes the func and so when I press the button but it doesn't send me to the new view and also i cant see if it is passing the information from one view to another.
Button(action: {watchGame(name: "Cuphead")} , label: {
Image("abzu")
.resizable()
.scaledToFit()
.frame(width: 240, height: 135)
}).navigationDestination(isPresented: $isGameViewActive)
{gameView(url: url,
titulo: titulo,
studio: studio,
calificacion: calificacion,
anoPublicacion: anoPublicacion,
descripcion: descripcion,
tags: tags,
imgsUrl: imgsUrl)
}
func watchGame(name:String) {
juegoEncontrado.search(gameName: name)
DispatchQueue.main.asyncAfter(deadline: .now() + 1){
print("Cantidad E: \(juegoEncontrado.gameInfo.count)")
print("juego \(juegoEncontrado.gameInfo[0].title)")
print(isGameViewActive)
if juegoEncontrado.gameInfo.count == 0 {
isGameInfoEmpty = true
}else{
url = juegoEncontrado.gameInfo[0].videosUrls.mobile
titulo = juegoEncontrado.gameInfo[0].title
studio = juegoEncontrado.gameInfo[0].studio
calificacion = juegoEncontrado.gameInfo[0].contentRaiting
anoPublicacion = juegoEncontrado.gameInfo[0].publicationYear
descripcion = juegoEncontrado.gameInfo[0].description
tags = juegoEncontrado.gameInfo[0].tags
imgsUrl = juegoEncontrado.gameInfo[0].galleryImages
isGameViewActive = true
}
}
}
watchGame is my function to search the name given and return all the information strings that I need to give back to my new view, the isGameViewActive toggle is inside this function so don't worry about that, any idea on how can I solve this?
I tried putting the button or the hole view inside a NavigationStack but when I do that all the content disappears from the screen, Im not understanding this new navigation schemes. The function inside the button executes but it doesn't send me to the other view on the .navigationDestination