32 lines
797 B
Swift
32 lines
797 B
Swift
//
|
|
// SurfaceConfigurationValue.swift
|
|
// VDS
|
|
//
|
|
// Created by Bandaru, Krishna Kishore on 05/03/24.
|
|
//
|
|
|
|
import Foundation
|
|
|
|
/**
|
|
SurfaceConfiguration is a type that holds the generic datatype for light surface & dark surface and returns the value based on the surface.
|
|
*/
|
|
public struct SurfaceConfigurationValue<ValueType> {
|
|
|
|
public var lightValue: ValueType
|
|
public var darkValue: ValueType
|
|
|
|
public init(_ lightValue: ValueType, _ darkValue: ValueType) {
|
|
self.lightValue = lightValue
|
|
self.darkValue = darkValue
|
|
}
|
|
|
|
public init(value: ValueType) {
|
|
self.lightValue = value
|
|
self.darkValue = value
|
|
}
|
|
|
|
public func value(for object: Surfaceable) -> ValueType {
|
|
object.surface == .light ? lightValue : darkValue
|
|
}
|
|
}
|