added in CheckBox/RadioButton with Item
Signed-off-by: Matt Bruce <matt.bruce@verizon.com>
This commit is contained in:
parent
cf242f829d
commit
d52c1f989b
@ -35,6 +35,9 @@
|
||||
445BA07A29C088470036A7C5 /* NotificationViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 445BA07929C088470036A7C5 /* NotificationViewController.swift */; };
|
||||
44604AD929CE1CF900E62B51 /* LineViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 44604AD829CE1CF900E62B51 /* LineViewController.swift */; };
|
||||
5FC35BE928D5235A004EBEAC /* ButtonViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5FC35BE828D5235A004EBEAC /* ButtonViewController.swift */; };
|
||||
EA0D1C2F2A66CFE900E5C127 /* CheckboxViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA0D1C2E2A66CFE900E5C127 /* CheckboxViewController.swift */; };
|
||||
EA0D1C312A673F3500E5C127 /* RadioButtonViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA0D1C302A673F3500E5C127 /* RadioButtonViewController.swift */; };
|
||||
EA0D1C332A673FD400E5C127 /* RadioButtonItemViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA0D1C322A673FD400E5C127 /* RadioButtonItemViewController.swift */; };
|
||||
EA0FC2C12912DC5500DF80B4 /* TextLinkCaretViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA0FC2C02912DC5500DF80B4 /* TextLinkCaretViewController.swift */; };
|
||||
EA3C3B9D289966EF000CA526 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA3C3B9C289966EF000CA526 /* AppDelegate.swift */; };
|
||||
EA3C3B9F289966EF000CA526 /* SceneDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA3C3B9E289966EF000CA526 /* SceneDelegate.swift */; };
|
||||
@ -81,11 +84,11 @@
|
||||
EAD062AD2A3B86950015965D /* BadgeIndicatorViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = EAD062AC2A3B86950015965D /* BadgeIndicatorViewController.swift */; };
|
||||
EAD068902A55FC11002E3A2D /* LoaderViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = EAD0688F2A55FC11002E3A2D /* LoaderViewController.swift */; };
|
||||
EAF7F07D2899698800B287F5 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = EAF7F07B2899698800B287F5 /* Assets.xcassets */; };
|
||||
EAF7F09C2899B92400B287F5 /* CheckboxViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = EAF7F09B2899B92400B287F5 /* CheckboxViewController.swift */; };
|
||||
EAF7F09C2899B92400B287F5 /* CheckboxItemViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = EAF7F09B2899B92400B287F5 /* CheckboxItemViewController.swift */; };
|
||||
EAF7F0CA289DA24F00B287F5 /* ArtifactoryItems.txt in Resources */ = {isa = PBXBuildFile; fileRef = EAF7F0C5289DA24F00B287F5 /* ArtifactoryItems.txt */; };
|
||||
EAF7F0CC289DA24F00B287F5 /* DownloadArtifactoryItems.sh in Resources */ = {isa = PBXBuildFile; fileRef = EAF7F0C8289DA24F00B287F5 /* DownloadArtifactoryItems.sh */; };
|
||||
EAF7F0CD289DA24F00B287F5 /* Artifactory.sh in Resources */ = {isa = PBXBuildFile; fileRef = EAF7F0C9289DA24F00B287F5 /* Artifactory.sh */; };
|
||||
EAF7F11A28A14A0E00B287F5 /* RadioButtonViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = EAF7F11928A14A0E00B287F5 /* RadioButtonViewController.swift */; };
|
||||
EAF7F11A28A14A0E00B287F5 /* RadioButtonGroupViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = EAF7F11928A14A0E00B287F5 /* RadioButtonGroupViewController.swift */; };
|
||||
EAF7F11B28A1585000B287F5 /* VDSTypographyTokens.xcframework in Frameworks */ = {isa = PBXBuildFile; fileRef = EAF7F0DA289DB0B400B287F5 /* VDSTypographyTokens.xcframework */; };
|
||||
EAF7F11C28A1585000B287F5 /* VDSTypographyTokens.xcframework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = EAF7F0DA289DB0B400B287F5 /* VDSTypographyTokens.xcframework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
|
||||
EAF7F11D28A1585000B287F5 /* VDSFormControlsTokens.xcframework in Frameworks */ = {isa = PBXBuildFile; fileRef = EAF7F0DB289DB0B400B287F5 /* VDSFormControlsTokens.xcframework */; };
|
||||
@ -125,6 +128,9 @@
|
||||
445BA07929C088470036A7C5 /* NotificationViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NotificationViewController.swift; sourceTree = "<group>"; };
|
||||
44604AD829CE1CF900E62B51 /* LineViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LineViewController.swift; sourceTree = "<group>"; };
|
||||
5FC35BE828D5235A004EBEAC /* ButtonViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ButtonViewController.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>"; };
|
||||
EA0D1C322A673FD400E5C127 /* RadioButtonItemViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RadioButtonItemViewController.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; };
|
||||
EA3C3B9C289966EF000CA526 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
|
||||
@ -172,14 +178,14 @@
|
||||
EAD062AC2A3B86950015965D /* BadgeIndicatorViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BadgeIndicatorViewController.swift; sourceTree = "<group>"; };
|
||||
EAD0688F2A55FC11002E3A2D /* LoaderViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LoaderViewController.swift; sourceTree = "<group>"; };
|
||||
EAF7F07B2899698800B287F5 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
|
||||
EAF7F09B2899B92400B287F5 /* CheckboxViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CheckboxViewController.swift; sourceTree = "<group>"; };
|
||||
EAF7F09B2899B92400B287F5 /* CheckboxItemViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CheckboxItemViewController.swift; sourceTree = "<group>"; };
|
||||
EAF7F0C5289DA24F00B287F5 /* ArtifactoryItems.txt */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = ArtifactoryItems.txt; sourceTree = "<group>"; };
|
||||
EAF7F0C8289DA24F00B287F5 /* DownloadArtifactoryItems.sh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.sh; path = DownloadArtifactoryItems.sh; sourceTree = "<group>"; };
|
||||
EAF7F0C9289DA24F00B287F5 /* Artifactory.sh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.sh; path = Artifactory.sh; sourceTree = "<group>"; };
|
||||
EAF7F0DA289DB0B400B287F5 /* VDSTypographyTokens.xcframework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcframework; name = VDSTypographyTokens.xcframework; path = SharedFrameworks/VDSTypographyTokens.xcframework; sourceTree = "<group>"; };
|
||||
EAF7F0DB289DB0B400B287F5 /* VDSFormControlsTokens.xcframework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcframework; name = VDSFormControlsTokens.xcframework; path = SharedFrameworks/VDSFormControlsTokens.xcframework; sourceTree = "<group>"; };
|
||||
EAF7F0DC289DB0B400B287F5 /* VDSColorTokens.xcframework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcframework; name = VDSColorTokens.xcframework; path = SharedFrameworks/VDSColorTokens.xcframework; sourceTree = "<group>"; };
|
||||
EAF7F11928A14A0E00B287F5 /* RadioButtonViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RadioButtonViewController.swift; sourceTree = "<group>"; };
|
||||
EAF7F11928A14A0E00B287F5 /* RadioButtonGroupViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RadioButtonGroupViewController.swift; sourceTree = "<group>"; };
|
||||
/* End PBXFileReference section */
|
||||
|
||||
/* Begin PBXFrameworksBuildPhase section */
|
||||
@ -305,7 +311,8 @@
|
||||
EAB5FEEE2927E28400998C17 /* ButtonGroupViewController.swift */,
|
||||
5FC35BE828D5235A004EBEAC /* ButtonViewController.swift */,
|
||||
EA89204D28B67332006B9984 /* CheckBoxGroupViewController.swift */,
|
||||
EAF7F09B2899B92400B287F5 /* CheckboxViewController.swift */,
|
||||
EAF7F09B2899B92400B287F5 /* CheckboxItemViewController.swift */,
|
||||
EA0D1C2E2A66CFE900E5C127 /* CheckboxViewController.swift */,
|
||||
EA985C00296CC21C00F2FF2E /* IconViewController.swift */,
|
||||
EAA5EEAC28EB6924003B3210 /* InputFieldViewController.swift */,
|
||||
EAB1D2D328AC409F00DAE764 /* LabelViewController.swift */,
|
||||
@ -313,7 +320,9 @@
|
||||
EAD0688F2A55FC11002E3A2D /* LoaderViewController.swift */,
|
||||
445BA07929C088470036A7C5 /* NotificationViewController.swift */,
|
||||
EA89201828B56DF5006B9984 /* RadioBoxGroupViewController.swift */,
|
||||
EAF7F11928A14A0E00B287F5 /* RadioButtonViewController.swift */,
|
||||
EA0D1C302A673F3500E5C127 /* RadioButtonViewController.swift */,
|
||||
EA0D1C322A673FD400E5C127 /* RadioButtonItemViewController.swift */,
|
||||
EAF7F11928A14A0E00B287F5 /* RadioButtonGroupViewController.swift */,
|
||||
EA84F76128BE4AE500D67ABC /* RadioSwatchGroupViewController.swift */,
|
||||
EA5F86CD2A1E863F00BC83E4 /* TabsContainerViewController.swift */,
|
||||
EA596AB92A16B2ED00300C4B /* TabsViewController.swift */,
|
||||
@ -483,9 +492,10 @@
|
||||
EA3C3B9D289966EF000CA526 /* AppDelegate.swift in Sources */,
|
||||
EA5E3050294D11540082B959 /* TileContainerViewController.swift in Sources */,
|
||||
445BA07A29C088470036A7C5 /* NotificationViewController.swift in Sources */,
|
||||
EAF7F11A28A14A0E00B287F5 /* RadioButtonViewController.swift in Sources */,
|
||||
EAF7F11A28A14A0E00B287F5 /* RadioButtonGroupViewController.swift in Sources */,
|
||||
EA89204628B66CE2006B9984 /* ScrollViewController.swift in Sources */,
|
||||
EA3C3B9F289966EF000CA526 /* SceneDelegate.swift in Sources */,
|
||||
EA0D1C332A673FD400E5C127 /* RadioButtonItemViewController.swift in Sources */,
|
||||
5FC35BE928D5235A004EBEAC /* ButtonViewController.swift in Sources */,
|
||||
EA89204A28B66CE2006B9984 /* KeyboardFrameChange.swift in Sources */,
|
||||
EA3C3BB428996775000CA526 /* PickerBase.swift in Sources */,
|
||||
@ -494,13 +504,15 @@
|
||||
EAD062AD2A3B86950015965D /* BadgeIndicatorViewController.swift in Sources */,
|
||||
EA5E305C295111050082B959 /* TileletViewController.swift in Sources */,
|
||||
EAD062A32A3913920015965D /* DropShawdowViewController.swift in Sources */,
|
||||
EA0D1C312A673F3500E5C127 /* RadioButtonViewController.swift in Sources */,
|
||||
EAB5FEF32928153D00998C17 /* Helper.swift in Sources */,
|
||||
EA89204728B66CE2006B9984 /* KeyboardFrameChangeListener.swift in Sources */,
|
||||
EA4DB30428DCD25B00103EE3 /* BadgeViewController.swift in Sources */,
|
||||
EAB2376029E88D5D00AABE9A /* TooltipViewController.swift in Sources */,
|
||||
EA89204828B66CE2006B9984 /* ScrollViewKeyboardAvoiding.swift in Sources */,
|
||||
EA0FC2C12912DC5500DF80B4 /* TextLinkCaretViewController.swift in Sources */,
|
||||
EAF7F09C2899B92400B287F5 /* CheckboxViewController.swift in Sources */,
|
||||
EAF7F09C2899B92400B287F5 /* CheckboxItemViewController.swift in Sources */,
|
||||
EA0D1C2F2A66CFE900E5C127 /* CheckboxViewController.swift in Sources */,
|
||||
EA596ABA2A16B2ED00300C4B /* TabsViewController.swift in Sources */,
|
||||
EA89204E28B67332006B9984 /* CheckBoxGroupViewController.swift in Sources */,
|
||||
EAA5EEAD28EB6924003B3210 /* InputFieldViewController.swift in Sources */,
|
||||
|
||||
105
VDSSample/ViewControllers/CheckboxItemViewController.swift
Normal file
105
VDSSample/ViewControllers/CheckboxItemViewController.swift
Normal file
@ -0,0 +1,105 @@
|
||||
//
|
||||
// CheckboxViewController.swift
|
||||
// VDSSample
|
||||
//
|
||||
// Created by Matt Bruce on 8/1/22.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import UIKit
|
||||
import VDS
|
||||
import VDSColorTokens
|
||||
import Combine
|
||||
|
||||
class CheckboxItemViewController: BaseViewController<CheckboxItem> {
|
||||
|
||||
var disabledSwitch = Toggle()
|
||||
var labelTextField = TextField()
|
||||
var childTextField = TextField()
|
||||
var errorTextField = TextField()
|
||||
var showErrorSwitch = Toggle()
|
||||
|
||||
override func viewDidLoad() {
|
||||
super.viewDidLoad()
|
||||
addContentTopView(view: component)
|
||||
|
||||
setupPicker()
|
||||
setupModel()
|
||||
}
|
||||
|
||||
override func allTextFields() -> [TextField]? { [labelTextField, childTextField, errorTextField] }
|
||||
|
||||
override func setupForm(){
|
||||
super.setupForm()
|
||||
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: .makeWrapper(for: showErrorSwitch))
|
||||
addFormRow(label: "Error Text", view: errorTextField)
|
||||
|
||||
showErrorSwitch.onChange = { [weak self] sender in
|
||||
guard let self else { return }
|
||||
self.component.showError = sender.isOn
|
||||
if self.component.showError != sender.isOn {
|
||||
self.showErrorSwitch.isOn = self.component.showError
|
||||
}
|
||||
}
|
||||
|
||||
disabledSwitch.onChange = { [weak self] sender in
|
||||
self?.component.disabled = sender.isOn
|
||||
}
|
||||
|
||||
labelTextField
|
||||
.textPublisher
|
||||
.sink { [weak self] text in
|
||||
self?.component.labelText = text
|
||||
}.store(in: &subscribers)
|
||||
|
||||
childTextField
|
||||
.textPublisher
|
||||
.sink { [weak self] text in
|
||||
self?.component.childText = text
|
||||
}.store(in: &subscribers)
|
||||
|
||||
errorTextField
|
||||
.textPublisher
|
||||
.sink { [weak self] text in
|
||||
self?.component.errorText = text
|
||||
}.store(in: &subscribers)
|
||||
}
|
||||
|
||||
func setupModel() {
|
||||
component.labelText = "Terms and conditions"
|
||||
component.childText = "I agree to Verizon's terms and conditions click here"
|
||||
component.errorText = "Error Text"
|
||||
|
||||
component.onChange = { [weak self] checkbox in
|
||||
let alertController:UIAlertController = UIAlertController(title: "Alert",
|
||||
message: "\(checkbox.labelText!): \(checkbox.isSelected)",
|
||||
preferredStyle: UIAlertController.Style.alert)
|
||||
alertController.addAction(UIAlertAction(title: "OK", style: UIAlertAction.Style.default, handler:nil))
|
||||
self?.present(alertController, animated: true)
|
||||
self?.showErrorSwitch.isOn = checkbox.showError
|
||||
print("checkbox selected: \(checkbox.isSelected)")
|
||||
}
|
||||
|
||||
//setup UI
|
||||
surfacePickerSelectorView.text = component.surface.rawValue
|
||||
disabledSwitch.isOn = component.disabled
|
||||
labelTextField.text = component.labelText
|
||||
childTextField.text = component.childText
|
||||
showErrorSwitch.isOn = component.showError
|
||||
errorTextField.text = component.errorText
|
||||
|
||||
}
|
||||
|
||||
//Picker
|
||||
func setupPicker(){
|
||||
surfacePickerSelectorView.onPickerDidSelect = { [weak self] item in
|
||||
self?.component.surface = item
|
||||
self?.contentTopView.backgroundColor = item.color
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -11,32 +11,28 @@ import VDS
|
||||
import VDSColorTokens
|
||||
import Combine
|
||||
|
||||
class CheckboxViewController: BaseViewController<CheckboxItem> {
|
||||
class CheckboxViewController: BaseViewController<Checkbox> {
|
||||
|
||||
var disabledSwitch = Toggle()
|
||||
var labelTextField = TextField()
|
||||
var childTextField = TextField()
|
||||
var errorTextField = TextField()
|
||||
var showErrorSwitch = Toggle()
|
||||
|
||||
let toggle = UISwitch()
|
||||
override func viewDidLoad() {
|
||||
super.viewDidLoad()
|
||||
addContentTopView(view: component)
|
||||
|
||||
// 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)
|
||||
setupPicker()
|
||||
setupModel()
|
||||
}
|
||||
|
||||
override func allTextFields() -> [TextField]? { [labelTextField, childTextField, errorTextField] }
|
||||
|
||||
override func setupForm(){
|
||||
super.setupForm()
|
||||
super.setupForm()
|
||||
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: .makeWrapper(for: showErrorSwitch))
|
||||
addFormRow(label: "Error Text", view: errorTextField)
|
||||
|
||||
showErrorSwitch.onChange = { [weak self] sender in
|
||||
guard let self else { return }
|
||||
@ -50,33 +46,12 @@ class CheckboxViewController: BaseViewController<CheckboxItem> {
|
||||
self?.component.disabled = sender.isOn
|
||||
}
|
||||
|
||||
labelTextField
|
||||
.textPublisher
|
||||
.sink { [weak self] text in
|
||||
self?.component.labelText = text
|
||||
}.store(in: &subscribers)
|
||||
|
||||
childTextField
|
||||
.textPublisher
|
||||
.sink { [weak self] text in
|
||||
self?.component.childText = text
|
||||
}.store(in: &subscribers)
|
||||
|
||||
errorTextField
|
||||
.textPublisher
|
||||
.sink { [weak self] text in
|
||||
self?.component.errorText = text
|
||||
}.store(in: &subscribers)
|
||||
}
|
||||
|
||||
|
||||
func setupModel() {
|
||||
component.labelText = "Terms and conditions"
|
||||
component.childText = "I agree to Verizon's terms and conditions click here"
|
||||
component.errorText = "Error Text"
|
||||
|
||||
component.onChange = { [weak self] checkbox in
|
||||
let alertController:UIAlertController = UIAlertController(title: "Alert",
|
||||
message: "\(checkbox.labelText!): \(checkbox.isSelected)",
|
||||
message: "Checkbox: \(checkbox.isSelected)",
|
||||
preferredStyle: UIAlertController.Style.alert)
|
||||
alertController.addAction(UIAlertAction(title: "OK", style: UIAlertAction.Style.default, handler:nil))
|
||||
self?.present(alertController, animated: true)
|
||||
@ -87,10 +62,7 @@ class CheckboxViewController: BaseViewController<CheckboxItem> {
|
||||
//setup UI
|
||||
surfacePickerSelectorView.text = component.surface.rawValue
|
||||
disabledSwitch.isOn = component.disabled
|
||||
labelTextField.text = component.labelText
|
||||
childTextField.text = component.childText
|
||||
showErrorSwitch.isOn = component.showError
|
||||
errorTextField.text = component.errorText
|
||||
|
||||
}
|
||||
|
||||
@ -102,4 +74,3 @@ class CheckboxViewController: BaseViewController<CheckboxItem> {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -84,6 +84,7 @@ class MenuViewController: UITableViewController, TooltipLaunchable {
|
||||
MenuComponent(title: "ButtonGroup", completed: true, viewController: ButtonGroupViewController.self),
|
||||
MenuComponent(title: "ButtonIcon", completed: false, viewController: ButtonIconViewController.self),
|
||||
MenuComponent(title: "Checkbox", completed: true, viewController: CheckboxViewController.self),
|
||||
MenuComponent(title: "CheckboxItem", completed: true, viewController: CheckboxItemViewController.self),
|
||||
MenuComponent(title: "CheckboxGroup", completed: true, viewController: CheckboxGroupViewController.self),
|
||||
MenuComponent(title: "Icon", completed: true, viewController: IconViewController.self),
|
||||
MenuComponent(title: "InputField", completed: false, viewController: InputFieldViewController.self),
|
||||
@ -92,7 +93,9 @@ class MenuViewController: UITableViewController, TooltipLaunchable {
|
||||
MenuComponent(title: "Loader", completed: true, viewController: LoaderViewController.self),
|
||||
MenuComponent(title: "Notification", completed: true, viewController: NotificationViewController.self),
|
||||
MenuComponent(title: "RadioBoxGroup", completed: true, viewController: RadioBoxGroupViewController.self),
|
||||
MenuComponent(title: "RadioButtonGroup", completed: true, viewController: RadioButtonViewController.self),
|
||||
MenuComponent(title: "RadioButton", completed: true, viewController: RadioButtonViewController.self),
|
||||
MenuComponent(title: "RadioButtonItem", completed: true, viewController: RadioButtonItemViewController.self),
|
||||
MenuComponent(title: "RadioButtonGroup", completed: true, viewController: RadioButtonGroupViewController.self),
|
||||
MenuComponent(title: "RadioSwatchGroup", completed: true, viewController: RadioSwatchGroupViewController.self),
|
||||
//MenuComponent(title: "TabsContainer", completed: false, viewController: TabsContainerViewController.self),
|
||||
MenuComponent(title: "Tabs", completed: true, viewController: TabsViewController.self),
|
||||
|
||||
114
VDSSample/ViewControllers/RadioButtonGroupViewController.swift
Normal file
114
VDSSample/ViewControllers/RadioButtonGroupViewController.swift
Normal file
@ -0,0 +1,114 @@
|
||||
//
|
||||
// RadioButtonViewController.swift
|
||||
// VDSSample
|
||||
//
|
||||
// Created by Matt Bruce on 8/1/22.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import UIKit
|
||||
import VDS
|
||||
import VDSColorTokens
|
||||
import Combine
|
||||
|
||||
class RadioButtonGroupViewController: BaseViewController<RadioButtonGroup> {
|
||||
|
||||
var disabledSwitch = Toggle()
|
||||
var labelTextField = TextField()
|
||||
var childTextField = TextField()
|
||||
var showErrorSwitch = Toggle()
|
||||
|
||||
override func viewDidLoad() {
|
||||
super.viewDidLoad()
|
||||
addContentTopView(view: component)
|
||||
|
||||
setupPicker()
|
||||
setupModel()
|
||||
}
|
||||
|
||||
override func allTextFields() -> [TextField]? { [labelTextField, childTextField] }
|
||||
|
||||
override func setupForm() {
|
||||
super.setupForm()
|
||||
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: .makeWrapper(for: showErrorSwitch))
|
||||
|
||||
showErrorSwitch.onChange = { [weak self] sender in
|
||||
self?.component.showError = sender.isOn
|
||||
}
|
||||
|
||||
disabledSwitch.onChange = { [weak self] sender in
|
||||
self?.component.disabled = sender.isOn
|
||||
}
|
||||
|
||||
labelTextField
|
||||
.textPublisher
|
||||
.sink { [weak self] text in
|
||||
self?.radioButton?.labelText = text
|
||||
}.store(in: &subscribers)
|
||||
|
||||
childTextField
|
||||
.textPublisher
|
||||
.sink { [weak self] text in
|
||||
self?.radioButton?.childText = text
|
||||
}.store(in: &subscribers)
|
||||
|
||||
}
|
||||
|
||||
func setupModel(){
|
||||
var radioButton1 = RadioButtonGroup.RadioButtonModel()
|
||||
radioButton1.inputId = "model1"
|
||||
radioButton1.value = "model 1 Value"
|
||||
radioButton1.labelText = "iPhone 11 Bundle 1"
|
||||
radioButton1.childText = "Apple iPhone 11 - 64 GB\nOtterbox Case Red\nScreen Protector"
|
||||
|
||||
var radioButton2 = RadioButtonGroup.RadioButtonModel()
|
||||
radioButton2.inputId = "model2"
|
||||
radioButton2.value = "model 2 Value"
|
||||
radioButton2.labelText = "iPhone 11 Bundle 2"
|
||||
radioButton2.childText = "Apple iPhone 11 - 128 GB\nOtterbox Case Black\nScreen Protector"
|
||||
|
||||
var radioButton3 = RadioButtonGroup.RadioButtonModel()
|
||||
radioButton3.inputId = "model3"
|
||||
radioButton3.value = "model 3 Value"
|
||||
radioButton3.labelText = "iPhone 11 Bundle 3"
|
||||
radioButton3.childText = "Apple iPhone 11 - 256 GB\nOtterbox Case Black\nScreen Protector"
|
||||
|
||||
component.selectorModels = [radioButton1, radioButton2, radioButton3]
|
||||
|
||||
component.onChange = { [weak self] group in
|
||||
let alertController:UIAlertController = UIAlertController(title: "Alert",
|
||||
message: "Selected:\r\(group.selectedHandler?.labelText ?? "none")",
|
||||
preferredStyle: UIAlertController.Style.alert)
|
||||
alertController.addAction(UIAlertAction(title: "OK", style: UIAlertAction.Style.default, handler:nil))
|
||||
self?.present(alertController, animated: true)
|
||||
|
||||
print("Selected: \(group.selectedHandler?.labelText ?? "none")")
|
||||
}
|
||||
|
||||
//set UI values
|
||||
surfacePickerSelectorView.text = component.surface.rawValue
|
||||
disabledSwitch.isOn = component.disabled
|
||||
showErrorSwitch.isOn = component.showError
|
||||
labelTextField.text = radioButton1.labelText
|
||||
childTextField.text = radioButton1.childText
|
||||
}
|
||||
|
||||
var radioButton: RadioButtonItem? {
|
||||
component.selectorViews.first
|
||||
}
|
||||
|
||||
//Picker
|
||||
func setupPicker(){
|
||||
|
||||
picker.isHidden = true
|
||||
surfacePickerSelectorView.onPickerDidSelect = { [weak self] item in
|
||||
self?.component.surface = item
|
||||
self?.contentTopView.backgroundColor = item.color
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
105
VDSSample/ViewControllers/RadioButtonItemViewController.swift
Normal file
105
VDSSample/ViewControllers/RadioButtonItemViewController.swift
Normal file
@ -0,0 +1,105 @@
|
||||
//
|
||||
// RadioButtonItemViewController.swift
|
||||
// VDSSample
|
||||
//
|
||||
// Created by Matt Bruce on 7/18/23.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import UIKit
|
||||
import VDS
|
||||
import VDSColorTokens
|
||||
import Combine
|
||||
|
||||
class RadioButtonItemViewController: BaseViewController<RadioButtonItem> {
|
||||
|
||||
var disabledSwitch = Toggle()
|
||||
var labelTextField = TextField()
|
||||
var childTextField = TextField()
|
||||
var errorTextField = TextField()
|
||||
var showErrorSwitch = Toggle()
|
||||
|
||||
override func viewDidLoad() {
|
||||
super.viewDidLoad()
|
||||
addContentTopView(view: component)
|
||||
|
||||
setupPicker()
|
||||
setupModel()
|
||||
}
|
||||
|
||||
override func allTextFields() -> [TextField]? { [labelTextField, childTextField, errorTextField] }
|
||||
|
||||
override func setupForm(){
|
||||
super.setupForm()
|
||||
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: .makeWrapper(for: showErrorSwitch))
|
||||
addFormRow(label: "Error Text", view: errorTextField)
|
||||
|
||||
showErrorSwitch.onChange = { [weak self] sender in
|
||||
guard let self else { return }
|
||||
self.component.showError = sender.isOn
|
||||
if self.component.showError != sender.isOn {
|
||||
self.showErrorSwitch.isOn = self.component.showError
|
||||
}
|
||||
}
|
||||
|
||||
disabledSwitch.onChange = { [weak self] sender in
|
||||
self?.component.disabled = sender.isOn
|
||||
}
|
||||
|
||||
labelTextField
|
||||
.textPublisher
|
||||
.sink { [weak self] text in
|
||||
self?.component.labelText = text
|
||||
}.store(in: &subscribers)
|
||||
|
||||
childTextField
|
||||
.textPublisher
|
||||
.sink { [weak self] text in
|
||||
self?.component.childText = text
|
||||
}.store(in: &subscribers)
|
||||
|
||||
errorTextField
|
||||
.textPublisher
|
||||
.sink { [weak self] text in
|
||||
self?.component.errorText = text
|
||||
}.store(in: &subscribers)
|
||||
}
|
||||
|
||||
func setupModel() {
|
||||
component.labelText = "Terms and conditions"
|
||||
component.childText = "I agree to Verizon's terms and conditions click here"
|
||||
component.errorText = "Error Text"
|
||||
|
||||
component.onChange = { [weak self] item in
|
||||
let alertController:UIAlertController = UIAlertController(title: "Alert",
|
||||
message: "\(item.labelText!): \(item.isSelected)",
|
||||
preferredStyle: UIAlertController.Style.alert)
|
||||
alertController.addAction(UIAlertAction(title: "OK", style: UIAlertAction.Style.default, handler:nil))
|
||||
self?.present(alertController, animated: true)
|
||||
self?.showErrorSwitch.isOn = item.showError
|
||||
print("checkbox selected: \(item.isSelected)")
|
||||
}
|
||||
|
||||
//setup UI
|
||||
surfacePickerSelectorView.text = component.surface.rawValue
|
||||
disabledSwitch.isOn = component.disabled
|
||||
labelTextField.text = component.labelText
|
||||
childTextField.text = component.childText
|
||||
showErrorSwitch.isOn = component.showError
|
||||
errorTextField.text = component.errorText
|
||||
|
||||
}
|
||||
|
||||
//Picker
|
||||
func setupPicker(){
|
||||
surfacePickerSelectorView.onPickerDidSelect = { [weak self] item in
|
||||
self?.component.surface = item
|
||||
self?.contentTopView.backgroundColor = item.color
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,8 +1,8 @@
|
||||
//
|
||||
// RadioButtonViewController.swift
|
||||
// RadioButtonViewController.swift
|
||||
// VDSSample
|
||||
//
|
||||
// Created by Matt Bruce on 8/1/22.
|
||||
// Created by Matt Bruce on 7/18/23.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
@ -11,104 +11,59 @@ import VDS
|
||||
import VDSColorTokens
|
||||
import Combine
|
||||
|
||||
class RadioButtonViewController: BaseViewController<RadioButtonGroup> {
|
||||
|
||||
class RadioButtonViewController: BaseViewController<RadioButton> {
|
||||
|
||||
var disabledSwitch = Toggle()
|
||||
var labelTextField = TextField()
|
||||
var childTextField = TextField()
|
||||
var showErrorSwitch = Toggle()
|
||||
|
||||
let toggle = UISwitch()
|
||||
override func viewDidLoad() {
|
||||
super.viewDidLoad()
|
||||
addContentTopView(view: component)
|
||||
|
||||
addContentTopView(view: .makeWrapper(for: component, edgeSpacing: 16.0), edgeSpacing: 0.0)
|
||||
setupPicker()
|
||||
setupModel()
|
||||
}
|
||||
|
||||
override func allTextFields() -> [TextField]? { [labelTextField, childTextField] }
|
||||
|
||||
override func setupForm() {
|
||||
override func setupForm(){
|
||||
super.setupForm()
|
||||
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: .makeWrapper(for: showErrorSwitch))
|
||||
|
||||
showErrorSwitch.onChange = { [weak self] sender in
|
||||
self?.component.showError = sender.isOn
|
||||
guard let self else { return }
|
||||
self.component.showError = sender.isOn
|
||||
if self.component.showError != sender.isOn {
|
||||
self.showErrorSwitch.isOn = self.component.showError
|
||||
}
|
||||
}
|
||||
|
||||
disabledSwitch.onChange = { [weak self] sender in
|
||||
disabledSwitch.onChange = { [weak self] sender in
|
||||
self?.component.disabled = sender.isOn
|
||||
}
|
||||
|
||||
labelTextField
|
||||
.textPublisher
|
||||
.sink { [weak self] text in
|
||||
self?.radioButton?.labelText = text
|
||||
}.store(in: &subscribers)
|
||||
|
||||
childTextField
|
||||
.textPublisher
|
||||
.sink { [weak self] text in
|
||||
self?.radioButton?.childText = text
|
||||
}.store(in: &subscribers)
|
||||
|
||||
|
||||
}
|
||||
|
||||
func setupModel(){
|
||||
var radioButton1 = RadioButtonGroup.RadioButtonModel()
|
||||
radioButton1.inputId = "model1"
|
||||
radioButton1.value = "model 1 Value"
|
||||
radioButton1.labelText = "iPhone 11 Bundle 1"
|
||||
radioButton1.childText = "Apple iPhone 11 - 64 GB\nOtterbox Case Red\nScreen Protector"
|
||||
|
||||
var radioButton2 = RadioButtonGroup.RadioButtonModel()
|
||||
radioButton2.inputId = "model2"
|
||||
radioButton2.value = "model 2 Value"
|
||||
radioButton2.labelText = "iPhone 11 Bundle 2"
|
||||
radioButton2.childText = "Apple iPhone 11 - 128 GB\nOtterbox Case Black\nScreen Protector"
|
||||
|
||||
var radioButton3 = RadioButtonGroup.RadioButtonModel()
|
||||
radioButton3.inputId = "model3"
|
||||
radioButton3.value = "model 3 Value"
|
||||
radioButton3.labelText = "iPhone 11 Bundle 3"
|
||||
radioButton3.childText = "Apple iPhone 11 - 256 GB\nOtterbox Case Black\nScreen Protector"
|
||||
|
||||
component.selectorModels = [radioButton1, radioButton2, radioButton3]
|
||||
|
||||
component.onChange = { [weak self] group in
|
||||
func setupModel() {
|
||||
component.onChange = { [weak self] item in
|
||||
let alertController:UIAlertController = UIAlertController(title: "Alert",
|
||||
message: "Selected:\r\(group.selectedHandler?.labelText ?? "none")",
|
||||
message: "RadioButton: \(item.isSelected)",
|
||||
preferredStyle: UIAlertController.Style.alert)
|
||||
alertController.addAction(UIAlertAction(title: "OK", style: UIAlertAction.Style.default, handler:nil))
|
||||
self?.present(alertController, animated: true)
|
||||
|
||||
print("Selected: \(group.selectedHandler?.labelText ?? "none")")
|
||||
self?.showErrorSwitch.isOn = item.showError
|
||||
}
|
||||
|
||||
//set UI values
|
||||
|
||||
//setup UI
|
||||
surfacePickerSelectorView.text = component.surface.rawValue
|
||||
disabledSwitch.isOn = component.disabled
|
||||
showErrorSwitch.isOn = component.showError
|
||||
labelTextField.text = radioButton1.labelText
|
||||
childTextField.text = radioButton1.childText
|
||||
|
||||
}
|
||||
|
||||
var radioButton: RadioButtonItem? {
|
||||
component.selectorViews.first
|
||||
}
|
||||
|
||||
|
||||
//Picker
|
||||
func setupPicker(){
|
||||
|
||||
picker.isHidden = true
|
||||
surfacePickerSelectorView.onPickerDidSelect = { [weak self] item in
|
||||
surfacePickerSelectorView.onPickerDidSelect = { [weak self] item in
|
||||
self?.component.surface = item
|
||||
self?.contentTopView.backgroundColor = item.color
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user