// // ToggleModel.swift // VDS // // Created by Matt Bruce on 7/22/22. // import Foundation import UIKit public enum ToggleTextSize: String, CaseIterable { case small, large } public enum ToggleTextWeight: String, CaseIterable { case regular, bold } public enum ToggleTextPosition: String, CaseIterable { case left, right } public protocol ToggleModel: Modelable, FormFieldable, DataTrackable, Accessable, BinaryColorable { var showText: Bool { get set } var on: Bool { get set } var offText: String { get set } var onText: String { get set } var textWeight: ToggleTextWeight { get set } var textSize: ToggleTextSize { get set } var textPosition: ToggleTextPosition { get set } } extension ToggleModel { public var userTrueColor: Bool { return on } public var labelModel: DefaultLabelModel { var typograpicalStyle: TypographicalStyle if textSize == .small { if textWeight == .bold { typograpicalStyle = .BoldBodySmall } else { typograpicalStyle = .BodySmall } } else { if textWeight == .bold { typograpicalStyle = .BoldBodyLarge } else { typograpicalStyle = .BodyLarge } } var model = DefaultLabelModel() model.textPosition = textPosition == .left ? .left : .right model.typograpicalStyle = typograpicalStyle model.text = on ? onText : offText model.surface = surface model.disabled = disabled return model } } public struct DefaultToggleModel: ToggleModel { public var id = UUID() public var on: Bool = false public var showText: Bool = false public var offText: String = "Off" public var onText: String = "On" public var textWeight: ToggleTextWeight = .regular public var textSize: ToggleTextSize = .small public var textPosition: ToggleTextPosition = .left public var inputId: String? 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? public init() { } }