Use normal NavigationLink

This commit is contained in:
Justin Mazzocchi 2021-01-05 13:34:14 -08:00
parent 9c768c82e0
commit 98ac456be6
No known key found for this signature in database
GPG key ID: E223E6937AAFB01C

View file

@ -9,8 +9,6 @@ struct AddIdentityView: View {
@Environment(\.accessibilityReduceMotion) var accessibilityReduceMotion @Environment(\.accessibilityReduceMotion) var accessibilityReduceMotion
@EnvironmentObject var rootViewModel: RootViewModel @EnvironmentObject var rootViewModel: RootViewModel
@State private var navigateToRegister = false
var body: some View { var body: some View {
Form { Form {
Section { Section {
@ -45,28 +43,21 @@ struct AddIdentityView: View {
} else { } else {
Button("add-identity.log-in", Button("add-identity.log-in",
action: viewModel.logInTapped) action: viewModel.logInTapped)
if let instance = viewModel.instance, let url = viewModel.url,
instance.registrations {
ZStack {
NavigationLink(
destination: RegistrationView(
viewModel: viewModel.registrationViewModel(
instance: instance,
url: url)),
isActive: $navigateToRegister) {
EmptyView()
}
.hidden()
Button(instance.approvalRequired
? "add-identity.request-invite"
: "add-identity.join") {
navigateToRegister.toggle()
}
}
}
if viewModel.isPublicTimelineAvailable { if viewModel.isPublicTimelineAvailable {
Button("add-identity.browse", action: viewModel.browseTapped) Button("add-identity.browse", action: viewModel.browseTapped)
} }
if let instance = viewModel.instance,
let url = viewModel.url,
instance.registrations {
NavigationLink(
instance.approvalRequired
? "add-identity.request-invite"
: "add-identity.join",
destination: RegistrationView(
viewModel: viewModel.registrationViewModel(
instance: instance,
url: url)))
}
} }
} }
.frame(maxWidth: .infinity, alignment: .center) .frame(maxWidth: .infinity, alignment: .center)