|
|
|
|
@ -9,9 +9,9 @@ import SwiftUI |
|
|
|
|
|
|
|
|
|
struct ActivityView: View { |
|
|
|
|
@EnvironmentObject var dataStore: DataStore |
|
|
|
|
|
|
|
|
|
@Environment(NavigationViewModel.self) private var navigation |
|
|
|
|
|
|
|
|
|
@State private var searchText: String = "" |
|
|
|
|
@State private var agendaDestination: AgendaDestination? = .activity |
|
|
|
|
|
|
|
|
|
@State private var filterEnabled: Bool = false |
|
|
|
|
@State private var presentToolbar: Bool = false |
|
|
|
|
@ -41,7 +41,7 @@ struct ActivityView: View { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
var tournaments: [FederalTournamentHolder] { |
|
|
|
|
switch agendaDestination! { |
|
|
|
|
switch navigation.agendaDestination! { |
|
|
|
|
case .activity: |
|
|
|
|
runningTournaments |
|
|
|
|
case .history: |
|
|
|
|
@ -53,10 +53,11 @@ struct ActivityView: View { |
|
|
|
|
|
|
|
|
|
var body: some View { |
|
|
|
|
NavigationStack { |
|
|
|
|
@Bindable var navigation = navigation |
|
|
|
|
VStack(spacing: 0) { |
|
|
|
|
GenericDestinationPickerView(selectedDestination: $agendaDestination, destinations: AgendaDestination.allCases, nilDestinationIsValid: false) |
|
|
|
|
GenericDestinationPickerView(selectedDestination: $navigation.agendaDestination, destinations: AgendaDestination.allCases, nilDestinationIsValid: false) |
|
|
|
|
List { |
|
|
|
|
switch agendaDestination! { |
|
|
|
|
switch navigation.agendaDestination! { |
|
|
|
|
case .activity: |
|
|
|
|
EventListView(tournaments: runningTournaments, viewStyle: viewStyle) |
|
|
|
|
case .history: |
|
|
|
|
@ -66,7 +67,7 @@ struct ActivityView: View { |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
.overlay { |
|
|
|
|
if let error, agendaDestination == .tenup { |
|
|
|
|
if let error, navigation.agendaDestination == .tenup { |
|
|
|
|
ContentUnavailableView { |
|
|
|
|
Label("Erreur", systemImage: "exclamationmark") |
|
|
|
|
} description: { |
|
|
|
|
@ -105,20 +106,20 @@ struct ActivityView: View { |
|
|
|
|
EventCreationView(tournaments: [tournament]) |
|
|
|
|
} |
|
|
|
|
.refreshable { |
|
|
|
|
if agendaDestination == .tenup { |
|
|
|
|
if navigation.agendaDestination == .tenup { |
|
|
|
|
federalTournaments.removeAll() |
|
|
|
|
_gatherFederalTournaments() |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
.task { |
|
|
|
|
if agendaDestination == .tenup |
|
|
|
|
if navigation.agendaDestination == .tenup |
|
|
|
|
&& dataStore.clubs.isEmpty == false |
|
|
|
|
&& federalTournaments.isEmpty { |
|
|
|
|
_gatherFederalTournaments() |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
.onChange(of: agendaDestination) { |
|
|
|
|
if agendaDestination == .tenup |
|
|
|
|
.onChange(of: navigation.agendaDestination) { |
|
|
|
|
if navigation.agendaDestination == .tenup |
|
|
|
|
&& dataStore.clubs.isEmpty == false |
|
|
|
|
&& federalTournaments.isEmpty { |
|
|
|
|
_gatherFederalTournaments() |
|
|
|
|
@ -186,6 +187,10 @@ struct ActivityView: View { |
|
|
|
|
TournamentView() |
|
|
|
|
.environment(tournament) |
|
|
|
|
} |
|
|
|
|
.navigationDestination(item: $navigation.tournament) { tournament in |
|
|
|
|
TournamentView() |
|
|
|
|
.environment(tournament) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
@ -206,7 +211,7 @@ struct ActivityView: View { |
|
|
|
|
|
|
|
|
|
@ViewBuilder |
|
|
|
|
private func _dataEmptyView() -> some View { |
|
|
|
|
switch agendaDestination! { |
|
|
|
|
switch navigation.agendaDestination! { |
|
|
|
|
case .activity: |
|
|
|
|
_runningEmptyView() |
|
|
|
|
case .history: |
|
|
|
|
@ -234,7 +239,7 @@ struct ActivityView: View { |
|
|
|
|
newTournament = Tournament.newEmptyInstance() |
|
|
|
|
} |
|
|
|
|
RowButtonView("Importer via Tenup") { |
|
|
|
|
agendaDestination = .tenup |
|
|
|
|
navigation.agendaDestination = .tenup |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|