refactored properties using this

Signed-off-by: Matt Bruce <matt.bruce@verizon.com>
This commit is contained in:
Matt Bruce 2022-07-29 16:06:42 -05:00
parent 13b5ea2a55
commit e8da41eb70
2 changed files with 26 additions and 105 deletions

View File

@ -23,50 +23,20 @@ open class VDSLabel: UILabel, Modelable {
@Published public var model: VDSLabelModel = DefaultLabelModel()
private var cancellable: AnyCancellable?
public var fontSize: VDSFontSize {
get { model.fontSize }
set {
if model.fontSize != newValue {
model.fontSize = newValue
}
}
}
@Proxy(\VDSLabel.model.fontSize)
public var fontSize: VDSFontSize
public var textPosition: VDSTextPosition {
get { model.textPosition }
set {
if model.textPosition != newValue {
model.textPosition = newValue
}
}
}
@Proxy(\VDSLabel.model.textPosition)
public var textPosition: VDSTextPosition
public var fontWeight: VDSFontWeight {
get { model.fontWeight }
set {
if model.fontWeight != newValue {
model.fontWeight = newValue
}
}
}
@Proxy(\VDSLabel.model.fontWeight)
public var fontWeight: VDSFontWeight
public var fontCategory: VDSFontCategory {
get { model.fontCategory }
set {
if model.fontCategory != newValue {
model.fontCategory = newValue
}
}
}
@Proxy(\VDSLabel.model.fontCategory)
public var fontCategory: VDSFontCategory
public var surface: Surface {
get { model.surface }
set {
if model.surface != newValue {
model.surface = newValue
}
}
}
@Proxy(\VDSLabel.model.surface)
public var surface: Surface
//Initializers
public convenience init() {

View File

@ -17,7 +17,6 @@ import Combine
Container: The background of the toggle control.
Knob: The circular indicator that slides on the container.
*/
public class DefaultToggleModel: DefaultLabelModel, VDSToggleModel {
public var id: String?
public var inputId: String?
@ -110,68 +109,26 @@ public class DefaultToggleModel: DefaultLabelModel, VDSToggleModel {
//--------------------------------------------------
// MARK: - Computed Properties
//--------------------------------------------------
public var showText: Bool {
get { model.showText }
set {
if model.showText != newValue {
model.showText = newValue
}
}
}
@Proxy(\VDSToggle.model.showText)
public var showText: Bool
public var onText: String {
get { model.onText }
set {
if model.onText != newValue {
model.onText = newValue
}
}
}
@Proxy(\VDSToggle.model.onText)
public var onText: String
public var offText: String {
get { model.offText }
set {
if model.offText != newValue {
model.offText = newValue
}
}
}
@Proxy(\VDSToggle.model.offText)
public var offText: String
public var textPosition: VDSTextPosition {
get { model.textPosition }
set {
if model.textPosition != newValue {
model.textPosition = newValue
}
}
}
@Proxy(\VDSToggle.model.textPosition)
public var textPosition: VDSTextPosition
public var fontSize: VDSFontSize {
get { model.fontSize }
set {
if model.fontSize != newValue {
model.fontSize = newValue
}
}
}
@Proxy(\VDSToggle.model.fontSize)
public var fontSize: VDSFontSize
public var fontWeight: VDSFontWeight {
get { model.fontWeight }
set {
if model.fontWeight != newValue {
model.fontWeight = newValue
}
}
}
@Proxy(\VDSToggle.model.fontWeight)
public var fontWeight: VDSFontWeight
public var surface: Surface {
get { model.surface }
set {
if model.surface != newValue {
model.surface = newValue
}
}
}
@Proxy(\VDSToggle.model.surface)
public var surface: Surface
open override var isEnabled: Bool {
get { !model.disabled }
@ -190,14 +147,8 @@ public class DefaultToggleModel: DefaultLabelModel, VDSToggleModel {
}
/// The state on the toggle. Default value: false.
open var isOn: Bool {
get { model.on }
set {
if model.on != newValue {
model.on = newValue
}
}
}
@Proxy(\VDSToggle.model.on)
open var isOn: Bool
//--------------------------------------------------
// MARK: - Constraints