diff --git a/PadelClub.xcodeproj/project.pbxproj b/PadelClub.xcodeproj/project.pbxproj index 3547bc7..05fb0bd 100644 --- a/PadelClub.xcodeproj/project.pbxproj +++ b/PadelClub.xcodeproj/project.pbxproj @@ -3254,7 +3254,7 @@ CODE_SIGN_ENTITLEMENTS = PadelClub/PadelClub.entitlements; CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 1; + CURRENT_PROJECT_VERSION = 3; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; DEFINES_MODULE = YES; DEVELOPMENT_ASSET_PATHS = "\"PadelClub/Preview Content\""; @@ -3299,7 +3299,7 @@ CODE_SIGN_ENTITLEMENTS = PadelClub/PadelClub.entitlements; CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 1; + CURRENT_PROJECT_VERSION = 3; DEFINES_MODULE = YES; DEVELOPMENT_ASSET_PATHS = "\"PadelClub/Preview Content\""; DEVELOPMENT_TEAM = BQ3Y44M3Q6; @@ -3415,7 +3415,7 @@ CODE_SIGN_ENTITLEMENTS = PadelClub/PadelClub.entitlements; CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 1; + CURRENT_PROJECT_VERSION = 2; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; DEFINES_MODULE = YES; DEVELOPMENT_ASSET_PATHS = "\"PadelClub/Preview Content\""; @@ -3459,7 +3459,7 @@ CODE_SIGN_ENTITLEMENTS = PadelClub/PadelClub.entitlements; CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 1; + CURRENT_PROJECT_VERSION = 2; DEFINES_MODULE = YES; DEVELOPMENT_ASSET_PATHS = "\"PadelClub/Preview Content\""; DEVELOPMENT_TEAM = BQ3Y44M3Q6; diff --git a/PadelClub/Views/Match/Components/PlayerBlockView.swift b/PadelClub/Views/Match/Components/PlayerBlockView.swift index eca6643..5813ab9 100644 --- a/PadelClub/Views/Match/Components/PlayerBlockView.swift +++ b/PadelClub/Views/Match/Components/PlayerBlockView.swift @@ -71,16 +71,18 @@ struct PlayerBlockView: View { var body: some View { HStack { VStack(alignment: .leading) { - if let names { + if let team { if let teamScore, teamScore.luckyLoser != nil, match.isLoserBracket == false { Text("Repêchée").italic().font(.caption) } - if let teamName = team?.name { + if let teamName = team.name { Text(teamName).foregroundStyle(.secondary).font(.footnote) } - ForEach(names, id: \.self) { name in - Text(name).lineLimit(1) + ForEach(team.players()) { player in + Text(player.playerLabel()).lineLimit(1) + .italic(player.hasArrived == false) + .foregroundStyle(player.hasArrived == false ? .secondary : .primary) } } else { ZStack(alignment: .leading) { diff --git a/PadelClub/Views/Match/MatchRowView.swift b/PadelClub/Views/Match/MatchRowView.swift index 1cde456..1a778c1 100644 --- a/PadelClub/Views/Match/MatchRowView.swift +++ b/PadelClub/Views/Match/MatchRowView.swift @@ -6,6 +6,7 @@ // import SwiftUI +import LeStorage struct MatchRowView: View { @@ -63,6 +64,24 @@ struct MatchRowView: View { } label: { MatchSummaryView(match: match, matchViewStyle: matchViewStyle, title: title, updatedField: updatedField) .contextMenu { + Section { + ForEach(match.teams().flatMap({ $0.players() })) { player in + Button { + player.hasArrived.toggle() + do { + try player.tournamentStore.playerRegistrations.addOrUpdate(instance: player) + } catch { + Logger.error(error) + } + } label: { + Label(player.playerLabel(), systemImage: player.hasArrived ? "checkmark" : "xmark") + } + } + } header: { + Text("Présence") + } + + Divider() NavigationLink { EditSharingView(match: match) } label: { diff --git a/PadelClub/Views/Match/MatchSummaryView.swift b/PadelClub/Views/Match/MatchSummaryView.swift index 9bdb2d8..5e3a86f 100644 --- a/PadelClub/Views/Match/MatchSummaryView.swift +++ b/PadelClub/Views/Match/MatchSummaryView.swift @@ -65,7 +65,7 @@ struct MatchSummaryView: View { VStack(alignment: .trailing, spacing: 0) { if let courtName { Text(courtName) - .strikethrough(match.courtIndex! != updatedField && match.isReady() && match.canBePlayedInSpecifiedCourt() == false) + .strikethrough(courtIsNotValid()) } } .foregroundStyle(.secondary) @@ -123,6 +123,31 @@ struct MatchSummaryView: View { } return updatedField } + + func courtIsNotValid() -> Bool { + if match.courtIndex == updatedField { + return false + } + + if match.isReady() == false { + return false + } + + if match.canBePlayedInSpecifiedCourt() { + return false + } + + if let estimatedStartDate, estimatedStartDate.0 == updatedField { + return false + } + + if let estimatedStartDate, estimatedStartDate.0 == match.courtIndex { + return false + } + + + return true + } } //#Preview {