I am trying to make a button that goes to another screen that sits in a separate screen file when clicked.
Screen 1
screen one code
struct Login_Screen: View {
@State private var username = ""
@State private var password = ""
@State private var wrongusername = 0
@State private var wrongpassword = 0
@State private var showingLoginScreen = false
var body: some View {
NavigationStack {
ZStack {
backglogin()
VStack{
VStack {
NavigationLink(destination: Homepage()) {
loginB()}
}
.padding(.vertical, 140.0)
.navigationBarHidden(true)
}
}
}
}
}
ive hidden all of the not relevant data to the button im working on and thats the login button.
The other file is the Homepage file, and the loginB() is a reference to the format of the button from another file. I am trying to make it so that when this button is clicked it goes to this screen in the other swift file.
Screen 2 code
struct Homepage: View {
var body: some View {
ZStack{
backgmain()
welcome()
ZStack{
HStack(spacing: 70)
{
Button{print("hi")}label: {dumbbellB()}
Button{print("hi")}label: {dumbbellB()}
Button{print("hi")}label: {profileB()}
}
}
.ignoresSafeArea()
.position(x:200,y:700)
}
}
}```
again those button labels are formatted in another file.
I have tried searching youtube but all of the videoes I saw use the storyboard.