|
|
|
|
@ -28,32 +28,37 @@ struct ClubsView: View { |
|
|
|
|
var body: some View { |
|
|
|
|
List { |
|
|
|
|
let clubs : [Club] = dataStore.user.clubsObjects(includeCreated: false) |
|
|
|
|
Section { |
|
|
|
|
ForEach(clubs) { club in |
|
|
|
|
if let selection { |
|
|
|
|
Button { |
|
|
|
|
selection(club) |
|
|
|
|
dismiss() |
|
|
|
|
} label: { |
|
|
|
|
ClubRowView(club: club, displayContext: .selection) |
|
|
|
|
.frame(maxWidth: .infinity) |
|
|
|
|
} |
|
|
|
|
.contentShape(Rectangle()) |
|
|
|
|
.buttonStyle(.plain) |
|
|
|
|
} else { |
|
|
|
|
NavigationLink { |
|
|
|
|
ClubDetailView(club: club, displayContext: club.hasBeenCreated(by: dataStore.user.id) ? .edition : .lockedForEditing) |
|
|
|
|
} label: { |
|
|
|
|
ClubRowView(club: club) |
|
|
|
|
let onlyCreatedClubs : [Club] = dataStore.user.createdClubsObjectsNotFavorite() |
|
|
|
|
|
|
|
|
|
if clubs.isEmpty == false || onlyCreatedClubs.isEmpty == false { |
|
|
|
|
Section { |
|
|
|
|
if clubs.isEmpty && onlyCreatedClubs.isEmpty == false { |
|
|
|
|
_contentUnavailable() |
|
|
|
|
} |
|
|
|
|
ForEach(clubs) { club in |
|
|
|
|
if let selection { |
|
|
|
|
Button { |
|
|
|
|
selection(club) |
|
|
|
|
dismiss() |
|
|
|
|
} label: { |
|
|
|
|
ClubRowView(club: club, displayContext: .selection) |
|
|
|
|
.frame(maxWidth: .infinity) |
|
|
|
|
} |
|
|
|
|
.contentShape(Rectangle()) |
|
|
|
|
.buttonStyle(.plain) |
|
|
|
|
} else { |
|
|
|
|
NavigationLink { |
|
|
|
|
ClubDetailView(club: club, displayContext: club.hasBeenCreated(by: dataStore.user.id) ? .edition : .lockedForEditing) |
|
|
|
|
} label: { |
|
|
|
|
ClubRowView(club: club) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} header: { |
|
|
|
|
Text("Clubs favoris") |
|
|
|
|
} |
|
|
|
|
} header: { |
|
|
|
|
Text("Clubs favoris") |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
let onlyCreatedClubs : [Club] = dataStore.user.createdClubsObjectsNotFavorite() |
|
|
|
|
|
|
|
|
|
if onlyCreatedClubs.isEmpty == false { |
|
|
|
|
Section { |
|
|
|
|
ForEach(onlyCreatedClubs) { club in |
|
|
|
|
@ -81,22 +86,11 @@ struct ClubsView: View { |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
.overlay { |
|
|
|
|
if dataStore.user.hasFavoriteClubsAndCreatedClubs() == false { |
|
|
|
|
ContentUnavailableView { |
|
|
|
|
Label("Aucun club", systemImage: "house.and.flag.fill") |
|
|
|
|
} description: { |
|
|
|
|
Text("Texte décrivant l'utilité d'un club et les features que cela apporte") |
|
|
|
|
} actions: { |
|
|
|
|
RowButtonView("Créer un nouveau club", systemImage: "plus.circle.fill") { |
|
|
|
|
newClub = Club.newEmptyInstance() |
|
|
|
|
} |
|
|
|
|
RowButtonView("Chercher un club", systemImage: "magnifyingglass.circle.fill") { |
|
|
|
|
presentClubSearchView = true |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
if dataStore.user.clubsObjects(includeCreated: true).isEmpty { |
|
|
|
|
_contentUnavailable() |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
.navigationTitle(selection == nil ? "Mes clubs" : "Choisir un club") |
|
|
|
|
.navigationTitle(selection == nil ? "Clubs favoris" : "Choisir un club") |
|
|
|
|
.navigationBarTitleDisplayMode(.inline) |
|
|
|
|
.toolbarBackground(.visible, for: .navigationBar) |
|
|
|
|
.sheet(isPresented: presentClubCreationView) { |
|
|
|
|
@ -141,6 +135,22 @@ struct ClubsView: View { |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private func _contentUnavailable() -> some View { |
|
|
|
|
ContentUnavailableView { |
|
|
|
|
Label("Aucun club", systemImage: "house.and.flag.fill") |
|
|
|
|
} description: { |
|
|
|
|
Text("Avoir un club en favori permet d'accéder aux tournois enregistrés sur Tenup.") |
|
|
|
|
} actions: { |
|
|
|
|
RowButtonView("Créer un nouveau club", systemImage: "plus.circle.fill") { |
|
|
|
|
newClub = Club.newEmptyInstance() |
|
|
|
|
} |
|
|
|
|
RowButtonView("Chercher un club", systemImage: "magnifyingglass.circle.fill") { |
|
|
|
|
presentClubSearchView = true |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
#Preview { |
|
|
|
|
|