|
|
@ -7,19 +7,38 @@ struct LoginView : View { |
|
|
|
@AppStorage("username") var username: String = "" |
|
|
|
@AppStorage("username") var username: String = "" |
|
|
|
@AppStorage("password") var password: String = "" |
|
|
|
@AppStorage("password") var password: String = "" |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@State private var loggingIn = false |
|
|
|
|
|
|
|
|
|
|
|
var onLogin: (ConnectionInfo) -> Void = { _ in } |
|
|
|
var onLogin: (ConnectionInfo) -> Void = { _ in } |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private func login() { |
|
|
|
|
|
|
|
loggingIn = true |
|
|
|
|
|
|
|
onLogin(ConnectionInfo(serverAddress: serverAddress, |
|
|
|
|
|
|
|
credentials: Credentials(username: username, |
|
|
|
|
|
|
|
password: password))) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
var body: some View { |
|
|
|
var body: some View { |
|
|
|
VStack { |
|
|
|
VStack { |
|
|
|
TextField("server", text: $serverAddress) |
|
|
|
TextField("server", text: $serverAddress) |
|
|
|
|
|
|
|
.onSubmit { |
|
|
|
|
|
|
|
login() |
|
|
|
|
|
|
|
} |
|
|
|
TextField("username", text: $username) |
|
|
|
TextField("username", text: $username) |
|
|
|
|
|
|
|
.onSubmit { |
|
|
|
|
|
|
|
login() |
|
|
|
|
|
|
|
} |
|
|
|
SecureField("password", text: $password) |
|
|
|
SecureField("password", text: $password) |
|
|
|
|
|
|
|
.onSubmit { |
|
|
|
|
|
|
|
login() |
|
|
|
|
|
|
|
} |
|
|
|
Button("Login") { |
|
|
|
Button("Login") { |
|
|
|
onLogin(ConnectionInfo(serverAddress: serverAddress, |
|
|
|
login() |
|
|
|
credentials: Credentials(username: username, |
|
|
|
|
|
|
|
password: password))) |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
.keyboardShortcut(.return) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
.disabled(loggingIn) |
|
|
|
|
|
|
|
.animation(.spring(), value: loggingIn) |
|
|
|
.padding() |
|
|
|
.padding() |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|