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 { func loserBracketSmartMatchFormat(_ roundIndex: Int) -> MatchFormat {
let format = tournamentLevel.federalFormatForLoserBracketRound(roundIndex) let format = tournamentLevel.federalFormatForLoserBracketRound(roundIndex)
if loserBracketMatchFormat.rank > format.rank { if format.rank > loserBracketMatchFormat.rank {
return format return format
} else { } else {
return loserBracketMatchFormat return loserBracketMatchFormat
@ -1534,7 +1534,7 @@ class Tournament : ModelObject, Storable {
func groupStageSmartMatchFormat() -> MatchFormat { func groupStageSmartMatchFormat() -> MatchFormat {
let format = tournamentLevel.federalFormatForGroupStage() let format = tournamentLevel.federalFormatForGroupStage()
if groupStageMatchFormat.rank > format.rank { if format.rank > groupStageMatchFormat.rank {
return format return format
} else { } else {
return groupStageMatchFormat return groupStageMatchFormat
@ -1550,7 +1550,7 @@ class Tournament : ModelObject, Storable {
func roundSmartMatchFormat(_ roundIndex: Int) -> MatchFormat { func roundSmartMatchFormat(_ roundIndex: Int) -> MatchFormat {
let format = tournamentLevel.federalFormatForBracketRound(roundIndex) let format = tournamentLevel.federalFormatForBracketRound(roundIndex)
if matchFormat.rank > format.rank { if format.rank > matchFormat.rank {
return format return format
} else { } else {
return matchFormat return matchFormat
@ -1754,7 +1754,7 @@ extension Tournament {
} }
let rankSourceDate = _mostRecentDateAvailable 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 tournamentLevel = TournamentLevel.mostUsed(inTournaments: tournaments)
let tournamentCategory = TournamentCategory.mostUsed(inTournaments: tournaments) let tournamentCategory = TournamentCategory.mostUsed(inTournaments: tournaments)
let federalTournamentAge = FederalTournamentAge.mostUsed(inTournaments: tournaments) let federalTournamentAge = FederalTournamentAge.mostUsed(inTournaments: tournaments)

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

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

@ -34,7 +34,8 @@ struct TournamentOrganizerView: View {
HStack { HStack {
ScrollView(.horizontal) { ScrollView(.horizontal) {
HStack { 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) TournamentButtonView(tournament: tournament)
} }
} }

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

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

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

Loading…
Cancel
Save