Adds login view

multistore
Laurent 2 years ago
parent d40dbcba9c
commit 902cc1af54
  1. 4
      PadelClub.xcodeproj/project.pbxproj
  2. 2
      PadelClub/Views/ContentView.swift
  3. 59
      PadelClub/Views/User/LoginView.swift
  4. 2
      PadelClub/Views/User/UserCreationView.swift

@ -28,6 +28,7 @@
C4A47D912B7BBBEC00ADC637 /* Guard.swift in Sources */ = {isa = PBXBuildFile; fileRef = C4A47D8E2B7BBBEC00ADC637 /* Guard.swift */; };
C4A47D922B7BBBEC00ADC637 /* StoreItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = C4A47D8F2B7BBBEC00ADC637 /* StoreItem.swift */; };
C4A47D9F2B7D0BCE00ADC637 /* StepperView.swift in Sources */ = {isa = PBXBuildFile; fileRef = C4A47D9E2B7D0BCE00ADC637 /* StepperView.swift */; };
C4A47DA62B83948E00ADC637 /* LoginView.swift in Sources */ = {isa = PBXBuildFile; fileRef = C4A47DA52B83948E00ADC637 /* LoginView.swift */; };
/* End PBXBuildFile section */
/* Begin PBXContainerItemProxy section */
@ -86,6 +87,7 @@
C4A47D8E2B7BBBEC00ADC637 /* Guard.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Guard.swift; sourceTree = "<group>"; };
C4A47D8F2B7BBBEC00ADC637 /* StoreItem.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = StoreItem.swift; sourceTree = "<group>"; };
C4A47D9E2B7D0BCE00ADC637 /* StepperView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StepperView.swift; sourceTree = "<group>"; };
C4A47DA52B83948E00ADC637 /* LoginView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LoginView.swift; sourceTree = "<group>"; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
@ -226,6 +228,7 @@
isa = PBXGroup;
children = (
C4A47D862B7BA36D00ADC637 /* UserCreationView.swift */,
C4A47DA52B83948E00ADC637 /* LoginView.swift */,
);
path = User;
sourceTree = "<group>";
@ -416,6 +419,7 @@
C425D4012B6D249D002A7B48 /* PadelClubApp.swift in Sources */,
C4A47D772B73789100ADC637 /* TournamentV1.swift in Sources */,
C4A47D922B7BBBEC00ADC637 /* StoreItem.swift in Sources */,
C4A47DA62B83948E00ADC637 /* LoginView.swift in Sources */,
C4A47D912B7BBBEC00ADC637 /* Guard.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;

@ -35,7 +35,7 @@ struct ContentView: View {
.toolbar(content: {
ToolbarItem {
NavigationLink {
UserCreationView()
LoginView()
} label: {
Image(systemName: "person.circle.fill")
}

@ -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()
}

@ -19,7 +19,9 @@ struct UserCreationView: View {
Form {
TextField("Username", text: self.$username)
.autocorrectionDisabled()
TextField("Password", text: self.$password)
.autocorrectionDisabled()
TextField("Email", text: self.$email)
Section {

Loading…
Cancel
Save