multistore
Razmig Sarkissian 2 years ago
parent 70c943330f
commit afcd359293
  1. 2
      PadelClub/Views/Calling/Components/MenuWarningView.swift
  2. 2
      PadelClub/Views/Calling/SendToAllView.swift
  3. 4
      PadelClub/Views/Match/Components/MatchDateView.swift
  4. 67
      PadelClub/Views/Match/MatchSummaryView.swift
  5. 4
      PadelClub/Views/Navigation/Ongoing/OngoingView.swift
  6. 10
      PadelClub/Views/Tournament/Screen/Components/TournamentGeneralSettingsView.swift
  7. 40
      PadelClub/Views/Tournament/Shared/TournamentCellView.swift

@ -55,7 +55,7 @@ struct MenuWarningView: View {
let players = [player]
_actionView(players: players)
} label: {
Text(player.playerLabel(.short))
Text(player.playerLabel())
}
}

@ -71,7 +71,7 @@ struct SendToAllView: View {
if contactMethod == 0 {
contactType = .message(date: nil, recipients: _teams().flatMap { $0.unsortedPlayers() }.compactMap { $0.phoneNumber }, body: tournament.tournamentTitle(), tournamentBuild: nil)
} else {
contactType = .mail(date: nil, recipients: nil, bccRecipients: _teams().flatMap { $0.unsortedPlayers() }.compactMap { $0.email }, body: nil, subject: tournament.tournamentTitle(), tournamentBuild: nil)
contactType = .mail(date: nil, recipients: tournament.umpireMail(), bccRecipients: _teams().flatMap { $0.unsortedPlayers() }.compactMap { $0.email }, body: nil, subject: tournament.tournamentTitle(), tournamentBuild: nil)
}
}
}

@ -8,7 +8,6 @@
import SwiftUI
struct MatchDateView: View {
@Environment(Tournament.self) var tournament: Tournament
@EnvironmentObject var dataStore: DataStore
var match: Match
var showPrefix: Bool = false
@ -32,7 +31,8 @@ struct MatchDateView: View {
save()
}
} else {
let estimatedDuration = match.matchFormat.getEstimatedDuration(tournament.additionalEstimationDuration)
let tournament = match.currentTournament()
let estimatedDuration = tournament != nil ? match.matchFormat.getEstimatedDuration(tournament!.additionalEstimationDuration) : match.matchFormat.getEstimatedDuration()
Button("Décaler de \(estimatedDuration) minutes") {
match.startDate = match.startDate?.addingTimeInterval(Double(estimatedDuration) * 60.0)
match.endDate = nil

@ -21,7 +21,7 @@ struct MatchSummaryView: View {
var color: Color {
return Color(white: 0.9)
matchViewStyle == .plainStyle ? Color(uiColor: .tertiaryLabel) : Color(uiColor: .secondaryLabel)
//matchViewStyle == .plainStyle ? Color(uiColor: .tertiaryLabel) : Color(uiColor: .secondaryLabel)
}
var width: CGFloat {
@ -58,59 +58,51 @@ struct MatchSummaryView: View {
var matchSummaryView: some View {
VStack(alignment: .leading) {
if matchViewStyle != .plainStyle {
if matchViewStyle == .feedStyle, let tournament = match.currentTournament() {
tournamentHeaderView(tournament)
}
HStack {
if match.isGroupStage() && matchViewStyle != .feedStyle {
if let groupStage = match.groupStageObject, matchViewStyle == .standardStyle {
if match.isGroupStage() {
if let groupStage = match.groupStageObject {
Text(groupStage.groupStageTitle())
} else if let round = match.roundObject {
Text(round.roundTitle())
}
Text(match.matchTitle())
} else if let currentTournament = match.currentTournament() {
if matchViewStyle == .feedStyle {
//tournamentHeaderView(currentTournament)
} else if matchViewStyle != .sectionedStandardStyle {
Text(match.matchTitle(.short))
}
}
if matchViewStyle == .standardStyle || matchViewStyle == .sectionedStandardStyle
{
Spacer()
if let court = match.courtName(), match.hasEnded() == false {
Spacer()
if let court = match.courtName(), match.hasEnded() == false {
Spacer()
Text(court)
}
Text(court)
}
}
.lineLimit(1)
}
if matchViewStyle != .feedStyle {
HStack(spacing: 0) {
VStack(alignment: .leading, spacing: matchViewStyle == .plainStyle ? 8 : 0) {
PlayerBlockView(match: match, teamPosition: .one, color: color, width: width)
.padding(matchViewStyle == .plainStyle ? 0 : 8)
if width == 1 {
Divider()
} else {
Divider().frame(height: width).overlay(color)
}
PlayerBlockView(match: match, teamPosition: .two, color: color, width: width)
.padding(matchViewStyle == .plainStyle ? 0 : 8)
HStack(spacing: 0) {
VStack(alignment: .leading, spacing: matchViewStyle == .plainStyle ? 8 : 0) {
PlayerBlockView(match: match, teamPosition: .one, color: color, width: width)
.padding(matchViewStyle == .plainStyle ? 0 : 8)
if width == 1 {
Divider()
} else {
Divider().frame(height: width).overlay(color)
}
PlayerBlockView(match: match, teamPosition: .two, color: color, width: width)
.padding(matchViewStyle == .plainStyle ? 0 : 8)
}
.overlay {
if matchViewStyle != .plainStyle {
RoundedRectangle(cornerRadius: 8)
.stroke(color, lineWidth: 2)
}
}
.overlay {
if matchViewStyle != .plainStyle {
RoundedRectangle(cornerRadius: 8)
.stroke(color, lineWidth: 2)
}
}
if matchViewStyle != .plainStyle {
HStack {
Spacer()
MatchDateView(match: match, showPrefix: matchViewStyle == .tournamentResultStyle ? true : false)
}
if matchViewStyle != .plainStyle {
HStack {
Spacer()
MatchDateView(match: match, showPrefix: matchViewStyle == .tournamentResultStyle)
}
}
}
@ -120,6 +112,7 @@ struct MatchSummaryView: View {
@ViewBuilder
func tournamentHeaderView(_ currentTournament: Tournament) -> some View {
return Text(currentTournament.tournamentTitle())
VStack(alignment: .leading) {
// HStack {
// ZStack(alignment: .leading) {

@ -22,7 +22,9 @@ struct OngoingView: View {
}
}
.overlay {
ContentUnavailableView("Aucun match en cours", systemImage: "figure.tennis", description: Text("Tous vos matchs en cours seront visibles ici, quelque soit le tournoi."))
if matches.isEmpty {
ContentUnavailableView("Aucun match en cours", systemImage: "figure.tennis", description: Text("Tous vos matchs en cours seront visibles ici, quelque soit le tournoi."))
}
}
.navigationTitle("En cours")
.toolbar(matches.isEmpty ? .hidden : .visible, for: .navigationBar)

@ -32,6 +32,7 @@ struct TournamentGeneralSettingsView: View {
.keyboardType(.decimalPad)
.multilineTextAlignment(.trailing)
.frame(maxWidth: .infinity)
.focused($textFieldIsFocus)
} label: {
Text("Inscription")
}
@ -56,13 +57,14 @@ struct TournamentGeneralSettingsView: View {
}
}
}
.focused($textFieldIsFocus)
.scrollDismissesKeyboard(.immediately)
.toolbarBackground(.visible, for: .navigationBar)
.toolbar {
ToolbarItem(placement: .keyboard) {
Button("Valider") {
textFieldIsFocus = false
if textFieldIsFocus {
ToolbarItem(placement: .keyboard) {
Button("Valider") {
textFieldIsFocus = false
}
}
}
}

@ -55,24 +55,7 @@ struct TournamentCellView: View {
Text(tournament.sortedTeams().count.formatted())
} else if let federalTournament = tournament as? FederalTournament {
Button {
if let existingTournament {
navigation.agendaDestination = .activity
navigation.path.append(existingTournament)
} else {
let event = federalTournament.getEvent()
let newTournament = Tournament.newEmptyInstance()
newTournament.event = event.id
//todo
//newTournament.umpireMail()
//newTournament.jsonData = jsonData
newTournament.tournamentLevel = build.level
newTournament.tournamentCategory = build.category
newTournament.federalTournamentAge = build.age
newTournament.dayDuration = federalTournament.dayDuration
newTournament.startDate = federalTournament.startDate.atBeginningOfDay(hourInt: 9)
newTournament.setupFederalSettings()
try? dataStore.tournaments.addOrUpdate(instance: newTournament)
}
_createOrShow(federalTournament: federalTournament, existingTournament: existingTournament, build: build)
} label: {
Image(systemName: existingTournament != nil ? "checkmark.circle.fill" : "square.and.arrow.down")
.resizable()
@ -101,6 +84,27 @@ struct TournamentCellView: View {
}
.font(.caption)
}
private func _createOrShow(federalTournament: FederalTournament, existingTournament: Tournament?, build: any TournamentBuildHolder) {
if let existingTournament {
navigation.agendaDestination = .activity
navigation.path.append(existingTournament)
} else {
let event = federalTournament.getEvent()
let newTournament = Tournament.newEmptyInstance()
newTournament.event = event.id
//todo
//newTournament.umpireMail()
//newTournament.jsonData = jsonData
newTournament.tournamentLevel = build.level
newTournament.tournamentCategory = build.category
newTournament.federalTournamentAge = build.age
newTournament.dayDuration = federalTournament.dayDuration
newTournament.startDate = federalTournament.startDate.atBeginningOfDay(hourInt: 9)
newTournament.setupFederalSettings()
try? dataStore.tournaments.addOrUpdate(instance: newTournament)
}
}
}
#Preview {

Loading…
Cancel
Save