I want to run account creation logic and then, if successful, transition to the destination view. Otherwise, I\'ll present an error sheet. NavigationLink transitions immedia
Building off of Mohit's answer, making a little more Swifty with an enum that encapsulates screen state:
enum ActionState: Int {
case setup = 0
case readyForPush = 1
}
struct SwiftView: View {
@State private var actionState: ActionState? = .setup
var body: some View {
NavigationView {
VStack {
NavigationLink(destination: SomeView, tag: .readyForPush, selection: $actionState) {
EmptyView()
}
Text("Create Account")
.onTapGesture {
self.asyncTask()
}
}
}
}
func asyncTask() {
//some task which on completion will set the value of actionState
self.actionState = .readyForPush
}