refactored to new toggle that doesn't fill screen width
Signed-off-by: Matt Bruce <matt.bruce@verizon.com>
This commit is contained in:
parent
4b03f39443
commit
20e053ab5f
@ -38,7 +38,6 @@
|
|||||||
EA0D1C2F2A66CFE900E5C127 /* CheckboxViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA0D1C2E2A66CFE900E5C127 /* CheckboxViewController.swift */; };
|
EA0D1C2F2A66CFE900E5C127 /* CheckboxViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA0D1C2E2A66CFE900E5C127 /* CheckboxViewController.swift */; };
|
||||||
EA0D1C312A673F3500E5C127 /* RadioButtonViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA0D1C302A673F3500E5C127 /* RadioButtonViewController.swift */; };
|
EA0D1C312A673F3500E5C127 /* RadioButtonViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA0D1C302A673F3500E5C127 /* RadioButtonViewController.swift */; };
|
||||||
EA0D1C332A673FD400E5C127 /* RadioButtonItemViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA0D1C322A673FD400E5C127 /* RadioButtonItemViewController.swift */; };
|
EA0D1C332A673FD400E5C127 /* RadioButtonItemViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA0D1C322A673FD400E5C127 /* RadioButtonItemViewController.swift */; };
|
||||||
EA0D1C352A68180100E5C127 /* ToggleViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA0D1C342A68180100E5C127 /* ToggleViewController.swift */; };
|
|
||||||
EA0FC2C12912DC5500DF80B4 /* TextLinkCaretViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA0FC2C02912DC5500DF80B4 /* TextLinkCaretViewController.swift */; };
|
EA0FC2C12912DC5500DF80B4 /* TextLinkCaretViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA0FC2C02912DC5500DF80B4 /* TextLinkCaretViewController.swift */; };
|
||||||
EA3C3B9D289966EF000CA526 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA3C3B9C289966EF000CA526 /* AppDelegate.swift */; };
|
EA3C3B9D289966EF000CA526 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA3C3B9C289966EF000CA526 /* AppDelegate.swift */; };
|
||||||
EA3C3B9F289966EF000CA526 /* SceneDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA3C3B9E289966EF000CA526 /* SceneDelegate.swift */; };
|
EA3C3B9F289966EF000CA526 /* SceneDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA3C3B9E289966EF000CA526 /* SceneDelegate.swift */; };
|
||||||
@ -47,7 +46,7 @@
|
|||||||
EA3C3BB428996775000CA526 /* PickerBase.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA3C3BB028996775000CA526 /* PickerBase.swift */; };
|
EA3C3BB428996775000CA526 /* PickerBase.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA3C3BB028996775000CA526 /* PickerBase.swift */; };
|
||||||
EA3C3BB528996775000CA526 /* StoryboardInitable.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA3C3BB128996775000CA526 /* StoryboardInitable.swift */; };
|
EA3C3BB528996775000CA526 /* StoryboardInitable.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA3C3BB128996775000CA526 /* StoryboardInitable.swift */; };
|
||||||
EA3C3BB628996775000CA526 /* MenuViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA3C3BB228996775000CA526 /* MenuViewController.swift */; };
|
EA3C3BB628996775000CA526 /* MenuViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA3C3BB228996775000CA526 /* MenuViewController.swift */; };
|
||||||
EA3C3BB728996775000CA526 /* ToggleItemViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA3C3BB328996775000CA526 /* ToggleItemViewController.swift */; };
|
EA3C3BB728996775000CA526 /* ToggleViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA3C3BB328996775000CA526 /* ToggleViewController.swift */; };
|
||||||
EA4DB30428DCD25B00103EE3 /* BadgeViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA4DB30328DCD25B00103EE3 /* BadgeViewController.swift */; };
|
EA4DB30428DCD25B00103EE3 /* BadgeViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA4DB30328DCD25B00103EE3 /* BadgeViewController.swift */; };
|
||||||
EA596ABA2A16B2ED00300C4B /* TabsViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA596AB92A16B2ED00300C4B /* TabsViewController.swift */; };
|
EA596ABA2A16B2ED00300C4B /* TabsViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA596AB92A16B2ED00300C4B /* TabsViewController.swift */; };
|
||||||
EA5E3050294D11540082B959 /* TileContainerViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA5E304F294D11540082B959 /* TileContainerViewController.swift */; };
|
EA5E3050294D11540082B959 /* TileContainerViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA5E304F294D11540082B959 /* TileContainerViewController.swift */; };
|
||||||
@ -132,7 +131,6 @@
|
|||||||
EA0D1C2E2A66CFE900E5C127 /* CheckboxViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CheckboxViewController.swift; sourceTree = "<group>"; };
|
EA0D1C2E2A66CFE900E5C127 /* CheckboxViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CheckboxViewController.swift; sourceTree = "<group>"; };
|
||||||
EA0D1C302A673F3500E5C127 /* RadioButtonViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RadioButtonViewController.swift; sourceTree = "<group>"; };
|
EA0D1C302A673F3500E5C127 /* RadioButtonViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RadioButtonViewController.swift; sourceTree = "<group>"; };
|
||||||
EA0D1C322A673FD400E5C127 /* RadioButtonItemViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RadioButtonItemViewController.swift; sourceTree = "<group>"; };
|
EA0D1C322A673FD400E5C127 /* RadioButtonItemViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RadioButtonItemViewController.swift; sourceTree = "<group>"; };
|
||||||
EA0D1C342A68180100E5C127 /* ToggleViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ToggleViewController.swift; sourceTree = "<group>"; };
|
|
||||||
EA0FC2C02912DC5500DF80B4 /* TextLinkCaretViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TextLinkCaretViewController.swift; sourceTree = "<group>"; };
|
EA0FC2C02912DC5500DF80B4 /* TextLinkCaretViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TextLinkCaretViewController.swift; sourceTree = "<group>"; };
|
||||||
EA3C3B99289966EF000CA526 /* VDSSample.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = VDSSample.app; sourceTree = BUILT_PRODUCTS_DIR; };
|
EA3C3B99289966EF000CA526 /* VDSSample.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = VDSSample.app; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||||
EA3C3B9C289966EF000CA526 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
|
EA3C3B9C289966EF000CA526 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
|
||||||
@ -143,7 +141,7 @@
|
|||||||
EA3C3BB028996775000CA526 /* PickerBase.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PickerBase.swift; sourceTree = "<group>"; };
|
EA3C3BB028996775000CA526 /* PickerBase.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PickerBase.swift; sourceTree = "<group>"; };
|
||||||
EA3C3BB128996775000CA526 /* StoryboardInitable.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = StoryboardInitable.swift; sourceTree = "<group>"; };
|
EA3C3BB128996775000CA526 /* StoryboardInitable.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = StoryboardInitable.swift; sourceTree = "<group>"; };
|
||||||
EA3C3BB228996775000CA526 /* MenuViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MenuViewController.swift; sourceTree = "<group>"; };
|
EA3C3BB228996775000CA526 /* MenuViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MenuViewController.swift; sourceTree = "<group>"; };
|
||||||
EA3C3BB328996775000CA526 /* ToggleItemViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ToggleItemViewController.swift; sourceTree = "<group>"; };
|
EA3C3BB328996775000CA526 /* ToggleViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ToggleViewController.swift; sourceTree = "<group>"; };
|
||||||
EA4DB30328DCD25B00103EE3 /* BadgeViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BadgeViewController.swift; sourceTree = "<group>"; };
|
EA4DB30328DCD25B00103EE3 /* BadgeViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BadgeViewController.swift; sourceTree = "<group>"; };
|
||||||
EA596AB92A16B2ED00300C4B /* TabsViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TabsViewController.swift; sourceTree = "<group>"; };
|
EA596AB92A16B2ED00300C4B /* TabsViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TabsViewController.swift; sourceTree = "<group>"; };
|
||||||
EA5E304F294D11540082B959 /* TileContainerViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TileContainerViewController.swift; sourceTree = "<group>"; };
|
EA5E304F294D11540082B959 /* TileContainerViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TileContainerViewController.swift; sourceTree = "<group>"; };
|
||||||
@ -312,9 +310,9 @@
|
|||||||
EA81410D2A0ED8DC004F60D2 /* ButtonIconViewController.swift */,
|
EA81410D2A0ED8DC004F60D2 /* ButtonIconViewController.swift */,
|
||||||
EAB5FEEE2927E28400998C17 /* ButtonGroupViewController.swift */,
|
EAB5FEEE2927E28400998C17 /* ButtonGroupViewController.swift */,
|
||||||
5FC35BE828D5235A004EBEAC /* ButtonViewController.swift */,
|
5FC35BE828D5235A004EBEAC /* ButtonViewController.swift */,
|
||||||
EA89204D28B67332006B9984 /* CheckBoxGroupViewController.swift */,
|
|
||||||
EAF7F09B2899B92400B287F5 /* CheckboxItemViewController.swift */,
|
|
||||||
EA0D1C2E2A66CFE900E5C127 /* CheckboxViewController.swift */,
|
EA0D1C2E2A66CFE900E5C127 /* CheckboxViewController.swift */,
|
||||||
|
EAF7F09B2899B92400B287F5 /* CheckboxItemViewController.swift */,
|
||||||
|
EA89204D28B67332006B9984 /* CheckBoxGroupViewController.swift */,
|
||||||
EA985C00296CC21C00F2FF2E /* IconViewController.swift */,
|
EA985C00296CC21C00F2FF2E /* IconViewController.swift */,
|
||||||
EAA5EEAC28EB6924003B3210 /* InputFieldViewController.swift */,
|
EAA5EEAC28EB6924003B3210 /* InputFieldViewController.swift */,
|
||||||
EAB1D2D328AC409F00DAE764 /* LabelViewController.swift */,
|
EAB1D2D328AC409F00DAE764 /* LabelViewController.swift */,
|
||||||
@ -334,8 +332,7 @@
|
|||||||
EA5E304F294D11540082B959 /* TileContainerViewController.swift */,
|
EA5E304F294D11540082B959 /* TileContainerViewController.swift */,
|
||||||
EA5E305B295111050082B959 /* TileletViewController.swift */,
|
EA5E305B295111050082B959 /* TileletViewController.swift */,
|
||||||
EA5E30542950EA6E0082B959 /* TitleLockupViewController.swift */,
|
EA5E30542950EA6E0082B959 /* TitleLockupViewController.swift */,
|
||||||
EA0D1C342A68180100E5C127 /* ToggleViewController.swift */,
|
EA3C3BB328996775000CA526 /* ToggleViewController.swift */,
|
||||||
EA3C3BB328996775000CA526 /* ToggleItemViewController.swift */,
|
|
||||||
EAB2375F29E88D5D00AABE9A /* TooltipViewController.swift */,
|
EAB2375F29E88D5D00AABE9A /* TooltipViewController.swift */,
|
||||||
EAB2376B29E9E74900AABE9A /* TrailingTooltipLabelViewController.swift */,
|
EAB2376B29E9E74900AABE9A /* TrailingTooltipLabelViewController.swift */,
|
||||||
);
|
);
|
||||||
@ -483,7 +480,7 @@
|
|||||||
isa = PBXSourcesBuildPhase;
|
isa = PBXSourcesBuildPhase;
|
||||||
buildActionMask = 2147483647;
|
buildActionMask = 2147483647;
|
||||||
files = (
|
files = (
|
||||||
EA3C3BB728996775000CA526 /* ToggleItemViewController.swift in Sources */,
|
EA3C3BB728996775000CA526 /* ToggleViewController.swift in Sources */,
|
||||||
EA5E30552950EA6E0082B959 /* TitleLockupViewController.swift in Sources */,
|
EA5E30552950EA6E0082B959 /* TitleLockupViewController.swift in Sources */,
|
||||||
EAB5FEEF2927E28400998C17 /* ButtonGroupViewController.swift in Sources */,
|
EAB5FEEF2927E28400998C17 /* ButtonGroupViewController.swift in Sources */,
|
||||||
EA89204C28B66CE2006B9984 /* ScrollWrapperView.swift in Sources */,
|
EA89204C28B66CE2006B9984 /* ScrollWrapperView.swift in Sources */,
|
||||||
@ -494,7 +491,6 @@
|
|||||||
EA3C3BB628996775000CA526 /* MenuViewController.swift in Sources */,
|
EA3C3BB628996775000CA526 /* MenuViewController.swift in Sources */,
|
||||||
EA3C3B9D289966EF000CA526 /* AppDelegate.swift in Sources */,
|
EA3C3B9D289966EF000CA526 /* AppDelegate.swift in Sources */,
|
||||||
EA5E3050294D11540082B959 /* TileContainerViewController.swift in Sources */,
|
EA5E3050294D11540082B959 /* TileContainerViewController.swift in Sources */,
|
||||||
EA0D1C352A68180100E5C127 /* ToggleViewController.swift in Sources */,
|
|
||||||
445BA07A29C088470036A7C5 /* NotificationViewController.swift in Sources */,
|
445BA07A29C088470036A7C5 /* NotificationViewController.swift in Sources */,
|
||||||
EAF7F11A28A14A0E00B287F5 /* RadioButtonGroupViewController.swift in Sources */,
|
EAF7F11A28A14A0E00B287F5 /* RadioButtonGroupViewController.swift in Sources */,
|
||||||
EA89204628B66CE2006B9984 /* ScrollViewController.swift in Sources */,
|
EA89204628B66CE2006B9984 /* ScrollViewController.swift in Sources */,
|
||||||
|
|||||||
@ -10,9 +10,12 @@ import VDS
|
|||||||
import UIKit
|
import UIKit
|
||||||
|
|
||||||
extension UIView {
|
extension UIView {
|
||||||
|
public func makeWrapper(edgeSpacing: CGFloat = 0.0, isTrailing: Bool = true) -> UIView {
|
||||||
|
UIView.makeWrapper(for: self, edgeSpacing: edgeSpacing, isTrailing: isTrailing)
|
||||||
|
}
|
||||||
|
|
||||||
public static func makeWrapper(for view: UIView, edgeSpacing: CGFloat = 0.0, isTrailing: Bool = true) -> UIView {
|
public static func makeWrapper(for view: UIView, edgeSpacing: CGFloat = 0.0, isTrailing: Bool = true) -> UIView {
|
||||||
return makeWrapperWithConstraints(for: view, edgeSpacing: edgeSpacing, isTrailing: isTrailing).view
|
makeWrapperWithConstraints(for: view, edgeSpacing: edgeSpacing, isTrailing: isTrailing).view
|
||||||
}
|
}
|
||||||
|
|
||||||
public static func makeWrapperWithConstraints(for view: UIView, edgeSpacing: CGFloat = 0.0, isTrailing: Bool = true) -> (view: UIView, container: NSLayoutConstraint.Container) {
|
public static func makeWrapperWithConstraints(for view: UIView, edgeSpacing: CGFloat = 0.0, isTrailing: Bool = true) -> (view: UIView, container: NSLayoutConstraint.Container) {
|
||||||
|
|||||||
@ -18,12 +18,6 @@ class CheckboxViewController: BaseViewController<Checkbox> {
|
|||||||
let toggle = UISwitch()
|
let toggle = UISwitch()
|
||||||
override func viewDidLoad() {
|
override func viewDidLoad() {
|
||||||
super.viewDidLoad()
|
super.viewDidLoad()
|
||||||
// let stack = UIStackView()
|
|
||||||
// stack.axis = .vertical
|
|
||||||
// stack.distribution = .fill
|
|
||||||
// stack.alignment = .center
|
|
||||||
// stack.addArrangedSubview(component)
|
|
||||||
// addContentTopView(view: component)
|
|
||||||
addContentTopView(view: .makeWrapper(for: component, edgeSpacing: 16.0), edgeSpacing: 0.0)
|
addContentTopView(view: .makeWrapper(for: component, edgeSpacing: 16.0), edgeSpacing: 0.0)
|
||||||
setupPicker()
|
setupPicker()
|
||||||
setupModel()
|
setupModel()
|
||||||
|
|||||||
@ -106,7 +106,6 @@ class MenuViewController: UITableViewController, TooltipLaunchable {
|
|||||||
MenuComponent(title: "Tilelet", completed: false, viewController: TileletViewController.self),
|
MenuComponent(title: "Tilelet", completed: false, viewController: TileletViewController.self),
|
||||||
MenuComponent(title: "TitleLockup", completed: true, viewController: TitleLockupViewController.self),
|
MenuComponent(title: "TitleLockup", completed: true, viewController: TitleLockupViewController.self),
|
||||||
MenuComponent(title: "Toggle", completed: true, viewController: ToggleViewController.self),
|
MenuComponent(title: "Toggle", completed: true, viewController: ToggleViewController.self),
|
||||||
MenuComponent(title: "ToggleItem", completed: true, viewController: ToggleItemViewController.self),
|
|
||||||
MenuComponent(title: "Tooltip", completed: true, viewController: TooltipViewController.self),
|
MenuComponent(title: "Tooltip", completed: true, viewController: TooltipViewController.self),
|
||||||
MenuComponent(title: "TrailingTooltipLabel", completed: true, viewController: TrailingTooltipLabelViewController.self),
|
MenuComponent(title: "TrailingTooltipLabel", completed: true, viewController: TrailingTooltipLabelViewController.self),
|
||||||
|
|
||||||
|
|||||||
@ -1,132 +0,0 @@
|
|||||||
//
|
|
||||||
// ToggleViewController.swift
|
|
||||||
// VDSSample
|
|
||||||
//
|
|
||||||
// Created by Matt Bruce on 8/1/22.
|
|
||||||
//
|
|
||||||
|
|
||||||
import Foundation
|
|
||||||
import UIKit
|
|
||||||
import VDS
|
|
||||||
import VDSColorTokens
|
|
||||||
|
|
||||||
class ToggleItemViewController: BaseViewController<ToggleItem> {
|
|
||||||
|
|
||||||
lazy var textSizePickerSelectorView = {
|
|
||||||
PickerSelectorView(title: "",
|
|
||||||
picker: self.picker,
|
|
||||||
items: ToggleItem.TextSize.allCases)
|
|
||||||
|
|
||||||
}()
|
|
||||||
|
|
||||||
lazy var textPositionPickerSelectorView = {
|
|
||||||
PickerSelectorView(title: "",
|
|
||||||
picker: self.picker,
|
|
||||||
items: ToggleItem.TextPosition.allCases)
|
|
||||||
}()
|
|
||||||
|
|
||||||
var disabledSwitch = Toggle()
|
|
||||||
var showTextSwitch = Toggle()
|
|
||||||
|
|
||||||
var textFormStackView = FormSection()
|
|
||||||
|
|
||||||
var boldSwitch = Toggle()
|
|
||||||
var onTextField = TextField()
|
|
||||||
var offTextField = TextField()
|
|
||||||
|
|
||||||
override func viewDidLoad() {
|
|
||||||
super.viewDidLoad()
|
|
||||||
|
|
||||||
let stack = UIStackView()
|
|
||||||
stack.axis = .vertical
|
|
||||||
stack.distribution = .fill
|
|
||||||
stack.alignment = .trailing
|
|
||||||
stack.addArrangedSubview(component)
|
|
||||||
//addContentTopView(view: component)
|
|
||||||
|
|
||||||
addContentTopView(view: .makeWrapper(for: component))
|
|
||||||
|
|
||||||
setupPicker()
|
|
||||||
}
|
|
||||||
|
|
||||||
override func allTextFields() -> [TextField]? { [onTextField, offTextField] }
|
|
||||||
|
|
||||||
override func setupForm() {
|
|
||||||
super.setupForm()
|
|
||||||
|
|
||||||
addFormRow(label: "Show Text", view: showTextSwitch)
|
|
||||||
addFormRow(label: "Surface", view: surfacePickerSelectorView)
|
|
||||||
addFormRow(label: "Disabled", view: disabledSwitch)
|
|
||||||
|
|
||||||
//add the hidden elements to textFormStackView
|
|
||||||
textFormStackView.addFormRow(label: "Bold", view: boldSwitch)
|
|
||||||
textFormStackView.addFormRow(label: "Text Size", view: textSizePickerSelectorView)
|
|
||||||
textFormStackView.addFormRow(label: "Text Position", view: textPositionPickerSelectorView)
|
|
||||||
textFormStackView.addFormRow(label: "On Text", view: onTextField)
|
|
||||||
textFormStackView.addFormRow(label: "Off Text", view: offTextField)
|
|
||||||
|
|
||||||
//add textFormStackView to main form
|
|
||||||
append(section: textFormStackView)
|
|
||||||
|
|
||||||
component.onChange = { [weak self] toggle in
|
|
||||||
let alertController:UIAlertController = UIAlertController(title: "Alert",
|
|
||||||
message: "Toggle Value: \(toggle.isOn)",
|
|
||||||
preferredStyle: UIAlertController.Style.alert)
|
|
||||||
alertController.addAction(UIAlertAction(title: "OK", style: UIAlertAction.Style.default, handler:nil))
|
|
||||||
self?.present(alertController, animated: true)
|
|
||||||
print("toggle changed: \(toggle.isOn)")
|
|
||||||
}
|
|
||||||
|
|
||||||
showTextSwitch.onChange = { [weak self] sender in
|
|
||||||
self?.component.showText = sender.isOn
|
|
||||||
self?.textFormStackView.isHidden = !sender.isOn
|
|
||||||
}
|
|
||||||
|
|
||||||
disabledSwitch.onChange = { [weak self] sender in
|
|
||||||
self?.component.disabled = sender.isOn
|
|
||||||
}
|
|
||||||
|
|
||||||
boldSwitch.onChange = { [weak self] sender in
|
|
||||||
self?.component.textWeight = sender.isOn ? .bold : .regular
|
|
||||||
}
|
|
||||||
|
|
||||||
onTextField
|
|
||||||
.textPublisher
|
|
||||||
.sink { [weak self] text in
|
|
||||||
self?.component.onText = text
|
|
||||||
}.store(in: &subscribers)
|
|
||||||
|
|
||||||
offTextField
|
|
||||||
.textPublisher
|
|
||||||
.sink { [weak self] text in
|
|
||||||
self?.component.offText = text
|
|
||||||
}.store(in: &subscribers)
|
|
||||||
|
|
||||||
textFormStackView.isHidden = true
|
|
||||||
|
|
||||||
//setup UI
|
|
||||||
surfacePickerSelectorView.text = component.surface.rawValue
|
|
||||||
textSizePickerSelectorView.text = component.textSize.rawValue
|
|
||||||
textPositionPickerSelectorView.text = component.textPosition.rawValue
|
|
||||||
onTextField.text = component.onText
|
|
||||||
offTextField.text = component.offText
|
|
||||||
}
|
|
||||||
|
|
||||||
//Picker
|
|
||||||
func setupPicker(){
|
|
||||||
|
|
||||||
surfacePickerSelectorView.onPickerDidSelect = { [weak self] item in
|
|
||||||
self?.component.surface = item
|
|
||||||
self?.contentTopView.backgroundColor = item.color
|
|
||||||
}
|
|
||||||
|
|
||||||
textSizePickerSelectorView.onPickerDidSelect = { [weak self] item in
|
|
||||||
self?.component.textSize = item
|
|
||||||
}
|
|
||||||
|
|
||||||
textPositionPickerSelectorView.onPickerDidSelect = { [weak self] item in
|
|
||||||
self?.component.textPosition = item
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,8 +1,8 @@
|
|||||||
//
|
//
|
||||||
// ToggleElementViewController.swift
|
// ToggleViewController.swift
|
||||||
// VDSSample
|
// VDSSample
|
||||||
//
|
//
|
||||||
// Created by Matt Bruce on 7/19/23.
|
// Created by Matt Bruce on 8/1/22.
|
||||||
//
|
//
|
||||||
|
|
||||||
import Foundation
|
import Foundation
|
||||||
@ -11,31 +11,55 @@ import VDS
|
|||||||
import VDSColorTokens
|
import VDSColorTokens
|
||||||
|
|
||||||
class ToggleViewController: BaseViewController<Toggle> {
|
class ToggleViewController: BaseViewController<Toggle> {
|
||||||
|
|
||||||
|
lazy var textSizePickerSelectorView = {
|
||||||
|
PickerSelectorView(title: "",
|
||||||
|
picker: self.picker,
|
||||||
|
items: Toggle.TextSize.allCases)
|
||||||
|
|
||||||
|
}()
|
||||||
|
|
||||||
|
lazy var textPositionPickerSelectorView = {
|
||||||
|
PickerSelectorView(title: "",
|
||||||
|
picker: self.picker,
|
||||||
|
items: Toggle.TextPosition.allCases)
|
||||||
|
}()
|
||||||
|
|
||||||
var disabledSwitch = Toggle()
|
var disabledSwitch = Toggle()
|
||||||
|
var showTextSwitch = Toggle()
|
||||||
|
|
||||||
|
var textFormStackView = FormSection()
|
||||||
|
|
||||||
|
var boldSwitch = Toggle()
|
||||||
|
var onTextField = TextField()
|
||||||
|
var offTextField = TextField()
|
||||||
|
|
||||||
override func viewDidLoad() {
|
override func viewDidLoad() {
|
||||||
super.viewDidLoad()
|
super.viewDidLoad()
|
||||||
|
addContentTopView(view: component.makeWrapper(edgeSpacing: 16.0), edgeSpacing: 0)
|
||||||
// let stack = UIStackView()
|
|
||||||
// stack.axis = .vertical
|
|
||||||
// stack.spacing = 10
|
|
||||||
// stack.distribution = .fill
|
|
||||||
// stack.alignment = .trailing
|
|
||||||
// stack.addArrangedSubview(component)
|
|
||||||
// stack.addArrangedSubview(UISwitch().with { $0.isOn = true })
|
|
||||||
// addContentTopView(view: stack)
|
|
||||||
addContentTopView(view: component)
|
|
||||||
|
|
||||||
setupPicker()
|
setupPicker()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override func allTextFields() -> [TextField]? { [onTextField, offTextField] }
|
||||||
|
|
||||||
override func setupForm() {
|
override func setupForm() {
|
||||||
super.setupForm()
|
super.setupForm()
|
||||||
|
|
||||||
|
addFormRow(label: "Show Text", view: showTextSwitch)
|
||||||
addFormRow(label: "Surface", view: surfacePickerSelectorView)
|
addFormRow(label: "Surface", view: surfacePickerSelectorView)
|
||||||
addFormRow(label: "Disabled", view: disabledSwitch)
|
addFormRow(label: "Disabled", view: disabledSwitch)
|
||||||
|
|
||||||
|
//add the hidden elements to textFormStackView
|
||||||
|
textFormStackView.addFormRow(label: "Bold", view: boldSwitch)
|
||||||
|
textFormStackView.addFormRow(label: "Text Size", view: textSizePickerSelectorView)
|
||||||
|
textFormStackView.addFormRow(label: "Text Position", view: textPositionPickerSelectorView)
|
||||||
|
textFormStackView.addFormRow(label: "On Text", view: onTextField)
|
||||||
|
textFormStackView.addFormRow(label: "Off Text", view: offTextField)
|
||||||
|
|
||||||
|
//add textFormStackView to main form
|
||||||
|
append(section: textFormStackView)
|
||||||
|
|
||||||
component.onChange = { [weak self] toggle in
|
component.onChange = { [weak self] toggle in
|
||||||
let alertController:UIAlertController = UIAlertController(title: "Alert",
|
let alertController:UIAlertController = UIAlertController(title: "Alert",
|
||||||
message: "Toggle Value: \(toggle.isOn)",
|
message: "Toggle Value: \(toggle.isOn)",
|
||||||
@ -45,20 +69,56 @@ class ToggleViewController: BaseViewController<Toggle> {
|
|||||||
print("toggle changed: \(toggle.isOn)")
|
print("toggle changed: \(toggle.isOn)")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
showTextSwitch.onChange = { [weak self] sender in
|
||||||
|
self?.component.showText = sender.isOn
|
||||||
|
self?.textFormStackView.isHidden = !sender.isOn
|
||||||
|
}
|
||||||
|
|
||||||
disabledSwitch.onChange = { [weak self] sender in
|
disabledSwitch.onChange = { [weak self] sender in
|
||||||
self?.component.disabled = sender.isOn
|
self?.component.disabled = sender.isOn
|
||||||
}
|
}
|
||||||
|
|
||||||
|
boldSwitch.onChange = { [weak self] sender in
|
||||||
|
self?.component.textWeight = sender.isOn ? .bold : .regular
|
||||||
|
}
|
||||||
|
|
||||||
|
onTextField
|
||||||
|
.textPublisher
|
||||||
|
.sink { [weak self] text in
|
||||||
|
self?.component.onText = text
|
||||||
|
}.store(in: &subscribers)
|
||||||
|
|
||||||
|
offTextField
|
||||||
|
.textPublisher
|
||||||
|
.sink { [weak self] text in
|
||||||
|
self?.component.offText = text
|
||||||
|
}.store(in: &subscribers)
|
||||||
|
|
||||||
|
textFormStackView.isHidden = true
|
||||||
|
|
||||||
//setup UI
|
//setup UI
|
||||||
surfacePickerSelectorView.text = component.surface.rawValue
|
surfacePickerSelectorView.text = component.surface.rawValue
|
||||||
|
textSizePickerSelectorView.text = component.textSize.rawValue
|
||||||
|
textPositionPickerSelectorView.text = component.textPosition.rawValue
|
||||||
|
onTextField.text = component.onText
|
||||||
|
offTextField.text = component.offText
|
||||||
}
|
}
|
||||||
|
|
||||||
//Picker
|
//Picker
|
||||||
func setupPicker(){
|
func setupPicker(){
|
||||||
|
|
||||||
surfacePickerSelectorView.onPickerDidSelect = { [weak self] item in
|
surfacePickerSelectorView.onPickerDidSelect = { [weak self] item in
|
||||||
self?.component.surface = item
|
self?.component.surface = item
|
||||||
self?.contentTopView.backgroundColor = item.color
|
self?.contentTopView.backgroundColor = item.color
|
||||||
}
|
}
|
||||||
|
|
||||||
|
textSizePickerSelectorView.onPickerDidSelect = { [weak self] item in
|
||||||
|
self?.component.textSize = item
|
||||||
|
}
|
||||||
|
|
||||||
|
textPositionPickerSelectorView.onPickerDidSelect = { [weak self] item in
|
||||||
|
self?.component.textPosition = item
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user