parent
d40dbcba9c
commit
902cc1af54
@ -0,0 +1,59 @@ |
|||||||
|
// |
||||||
|
// LoginView.swift |
||||||
|
// PadelClub |
||||||
|
// |
||||||
|
// Created by Laurent Morvillier on 19/02/2024. |
||||||
|
// |
||||||
|
|
||||||
|
import SwiftUI |
||||||
|
import LeStorage |
||||||
|
|
||||||
|
struct LoginView: View { |
||||||
|
|
||||||
|
@State var username: String = "laurent" |
||||||
|
@State var password: String = "staxkikoo" |
||||||
|
|
||||||
|
var body: some View { |
||||||
|
|
||||||
|
Form { |
||||||
|
|
||||||
|
TextField("Username", text: self.$username) |
||||||
|
.autocorrectionDisabled() |
||||||
|
.textInputAutocapitalization(.never) |
||||||
|
SecureField("Password", text: self.$password) |
||||||
|
.autocorrectionDisabled() |
||||||
|
.textInputAutocapitalization(.never) |
||||||
|
|
||||||
|
Section { |
||||||
|
Button(action: { |
||||||
|
self._login() |
||||||
|
}, label: { |
||||||
|
Text("Login") |
||||||
|
}) |
||||||
|
.frame(maxWidth: .infinity) |
||||||
|
} |
||||||
|
} |
||||||
|
.navigationTitle("Login") |
||||||
|
} |
||||||
|
|
||||||
|
fileprivate func _login() { |
||||||
|
guard let service = Store.main.service else { |
||||||
|
return |
||||||
|
} |
||||||
|
Task { |
||||||
|
do { |
||||||
|
_ = try await service.login( |
||||||
|
username: self.username, |
||||||
|
password: self.password) |
||||||
|
} catch { |
||||||
|
Logger.error(error) |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
#Preview { |
||||||
|
LoginView() |
||||||
|
} |
||||||
Loading…
Reference in new issue