multistore
Razmig Sarkissian 1 year ago
parent 7daac875f2
commit 1315f54af3
  1. 8
      PadelClub/Data/Tournament.swift
  2. 24
      PadelClub/Utils/PadelRule.swift
  3. 2
      PadelClub/Views/Components/StepperView.swift
  4. 3
      PadelClub/Views/Navigation/Organizer/TournamentOrganizerView.swift
  5. 4
      PadelClub/Views/Tournament/Screen/Components/InscriptionInfoView.swift
  6. 2
      PadelClub/Views/Tournament/Shared/TournamentCellView.swift
  7. 12
      PadelClub/Views/ViewModifiers/ListRowViewModifier.swift

@ -1525,7 +1525,7 @@ class Tournament : ModelObject, Storable {
func loserBracketSmartMatchFormat(_ roundIndex: Int) -> MatchFormat {
let format = tournamentLevel.federalFormatForLoserBracketRound(roundIndex)
if loserBracketMatchFormat.rank > format.rank {
if format.rank > loserBracketMatchFormat.rank {
return format
} else {
return loserBracketMatchFormat
@ -1534,7 +1534,7 @@ class Tournament : ModelObject, Storable {
func groupStageSmartMatchFormat() -> MatchFormat {
let format = tournamentLevel.federalFormatForGroupStage()
if groupStageMatchFormat.rank > format.rank {
if format.rank > groupStageMatchFormat.rank {
return format
} else {
return groupStageMatchFormat
@ -1550,7 +1550,7 @@ class Tournament : ModelObject, Storable {
func roundSmartMatchFormat(_ roundIndex: Int) -> MatchFormat {
let format = tournamentLevel.federalFormatForBracketRound(roundIndex)
if matchFormat.rank > format.rank {
if format.rank > matchFormat.rank {
return format
} else {
return matchFormat
@ -1754,7 +1754,7 @@ extension Tournament {
}
let rankSourceDate = _mostRecentDateAvailable
let tournaments : [Tournament] = DataStore.shared.tournaments.filter { $0.endDate != nil }.sorted(by: \.startDate).reversed()
let tournaments : [Tournament] = DataStore.shared.tournaments.filter { $0.endDate != nil && $0.isDeleted == false }
let tournamentLevel = TournamentLevel.mostUsed(inTournaments: tournaments)
let tournamentCategory = TournamentCategory.mostUsed(inTournaments: tournaments)
let federalTournamentAge = FederalTournamentAge.mostUsed(inTournaments: tournaments)

@ -278,14 +278,14 @@ enum TournamentLevel: Int, Hashable, Codable, CaseIterable, Identifiable {
switch self {
case .p25:
switch ageCategory {
case .senior:
case .senior, .a45, .a55:
return category == .men ? 10000 : 1000
default:
return 0
}
case .p100:
switch ageCategory {
case .senior:
case .senior, .a45, .a55:
return category == .men ? 2000 : 300
default:
return 0
@ -293,7 +293,7 @@ enum TournamentLevel: Int, Hashable, Codable, CaseIterable, Identifiable {
case .p250:
switch ageCategory {
case .senior:
case .senior, .a45, .a55:
return category == .men ? 500 : 100
default:
return 0
@ -1052,23 +1052,23 @@ enum MatchFormat: Int, Hashable, Codable, CaseIterable {
case .twoSets:
return 0
case .twoSetsDecisivePoint:
return 1
return 0
case .twoSetsSuperTie:
return 2
return 1
case .twoSetsDecisivePointSuperTie:
return 3
return 1
case .twoSetsOfFourGames:
return 4
return 2
case .twoSetsOfFourGamesDecisivePoint:
return 5
return 2
case .nineGames:
return 6
return 3
case .nineGamesDecisivePoint:
return 7
return 3
case .superTie:
return 8
return 4
case .megaTie:
return 9
return 5
}
}

@ -36,7 +36,7 @@ struct StepperView: View {
.fixedSize()
// .font(.title2)
.monospacedDigit()
.multilineTextAlignment(.center)
.multilineTextAlignment(.trailing)
.onSubmit {
if let minimum, count < minimum {
count = minimum

@ -34,7 +34,8 @@ struct TournamentOrganizerView: View {
HStack {
ScrollView(.horizontal) {
HStack {
ForEach(dataStore.tournaments.filter({ $0.isDeleted == false })) { tournament in
let tournaments = dataStore.tournaments.filter({ $0.hasEnded() == false && $0.isDeleted == false && $0.isCanceled == false }).sorted(by: \.startDate).reversed()
ForEach(tournaments) { tournament in
TournamentButtonView(tournament: tournament)
}
}

@ -29,11 +29,13 @@ struct InscriptionInfoView: View {
var body: some View {
List {
Section {
let footerString = "via [beach-padel.app.fft.fr](\(URLs.beachPadel.rawValue))"
LabeledContent {
Text(entriesFromBeachPadel.count.formatted())
} label: {
Text("Paires importées")
Text(URLs.beachPadel.url.absoluteString)
Text(.init(footerString))
}
.listRowView(color: .indigo)

@ -57,7 +57,7 @@ struct TournamentCellView: View {
.font(.caption)
Spacer()
if tournament.isPrivate {
Text("privé").foregroundStyle(.secondary)
Text("privé").foregroundStyle(.logoRed)
}
}
} else {

@ -14,12 +14,12 @@ struct ListRowViewModifier: ViewModifier {
func body(content: Content) -> some View {
if isActive {
content
.listRowBackground(
color.variation()
.overlay(alignment: .leading, content: {
color.frame(width: 8)
})
)
// .listRowBackground(
// color.variation()
// .overlay(alignment: .leading, content: {
// color.frame(width: 8)
// })
// )
} else {
content
}

Loading…
Cancel
Save