You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
PadelClub/PadelClub/ViewModel/AgendaDestination.swift

73 lines
1.8 KiB

//
// AgendaDestination.swift
// PadelClub
//
// Created by Razmig Sarkissian on 01/03/2024.
//
import Foundation
enum AgendaDestination: CaseIterable, Identifiable, Selectable {
var id: Self { self }
case activity
case history
case tenup
enum ViewStyle {
case list
case calendar
}
var localizedTitleKey: String {
switch self {
case .activity:
return "En cours"
case .history:
return "Terminé"
case .tenup:
return "Tenup"
}
}
func selectionLabel() -> String {
localizedTitleKey
}
var systemImage: String {
switch self {
case .activity:
return "squares.leading.rectangle"
case .history:
return "book.closed"
case .tenup:
return "tennisball"
}
}
func badgeValue() -> Int? {
switch self {
case .activity:
DataStore.shared.tournaments.filter { $0.endDate == nil && $0.isDeleted == false && FederalDataViewModel.shared.isTournamentValidForFilters($0) }.count
case .history:
DataStore.shared.tournaments.filter { $0.endDate != nil && FederalDataViewModel.shared.isTournamentValidForFilters($0) }.count
case .tenup:
FederalDataViewModel.shared.filteredFederalTournaments.count
}
}
func badgeImage() -> Badge? {
switch self {
case .activity:
return nil
case .history:
return nil
case .tenup:
if FederalDataViewModel.shared.federalTournaments.isEmpty {
return .custom(systemName: "exclamationmark.circle.fill", color: .yellow)
} else {
return nil
}
}
}
}