Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions SportApp.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -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 = "<group>";
Expand Down
Binary file not shown.
2 changes: 1 addition & 1 deletion SportApp/Registration/View/RegistrationShieldView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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("Нет аккаунта? ")
Expand Down
18 changes: 16 additions & 2 deletions SportApp/Statistics/View/StatisticsView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
39 changes: 33 additions & 6 deletions SportApp/Tournirs/Model/Tournir.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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?
Expand All @@ -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
Expand All @@ -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)
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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 {
Expand Down
25 changes: 14 additions & 11 deletions SportApp/Tournirs/View/TournirsDetail.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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()
}
Expand Down Expand Up @@ -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)
Expand All @@ -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 {
Expand All @@ -247,7 +247,7 @@ struct TournirsDetail: View {
if let winner = coordinator.currentTournir!.winner {
Text("Победитель \(winner.phio)")
} else {
Text("Победитель Влад")
Text("У вас недостаточно участников для начала соревнования")
}
}
}
Expand All @@ -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)
}
}
}
Expand Down
Loading