Here it's my code.
struct FirstPage: View {
var body: some View {
VStack{
NavigationView {
VStack{
Text("First Page")
.bold()
NavigationLink(destination: SecondPage()) {
Image(systemName:"arrowshape.turn.up.right.circle")
}
}
}
if (isVisible()) {
Image(systemName:"rhombus.fill")
.frame(width: 100, height: 100, alignment: .center)
}
}
}
}
func isVisible() -> Bool {
let result = Bool.random()
print("result", result)
return result
}
What I'd like to do is calling the global func isVisible() from SecondPage and change the visibility of Image(systemName:"rhombus.fill"). Is it possible to do that ?
SecondPage would be like below.
struct SecondPage: View {
var body: some View {
VStack{
NavigationView {
VStack {
Text("Second Page")
.bold()
Button(action: {
}){
Text("Click here")
}
}
}
}
}
}
I want to invoke the isVisible() and change the visibility of Image when I tap the Button of SecondPage.
Does anyone know how to do that ?