remove obsolete agendadestinationpicker view

multistore
Razmig Sarkissian 2 years ago
parent 797caf55a2
commit af97c40270
  1. 4
      PadelClub.xcodeproj/project.pbxproj
  2. 6
      PadelClub/ViewModel/AgendaDestination.swift
  3. 27
      PadelClub/Views/Components/GenericDestinationPickerView.swift
  4. 2
      PadelClub/Views/GroupStage/GroupStagesView.swift
  5. 221
      PadelClub/Views/Navigation/Agenda/ActivityView.swift
  6. 39
      PadelClub/Views/Navigation/Agenda/AgendaDestinationPickerView.swift
  7. 2
      PadelClub/Views/Round/RoundsView.swift

@ -173,7 +173,6 @@
FFC1E10C2BAC7FB0008D6F59 /* ClubImportView.swift in Sources */ = {isa = PBXBuildFile; fileRef = FFC1E10B2BAC7FB0008D6F59 /* ClubImportView.swift */; }; FFC1E10C2BAC7FB0008D6F59 /* ClubImportView.swift in Sources */ = {isa = PBXBuildFile; fileRef = FFC1E10B2BAC7FB0008D6F59 /* ClubImportView.swift */; };
FFC83D4F2BB807D100750834 /* RoundsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = FFC83D4E2BB807D100750834 /* RoundsView.swift */; }; FFC83D4F2BB807D100750834 /* RoundsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = FFC83D4E2BB807D100750834 /* RoundsView.swift */; };
FFC83D512BB8087E00750834 /* RoundView.swift in Sources */ = {isa = PBXBuildFile; fileRef = FFC83D502BB8087E00750834 /* RoundView.swift */; }; FFC83D512BB8087E00750834 /* RoundView.swift in Sources */ = {isa = PBXBuildFile; fileRef = FFC83D502BB8087E00750834 /* RoundView.swift */; };
FFD783FD2B91B9ED000F62A6 /* AgendaDestinationPickerView.swift in Sources */ = {isa = PBXBuildFile; fileRef = FFD783FC2B91B9ED000F62A6 /* AgendaDestinationPickerView.swift */; };
FFD783FF2B91BA42000F62A6 /* PadelClubView.swift in Sources */ = {isa = PBXBuildFile; fileRef = FFD783FE2B91BA42000F62A6 /* PadelClubView.swift */; }; FFD783FF2B91BA42000F62A6 /* PadelClubView.swift in Sources */ = {isa = PBXBuildFile; fileRef = FFD783FE2B91BA42000F62A6 /* PadelClubView.swift */; };
FFD784022B91C1B4000F62A6 /* WelcomeView.swift in Sources */ = {isa = PBXBuildFile; fileRef = FFD784012B91C1B4000F62A6 /* WelcomeView.swift */; }; FFD784022B91C1B4000F62A6 /* WelcomeView.swift in Sources */ = {isa = PBXBuildFile; fileRef = FFD784012B91C1B4000F62A6 /* WelcomeView.swift */; };
FFD784042B91C280000F62A6 /* EmptyActivityView.swift in Sources */ = {isa = PBXBuildFile; fileRef = FFD784032B91C280000F62A6 /* EmptyActivityView.swift */; }; FFD784042B91C280000F62A6 /* EmptyActivityView.swift in Sources */ = {isa = PBXBuildFile; fileRef = FFD784032B91C280000F62A6 /* EmptyActivityView.swift */; };
@ -402,7 +401,6 @@
FFC1E10B2BAC7FB0008D6F59 /* ClubImportView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ClubImportView.swift; sourceTree = "<group>"; }; FFC1E10B2BAC7FB0008D6F59 /* ClubImportView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ClubImportView.swift; sourceTree = "<group>"; };
FFC83D4E2BB807D100750834 /* RoundsView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RoundsView.swift; sourceTree = "<group>"; }; FFC83D4E2BB807D100750834 /* RoundsView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RoundsView.swift; sourceTree = "<group>"; };
FFC83D502BB8087E00750834 /* RoundView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RoundView.swift; sourceTree = "<group>"; }; FFC83D502BB8087E00750834 /* RoundView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RoundView.swift; sourceTree = "<group>"; };
FFD783FC2B91B9ED000F62A6 /* AgendaDestinationPickerView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AgendaDestinationPickerView.swift; sourceTree = "<group>"; };
FFD783FE2B91BA42000F62A6 /* PadelClubView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PadelClubView.swift; sourceTree = "<group>"; }; FFD783FE2B91BA42000F62A6 /* PadelClubView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PadelClubView.swift; sourceTree = "<group>"; };
FFD784002B91BF79000F62A6 /* Launch Screen.storyboard */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; path = "Launch Screen.storyboard"; sourceTree = "<group>"; }; FFD784002B91BF79000F62A6 /* Launch Screen.storyboard */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; path = "Launch Screen.storyboard"; sourceTree = "<group>"; };
FFD784012B91C1B4000F62A6 /* WelcomeView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WelcomeView.swift; sourceTree = "<group>"; }; FFD784012B91C1B4000F62A6 /* WelcomeView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WelcomeView.swift; sourceTree = "<group>"; };
@ -897,7 +895,6 @@
FFD784012B91C1B4000F62A6 /* WelcomeView.swift */, FFD784012B91C1B4000F62A6 /* WelcomeView.swift */,
FF59FFB22B90EFAC0061EFF9 /* EventListView.swift */, FF59FFB22B90EFAC0061EFF9 /* EventListView.swift */,
FF5D0D8A2BB4D1E3005CB568 /* CalendarView.swift */, FF5D0D8A2BB4D1E3005CB568 /* CalendarView.swift */,
FFD783FC2B91B9ED000F62A6 /* AgendaDestinationPickerView.swift */,
); );
path = Agenda; path = Agenda;
sourceTree = "<group>"; sourceTree = "<group>";
@ -1162,7 +1159,6 @@
FF1CBC1D2BB53DC10036DAAB /* Calendar+Extensions.swift in Sources */, FF1CBC1D2BB53DC10036DAAB /* Calendar+Extensions.swift in Sources */,
FF967CF22BAECC0B00A9A3BD /* TeamScore.swift in Sources */, FF967CF22BAECC0B00A9A3BD /* TeamScore.swift in Sources */,
FF5D0D762BB428B2005CB568 /* ListRowViewModifier.swift in Sources */, FF5D0D762BB428B2005CB568 /* ListRowViewModifier.swift in Sources */,
FFD783FD2B91B9ED000F62A6 /* AgendaDestinationPickerView.swift in Sources */,
FF6EC9002B94794700EA7F5A /* PresentationContext.swift in Sources */, FF6EC9002B94794700EA7F5A /* PresentationContext.swift in Sources */,
FFDB1C6D2BB2A02000F1E467 /* AppSettings.swift in Sources */, FFDB1C6D2BB2A02000F1E467 /* AppSettings.swift in Sources */,
FF0EC5202BB16F680056B6D1 /* SwiftParser.swift in Sources */, FF0EC5202BB16F680056B6D1 /* SwiftParser.swift in Sources */,

@ -7,7 +7,7 @@
import Foundation import Foundation
enum AgendaDestination: CaseIterable, Identifiable { enum AgendaDestination: CaseIterable, Identifiable, Selectable {
var id: Self { self } var id: Self { self }
case activity case activity
@ -30,6 +30,10 @@ enum AgendaDestination: CaseIterable, Identifiable {
} }
} }
func selectionLabel() -> String {
localizedTitleKey
}
var systemImage: String { var systemImage: String {
switch self { switch self {
case .activity: case .activity:

@ -14,23 +14,26 @@ protocol Selectable {
struct GenericDestinationPickerView<T: Identifiable & Selectable>: View { struct GenericDestinationPickerView<T: Identifiable & Selectable>: View {
@Binding var selectedDestination: T? @Binding var selectedDestination: T?
let destinations: [T] let destinations: [T]
let nilDestinationIsValid: Bool
var body: some View { var body: some View {
ScrollView(.horizontal) { ScrollView(.horizontal) {
HStack { HStack {
Button { if nilDestinationIsValid {
selectedDestination = nil Button {
} label: { selectedDestination = nil
Image(systemName: "wrench.and.screwdriver") } label: {
} Image(systemName: "wrench.and.screwdriver")
.padding() }
.background { .padding()
Circle() .background {
.fill(Color.white) Circle()
.opacity(selectedDestination == nil ? 1.0 : 0.5) .fill(Color.white)
.opacity(selectedDestination == nil ? 1.0 : 0.5)
}
.buttonStyle(.plain)
} }
.buttonStyle(.plain)
ForEach(destinations) { destination in ForEach(destinations) { destination in
Button { Button {
selectedDestination = destination selectedDestination = destination

@ -18,7 +18,7 @@ struct GroupStagesView: View {
var body: some View { var body: some View {
VStack(spacing: 0) { VStack(spacing: 0) {
GenericDestinationPickerView(selectedDestination: $selectedGroupStage, destinations: tournament.groupStages()) GenericDestinationPickerView(selectedDestination: $selectedGroupStage, destinations: tournament.groupStages(), nilDestinationIsValid: true)
switch selectedGroupStage { switch selectedGroupStage {
case .none: case .none:
GroupStageSettingsView() GroupStageSettingsView()

@ -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")
}
if let _activityStatus = _activityStatus() {
Text(_activityStatus)
.foregroundStyle(.secondary)
}
}
.font(.footnote)
} }
}
.toolbar {
ToolbarItem(placement: .topBarLeading) { if presentToolbar {
Button { ToolbarItem(placement: .status) {
switch viewStyle { VStack(spacing: -2) {
case .list: if filterEnabled {
viewStyle = .calendar Text("filtre actif")
case .calendar: }
viewStyle = .list if let _activityStatus = _activityStatus() {
Text(_activityStatus)
.foregroundStyle(.secondary)
}
} }
} label: { .font(.footnote)
Image(systemName: "calendar.circle")
.resizable()
.scaledToFit()
.frame(minHeight: 28)
} }
.symbolVariant(viewStyle == .calendar ? .fill : .none)
// ToolbarItem(placement: .topBarLeading) {
// Button { Button {
// filterEnabled.toggle() switch viewStyle {
// } label: { case .list:
// Image(systemName: "line.3.horizontal.decrease.circle") viewStyle = .calendar
// .resizable() case .calendar:
// .scaledToFit() viewStyle = .list
// .frame(minHeight: 28) }
// } } label: {
// .symbolVariant(filterEnabled ? .fill : .none) Image(systemName: "calendar.circle")
} .resizable()
.scaledToFit()
ToolbarItem(placement: .topBarTrailing) { .frame(minHeight: 28)
Button { }
newTournament = Tournament.newEmptyInstance() .symbolVariant(viewStyle == .calendar ? .fill : .none)
} label: { //
Image(systemName: "plus.circle.fill") // Button {
.resizable() // filterEnabled.toggle()
.scaledToFit() // } label: {
.frame(minHeight: 28) // Image(systemName: "line.3.horizontal.decrease.circle")
// .resizable()
// .scaledToFit()
// .frame(minHeight: 28)
// }
// .symbolVariant(filterEnabled ? .fill : .none)
}
ToolbarItem(placement: .topBarTrailing) {
Button {
newTournament = Tournament.newEmptyInstance()
} label: {
Image(systemName: "plus.circle.fill")
.resizable()
.scaledToFit()
.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:

@ -1,39 +0,0 @@
//
// AgendaDestinationPickerView.swift
// PadelClub
//
// Created by Razmig Sarkissian on 01/03/2024.
//
import SwiftUI
struct AgendaDestinationPickerView: View {
@Binding var agendaDestination: AgendaDestination
var body: some View {
HStack {
ForEach(AgendaDestination.allCases) { screen in
Button {
agendaDestination = screen
} label: {
Label(screen.localizedTitleKey, systemImage: screen.systemImage)
}
.padding()
.background {
Capsule(style: .continuous)
.fill(.white)
.opacity(screen == agendaDestination ? 1.0 : 0.5)
}
.labelStyle(.titleOnly)
.buttonStyle(.plain)
}
}
.listRowInsets(EdgeInsets(top: 0, leading: 0, bottom: 0, trailing: 0))
.listRowBackground(Color.clear)
}
}
#Preview {
AgendaDestinationPickerView(agendaDestination: .constant(.activity))
}

@ -18,7 +18,7 @@ struct RoundsView: View {
var body: some View { var body: some View {
VStack(spacing: 0) { VStack(spacing: 0) {
GenericDestinationPickerView(selectedDestination: $selectedRound, destinations: tournament.rounds()) GenericDestinationPickerView(selectedDestination: $selectedRound, destinations: tournament.rounds(), nilDestinationIsValid: true)
switch selectedRound { switch selectedRound {
case .none: case .none:
RoundSettingsView() RoundSettingsView()

Loading…
Cancel
Save