diff --git a/PadelClub.xcodeproj/project.pbxproj b/PadelClub.xcodeproj/project.pbxproj index 623c894..e1d853a 100644 --- a/PadelClub.xcodeproj/project.pbxproj +++ b/PadelClub.xcodeproj/project.pbxproj @@ -22,6 +22,7 @@ C4A47D772B73789100ADC637 /* TournamentV1.swift in Sources */ = {isa = PBXBuildFile; fileRef = C4A47D762B73789100ADC637 /* TournamentV1.swift */; }; C4A47D7B2B73C0F900ADC637 /* TournamentV2.swift in Sources */ = {isa = PBXBuildFile; fileRef = C4A47D7A2B73C0F900ADC637 /* TournamentV2.swift */; }; C4A47D7D2B73CDC300ADC637 /* ClubV1.swift in Sources */ = {isa = PBXBuildFile; fileRef = C4A47D7C2B73CDC300ADC637 /* ClubV1.swift */; }; + C4A47D872B7BA36D00ADC637 /* UserCreationView.swift in Sources */ = {isa = PBXBuildFile; fileRef = C4A47D862B7BA36D00ADC637 /* UserCreationView.swift */; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ @@ -74,6 +75,7 @@ C4A47D762B73789100ADC637 /* TournamentV1.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TournamentV1.swift; sourceTree = ""; }; C4A47D7A2B73C0F900ADC637 /* TournamentV2.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TournamentV2.swift; sourceTree = ""; }; C4A47D7C2B73CDC300ADC637 /* ClubV1.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ClubV1.swift; sourceTree = ""; }; + C4A47D862B7BA36D00ADC637 /* UserCreationView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UserCreationView.swift; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -191,6 +193,7 @@ C4A47D722B72881500ADC637 /* Views */ = { isa = PBXGroup; children = ( + C4A47D852B7BA33F00ADC637 /* User */, C425D4022B6D249D002A7B48 /* ContentView.swift */, C4A47D732B72881F00ADC637 /* ClubView.swift */, ); @@ -207,6 +210,14 @@ path = Migration; sourceTree = ""; }; + C4A47D852B7BA33F00ADC637 /* User */ = { + isa = PBXGroup; + children = ( + C4A47D862B7BA36D00ADC637 /* UserCreationView.swift */, + ); + path = User; + sourceTree = ""; + }; /* End PBXGroup section */ /* Begin PBXNativeTarget section */ @@ -360,6 +371,7 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( + C4A47D872B7BA36D00ADC637 /* UserCreationView.swift in Sources */, C4A47D742B72881F00ADC637 /* ClubView.swift in Sources */, C4A47D5A2B6D383C00ADC637 /* Tournament.swift in Sources */, C4A47D7B2B73C0F900ADC637 /* TournamentV2.swift in Sources */, diff --git a/PadelClub/Views/ContentView.swift b/PadelClub/Views/ContentView.swift index b634467..671ab8b 100644 --- a/PadelClub/Views/ContentView.swift +++ b/PadelClub/Views/ContentView.swift @@ -17,11 +17,6 @@ struct ContentView: View { VStack { - Image(systemName: "globe") - .imageScale(.large) - .foregroundStyle(.tint) - Text("Hello, world!") - List(self.dataStore.clubs) { club in NavigationLink { @@ -30,12 +25,26 @@ struct ContentView: View { Text(club.name) } } + + Button("add") { + self._add() + } + .padding() + .buttonStyle(.bordered) } + .toolbar(content: { + ToolbarItem { + + NavigationLink { + UserCreationView() + } label: { + Image(systemName: "person.circle.fill") + } + + } + }) + .navigationTitle("Home") - Button("add") { - self._add() - }.padding() - .buttonStyle(.bordered) } } diff --git a/PadelClub/Views/User/UserCreationView.swift b/PadelClub/Views/User/UserCreationView.swift new file mode 100644 index 0000000..4dd2f07 --- /dev/null +++ b/PadelClub/Views/User/UserCreationView.swift @@ -0,0 +1,58 @@ +// +// UserCreationView.swift +// PadelClub +// +// Created by Laurent Morvillier on 13/02/2024. +// + +import SwiftUI +import LeStorage + +struct UserCreationView: View { + + @State var username: String = "" + @State var password: String = "" + @State var email: String = "" + + var body: some View { + + Form { + + TextField("Username", text: self.$username) + TextField("Password", text: self.$password) + TextField("Email", text: self.$email) + + Section { + Button(action: { + self._create() + }, label: { + Text("Create") + }) + .frame(maxWidth: .infinity) + } + } + .navigationTitle("Create user") + } + + fileprivate func _create() { + guard let service = Store.main.service else { + return + } + Task { + do { + try await service.createAccount( + username: self.username, + password: self.password, + email: self.email) + } catch { + Logger.error(error) + } + } + + } + +} + +#Preview { + UserCreationView() +}