diff --git a/SportApp.xcodeproj/project.pbxproj b/SportApp.xcodeproj/project.pbxproj index e0291a3..94606c3 100644 --- a/SportApp.xcodeproj/project.pbxproj +++ b/SportApp.xcodeproj/project.pbxproj @@ -39,16 +39,28 @@ isa = PBXFileSystemSynchronizedBuildFileExceptionSet; membershipExceptions = ( Info.plist, + Statistics/Model/DTO/ReggedDTO.swift, ); target = 310422A32E14371C00D64B73 /* SportApp */; }; /* End PBXFileSystemSynchronizedBuildFileExceptionSet section */ +/* Begin PBXFileSystemSynchronizedGroupBuildPhaseMembershipExceptionSet section */ + CE544C352E214C5B0044B6B1 /* Exceptions for "SportApp" folder in "Copy Bundle Resources" phase from "SportApp" target */ = { + isa = PBXFileSystemSynchronizedGroupBuildPhaseMembershipExceptionSet; + buildPhase = 310422A22E14371C00D64B73 /* Resources */; + membershipExceptions = ( + Statistics/Model/DTO/ReggedDTO.swift, + ); + }; +/* End PBXFileSystemSynchronizedGroupBuildPhaseMembershipExceptionSet section */ + /* Begin PBXFileSystemSynchronizedRootGroup section */ 310422A62E14371C00D64B73 /* SportApp */ = { isa = PBXFileSystemSynchronizedRootGroup; exceptions = ( 319C0E342E168DEF00BF7D83 /* Exceptions for "SportApp" folder in "SportApp" target */, + CE544C352E214C5B0044B6B1 /* Exceptions for "SportApp" folder in "Copy Bundle Resources" phase from "SportApp" target */, ); path = SportApp; sourceTree = ""; diff --git a/SportApp.xcodeproj/project.xcworkspace/xcuserdata/user.xcuserdatad/UserInterfaceState.xcuserstate b/SportApp.xcodeproj/project.xcworkspace/xcuserdata/user.xcuserdatad/UserInterfaceState.xcuserstate index 1685eb2..d678d96 100644 Binary files a/SportApp.xcodeproj/project.xcworkspace/xcuserdata/user.xcuserdatad/UserInterfaceState.xcuserstate and b/SportApp.xcodeproj/project.xcworkspace/xcuserdata/user.xcuserdatad/UserInterfaceState.xcuserstate differ diff --git a/SportApp/Registration/View/RegistrationShieldView.swift b/SportApp/Registration/View/RegistrationShieldView.swift index 9ecb0be..b47b2ec 100644 --- a/SportApp/Registration/View/RegistrationShieldView.swift +++ b/SportApp/Registration/View/RegistrationShieldView.swift @@ -149,7 +149,7 @@ struct RegistrationShieldView: View { }, label: { if coordinator.user.isAdmin == false { VStack { - Text("Вы входите как пользователь") + Text("Вы входите как участник") .foregroundColor(Color(red: 25/255, green: 33/255, blue: 38/255)) HStack { Text("Нет аккаунта? ") diff --git a/SportApp/Statistics/View/StatisticsView.swift b/SportApp/Statistics/View/StatisticsView.swift index c3325ba..9558677 100644 --- a/SportApp/Statistics/View/StatisticsView.swift +++ b/SportApp/Statistics/View/StatisticsView.swift @@ -18,10 +18,24 @@ struct StatisticsView: View { var body: some View { VStack { + Text("Статистика") + .font(.system(size: 24, weight: .bold)) + .padding(.leading, 20) + .padding(.bottom, 32) + ScrollView { - ForEach(TournirInstaseState.list, id: \.id) { state in + ForEach(TournirInstantState.list, id: \.id) { state in VStack { - Text(state.rawValue) + Text(TournirInstantState.toString(state)) + .font(.system(size: 24, weight: .medium)) + .frame(maxWidth: .infinity, alignment: .leading) + .foregroundColor(Color(red: 123/255, green: 123/255, blue: 123/255)) + .padding(.horizontal, 20) + .padding(.bottom, 10) + Rectangle() + .fill(Color(red: 123/255, green: 123/255, blue: 123/255)) + .frame(height: 1) + .padding(.horizontal, 12) ForEach(tournirs, id: \.id) { tournir in if tournir.tournirInstanteState == state { diff --git a/SportApp/Tournirs/Model/Tournir.swift b/SportApp/Tournirs/Model/Tournir.swift index 3202e92..67127e6 100644 --- a/SportApp/Tournirs/Model/Tournir.swift +++ b/SportApp/Tournirs/Model/Tournir.swift @@ -23,7 +23,7 @@ struct Tournir: Codable, Identifiable, Hashable { var organizer_id: UUID var users: [User] = [] var requirements: Requirements - var tournirInstanteState: TournirInstaseState + var tournirInstanteState: TournirInstantState var currentMatch: Int = 0 var matchs: Int var winner: User? @@ -44,7 +44,7 @@ struct Tournir: Codable, Identifiable, Hashable { organizer_id: UUID, users: [User] = [], requirements: Requirements, - tournirInstaseState: TournirInstaseState = .openedRegistrationTournaments, + tournirInstaseState: TournirInstantState = .openedRegistrationTournaments, winner: User? = nil ) { self.id = id @@ -64,11 +64,13 @@ struct Tournir: Codable, Identifiable, Hashable { self.requirements = requirements self.matchs = 0 if max_participants > 0 { + let logValue = log2(Double(max_participants)) if logValue.isFinite { matchs = Int(ceil(logValue)) } } + self.tournirInstanteState = tournirInstaseState self.max_participants = nextPowerOfTwo(max_participants) @@ -82,7 +84,7 @@ struct Tournir: Codable, Identifiable, Hashable { } } -enum TournirInstaseState: String, Codable, Identifiable, Hashable { +enum TournirInstantState: String, Codable, Identifiable, Hashable { case endedTournaments case ongoingTournaments case closedRegistrationTournaments @@ -100,8 +102,33 @@ enum TournirInstaseState: String, Codable, Identifiable, Hashable { return 4 } } - - static func nextState(_ state: TournirInstaseState) -> TournirInstaseState { + static func toString(_ state: TournirInstantState) -> String { + switch state { + case .endedTournaments: + return "Завершенные соревнования" + case .ongoingTournaments: + return "Проходит сейчас" + case .closedRegistrationTournaments: + return "Закончилась регистация" + case .openedRegistrationTournaments: + return "Идёт регистрация" + } + } + static func fromString(_ string: String) -> TournirInstantState { + switch string { + case "Завершенные соревнования": + return .endedTournaments + case "Проходит сейчас": + return .ongoingTournaments + case "Закончилась регистация": + return .closedRegistrationTournaments + case "Идёт регистрация": + return .openedRegistrationTournaments + default: + return .openedRegistrationTournaments + } + } + static func nextState(_ state: TournirInstantState) -> TournirInstantState { switch state { case .openedRegistrationTournaments: return .closedRegistrationTournaments @@ -114,7 +141,7 @@ enum TournirInstaseState: String, Codable, Identifiable, Hashable { } } - static let list: [TournirInstaseState] = [.openedRegistrationTournaments, .closedRegistrationTournaments, .ongoingTournaments, .endedTournaments] + static let list: [TournirInstantState] = [.openedRegistrationTournaments, .closedRegistrationTournaments, .ongoingTournaments, .endedTournaments] } struct Requirements: Codable, Hashable { diff --git a/SportApp/Tournirs/View/TournirsDetail.swift b/SportApp/Tournirs/View/TournirsDetail.swift index 9bce6f2..a6e8359 100644 --- a/SportApp/Tournirs/View/TournirsDetail.swift +++ b/SportApp/Tournirs/View/TournirsDetail.swift @@ -124,7 +124,7 @@ struct TournirsDetail: View { return } - let newState = TournirInstaseState.nextState(currentTournir.tournirInstanteState) + let newState = TournirInstantState.nextState(currentTournir.tournirInstanteState) if let index = viewModel2.tournirs.firstIndex(where: { $0.id == currentTournir.id }) { viewModel2.tournirs[index].tournirInstanteState = newState @@ -164,6 +164,7 @@ struct TournirsDetail: View { Text(title) .frame(width: 80, height: 30) .background(match == coordinator.currentTournir!.currentMatch ? Color.green : Color.gray) + .cornerRadius(10) Spacer() } @@ -193,8 +194,7 @@ struct TournirsDetail: View { Rectangle() .fill(Color(red: 123/255, green: 123/255, blue: 123/255)) - .frame(height: 1) - .padding(.horizontal, 12) + .frame(width: 375, height: 1) HStack { Text(axoroms.second.phio) @@ -217,13 +217,13 @@ struct TournirsDetail: View { } .padding(.horizontal, 16) .padding(.vertical, 8) - .background(Color.gray) + .background(Color(red: 230/255, green: 230/255, blue: 230/255)) .cornerRadius(8) .padding(.horizontal, 16) .padding(.vertical, 8) } - Button("FFFFFFFFF мне за труд ибо я устал это писать") { + Button("Далее") { var c = 0 for i in viewModel.axoroms { if i.isFirstWinner != nil { @@ -247,7 +247,7 @@ struct TournirsDetail: View { if let winner = coordinator.currentTournir!.winner { Text("Победитель \(winner.phio)") } else { - Text("Победитель Влад") + Text("У вас недостаточно участников для начала соревнования") } } } @@ -265,16 +265,19 @@ struct TournirsDetail: View { var participantsView: some View { List { - HStack { + HStack{ + Spacer() Text("Участники") - .padding(.leading) - Spacer() } ScrollView { ForEach(viewModel.participants, id: \.id) { participant in - Text(participant.phio) - .padding() + HStack { + Text(participant.phio) + .padding(.leading) + Spacer() + } + .padding(.vertical, 8) } } }