From e8da41eb70f2a5947c340e39a8f4f97d88d361f4 Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Fri, 29 Jul 2022 16:06:42 -0500 Subject: [PATCH] refactored properties using this Signed-off-by: Matt Bruce --- VDS/Components/Label/VDSLabel.swift | 50 ++++------------- VDS/Components/Toggle/VDSToggle.swift | 81 ++++++--------------------- 2 files changed, 26 insertions(+), 105 deletions(-) diff --git a/VDS/Components/Label/VDSLabel.swift b/VDS/Components/Label/VDSLabel.swift index a74cb73a..4078477f 100644 --- a/VDS/Components/Label/VDSLabel.swift +++ b/VDS/Components/Label/VDSLabel.swift @@ -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() { diff --git a/VDS/Components/Toggle/VDSToggle.swift b/VDS/Components/Toggle/VDSToggle.swift index aa83ba5b..8e2ddb5e 100644 --- a/VDS/Components/Toggle/VDSToggle.swift +++ b/VDS/Components/Toggle/VDSToggle.swift @@ -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