90 lines
2.8 KiB
Swift
90 lines
2.8 KiB
Swift
//
|
|
// RadioBoxModel.swift
|
|
// VDS
|
|
//
|
|
// Created by Matt Bruce on 8/23/22.
|
|
//
|
|
|
|
import Foundation
|
|
import UIKit
|
|
|
|
public protocol RadioBoxModel: Modelable, FormFieldable, DataTrackable, Accessable, Selectable, BinaryColorable {
|
|
var text: String { get set }
|
|
var textAttributes: [any LabelAttributeModel]? { get set }
|
|
var subText: String? { get set }
|
|
var subTextAttributes: [any LabelAttributeModel]? { get set }
|
|
var subTextRight: String? { get set }
|
|
var subTextRightAttributes: [any LabelAttributeModel]? { get set }
|
|
var strikethrough: Bool { get set }
|
|
}
|
|
|
|
extension RadioBoxModel {
|
|
|
|
public var textModel: DefaultLabelModel {
|
|
var model = DefaultLabelModel()
|
|
model.textPosition = .left
|
|
model.typograpicalStyle = .BoldBodyLarge
|
|
model.text = text
|
|
model.surface = surface
|
|
model.disabled = disabled
|
|
model.attributes = textAttributes
|
|
return model
|
|
}
|
|
|
|
public var subTextModel: DefaultLabelModel? {
|
|
guard let subText else { return nil }
|
|
var model = DefaultLabelModel()
|
|
model.textPosition = .left
|
|
model.typograpicalStyle = .BodyLarge
|
|
model.text = subText
|
|
model.surface = surface
|
|
model.disabled = disabled
|
|
model.attributes = subTextAttributes
|
|
return model
|
|
}
|
|
|
|
public var subTextRightModel: DefaultLabelModel? {
|
|
guard let subTextRight else { return nil }
|
|
var model = DefaultLabelModel()
|
|
model.textPosition = .right
|
|
model.typograpicalStyle = .BodyLarge
|
|
model.text = subTextRight
|
|
model.surface = surface
|
|
model.disabled = disabled
|
|
model.attributes = subTextRightAttributes
|
|
return model
|
|
}
|
|
|
|
}
|
|
|
|
public struct DefaultRadioBoxModel: RadioBoxModel {
|
|
public var id = UUID()
|
|
public var selected: Bool = false
|
|
public var text: String = "Default Text"
|
|
public var textAttributes: [any LabelAttributeModel]?
|
|
public var subText: String?
|
|
public var subTextAttributes: [any LabelAttributeModel]?
|
|
public var subTextRight: String?
|
|
public var subTextRightAttributes: [any LabelAttributeModel]?
|
|
public var selectedAccentColor: UIColor?
|
|
public var strikethrough: Bool = false
|
|
|
|
public var inputId: String?
|
|
public var value: AnyHashable?
|
|
|
|
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() {}
|
|
}
|