Skip to content

Instantly share code, notes, and snippets.

@fdstevex
Last active July 7, 2020 15:09
Show Gist options
  • Save fdstevex/ff27caa24298bcc59484dabccfbe969e to your computer and use it in GitHub Desktop.
Save fdstevex/ff27caa24298bcc59484dabccfbe969e to your computer and use it in GitHub Desktop.
Login view based on @jordansinger's but with a placeholder for a function to do the login.
import SwiftUI
import PlaygroundSupport
struct SignUpView: View {
@State var username = ""
@State var password = ""
@State var loggedIn = false
var body: some View {
NavigationView {
Form {
Section {
TextField("Username", text: $username)
SecureField("Password", text: $password)
}
if loggedIn {
NavigationLink(destination: WelcomeView(), isActive: $loggedIn) {
Button("Log In") {
// Has to be here so it renders during the Back transition
}
}
} else {
Button("Log In") {
print("Logging in")
loggedIn = true
}
}
}
.navigationBarTitle("Sign up")
}
.accentColor(.primary)
.navigationViewStyle(StackNavigationViewStyle())
}
}
struct WelcomeView: View {
var body: some View {
VStack(spacing: 20) {
Image(systemName: "checkmark.circle.fill")
.font(.largeTitle)
.foregroundColor(.green)
Text("Welcome")
.font(.title)
}
}
}
PlaygroundPage.current.setLiveView(SignUpView())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment