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.
58 lines
1.2 KiB
58 lines
1.2 KiB
//
|
|
// Court.swift
|
|
// PadelClub
|
|
//
|
|
// Created by Razmig Sarkissian on 23/04/2024.
|
|
//
|
|
|
|
import Foundation
|
|
import SwiftUI
|
|
import LeStorage
|
|
|
|
@Observable
|
|
final class Court: BaseCourt {
|
|
|
|
static func == (lhs: Court, rhs: Court) -> Bool {
|
|
lhs.id == rhs.id
|
|
}
|
|
|
|
init(index: Int, club: String, name: String? = nil, exitAllowed: Bool = false, indoor: Bool = false) {
|
|
|
|
super.init()
|
|
|
|
self.index = index
|
|
self.lastUpdate = Date()
|
|
self.club = club
|
|
self.name = name
|
|
self.exitAllowed = exitAllowed
|
|
self.indoor = indoor
|
|
}
|
|
|
|
required init(from decoder: Decoder) throws {
|
|
try super.init(from: decoder)
|
|
}
|
|
|
|
required public init() {
|
|
super.init()
|
|
}
|
|
|
|
func courtTitle() -> String {
|
|
self.name ?? courtIndexTitle()
|
|
}
|
|
|
|
func courtIndexTitle() -> String {
|
|
Self.courtIndexedTitle(atIndex: index)
|
|
}
|
|
|
|
static func courtIndexedTitle(atIndex index: Int) -> String {
|
|
("Terrain #" + (index + 1).formatted())
|
|
}
|
|
|
|
func clubObject() -> Club? {
|
|
Store.main.findById(club)
|
|
}
|
|
|
|
override func deleteDependencies() {
|
|
}
|
|
|
|
}
|
|
|