|
|
|
@ -11,7 +11,7 @@ struct ActivityView: View { |
|
|
|
@EnvironmentObject var dataStore: DataStore |
|
|
|
@EnvironmentObject var dataStore: DataStore |
|
|
|
|
|
|
|
|
|
|
|
@State private var searchText: String = "" |
|
|
|
@State private var searchText: String = "" |
|
|
|
@State private var agendaDestination: AgendaDestination = .activity |
|
|
|
@State private var agendaDestination: AgendaDestination? = .activity |
|
|
|
|
|
|
|
|
|
|
|
@State private var filterEnabled: Bool = false |
|
|
|
@State private var filterEnabled: Bool = false |
|
|
|
@State private var presentToolbar: Bool = false |
|
|
|
@State private var presentToolbar: Bool = false |
|
|
|
@ -40,7 +40,7 @@ struct ActivityView: View { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
var tournaments: [FederalTournamentHolder] { |
|
|
|
var tournaments: [FederalTournamentHolder] { |
|
|
|
switch agendaDestination { |
|
|
|
switch agendaDestination! { |
|
|
|
case .activity: |
|
|
|
case .activity: |
|
|
|
runningTournaments |
|
|
|
runningTournaments |
|
|
|
case .history: |
|
|
|
case .history: |
|
|
|
@ -52,130 +52,129 @@ struct ActivityView: View { |
|
|
|
|
|
|
|
|
|
|
|
var body: some View { |
|
|
|
var body: some View { |
|
|
|
NavigationStack { |
|
|
|
NavigationStack { |
|
|
|
List { |
|
|
|
VStack(spacing: 0) { |
|
|
|
Section { |
|
|
|
GenericDestinationPickerView(selectedDestination: $agendaDestination, destinations: AgendaDestination.allCases, nilDestinationIsValid: false) |
|
|
|
AgendaDestinationPickerView(agendaDestination: $agendaDestination) |
|
|
|
List { |
|
|
|
} |
|
|
|
switch agendaDestination! { |
|
|
|
|
|
|
|
case .activity: |
|
|
|
switch agendaDestination { |
|
|
|
EventListView(tournaments: runningTournaments, viewStyle: viewStyle) |
|
|
|
case .activity: |
|
|
|
case .history: |
|
|
|
EventListView(tournaments: runningTournaments, viewStyle: viewStyle) |
|
|
|
EventListView(tournaments: endedTournaments, viewStyle: viewStyle) |
|
|
|
case .history: |
|
|
|
case .tenup: |
|
|
|
EventListView(tournaments: endedTournaments, viewStyle: viewStyle) |
|
|
|
EventListView(tournaments: federalTournaments, viewStyle: viewStyle) |
|
|
|
case .tenup: |
|
|
|
} |
|
|
|
EventListView(tournaments: federalTournaments, viewStyle: viewStyle) |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
.overlay { |
|
|
|
.overlay { |
|
|
|
if isGatheringFederalTournaments { |
|
|
|
if isGatheringFederalTournaments { |
|
|
|
ProgressView() |
|
|
|
ProgressView() |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
if tournaments.isEmpty { |
|
|
|
if tournaments.isEmpty { |
|
|
|
if searchText.isEmpty == false { |
|
|
|
if searchText.isEmpty == false { |
|
|
|
ContentUnavailableView.search(text: searchText) |
|
|
|
ContentUnavailableView.search(text: searchText) |
|
|
|
} else if filterEnabled { |
|
|
|
} else if filterEnabled { |
|
|
|
ContentUnavailableView { |
|
|
|
ContentUnavailableView { |
|
|
|
Text("Aucun résultat") |
|
|
|
Text("Aucun résultat") |
|
|
|
} description: { |
|
|
|
} description: { |
|
|
|
Text("Description du filtre") |
|
|
|
Text("Description du filtre") |
|
|
|
} actions: { |
|
|
|
} actions: { |
|
|
|
RowButtonView(title: "supprimer le filtre") { |
|
|
|
RowButtonView(title: "supprimer le filtre") { |
|
|
|
filterEnabled.toggle() |
|
|
|
filterEnabled.toggle() |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
_dataEmptyView() |
|
|
|
} |
|
|
|
} |
|
|
|
} else { |
|
|
|
|
|
|
|
_dataEmptyView() |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
//.searchable(text: $searchText) |
|
|
|
//.searchable(text: $searchText) |
|
|
|
.onAppear { presentToolbar = true } |
|
|
|
.onAppear { presentToolbar = true } |
|
|
|
.onDisappear { presentToolbar = false } |
|
|
|
.onDisappear { presentToolbar = false } |
|
|
|
.sheet(item: $newTournament) { tournament in |
|
|
|
.sheet(item: $newTournament) { tournament in |
|
|
|
EventCreationView(tournaments: [tournament]) |
|
|
|
EventCreationView(tournaments: [tournament]) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
.refreshable { |
|
|
|
|
|
|
|
if agendaDestination == .tenup { |
|
|
|
|
|
|
|
federalTournaments.removeAll() |
|
|
|
|
|
|
|
_gatherFederalTournaments() |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
.refreshable { |
|
|
|
.task { |
|
|
|
if agendaDestination == .tenup { |
|
|
|
if agendaDestination == .tenup |
|
|
|
federalTournaments.removeAll() |
|
|
|
&& dataStore.clubs.isEmpty == false |
|
|
|
_gatherFederalTournaments() |
|
|
|
&& federalTournaments.isEmpty { |
|
|
|
} |
|
|
|
_gatherFederalTournaments() |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
.task { |
|
|
|
.onChange(of: agendaDestination) { |
|
|
|
if agendaDestination == .tenup |
|
|
|
if agendaDestination == .tenup |
|
|
|
&& dataStore.clubs.isEmpty == false |
|
|
|
&& dataStore.clubs.isEmpty == false |
|
|
|
&& federalTournaments.isEmpty { |
|
|
|
&& federalTournaments.isEmpty { |
|
|
|
_gatherFederalTournaments() |
|
|
|
_gatherFederalTournaments() |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
.onChange(of: agendaDestination) { |
|
|
|
.toolbar { |
|
|
|
if agendaDestination == .tenup |
|
|
|
if presentToolbar { |
|
|
|
&& dataStore.clubs.isEmpty == false |
|
|
|
ToolbarItem(placement: .status) { |
|
|
|
&& federalTournaments.isEmpty { |
|
|
|
VStack(spacing: -2) { |
|
|
|
_gatherFederalTournaments() |
|
|
|
if filterEnabled { |
|
|
|
} |
|
|
|
Text("filtre actif") |
|
|
|
} |
|
|
|
} |
|
|
|
.toolbar { |
|
|
|
if let _activityStatus = _activityStatus() { |
|
|
|
if presentToolbar { |
|
|
|
Text(_activityStatus) |
|
|
|
ToolbarItem(placement: .status) { |
|
|
|
.foregroundStyle(.secondary) |
|
|
|
VStack(spacing: -2) { |
|
|
|
|
|
|
|
if filterEnabled { |
|
|
|
|
|
|
|
Text("filtre actif") |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if let _activityStatus = _activityStatus() { |
|
|
|
|
|
|
|
Text(_activityStatus) |
|
|
|
|
|
|
|
.foregroundStyle(.secondary) |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
.font(.footnote) |
|
|
|
} |
|
|
|
} |
|
|
|
.font(.footnote) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ToolbarItem(placement: .topBarLeading) { |
|
|
|
ToolbarItem(placement: .topBarLeading) { |
|
|
|
Button { |
|
|
|
Button { |
|
|
|
switch viewStyle { |
|
|
|
switch viewStyle { |
|
|
|
case .list: |
|
|
|
case .list: |
|
|
|
viewStyle = .calendar |
|
|
|
viewStyle = .calendar |
|
|
|
case .calendar: |
|
|
|
case .calendar: |
|
|
|
viewStyle = .list |
|
|
|
viewStyle = .list |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} label: { |
|
|
|
|
|
|
|
Image(systemName: "calendar.circle") |
|
|
|
|
|
|
|
.resizable() |
|
|
|
|
|
|
|
.scaledToFit() |
|
|
|
|
|
|
|
.frame(minHeight: 28) |
|
|
|
} |
|
|
|
} |
|
|
|
} label: { |
|
|
|
.symbolVariant(viewStyle == .calendar ? .fill : .none) |
|
|
|
Image(systemName: "calendar.circle") |
|
|
|
|
|
|
|
.resizable() |
|
|
|
|
|
|
|
.scaledToFit() |
|
|
|
|
|
|
|
.frame(minHeight: 28) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
.symbolVariant(viewStyle == .calendar ? .fill : .none) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// |
|
|
|
// |
|
|
|
// Button { |
|
|
|
// Button { |
|
|
|
// filterEnabled.toggle() |
|
|
|
// filterEnabled.toggle() |
|
|
|
// } label: { |
|
|
|
// } label: { |
|
|
|
// Image(systemName: "line.3.horizontal.decrease.circle") |
|
|
|
// Image(systemName: "line.3.horizontal.decrease.circle") |
|
|
|
// .resizable() |
|
|
|
// .resizable() |
|
|
|
// .scaledToFit() |
|
|
|
// .scaledToFit() |
|
|
|
// .frame(minHeight: 28) |
|
|
|
// .frame(minHeight: 28) |
|
|
|
// } |
|
|
|
// } |
|
|
|
// .symbolVariant(filterEnabled ? .fill : .none) |
|
|
|
// .symbolVariant(filterEnabled ? .fill : .none) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
ToolbarItem(placement: .topBarTrailing) { |
|
|
|
ToolbarItem(placement: .topBarTrailing) { |
|
|
|
Button { |
|
|
|
Button { |
|
|
|
newTournament = Tournament.newEmptyInstance() |
|
|
|
newTournament = Tournament.newEmptyInstance() |
|
|
|
|
|
|
|
|
|
|
|
} label: { |
|
|
|
} label: { |
|
|
|
Image(systemName: "plus.circle.fill") |
|
|
|
Image(systemName: "plus.circle.fill") |
|
|
|
.resizable() |
|
|
|
.resizable() |
|
|
|
.scaledToFit() |
|
|
|
.scaledToFit() |
|
|
|
.frame(minHeight: 28) |
|
|
|
.frame(minHeight: 28) |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
.navigationTitle(TabDestination.activity.title) |
|
|
|
.navigationTitle(TabDestination.activity.title) |
|
|
|
.navigationDestination(for: Tournament.self) { tournament in |
|
|
|
.navigationDestination(for: Tournament.self) { tournament in |
|
|
|
TournamentView() |
|
|
|
TournamentView() |
|
|
|
.environment(tournament) |
|
|
|
.environment(tournament) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
@ -192,7 +191,7 @@ struct ActivityView: View { |
|
|
|
|
|
|
|
|
|
|
|
@ViewBuilder |
|
|
|
@ViewBuilder |
|
|
|
private func _dataEmptyView() -> some View { |
|
|
|
private func _dataEmptyView() -> some View { |
|
|
|
switch agendaDestination { |
|
|
|
switch agendaDestination! { |
|
|
|
case .activity: |
|
|
|
case .activity: |
|
|
|
_runningEmptyView() |
|
|
|
_runningEmptyView() |
|
|
|
case .history: |
|
|
|
case .history: |
|
|
|
|