CHGenerator/Sources/Generator/Content/ThumbnailStyle.swift

52 lines
876 B
Swift
Raw Normal View History

2022-08-16 10:39:05 +02:00
import Foundation
enum ThumbnailStyle: String, CaseIterable {
case large
case square
case small
var height: Int {
switch self {
case .large:
return 210
case .square:
return 178
case .small:
return 78
}
}
var width: Int {
switch self {
case .large:
return 374
case .square:
2022-09-26 17:00:39 +02:00
return 178
2022-08-16 10:39:05 +02:00
case .small:
2022-09-26 17:00:39 +02:00
return 78
2022-08-16 10:39:05 +02:00
}
}
}
extension ThumbnailStyle: Codable {
}
extension ThumbnailStyle: StringProperty {
init?(_ value: String) {
self.init(rawValue: value)
}
static var castFailureReason: String {
"Thumbnail style must be 'large', 'square' or 'small'"
}
}
extension ThumbnailStyle: DefaultValueProvider {
static var defaultValue: ThumbnailStyle { .large }
}