From 8d6c744ae46f332d1d27a8bc103a3badebaf03a5 Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Fri, 18 Nov 2022 14:44:50 -0600 Subject: [PATCH] convert forms to use Toggle/Button instead of native Signed-off-by: Matt Bruce --- VDSSample/Protocols/PickerBase.swift | 7 ++++--- .../ButtonGroupViewController.swift | 4 ++-- .../ViewControllers/ButtonViewController.swift | 4 ++-- .../CheckBoxGroupViewController.swift | 8 ++++---- .../ViewControllers/CheckboxViewController.swift | 8 ++++---- .../ViewControllers/LabelViewController.swift | 8 ++++---- .../RadioBoxGroupViewController.swift | 10 +++++----- .../RadioButtonViewController.swift | 8 ++++---- .../RadioSwatchGroupViewController.swift | 8 ++++---- .../TextEntryFieldViewController.swift | 16 ++++++++-------- .../TextLinkCaretViewController.swift | 4 ++-- .../ViewControllers/TextLinkViewController.swift | 4 ++-- .../ViewControllers/ToggleViewController.swift | 12 ++++++------ 13 files changed, 51 insertions(+), 50 deletions(-) diff --git a/VDSSample/Protocols/PickerBase.swift b/VDSSample/Protocols/PickerBase.swift index fb7bf6f..448db0a 100644 --- a/VDSSample/Protocols/PickerBase.swift +++ b/VDSSample/Protocols/PickerBase.swift @@ -37,9 +37,10 @@ public class PickerSelectorView: UIStackView, Picker fileprivate var selectedIndex = 0 private var subscribers = Set() private var label = UILabel() - private var button = UIButton(type: .system).with { instance in - instance.configuration = .filled() - instance.setTitle("Select", for: .normal) + private var button = Button().with { instance in + instance.size = .small + instance.use = .secondary + instance.text = "Select" } public var text: String = "" { diff --git a/VDSSample/ViewControllers/ButtonGroupViewController.swift b/VDSSample/ViewControllers/ButtonGroupViewController.swift index 04ce51c..141e49b 100644 --- a/VDSSample/ViewControllers/ButtonGroupViewController.swift +++ b/VDSSample/ViewControllers/ButtonGroupViewController.swift @@ -19,7 +19,7 @@ class ButtonGroupViewController: BaseViewController { items: ButtonPosition.allCases) }() - var disabledSwitch = UISwitch() + var disabledSwitch = Toggle() var widthTextField = TextField() let buttonGroup = ButtonGroup() @@ -42,7 +42,7 @@ class ButtonGroupViewController: BaseViewController { func setupForm(){ addFormRow(label: "Surface", view: surfacePickerSelectorView) - addFormRow(label: "Disabled", view: disabledSwitch) + addFormRow(label: "Disabled", view: .makeWrapper(for: disabledSwitch)) addFormRow(label: "Position", view: buttonPositionSelectorView) // addFormRow(label: "Width", view: widthTextField) diff --git a/VDSSample/ViewControllers/ButtonViewController.swift b/VDSSample/ViewControllers/ButtonViewController.swift index 4d02c49..960beea 100644 --- a/VDSSample/ViewControllers/ButtonViewController.swift +++ b/VDSSample/ViewControllers/ButtonViewController.swift @@ -24,7 +24,7 @@ class ButtonViewController: BaseViewController { items: ButtonSize.allCases) }() - var disabledSwitch = UISwitch() + var disabledSwitch = Toggle() var textField = TextField() var widthTextField = TextField() @@ -43,7 +43,7 @@ class ButtonViewController: BaseViewController { func setupForm(){ addFormRow(label: "Surface", view: surfacePickerSelectorView) addFormRow(label: "Use", view: usePickerSelectorView) - addFormRow(label: "Disabled", view: disabledSwitch) + addFormRow(label: "Disabled", view: .makeWrapper(for: disabledSwitch)) addFormRow(label: "Label", view: textField) addFormRow(label: "Width", view: widthTextField) addFormRow(label: "Size", view: buttonSizePickerSelectorView) diff --git a/VDSSample/ViewControllers/CheckBoxGroupViewController.swift b/VDSSample/ViewControllers/CheckBoxGroupViewController.swift index b31a798..21bcb0e 100644 --- a/VDSSample/ViewControllers/CheckBoxGroupViewController.swift +++ b/VDSSample/ViewControllers/CheckBoxGroupViewController.swift @@ -13,10 +13,10 @@ import Combine class CheckboxGroupViewController: BaseViewController { - var disabledSwitch = UISwitch() + var disabledSwitch = Toggle() var labelTextField = TextField() var childTextField = TextField() - var showErrorSwitch = UISwitch() + var showErrorSwitch = Toggle() var checkboxGroup = CheckboxGroup() @@ -30,11 +30,11 @@ class CheckboxGroupViewController: BaseViewController { } func setupForm() { - addFormRow(label: "Disabled", view: disabledSwitch) + addFormRow(label: "Disabled", view: .makeWrapper(for: disabledSwitch)) addFormRow(label: "Surface", view: surfacePickerSelectorView) addFormRow(label: "Label Text", view: labelTextField) addFormRow(label: "Child Text", view: childTextField) - addFormRow(label: "Error", view: showErrorSwitch) + addFormRow(label: "Error", view: .makeWrapper(for: showErrorSwitch)) showErrorSwitch .publisher(for: .valueChanged) diff --git a/VDSSample/ViewControllers/CheckboxViewController.swift b/VDSSample/ViewControllers/CheckboxViewController.swift index bc2fcf9..a2d9c78 100644 --- a/VDSSample/ViewControllers/CheckboxViewController.swift +++ b/VDSSample/ViewControllers/CheckboxViewController.swift @@ -13,11 +13,11 @@ import Combine class CheckboxViewController: BaseViewController { - var disabledSwitch = UISwitch() + var disabledSwitch = Toggle() var labelTextField = TextField() var childTextField = TextField() var errorTextField = TextField() - var showErrorSwitch = UISwitch() + var showErrorSwitch = Toggle() var checkbox = SoloCheckbox() @@ -31,11 +31,11 @@ class CheckboxViewController: BaseViewController { } func setupForm(){ - addFormRow(label: "Disabled", view: disabledSwitch) + addFormRow(label: "Disabled", view: .makeWrapper(for: disabledSwitch)) addFormRow(label: "Surface", view: surfacePickerSelectorView) addFormRow(label: "Label Text", view: labelTextField) addFormRow(label: "Child Text", view: childTextField) - addFormRow(label: "Error", view: showErrorSwitch) + addFormRow(label: "Error", view: .makeWrapper(for: showErrorSwitch)) addFormRow(label: "Error Text", view: errorTextField) showErrorSwitch diff --git a/VDSSample/ViewControllers/LabelViewController.swift b/VDSSample/ViewControllers/LabelViewController.swift index 96589ed..2036185 100644 --- a/VDSSample/ViewControllers/LabelViewController.swift +++ b/VDSSample/ViewControllers/LabelViewController.swift @@ -22,8 +22,8 @@ class LabelViewController: BaseViewController { picker: self.picker) }() - var boldSwitch = UISwitch() - var disabledSwitch = UISwitch() + var boldSwitch = Toggle() + var disabledSwitch = Toggle() var textField = TextField() private var isBold: Bool = false @@ -39,8 +39,8 @@ class LabelViewController: BaseViewController { } func setupForm(){ - addFormRow(label: "Disabled", view: disabledSwitch) - addFormRow(label: "Bold", view: boldSwitch) + addFormRow(label: "Disabled", view: .makeWrapper(for: disabledSwitch)) + addFormRow(label: "Bold", view: .makeWrapper(for: boldSwitch)) addFormRow(label: "Surface", view: surfacePickerSelectorView) addFormRow(label: "Font Category", view: fontCategoryPickerSelectorView) addFormRow(label: "Text Size", view: textSizePickerSelectorView) diff --git a/VDSSample/ViewControllers/RadioBoxGroupViewController.swift b/VDSSample/ViewControllers/RadioBoxGroupViewController.swift index 89ce6df..ac3f58c 100644 --- a/VDSSample/ViewControllers/RadioBoxGroupViewController.swift +++ b/VDSSample/ViewControllers/RadioBoxGroupViewController.swift @@ -13,12 +13,12 @@ import Combine class RadioBoxGroupViewController: BaseViewController { - var disabledSwitch = UISwitch() - var strikeThroughSwitch = UISwitch() + var disabledSwitch = Toggle() + var strikeThroughSwitch = Toggle() var textField = TextField() var subTextField = TextField() var subTextRightField = TextField() - var showErrorSwitch = UISwitch() + var showErrorSwitch = Toggle() var radioBoxGroup = RadioBoxGroup() @@ -32,9 +32,9 @@ class RadioBoxGroupViewController: BaseViewController { } func setupForm() { - addFormRow(label: "Disabled", view: disabledSwitch) + addFormRow(label: "Disabled", view: .makeWrapper(for: disabledSwitch)) addFormRow(label: "Surface", view: surfacePickerSelectorView) - addFormRow(label: "Strikethrough", view: strikeThroughSwitch) + addFormRow(label: "Strikethrough", view: .makeWrapper(for: strikeThroughSwitch)) addFormRow(label: "Text", view: textField) addFormRow(label: "Sub Text", view: subTextField) addFormRow(label: "Sub Text Right", view: subTextRightField) diff --git a/VDSSample/ViewControllers/RadioButtonViewController.swift b/VDSSample/ViewControllers/RadioButtonViewController.swift index 315f8de..18afd8b 100644 --- a/VDSSample/ViewControllers/RadioButtonViewController.swift +++ b/VDSSample/ViewControllers/RadioButtonViewController.swift @@ -13,10 +13,10 @@ import Combine class RadioButtonViewController: BaseViewController { - var disabledSwitch = UISwitch() + var disabledSwitch = Toggle() var labelTextField = TextField() var childTextField = TextField() - var showErrorSwitch = UISwitch() + var showErrorSwitch = Toggle() var radioButtonGroup = RadioButtonGroup() @@ -30,11 +30,11 @@ class RadioButtonViewController: BaseViewController { } func setupForm() { - addFormRow(label: "Disabled", view: disabledSwitch) + addFormRow(label: "Disabled", view: .makeWrapper(for: disabledSwitch)) addFormRow(label: "Surface", view: surfacePickerSelectorView) addFormRow(label: "Label Text", view: labelTextField) addFormRow(label: "Child Text", view: childTextField) - addFormRow(label: "Error", view: showErrorSwitch) + addFormRow(label: "Error", view: .makeWrapper(for: showErrorSwitch)) showErrorSwitch .publisher(for: .valueChanged) diff --git a/VDSSample/ViewControllers/RadioSwatchGroupViewController.swift b/VDSSample/ViewControllers/RadioSwatchGroupViewController.swift index a2137ba..a6da0a7 100644 --- a/VDSSample/ViewControllers/RadioSwatchGroupViewController.swift +++ b/VDSSample/ViewControllers/RadioSwatchGroupViewController.swift @@ -13,8 +13,8 @@ import Combine class RadioSwatchGroupViewController: BaseViewController { - var disabledSwitch = UISwitch() - var strikeThroughSwitch = UISwitch() + var disabledSwitch = Toggle() + var strikeThroughSwitch = Toggle() var radioSwatchGroup = RadioSwatchGroup() override func viewDidLoad() { @@ -26,9 +26,9 @@ class RadioSwatchGroupViewController: BaseViewController { } func setupForm() { - addFormRow(label: "Disabled", view: disabledSwitch) + addFormRow(label: "Disabled", view: .makeWrapper(for: disabledSwitch)) addFormRow(label: "Surface", view: surfacePickerSelectorView) - addFormRow(label: "Strikethrough", view: strikeThroughSwitch) + addFormRow(label: "Strikethrough", view: .makeWrapper(for: strikeThroughSwitch)) disabledSwitch .publisher(for: .valueChanged) diff --git a/VDSSample/ViewControllers/TextEntryFieldViewController.swift b/VDSSample/ViewControllers/TextEntryFieldViewController.swift index d854e0a..4b01bfb 100644 --- a/VDSSample/ViewControllers/TextEntryFieldViewController.swift +++ b/VDSSample/ViewControllers/TextEntryFieldViewController.swift @@ -19,15 +19,15 @@ class TextEntryFieldViewController: BaseViewController { items: HelperTextPlacement.allCases) }() - var disabledSwitch = UISwitch() - var requiredSwitch = UISwitch() + var disabledSwitch = Toggle() + var requiredSwitch = Toggle() var labelTextField = TextField() var errorTextField = TextField() var successTextField = TextField() var helperTextField = TextField() var widthTextField = TextField() - var showErrorSwitch = UISwitch() - var showSuccessSwitch = UISwitch() + var showErrorSwitch = Toggle() + var showSuccessSwitch = Toggle() var tooltipTitleTextField = TextField() var tooltipContentTextField = TextField() @@ -42,15 +42,15 @@ class TextEntryFieldViewController: BaseViewController { } func setupForm(){ - addFormRow(label: "Disabled", view: disabledSwitch) - addFormRow(label: "Required", view: requiredSwitch) + addFormRow(label: "Disabled", view: .makeWrapper(for: disabledSwitch)) + addFormRow(label: "Required", view: .makeWrapper(for: requiredSwitch)) addFormRow(label: "Surface", view: surfacePickerSelectorView) addFormRow(label: "Label Text", view: labelTextField) addFormRow(label: "Helper Text Placement", view: helperTextPlacementPickerSelectorView) addFormRow(label: "Helper Text", view: helperTextField) - addFormRow(label: "Error", view: showErrorSwitch) + addFormRow(label: "Error", view: .makeWrapper(for: showErrorSwitch)) addFormRow(label: "Error Text", view: errorTextField) - addFormRow(label: "Success", view: showSuccessSwitch) + addFormRow(label: "Success", view: .makeWrapper(for: showSuccessSwitch)) addFormRow(label: "Success Text", view: successTextField) addFormRow(label: "Width", view: widthTextField) addFormRow(label: "ToolTip Title", view: tooltipTitleTextField) diff --git a/VDSSample/ViewControllers/TextLinkCaretViewController.swift b/VDSSample/ViewControllers/TextLinkCaretViewController.swift index fc00b20..5ea48c6 100644 --- a/VDSSample/ViewControllers/TextLinkCaretViewController.swift +++ b/VDSSample/ViewControllers/TextLinkCaretViewController.swift @@ -18,7 +18,7 @@ class TextLinkCaretViewController: BaseViewController { items: TextLinkCaretPosition.allCases) }() - var disabledSwitch = UISwitch() + var disabledSwitch = Toggle() var textField = TextField() lazy var textLinkCaret: TextLinkCaret = { makeTextLinkCaret("Text Link Caret") @@ -35,7 +35,7 @@ class TextLinkCaretViewController: BaseViewController { func setupForm(){ addFormRow(label: "Surface", view: surfacePickerSelectorView) - addFormRow(label: "Disabled", view: disabledSwitch) + addFormRow(label: "Disabled", view: .makeWrapper(for: disabledSwitch)) addFormRow(label: "Label", view: textField) addFormRow(label: "Caret Position", view: caretPositionPickerSelectorView) diff --git a/VDSSample/ViewControllers/TextLinkViewController.swift b/VDSSample/ViewControllers/TextLinkViewController.swift index 04c70d9..aab4b55 100644 --- a/VDSSample/ViewControllers/TextLinkViewController.swift +++ b/VDSSample/ViewControllers/TextLinkViewController.swift @@ -18,7 +18,7 @@ class TextLinkViewController: BaseViewController { items: ButtonSize.allCases) }() - var disabledSwitch = UISwitch() + var disabledSwitch = Toggle() var textField = TextField() lazy var textLink: TextLink = { makeTextLink("Text Link") @@ -36,7 +36,7 @@ class TextLinkViewController: BaseViewController { func setupForm(){ addFormRow(label: "Surface", view: surfacePickerSelectorView) - addFormRow(label: "Disabled", view: disabledSwitch) + addFormRow(label: "Disabled", view: .makeWrapper(for: disabledSwitch)) addFormRow(label: "Label", view: textField) addFormRow(label: "Size", view: buttonSizePickerSelectorView) diff --git a/VDSSample/ViewControllers/ToggleViewController.swift b/VDSSample/ViewControllers/ToggleViewController.swift index 24e51c1..b9d4b75 100644 --- a/VDSSample/ViewControllers/ToggleViewController.swift +++ b/VDSSample/ViewControllers/ToggleViewController.swift @@ -25,8 +25,8 @@ class ToggleViewController: BaseViewController { items: ToggleTextPosition.allCases) }() - var disabledSwitch = UISwitch() - var showTextSwitch = UISwitch() + var disabledSwitch = Toggle() + var showTextSwitch = Toggle() var textFormStackView: UIStackView = { return UIStackView().with { @@ -38,7 +38,7 @@ class ToggleViewController: BaseViewController { } }() - var boldSwitch = UISwitch() + var boldSwitch = Toggle() var onTextField = TextField() var offTextField = TextField() @@ -54,12 +54,12 @@ class ToggleViewController: BaseViewController { func setupForm() { - addFormRow(label: "Show Text", view: showTextSwitch) + addFormRow(label: "Show Text", view: .makeWrapper(for: showTextSwitch)) addFormRow(label: "Surface", view: surfacePickerSelectorView) - addFormRow(label: "Disabled", view: disabledSwitch) + addFormRow(label: "Disabled", view: .makeWrapper(for: disabledSwitch)) //add the hidden elements to textFormStackView - addFormRow(label: "Bold", view: boldSwitch, stackView: textFormStackView) + addFormRow(label: "Bold", view: .makeWrapper(for: boldSwitch), stackView: textFormStackView) addFormRow(label: "Text Size", view: textSizePickerSelectorView, stackView: textFormStackView) addFormRow(label: "Text Position", view: textPositionPickerSelectorView, stackView: textFormStackView) addFormRow(label: "On Text", view: onTextField, stackView: textFormStackView)