parent
c5e1f4b356
commit
55b69bc9b4
@ -0,0 +1,35 @@ |
||||
// |
||||
// SeedInterval.swift |
||||
// PadelClub |
||||
// |
||||
// Created by Razmig Sarkissian on 01/04/2024. |
||||
// |
||||
|
||||
import Foundation |
||||
|
||||
struct SeedInterval: Hashable, Comparable { |
||||
let first: Int |
||||
let last: Int |
||||
|
||||
static func <(lhs: SeedInterval, rhs: SeedInterval) -> Bool { |
||||
return lhs.first < rhs.first |
||||
} |
||||
|
||||
func chunk() -> SeedInterval? { |
||||
if last - (last - first) / 2 > first { |
||||
return SeedInterval(first: first, last: last - (last - first) / 2) |
||||
} else { |
||||
return nil |
||||
} |
||||
} |
||||
} |
||||
|
||||
extension SeedInterval { |
||||
func localizedLabel(_ displayStyle: DisplayStyle = .wide) -> String { |
||||
if last - first < 2 { |
||||
return "#\(first) / #\(last)" |
||||
} else { |
||||
return "#\(first) à #\(last)" |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,13 @@ |
||||
// |
||||
// Selectable.swift |
||||
// PadelClub |
||||
// |
||||
// Created by Razmig Sarkissian on 01/04/2024. |
||||
// |
||||
|
||||
import Foundation |
||||
|
||||
protocol Selectable { |
||||
func selectionLabel() -> String |
||||
func badgeValue() -> Int? |
||||
} |
||||
Loading…
Reference in new issue