Last active
July 7, 2020 15:09
-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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