diff --git a/Kordophone/Shared/LoginView.swift b/Kordophone/Shared/LoginView.swift index 9c73375..18a97c8 100644 --- a/Kordophone/Shared/LoginView.swift +++ b/Kordophone/Shared/LoginView.swift @@ -7,19 +7,38 @@ struct LoginView : View { @AppStorage("username") var username: String = "" @AppStorage("password") var password: String = "" + @State private var loggingIn = false + var onLogin: (ConnectionInfo) -> Void = { _ in } + private func login() { + loggingIn = true + onLogin(ConnectionInfo(serverAddress: serverAddress, + credentials: Credentials(username: username, + password: password))) + } + var body: some View { VStack { TextField("server", text: $serverAddress) + .onSubmit { + login() + } TextField("username", text: $username) + .onSubmit { + login() + } SecureField("password", text: $password) + .onSubmit { + login() + } Button("Login") { - onLogin(ConnectionInfo(serverAddress: serverAddress, - credentials: Credentials(username: username, - password: password))) + login() } + .keyboardShortcut(.return) } + .disabled(loggingIn) + .animation(.spring(), value: loggingIn) .padding() } }