multistore
Razmig Sarkissian 1 year ago
parent 586c305ba7
commit c735c023bb
  1. 4
      PadelClub.xcodeproj/project.pbxproj
  2. 4
      PadelClub/Data/User.swift
  3. 8
      PadelClub/Extensions/String+Extensions.swift
  4. 2
      PadelClub/Views/Club/ClubDetailView.swift
  5. 3
      PadelClub/Views/Club/ClubRowView.swift
  6. 10
      PadelClub/Views/Navigation/Agenda/ActivityView.swift
  7. 2
      PadelClub/Views/Navigation/Agenda/EventListView.swift
  8. 28
      PadelClub/Views/Tournament/FileImportView.swift
  9. 19
      PadelClub/Views/Tournament/Screen/InscriptionManagerView.swift

@ -1939,7 +1939,7 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 35;
CURRENT_PROJECT_VERSION = 36;
DEFINES_MODULE = YES;
DEVELOPMENT_ASSET_PATHS = "\"PadelClub/Preview Content\"";
DEVELOPMENT_TEAM = BQ3Y44M3Q6;
@ -1977,7 +1977,7 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 35;
CURRENT_PROJECT_VERSION = 36;
DEFINES_MODULE = YES;
DEVELOPMENT_ASSET_PATHS = "\"PadelClub/Preview Content\"";
DEVELOPMENT_TEAM = BQ3Y44M3Q6;

@ -73,8 +73,8 @@ class User: ModelObject, UserBase, Storable {
return "Sportivement,\n\(firstName) \(lastName), votre JAP."
}
func hasClubs() -> Bool {
self.clubs.isEmpty == false
func hasTenupClubs() -> Bool {
self.clubsObjects().filter({ $0.code != nil }).isEmpty == false
}
func hasFavoriteClubsAndCreatedClubs() -> Bool {

@ -46,16 +46,18 @@ extension String {
func acronym() -> String {
let acronym = canonicalVersion.replaceCharactersFromSet(characterSet: .whitespacesAndNewlines)
if acronym.count > 10 {
return concatenateFirstLetters()
return concatenateFirstLetters().uppercased()
} else {
return acronym
return acronym.uppercased()
}
}
func concatenateFirstLetters() -> String {
// Split the input into sentences
let sentences = self.components(separatedBy: .whitespacesAndNewlines)
if sentences.count == 1 {
return String(self.prefix(10))
}
// Extract the first character of each sentence
let firstLetters = sentences.compactMap { sentence -> Character? in
let trimmedSentence = sentence.trimmingCharacters(in: .whitespacesAndNewlines)

@ -59,7 +59,7 @@ struct ClubDetailView: View {
.submitLabel( displayContext == .addition ? .next : .done)
.onSubmit(of: .text) {
if club.acronym.isEmpty {
club.acronym = club.name.canonicalVersion.replaceCharactersFromSet(characterSet: .whitespacesAndNewlines)
club.acronym = club.name.canonicalVersion.replaceCharactersFromSet(characterSet: .whitespacesAndNewlines).acronym()
}
if displayContext == .edition && city.isEmpty == true {

@ -13,13 +13,14 @@ struct ClubRowView: View {
var body: some View {
LabeledContent {
Text(club.acronym)
// if displayContext == .edition {
// Image(systemName: club.isFavorite() ? "star.fill" : "star")
// .foregroundStyle(club.isFavorite() ? .green : .logoRed)
// }
} label: {
Text("Club")
Text(club.name)
Text(club.acronym)
}
}
}

@ -121,14 +121,14 @@ struct ActivityView: View {
}
.task {
if navigation.agendaDestination == .tenup
&& dataStore.user.hasClubs() == true
&& dataStore.user.hasTenupClubs() == true
&& federalDataViewModel.federalTournaments.isEmpty {
_gatherFederalTournaments()
}
}
.onChange(of: navigation.agendaDestination) {
if navigation.agendaDestination == .tenup
&& dataStore.user.hasClubs() == true
&& dataStore.user.hasTenupClubs() == true
&& federalDataViewModel.federalTournaments.isEmpty {
_gatherFederalTournaments()
}
@ -192,7 +192,7 @@ struct ActivityView: View {
.tint(.master)
}
.sheet(isPresented: $presentClubSearchView, onDismiss: {
if dataStore.user.hasClubs() == true {
if dataStore.user.hasTenupClubs() == true {
federalDataViewModel.federalTournaments.removeAll()
navigation.agendaDestination = .tenup
}
@ -247,7 +247,7 @@ struct ActivityView: View {
RowButtonView("Créer un nouvel événement") {
newTournament = Tournament.newEmptyInstance()
}
if dataStore.user.hasClubs() == false {
if dataStore.user.hasTenupClubs() == false {
RowButtonView("Chercher l'un de vos clubs") {
presentClubSearchView = true
}
@ -268,7 +268,7 @@ struct ActivityView: View {
}
private func _tenupEmptyView() -> some View {
if dataStore.user.hasClubs() == false {
if dataStore.user.hasTenupClubs() == false {
ContentUnavailableView {
Label("Aucun tournoi", systemImage: "shield.slash")
} description: {

@ -53,7 +53,7 @@ struct EventListView: View {
.headerProminence(.increased)
.task {
if navigation.agendaDestination == .tenup
&& dataStore.user.hasClubs() == true
&& dataStore.user.hasTenupClubs() == true
&& _tournaments.isEmpty {
_gatherFederalTournaments(startDate: section)
}

@ -104,17 +104,7 @@ struct FileImportView: View {
}
}
}
if validationInProgress {
Section {
LabeledContent {
ProgressView()
} label: {
Text("Mise à jour des équipes")
}
}
}
if let errorMessage {
Section {
Text(errorMessage)
@ -157,7 +147,7 @@ struct FileImportView: View {
Section {
ContentUnavailableView("Aucune équipe détectée", systemImage: "person.2.slash")
}
} else if didImport && validationInProgress == false {
} else if didImport {
let _filteredTeams = filteredTeams
let previousTeams = tournament.sortedTeams()
@ -232,18 +222,24 @@ struct FileImportView: View {
}
ToolbarItem(placement: .topBarTrailing) {
ButtonValidateView {
_validate()
if validationInProgress {
ProgressView()
} else {
ButtonValidateView {
validationInProgress = true
}
.disabled(teams.isEmpty)
}
.disabled(teams.isEmpty)
}
}
.interactiveDismissDisabled(validationInProgress)
.disabled(validationInProgress)
.onChange(of: validationInProgress) {
_validate()
}
}
private func _validate() {
validationInProgress = true
Task {
let previousTeams = filteredTeams.compactMap({ $0.previousTeam })

@ -152,14 +152,15 @@ struct InscriptionManagerView: View {
}
private func _handleHashDiff() async {
let newHash = _simpleHash(ids: tournament.selectedSortedTeams().map { $0.id })
if let teamsHash, newHash != teamsHash {
let selectedSortedTeams = tournament.selectedSortedTeams()
let newHash = _simpleHash(ids: selectedSortedTeams.map { $0.id })
if (self.teamsHash != nil && newHash != teamsHash!) || (self.teamsHash == nil && selectedSortedTeams.isEmpty == false) {
self.teamsHash = newHash
if self.tournament.shouldVerifyBracket == false || self.tournament.shouldVerifyGroupStage == false {
self.tournament.shouldVerifyBracket = true
self.tournament.shouldVerifyGroupStage = true
let waitingList = self.tournament.waitingListTeams(in: self.tournament.selectedSortedTeams())
let waitingList = self.tournament.waitingListTeams(in: selectedSortedTeams)
waitingList.forEach { team in
if team.bracketPosition != nil || team.groupStagePosition != nil {
team.resetPositions()
@ -181,10 +182,9 @@ struct InscriptionManagerView: View {
_managementView()
if _isEditingTeam() {
_buildingTeamView()
} else if tournament.unsortedTeams().isEmpty {
} else if unfilteredTeams.isEmpty {
_inscriptionTipsView()
}
if _isEditingTeam() == false {
} else {
_teamRegisteredView()
}
}
@ -284,7 +284,9 @@ struct InscriptionManagerView: View {
}
.tint(.master)
}
.sheet(isPresented: $presentImportView) {
.sheet(isPresented: $presentImportView, onDismiss: {
_getTeams()
}) {
NavigationStack {
FileImportView()
}
@ -428,12 +430,13 @@ struct InscriptionManagerView: View {
}
private func _prepareTeams() {
#if DEBUG_TIME
let start = Date()
defer {
let duration = Duration.milliseconds(Date().timeIntervalSince(start) * 1_000)
print("func _prepareTeams", duration.formatted(.units(allowed: [.seconds, .milliseconds])))
}
#endif
sortedTeams = tournament.sortedTeams()
var teams = sortedTeams

Loading…
Cancel
Save