|
|
|
|
@ -84,39 +84,26 @@ struct ActivityView: View { |
|
|
|
|
.buttonBorderShape(.capsule) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@ViewBuilder |
|
|
|
|
func _listView() -> some View { |
|
|
|
|
switch navigation.agendaDestination! { |
|
|
|
|
case .activity: |
|
|
|
|
List { |
|
|
|
|
EventListView(tournaments: runningTournaments, sortAscending: true) |
|
|
|
|
} |
|
|
|
|
case .history: |
|
|
|
|
List { |
|
|
|
|
EventListView(tournaments: endedTournaments, sortAscending: false) |
|
|
|
|
} |
|
|
|
|
case .tenup: |
|
|
|
|
List { |
|
|
|
|
EventListView(tournaments: federalDataViewModel.federalTournaments, sortAscending: true) |
|
|
|
|
.id(uuid) |
|
|
|
|
} |
|
|
|
|
case .around: |
|
|
|
|
List { |
|
|
|
|
EventListView(tournaments: federalDataViewModel.searchedFederalTournaments, sortAscending: true) |
|
|
|
|
.id(uuid) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var body: some View { |
|
|
|
|
@Bindable var navigation = navigation |
|
|
|
|
NavigationStack(path: $navigation.path) { |
|
|
|
|
VStack(spacing: 0) { |
|
|
|
|
GenericDestinationPickerView(selectedDestination: $navigation.agendaDestination, destinations: AgendaDestination.allCases, nilDestinationIsValid: false) |
|
|
|
|
|
|
|
|
|
_listView() |
|
|
|
|
.environment(\.viewStyle, viewStyle) |
|
|
|
|
List { |
|
|
|
|
switch navigation.agendaDestination! { |
|
|
|
|
case .activity: |
|
|
|
|
EventListView(tournaments: runningTournaments, sortAscending: true) |
|
|
|
|
case .history: |
|
|
|
|
EventListView(tournaments: endedTournaments, sortAscending: false) |
|
|
|
|
case .tenup: |
|
|
|
|
EventListView(tournaments: federalDataViewModel.federalTournaments, sortAscending: true) |
|
|
|
|
.id(uuid) |
|
|
|
|
case .around: |
|
|
|
|
EventListView(tournaments: federalDataViewModel.searchedFederalTournaments, sortAscending: true) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
.environment(\.viewStyle, viewStyle) |
|
|
|
|
.environment(federalDataViewModel) |
|
|
|
|
.overlay { |
|
|
|
|
if let error, navigation.agendaDestination == .tenup { |
|
|
|
|
@ -142,10 +129,14 @@ struct ActivityView: View { |
|
|
|
|
} description: { |
|
|
|
|
Text("Aucun tournoi ne correspond aux fitres que vous avez choisis : \(federalDataViewModel.filterStatus())") |
|
|
|
|
} actions: { |
|
|
|
|
RowButtonView("modifier vos filtres") { |
|
|
|
|
FooterButtonView("supprimer vos filtres") { |
|
|
|
|
federalDataViewModel.removeFilters() |
|
|
|
|
} |
|
|
|
|
.padding(.horizontal) |
|
|
|
|
FooterButtonView("modifier vos filtres") { |
|
|
|
|
presentFilterView = true |
|
|
|
|
} |
|
|
|
|
.padding(.horizontal) |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
_dataEmptyView() |
|
|
|
|
@ -153,166 +144,213 @@ struct ActivityView: View { |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
//.searchable(text: $searchText) |
|
|
|
|
.onAppear { presentToolbar = true } |
|
|
|
|
.onDisappear { presentToolbar = false } |
|
|
|
|
.sheet(isPresented: $displaySearchView) { |
|
|
|
|
NavigationStack { |
|
|
|
|
TournamentLookUpView() |
|
|
|
|
.environment(federalDataViewModel) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
//.searchable(text: $searchText) |
|
|
|
|
.onAppear { presentToolbar = true } |
|
|
|
|
.onDisappear { presentToolbar = false } |
|
|
|
|
.refreshable { |
|
|
|
|
if navigation.agendaDestination == .tenup { |
|
|
|
|
federalDataViewModel.federalTournaments.removeAll() |
|
|
|
|
NetworkFederalService.shared.formId = "" |
|
|
|
|
_gatherFederalTournaments() |
|
|
|
|
} |
|
|
|
|
.sheet(item: $newTournament) { tournament in |
|
|
|
|
EventCreationView(tournaments: [tournament], selectedClub: federalDataViewModel.selectedClub()) |
|
|
|
|
.environment(navigation) |
|
|
|
|
.tint(.master) |
|
|
|
|
} |
|
|
|
|
.task { |
|
|
|
|
if navigation.agendaDestination == .tenup |
|
|
|
|
&& dataStore.user.hasTenupClubs() == true |
|
|
|
|
&& federalDataViewModel.federalTournaments.isEmpty { |
|
|
|
|
_gatherFederalTournaments() |
|
|
|
|
} |
|
|
|
|
.refreshable { |
|
|
|
|
if navigation.agendaDestination == .tenup { |
|
|
|
|
federalDataViewModel.federalTournaments.removeAll() |
|
|
|
|
NetworkFederalService.shared.formId = "" |
|
|
|
|
_gatherFederalTournaments() |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
.onChange(of: navigation.agendaDestination) { |
|
|
|
|
if tournaments.isEmpty, viewStyle == .calendar { |
|
|
|
|
viewStyle = .list |
|
|
|
|
} |
|
|
|
|
.task { |
|
|
|
|
if navigation.agendaDestination == .tenup |
|
|
|
|
&& dataStore.user.hasTenupClubs() == true |
|
|
|
|
&& federalDataViewModel.federalTournaments.isEmpty { |
|
|
|
|
_gatherFederalTournaments() |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if navigation.agendaDestination == .tenup |
|
|
|
|
&& dataStore.user.hasTenupClubs() == true |
|
|
|
|
&& federalDataViewModel.federalTournaments.isEmpty { |
|
|
|
|
_gatherFederalTournaments() |
|
|
|
|
} |
|
|
|
|
.onChange(of: navigation.agendaDestination) { |
|
|
|
|
if navigation.agendaDestination == .tenup |
|
|
|
|
&& dataStore.user.hasTenupClubs() == true |
|
|
|
|
&& federalDataViewModel.federalTournaments.isEmpty { |
|
|
|
|
_gatherFederalTournaments() |
|
|
|
|
} |
|
|
|
|
.onChange(of: presentFilterView, { old, new in |
|
|
|
|
if old == true, new == false { //closing filter view |
|
|
|
|
if tournaments.isEmpty, viewStyle == .calendar { |
|
|
|
|
viewStyle = .list |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
.toolbar { |
|
|
|
|
ToolbarItemGroup(placement: .topBarLeading) { |
|
|
|
|
Button { |
|
|
|
|
switch viewStyle { |
|
|
|
|
case .list: |
|
|
|
|
viewStyle = .calendar |
|
|
|
|
case .calendar: |
|
|
|
|
viewStyle = .list |
|
|
|
|
} |
|
|
|
|
} label: { |
|
|
|
|
Image(systemName: "calendar.circle") |
|
|
|
|
.resizable() |
|
|
|
|
.scaledToFit() |
|
|
|
|
.frame(minHeight: 28) |
|
|
|
|
} |
|
|
|
|
.symbolVariant(viewStyle == .calendar ? .fill : .none) |
|
|
|
|
|
|
|
|
|
Button { |
|
|
|
|
presentFilterView.toggle() |
|
|
|
|
} label: { |
|
|
|
|
Image(systemName: "line.3.horizontal.decrease.circle") |
|
|
|
|
.resizable() |
|
|
|
|
.scaledToFit() |
|
|
|
|
.frame(minHeight: 28) |
|
|
|
|
}) |
|
|
|
|
.toolbarTitleDisplayMode(.large) |
|
|
|
|
.navigationTitle(TabDestination.activity.title) |
|
|
|
|
.navigationDestination(for: Tournament.self) { tournament in |
|
|
|
|
TournamentView(tournament: tournament) |
|
|
|
|
} |
|
|
|
|
.toolbar { |
|
|
|
|
ToolbarItemGroup(placement: .topBarLeading) { |
|
|
|
|
Button { |
|
|
|
|
switch viewStyle { |
|
|
|
|
case .list: |
|
|
|
|
viewStyle = .calendar |
|
|
|
|
case .calendar: |
|
|
|
|
viewStyle = .list |
|
|
|
|
} |
|
|
|
|
.symbolVariant(federalDataViewModel.areFiltersEnabled() ? .fill : .none) |
|
|
|
|
} label: { |
|
|
|
|
Image(systemName: "calendar.circle") |
|
|
|
|
.resizable() |
|
|
|
|
.scaledToFit() |
|
|
|
|
.frame(minHeight: 32) |
|
|
|
|
} |
|
|
|
|
.symbolVariant(viewStyle == .calendar ? .fill : .none) |
|
|
|
|
|
|
|
|
|
_pasteView() |
|
|
|
|
Button { |
|
|
|
|
presentFilterView.toggle() |
|
|
|
|
} label: { |
|
|
|
|
Image(systemName: "line.3.horizontal.decrease.circle") |
|
|
|
|
.resizable() |
|
|
|
|
.scaledToFit() |
|
|
|
|
.frame(minHeight: 32) |
|
|
|
|
} |
|
|
|
|
.symbolVariant(federalDataViewModel.areFiltersEnabled() ? .fill : .none) |
|
|
|
|
|
|
|
|
|
_pasteView() |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
ToolbarItem(placement: .topBarTrailing) { |
|
|
|
|
Button { |
|
|
|
|
newTournament = Tournament.newEmptyInstance() |
|
|
|
|
ToolbarItem(placement: .topBarTrailing) { |
|
|
|
|
Button { |
|
|
|
|
newTournament = Tournament.newEmptyInstance() |
|
|
|
|
|
|
|
|
|
} label: { |
|
|
|
|
Image(systemName: "plus.circle.fill") |
|
|
|
|
.resizable() |
|
|
|
|
.scaledToFit() |
|
|
|
|
.frame(minHeight: 28) |
|
|
|
|
} |
|
|
|
|
} label: { |
|
|
|
|
Image(systemName: "plus.circle.fill") |
|
|
|
|
.resizable() |
|
|
|
|
.scaledToFit() |
|
|
|
|
.frame(minHeight: 32) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if presentToolbar { |
|
|
|
|
if navigation.agendaDestination == .around, federalDataViewModel.searchedFederalTournaments.isEmpty == false { |
|
|
|
|
let filteredSearchedFederalTournaments = federalDataViewModel.filteredSearchedFederalTournaments |
|
|
|
|
|
|
|
|
|
let status : String = filteredSearchedFederalTournaments.count.formatted() + " tournoi" + filteredSearchedFederalTournaments.count.pluralSuffix |
|
|
|
|
if presentToolbar, tournaments.isEmpty == false { |
|
|
|
|
ToolbarItemGroup(placement: .bottomBar) { |
|
|
|
|
VStack(spacing: 0) { |
|
|
|
|
let searchStatus = _searchStatus() |
|
|
|
|
if searchStatus.isEmpty == false { |
|
|
|
|
Text(_searchStatus()) |
|
|
|
|
.font(.footnote) |
|
|
|
|
.foregroundStyle(.secondary) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
ToolbarItem(placement: .bottomBar) { |
|
|
|
|
VStack { |
|
|
|
|
Text(status) |
|
|
|
|
FooterButtonView("modifier les critères de recherche") { |
|
|
|
|
HStack { |
|
|
|
|
if navigation.agendaDestination == .around { |
|
|
|
|
FooterButtonView("modifier votre recherche") { |
|
|
|
|
displaySearchView = true |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if federalDataViewModel.areFiltersEnabled() { |
|
|
|
|
Text("ou") |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if federalDataViewModel.areFiltersEnabled() { |
|
|
|
|
FooterButtonView(_filterButtonTitle()) { |
|
|
|
|
presentFilterView = true |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
.font(.footnote) |
|
|
|
|
} |
|
|
|
|
} else if federalDataViewModel.areFiltersEnabled() { |
|
|
|
|
ToolbarItem(placement: .status) { |
|
|
|
|
Text(federalDataViewModel.filterStatus()) |
|
|
|
|
} |
|
|
|
|
.padding(.bottom, 8) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
.navigationTitle(TabDestination.activity.title) |
|
|
|
|
.navigationDestination(for: Tournament.self) { tournament in |
|
|
|
|
TournamentView(tournament: tournament) |
|
|
|
|
} |
|
|
|
|
.sheet(isPresented: $presentFilterView) { |
|
|
|
|
TournamentFilterView(federalDataViewModel: federalDataViewModel) |
|
|
|
|
.environment(navigation) |
|
|
|
|
.tint(.master) |
|
|
|
|
} |
|
|
|
|
.sheet(isPresented: $presentClubSearchView, onDismiss: { |
|
|
|
|
if dataStore.user.hasTenupClubs() == true { |
|
|
|
|
federalDataViewModel.federalTournaments.removeAll() |
|
|
|
|
navigation.agendaDestination = .tenup |
|
|
|
|
} |
|
|
|
|
}) { |
|
|
|
|
ClubImportView() |
|
|
|
|
.tint(.master) |
|
|
|
|
} |
|
|
|
|
.sheet(isPresented: $presentFilterView) { |
|
|
|
|
TournamentFilterView(federalDataViewModel: federalDataViewModel) |
|
|
|
|
.environment(navigation) |
|
|
|
|
.tint(.master) |
|
|
|
|
} |
|
|
|
|
.sheet(isPresented: $presentClubSearchView, onDismiss: { |
|
|
|
|
if dataStore.user.hasTenupClubs() == true { |
|
|
|
|
federalDataViewModel.federalTournaments.removeAll() |
|
|
|
|
navigation.agendaDestination = .tenup |
|
|
|
|
} |
|
|
|
|
}) { |
|
|
|
|
ClubImportView() |
|
|
|
|
.tint(.master) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
.sheet(item: $quickAccessScreen) { screen in |
|
|
|
|
switch screen { |
|
|
|
|
case .inscription(let pasteString): |
|
|
|
|
.sheet(isPresented: $displaySearchView) { |
|
|
|
|
NavigationStack { |
|
|
|
|
List { |
|
|
|
|
Section { |
|
|
|
|
Text(pasteString) |
|
|
|
|
} header: { |
|
|
|
|
Text("Contenu du presse-papier") |
|
|
|
|
} |
|
|
|
|
TournamentLookUpView() |
|
|
|
|
.environment(federalDataViewModel) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
.sheet(item: $newTournament) { tournament in |
|
|
|
|
EventCreationView(tournaments: [tournament], selectedClub: federalDataViewModel.selectedClub()) |
|
|
|
|
.environment(navigation) |
|
|
|
|
.tint(.master) |
|
|
|
|
} |
|
|
|
|
.sheet(item: $quickAccessScreen) { screen in |
|
|
|
|
switch screen { |
|
|
|
|
case .inscription(let pasteString): |
|
|
|
|
NavigationStack { |
|
|
|
|
List { |
|
|
|
|
Section { |
|
|
|
|
Text(pasteString) |
|
|
|
|
} header: { |
|
|
|
|
Text("Contenu du presse-papier") |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
Section { |
|
|
|
|
ForEach(getRunningTournaments()) { tournament in |
|
|
|
|
NavigationLink { |
|
|
|
|
AddTeamView(tournament: tournament, pasteString: pasteString, editedTeam: nil) |
|
|
|
|
} label: { |
|
|
|
|
VStack(alignment: .leading) { |
|
|
|
|
Text(tournament.tournamentTitle()) |
|
|
|
|
Text(tournament.formattedDate()).foregroundStyle(.secondary) |
|
|
|
|
Section { |
|
|
|
|
ForEach(getRunningTournaments()) { tournament in |
|
|
|
|
NavigationLink { |
|
|
|
|
AddTeamView(tournament: tournament, pasteString: pasteString, editedTeam: nil) |
|
|
|
|
} label: { |
|
|
|
|
VStack(alignment: .leading) { |
|
|
|
|
Text(tournament.tournamentTitle()) |
|
|
|
|
Text(tournament.formattedDate()).foregroundStyle(.secondary) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} header: { |
|
|
|
|
Text("À coller dans la liste d'inscription") |
|
|
|
|
} |
|
|
|
|
} header: { |
|
|
|
|
Text("À coller dans la liste d'inscription") |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
.toolbar { |
|
|
|
|
ToolbarItem(placement: .topBarLeading) { |
|
|
|
|
Button("Fermer") { |
|
|
|
|
self.quickAccessScreen = nil |
|
|
|
|
.toolbar { |
|
|
|
|
ToolbarItem(placement: .topBarLeading) { |
|
|
|
|
Button("Fermer") { |
|
|
|
|
self.quickAccessScreen = nil |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
.navigationTitle("Choix du tournoi") |
|
|
|
|
.navigationBarTitleDisplayMode(.inline) |
|
|
|
|
.toolbarBackground(.visible, for: .navigationBar) |
|
|
|
|
} |
|
|
|
|
.navigationTitle("Choix du tournoi") |
|
|
|
|
.navigationBarTitleDisplayMode(.inline) |
|
|
|
|
.toolbarBackground(.visible, for: .navigationBar) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private func _searchStatus() -> String { |
|
|
|
|
var searchStatus : [String] = [] |
|
|
|
|
if navigation.agendaDestination == .around, federalDataViewModel.searchedFederalTournaments.isEmpty == false { |
|
|
|
|
let filteredSearchedFederalTournaments = federalDataViewModel.filteredSearchedFederalTournaments |
|
|
|
|
|
|
|
|
|
let status : String = filteredSearchedFederalTournaments.count.formatted() + " tournoi" + filteredSearchedFederalTournaments.count.pluralSuffix |
|
|
|
|
searchStatus.append(status) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if federalDataViewModel.areFiltersEnabled(), tournaments.isEmpty == false { |
|
|
|
|
searchStatus.append(federalDataViewModel.filterStatus()) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return searchStatus.joined(separator: " ") |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private func _filterButtonTitle() -> String { |
|
|
|
|
var prefix = "modifier " |
|
|
|
|
if navigation.agendaDestination == .around, federalDataViewModel.searchedFederalTournaments.isEmpty == false { |
|
|
|
|
prefix = "" |
|
|
|
|
} |
|
|
|
|
return prefix + "vos filtres" |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private func _gatherFederalTournaments() { |
|
|
|
|
isGatheringFederalTournaments = true |
|
|
|
|
Task { |
|
|
|
|
@ -422,7 +460,7 @@ struct ActivityView: View { |
|
|
|
|
} description: { |
|
|
|
|
Text("Aucun tournoi ne correspond aux critères sélectionnés.") |
|
|
|
|
} actions: { |
|
|
|
|
RowButtonView("Modifier vos critères de recherche") { |
|
|
|
|
FooterButtonView("modifier vos critères de recherche") { |
|
|
|
|
displaySearchView = true |
|
|
|
|
} |
|
|
|
|
.padding() |
|
|
|
|
|