quick enhance tip

online_reg
Raz 11 months ago
parent 7b06c8cefc
commit 906172d9e2
  1. 2
      PadelClub/PadelClubApp.swift
  2. 17
      PadelClub/Utils/Tips.swift
  3. 3
      PadelClub/Views/Navigation/Agenda/EventListView.swift
  4. 14
      PadelClub/Views/Tournament/Shared/TournamentCellView.swift
  5. 31
      PadelClub/Views/Tournament/TournamentView.swift

@ -99,7 +99,7 @@ print("Running in Release mode")
}
.task {
//try? Tips.resetDatastore()
try? Tips.resetDatastore()
try? Tips.configure([
.displayFrequency(.immediate),

@ -594,6 +594,23 @@ struct OnlineRegistrationTip: Tip {
}
}
struct ShouldTournamentBeOverTip: Tip {
var title: Text {
Text("Clôturer le tournoi ?")
}
var message: Text? {
Text("Le dernier match est terminé depuis plus de 2 heures. Si le tournoi a été annulé pour cause de météo vous pouvez l'indiquer comme 'Annulé' dans le menu 􀍡, si ce n'est pas le cas, saisissez les scores manquants pour clôturer automatiquement le tournoi et publier le classement final.")
}
var image: Image? {
Image(systemName: "clock.badge.questionmark")
}
var actions: [Action] {
Action(id: "tournament-status", title: "Gérer le statut du tournoi")
}
}
struct TipStyleModifier: ViewModifier {
@Environment(\.colorScheme) var colorScheme

@ -116,9 +116,8 @@ struct EventListView: View {
private func _tournamentView(_ tournament: Tournament) -> some View {
NavigationLink(value: tournament) {
TournamentCellView(tournament: tournament)
TournamentCellView(tournament: tournament, shouldTournamentBeOver: tournament.shouldTournamentBeOver())
}
.listRowView(isActive: tournament.shouldTournamentBeOver(), color: .red, hideColorVariation: true, alignment: .leading)
.contextMenu {
if tournament.hasEnded() == false {
Button {

@ -15,6 +15,7 @@ struct TournamentCellView: View {
let tournament: FederalTournamentHolder
// let color: Color = .black
var displayStyle: DisplayStyle = .wide
var shouldTournamentBeOver: Bool = false
var event: Event? {
guard let federalTournament = tournament as? FederalTournament else { return nil }
@ -115,8 +116,9 @@ struct TournamentCellView: View {
if let tournament = tournament as? Tournament, displayStyle == .wide {
if tournament.isCanceled {
Text("Annulé".uppercased())
.capsule(foreground: .white, background: .red)
.capsule(foreground: .white, background: .logoRed)
} else if shouldTournamentBeOver {
Image(systemName: "clock.badge.questionmark").foregroundStyle(.logoRed)
} else if let teamCount {
Text(teamCount.formatted())
}
@ -147,12 +149,17 @@ struct TournamentCellView: View {
Text(tournament.durationLabel())
}
Spacer()
if let tournament = tournament as? Tournament, tournament.isCanceled == false, let teamCount {
if let tournament = tournament as? Tournament, tournament.isCanceled == false {
if shouldTournamentBeOver {
Text("à clôturer ?")
.foregroundStyle(.logoRed)
} else if let teamCount {
let hasStarted = tournament.inscriptionClosed() || tournament.hasStarted()
let word = hasStarted ? "équipe" : "inscription"
Text(word + teamCount.pluralSuffix)
}
}
}
} else {
Text(build.category.localizedLabel())
Text(build.age.localizedFederalAgeLabel())
@ -160,7 +167,6 @@ struct TournamentCellView: View {
}
}
.font(.caption)
.listRowView(isActive: existingTournament != nil, color: .green, hideColorVariation: true, alignment: .leading)
}
private func _createOrShow(federalTournament: FederalTournament, existingTournament: Tournament?, build: any TournamentBuildHolder) {

@ -19,6 +19,7 @@ struct TournamentView: View {
let tournamentSelectionTip: TournamentSelectionTip = TournamentSelectionTip()
let tournamentRunningTip: TournamentRunningTip = TournamentRunningTip()
let onlineRegistrationTip: OnlineRegistrationTip = OnlineRegistrationTip()
let shouldTournamentBeOverTip: ShouldTournamentBeOverTip = ShouldTournamentBeOverTip()
var selectedTournamentId: Binding<String> { Binding(
get: { tournament.id },
@ -76,7 +77,7 @@ struct TournamentView: View {
TipView(onlineRegistrationTip) { actions in
navigation.path.append(Screen.settings)
}
.tipStyle(tint: .master, asSection: true)
.tipStyle(tint: .green, asSection: true)
}
Section {
@ -87,34 +88,10 @@ struct TournamentView: View {
case .running:
if tournament.shouldTournamentBeOver() {
Section {
Menu {
Button("Scores manquants") {
if let activeRound = tournament.getActiveRound() {
navigation.path.append(Screen.round)
} else if let activeGroupStage = tournament.getActiveGroupStage() {
navigation.path.append(Screen.groupStage)
}
}
Button {
TipView(shouldTournamentBeOverTip) { actions in
navigation.path.append(Screen.stateSettings)
} label: {
Text("Annuler le tournoi")
}
} label: {
Label("Actions rapides", systemImage: "bolt.circle")
.foregroundColor(.white)
.frame(height: 32)
.font(.headline)
.frame(maxWidth: .infinity)
}
.menuStyle(.button)
.buttonStyle(.borderedProminent)
.tint(.logoYellow)
.listRowBackground(Color.clear)
.listRowInsets(EdgeInsets(.zero))
.tipStyle(tint: .logoRed, asSection: true)
}
}
TournamentBuildView(tournament: tournament)

Loading…
Cancel
Save