diff --git a/PadelClub.xcodeproj/project.pbxproj b/PadelClub.xcodeproj/project.pbxproj index 8b0ac36..a4957cd 100644 --- a/PadelClub.xcodeproj/project.pbxproj +++ b/PadelClub.xcodeproj/project.pbxproj @@ -1911,7 +1911,7 @@ CODE_SIGN_ENTITLEMENTS = PadelClub/PadelClub.entitlements; CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 93; + CURRENT_PROJECT_VERSION = 94; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; DEFINES_MODULE = YES; DEVELOPMENT_ASSET_PATHS = "\"PadelClub/Preview Content\""; @@ -1958,7 +1958,7 @@ CODE_SIGN_ENTITLEMENTS = PadelClub/PadelClub.entitlements; CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 93; + CURRENT_PROJECT_VERSION = 94; DEFINES_MODULE = YES; DEVELOPMENT_ASSET_PATHS = "\"PadelClub/Preview Content\""; DEVELOPMENT_TEAM = BQ3Y44M3Q6; diff --git a/PadelClub/Data/GroupStage.swift b/PadelClub/Data/GroupStage.swift index c172cb3..2b62442 100644 --- a/PadelClub/Data/GroupStage.swift +++ b/PadelClub/Data/GroupStage.swift @@ -262,7 +262,7 @@ final class GroupStage: ModelObject, Storable { } private func _matchUp(for matchIndex: Int) -> [Int] { - Array((0.. String { @@ -278,9 +278,9 @@ final class GroupStage: ModelObject, Storable { let _teams = _teams(for: matchIndex) switch team { case .one: - return _teams.first! + return _teams.first ?? nil case .two: - return _teams.last! + return _teams.last ?? nil } } @@ -367,6 +367,16 @@ final class GroupStage: ModelObject, Storable { Logger.error(error) } } + + func pasteData() -> String { + var data: [String] = [] + data.append(self.groupStageTitle()) + teams().forEach { team in + data.append(team.teamLabelRanked(displayRank: true, displayTeamName: true)) + } + + return data.joined(separator: "\n") + } override func deleteDependencies() throws { let matches = self._matches() diff --git a/PadelClub/Data/Round.swift b/PadelClub/Data/Round.swift index b4acba5..8b6098f 100644 --- a/PadelClub/Data/Round.swift +++ b/PadelClub/Data/Round.swift @@ -455,6 +455,19 @@ defer { return nextRound()?.isRankDisabled() == false } + func pasteData() -> String { + var data: [String] = [] + data.append(self.roundTitle()) + + playedMatches().forEach { match in + data.append(match.matchTitle()) + data.append(match.team(.one)?.teamLabelRanked(displayRank: true, displayTeamName: true) ?? "-----") + data.append(match.team(.two)?.teamLabelRanked(displayRank: true, displayTeamName: true) ?? "-----") + } + + return data.joined(separator: "\n") + } + func seedInterval(initialMode: Bool = false) -> SeedInterval? { #if DEBUG_TIME //DEBUGING TIME let start = Date() diff --git a/PadelClub/Views/GroupStage/GroupStageSettingsView.swift b/PadelClub/Views/GroupStage/GroupStageSettingsView.swift index f999e11..0900ff9 100644 --- a/PadelClub/Views/GroupStage/GroupStageSettingsView.swift +++ b/PadelClub/Views/GroupStage/GroupStageSettingsView.swift @@ -74,6 +74,12 @@ struct GroupStageSettingsView: View { } } + Section { + ShareLink(item: tournament.groupStages().compactMap { $0.pasteData() }.joined(separator: "\n\n")) { + Text("Exportez l'état poules") + } + } + #if DEBUG Section { RowButtonView("delete all group stages") { diff --git a/PadelClub/Views/GroupStage/GroupStageView.swift b/PadelClub/Views/GroupStage/GroupStageView.swift index 061f0fb..e22963f 100644 --- a/PadelClub/Views/GroupStage/GroupStageView.swift +++ b/PadelClub/Views/GroupStage/GroupStageView.swift @@ -370,27 +370,29 @@ struct GroupStageNameEditionView: View { } private func maximumSize() -> Int { - if groupStage.index == 0 { - return tournament.teamsPerGroupStage + 1 - } - - if let previousGroupStage = tournament.groupStages().first(where: { $0.index == groupStage.index - 1 }), previousGroupStage.size > groupStage.size { - return tournament.teamsPerGroupStage + 1 - } - - return tournament.teamsPerGroupStage + return 10 +// if groupStage.index == 0 { +// return tournament.teamsPerGroupStage + 1 +// } +// +// if let previousGroupStage = tournament.groupStages().first(where: { $0.index == groupStage.index - 1 }), previousGroupStage.size > groupStage.size { +// return tournament.teamsPerGroupStage + 1 +// } +// +// return tournament.teamsPerGroupStage } private func minimumSize() -> Int { - if groupStage.index == tournament.groupStageCount - 1 { - return max(3, tournament.teamsPerGroupStage - 1) - } - - if let nextGroupStage = tournament.groupStages().first(where: { $0.index == groupStage.index + 1 }), nextGroupStage.size < groupStage.size { - return max(3, tournament.teamsPerGroupStage - 1) - } - - return tournament.teamsPerGroupStage + return 3 +// if groupStage.index == tournament.groupStageCount - 1 { +// return max(3, tournament.teamsPerGroupStage - 1) +// } +// +// if let nextGroupStage = tournament.groupStages().first(where: { $0.index == groupStage.index + 1 }), nextGroupStage.size < groupStage.size { +// return max(3, tournament.teamsPerGroupStage - 1) +// } +// +// return tournament.teamsPerGroupStage } private func _save() { diff --git a/PadelClub/Views/Round/RoundSettingsView.swift b/PadelClub/Views/Round/RoundSettingsView.swift index eb13a7b..e913a61 100644 --- a/PadelClub/Views/Round/RoundSettingsView.swift +++ b/PadelClub/Views/Round/RoundSettingsView.swift @@ -74,6 +74,12 @@ struct RoundSettingsView: View { } } + Section { + ShareLink(item: tournament.rounds().compactMap { $0.pasteData() }.joined(separator: "\n\n")) { + Text("Exportez l'état du tableau") + } + } + // Section { // RowButtonView("Enabled", role: .destructive) { // let allMatches = tournament._allMatchesIncludingDisabled()