vds_ios/VDS/Utilities/SurfaceConfigurationValue.swift
Krishna Kishore Bandaru 1c0b8bbf45 Addressed review comments
2024-03-05 17:49:25 +05:30

32 lines
776 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.
*/
struct SurfaceConfigurationValue<ValueType> {
var lightValue: ValueType
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
}
}