parent
413e2436dd
commit
858a68c572
@ -0,0 +1,40 @@ |
|||||||
|
// |
||||||
|
// TeamMatchesView.swift |
||||||
|
// PadelClub |
||||||
|
// |
||||||
|
// Created by Razmig Sarkissian on 16/10/2025. |
||||||
|
// |
||||||
|
|
||||||
|
import SwiftUI |
||||||
|
import LeStorage |
||||||
|
import PadelClubData |
||||||
|
|
||||||
|
struct TeamMatchesView: View { |
||||||
|
let team: TeamRegistration |
||||||
|
|
||||||
|
var body: some View { |
||||||
|
List { |
||||||
|
if let currentMatch = team.currentMatch() { |
||||||
|
Section { |
||||||
|
MatchRowView(match: currentMatch) |
||||||
|
} header: { |
||||||
|
Text("Prochain match") |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
let followingMatches = team.followingMatches() |
||||||
|
if followingMatches.isEmpty == false { |
||||||
|
Section { |
||||||
|
ForEach(followingMatches) { match in |
||||||
|
MatchRowView(match: match) |
||||||
|
} |
||||||
|
} header: { |
||||||
|
Text("Tous les matchs") |
||||||
|
} |
||||||
|
} else { |
||||||
|
ContentUnavailableView("Aucun match à venir", systemImage: "calendar.badge.exclamation", description: Text("Il n’y a pas de matchs prévus pour cette équipe.")) |
||||||
|
} |
||||||
|
} |
||||||
|
.navigationTitle("Liste des matchs") |
||||||
|
} |
||||||
|
} |
||||||
@ -0,0 +1,83 @@ |
|||||||
|
// |
||||||
|
// PlayerSearchView.swift |
||||||
|
// PadelClub |
||||||
|
// |
||||||
|
// Created by Razmig Sarkissian on 16/10/2025. |
||||||
|
// |
||||||
|
|
||||||
|
import SwiftUI |
||||||
|
import LeStorage |
||||||
|
import PadelClubData |
||||||
|
|
||||||
|
struct PlayerSearchView: View { |
||||||
|
@State private var searchText: String = "" |
||||||
|
@State private var presentSearch: Bool = true |
||||||
|
@EnvironmentObject var dataStore: DataStore |
||||||
|
@Environment(\.dismiss) private var dismiss |
||||||
|
|
||||||
|
let event: Event |
||||||
|
|
||||||
|
let tournaments: [Tournament] |
||||||
|
let players: [PlayerRegistration] |
||||||
|
|
||||||
|
init(event: Event) { |
||||||
|
self.event = event |
||||||
|
self.tournaments = event.tournaments |
||||||
|
self.players = event.tournaments.flatMap({ $0.players() }) |
||||||
|
} |
||||||
|
|
||||||
|
var searchedPlayers: [PlayerRegistration] { |
||||||
|
if searchText.isEmpty { |
||||||
|
return [] |
||||||
|
} else { |
||||||
|
return players.filter({ $0.contains(searchText) }) |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
var body: some View { |
||||||
|
NavigationStack { |
||||||
|
let _searchedPlayers = searchedPlayers |
||||||
|
let teams = Set(searchedPlayers.compactMap({ $0.team() })) |
||||||
|
List { |
||||||
|
ForEach(teams.sorted(by: \.tournament)) { team in |
||||||
|
if let tournament = team.tournamentObject() { |
||||||
|
Section { |
||||||
|
NavigationLink { |
||||||
|
EditingTeamView(team: team) |
||||||
|
.environment(tournament) |
||||||
|
} label: { |
||||||
|
TeamRowView(team: team) |
||||||
|
} |
||||||
|
} footer: { |
||||||
|
Text(tournament.tournamentTitle(.title)) |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
.ifAvailableiOS26 { |
||||||
|
if #available(iOS 26.0, *) { |
||||||
|
$0.navigationSubtitle(event.eventTitle()) |
||||||
|
} |
||||||
|
} |
||||||
|
.navigationTitle("Rechercher un joueur") |
||||||
|
.toolbar { |
||||||
|
ToolbarItem(placement: .topBarLeading) { |
||||||
|
Button("Fermer", systemImage: "xmark") { |
||||||
|
dismiss() |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
.overlay(content: { |
||||||
|
if _searchedPlayers.isEmpty { |
||||||
|
if searchText.isEmpty { |
||||||
|
ContentUnavailableView("Rechercher des joueurs", systemImage: "magnifyingglass", description: Text("Tapez un nom de joueur ci-dessus pour commencer la recherche.\nVous pouvez aussi rechercher par email, numéro de téléphone, licence ou identifiant de paiement Stripe.")) |
||||||
|
} else { |
||||||
|
ContentUnavailableView.search(text: searchText) |
||||||
|
} |
||||||
|
} |
||||||
|
}) |
||||||
|
.searchable(text: $searchText, isPresented: $presentSearch, placement: .navigationBarDrawer(displayMode: .always), prompt: "Rechercher un joueur") |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
Loading…
Reference in new issue