I am currently refactoring my navigation system from NavigationView to the new NavigationStack and I have a view in which if the user presses a button and has a certain device (i.e iPhone SE) then it redirects him to a specific view, and if he doesn't have a certain device the navigation will redirect him to another view.
Here is how I tried to do it
I have the following NavigationLink inside the body:
NavigationLink(value: SignUpDate(deviceName: UIDevice.modelName)) {
Button {
print("log in btn")
} label: {
Text("Log In")
.frame(minWidth: 0, maxWidth: 280)
.font(Font.headline.weight(.bold))
}
.buttonType1()
}
And my NavigationStack has this modifier:
.navigationDestination(for: SignUpDate.self) { destination in
print(destination.deviceName)
if isDeviceRestricted == true {
RestrictedDeviceView()
} else {
SignUpDateView()
}
}
SignUpDate is as follows:
struct SignUpDate: Hashable {
let deviceName: String
}
I don't know what I'm doing wrong but the button actually does nothing, it just acts as if there was no link in the first place.