vds_ios/VDS/Components/Toggle/VDSToggleModel.swift
Matt Bruce ce4faadf0c converted defaults to structs
Signed-off-by: Matt Bruce <matt.bruce@verizon.com>
2022-08-03 09:01:46 -05:00

72 lines
2.0 KiB
Swift

//
// ToggleModel.swift
// VDS
//
// Created by Matt Bruce on 7/22/22.
//
import Foundation
import UIKit
extension VDSToggle {
public enum TextPosition: String, Codable {
case left, right
}
}
public protocol VDSToggleModel: FormFieldable, DataTrackable, Accessable, Initable, Labelable, Surfaceable, Disabling {
var id: String? { get set }
var showText: Bool { get set }
var on: Bool { get set }
var offText: String { get set }
var onText: String { get set }
}
extension VDSToggleModel {
public var fontCategory: VDSFontCategory {
get { return .body }
set { return }
}
public var label: VDSLabelModel {
let model = DefaultLabelModel()
model.fontSize = fontSize
model.textPosition = textPosition
model.fontWeight = fontWeight
model.fontCategory = .body
model.text = on ? onText : offText
model.surface = surface
model.disabled = disabled
return model
}
}
public struct DefaultToggleModel: VDSToggleModel {
public var id: String?
public var inputId: String?
public var showText: Bool = false
public var on: Bool = false
public var offText: String = "Off"
public var onText: String = "On"
public var value: AnyHashable? = true
public var surface: Surface = .light
public var disabled: Bool = false
public var dataAnalyticsTrack: String?
public var dataClickStream: String?
public var dataTrack: String?
public var accessibilityHintEnabled: String?
public var accessibilityHintDisabled: String?
public var accessibilityValueEnabled: String?
public var accessibilityValueDisabled: String?
public var accessibilityLabelEnabled: String?
public var accessibilityLabelDisabled: String?
//labelmodel
public var fontCategory: VDSFontCategory = .body
public var fontSize: VDSFontSize = .small
public var fontWeight: VDSFontWeight = .regular
public var textPosition: VDSTextPosition = .left
public init() { }
}