Created
January 16, 2023 19:10
-
-
Save dinotrnka/6489643540ebdb9aaf11366bb292344c to your computer and use it in GitHub Desktop.
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 | |
struct LoginScreen: View { | |
@ObservedObject var viewModel: LoginViewModel = LoginViewModel() | |
var body: some View { | |
VStack { | |
Spacer() | |
VStack { | |
TextField( | |
"Login.UsernameField.Title".localized, | |
text: $viewModel.username | |
) | |
.autocapitalization(.none) | |
.disableAutocorrection(true) | |
.padding(.top, 20) | |
Divider() | |
SecureField( | |
"Login.PasswordField.Title".localized, | |
text: $viewModel.password | |
) | |
.padding(.top, 20) | |
Divider() | |
} | |
Spacer() | |
if viewModel.error != nil { // Added this | |
Text("Login error") | |
.fontWeight(.bold) | |
.foregroundColor(.red) | |
} | |
Spacer() | |
Button( | |
action: viewModel.login, | |
label: { | |
Text("Login.LoginButton.Title".localized) | |
.modifier(MainButton()) | |
} | |
) | |
} | |
.padding(30) | |
} | |
} | |
struct LoginScreen_Previews: PreviewProvider { | |
static var previews: some View { | |
LoginScreen() | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment