Merge branch 'feature/tableviewtester' of https://gitlab.verizon.com/BPHV_MIPS/vds_ios_sample into develop

This commit is contained in:
Matt Bruce 2023-08-31 10:32:53 -05:00
commit e3ed5fea17
17 changed files with 102 additions and 284 deletions

View File

@ -56,7 +56,6 @@
EA5E305C295111050082B959 /* TileletViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA5E305B295111050082B959 /* TileletViewController.swift */; };
EA5F86CE2A1E863F00BC83E4 /* TabsContainerViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA5F86CD2A1E863F00BC83E4 /* TabsContainerViewController.swift */; };
EA81410E2A0ED8DC004F60D2 /* ButtonIconViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA81410D2A0ED8DC004F60D2 /* ButtonIconViewController.swift */; };
EA84F76228BE4AE500D67ABC /* RadioSwatchGroupViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA84F76128BE4AE500D67ABC /* RadioSwatchGroupViewController.swift */; };
EA89201928B56DF5006B9984 /* RadioBoxGroupViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA89201828B56DF5006B9984 /* RadioBoxGroupViewController.swift */; };
EA89204628B66CE2006B9984 /* ScrollViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA89203F28B66CE2006B9984 /* ScrollViewController.swift */; };
EA89204728B66CE2006B9984 /* KeyboardFrameChangeListener.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA89204028B66CE2006B9984 /* KeyboardFrameChangeListener.swift */; };
@ -153,7 +152,6 @@
EA5E305B295111050082B959 /* TileletViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TileletViewController.swift; sourceTree = "<group>"; };
EA5F86CD2A1E863F00BC83E4 /* TabsContainerViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TabsContainerViewController.swift; sourceTree = "<group>"; };
EA81410D2A0ED8DC004F60D2 /* ButtonIconViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ButtonIconViewController.swift; sourceTree = "<group>"; };
EA84F76128BE4AE500D67ABC /* RadioSwatchGroupViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RadioSwatchGroupViewController.swift; sourceTree = "<group>"; };
EA89201828B56DF5006B9984 /* RadioBoxGroupViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RadioBoxGroupViewController.swift; sourceTree = "<group>"; };
EA89203F28B66CE2006B9984 /* ScrollViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ScrollViewController.swift; sourceTree = "<group>"; };
EA89204028B66CE2006B9984 /* KeyboardFrameChangeListener.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = KeyboardFrameChangeListener.swift; sourceTree = "<group>"; };
@ -329,7 +327,6 @@
EA0D1C302A673F3500E5C127 /* RadioButtonViewController.swift */,
EA0D1C322A673FD400E5C127 /* RadioButtonItemViewController.swift */,
EAF7F11928A14A0E00B287F5 /* RadioButtonGroupViewController.swift */,
EA84F76128BE4AE500D67ABC /* RadioSwatchGroupViewController.swift */,
EA5F86CD2A1E863F00BC83E4 /* TabsContainerViewController.swift */,
EA596AB92A16B2ED00300C4B /* TabsViewController.swift */,
EA0FC2C02912DC5500DF80B4 /* TextLinkCaretViewController.swift */,
@ -535,7 +532,6 @@
EAD062A52A3B5CDF0015965D /* Slider.swift in Sources */,
EAB1D2D428AC409F00DAE764 /* LabelViewController.swift in Sources */,
EA89204B28B66CE2006B9984 /* ScrollViewKeyboardAvoider.swift in Sources */,
EA84F76228BE4AE500D67ABC /* RadioSwatchGroupViewController.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};

View File

@ -11,7 +11,7 @@ import VDS
import VDSFormControlsTokens
import Combine
public class TextField: UITextField {
open class TextField: UITextField {
public var resigner: AnyCancellable?
public var resignAction: ((TextField) -> Void)?

View File

@ -13,79 +13,62 @@ public protocol CustomRotorable: UIViewController {
}
extension CustomRotorable {
/// Adds CustomRotor to the accessibilityCustomRotors array.
/// - Parameters:
/// - name: Name that will show up in the Rotor picker.
/// - trait: Any UIView that has this traits will be added to this Name.
internal func addCustomRotor(with name: String, for trait: UIAccessibilityTraits) {
//filter out old rotors with same name
accessibilityCustomRotors = (accessibilityCustomRotors ?? []).filter { $0.name != name }
//create new rotor
let newRotor = UIAccessibilityCustomRotor(name: name) { [weak self] predicate in
guard let self else { return nil }
let views = self.view.accessibleElements(with: trait)
guard !views.isEmpty else { return nil }
guard let self = self else { return nil }
let elements = self.view.accessibleElements(with: trait)
guard !elements.isEmpty else { return nil }
let currentIndex = views.firstIndex(where: { $0 === predicate.currentItem.targetElement })
let count = views.count
//find the nextIndex
let currentIndex = elements.firstIndex(where: { ($0 as AnyObject) === predicate.currentItem.targetElement })
let count = elements.count
let nextIndex: Int
switch predicate.searchDirection {
case .next:
if let currentIndex, currentIndex != count - 1{
//go forwards
nextIndex = currentIndex + 1
} else {
//get the first
nextIndex = 0
}
nextIndex = currentIndex.map { ($0 + 1) % count } ?? 0
case .previous:
if let currentIndex, currentIndex != 0 {
//go backwards
nextIndex = currentIndex - 1
} else {
//get the last
nextIndex = count - 1
}
nextIndex = currentIndex.map { ($0 - 1 + count) % count } ?? 0
@unknown default:
//get the first
nextIndex = 0
}
return UIAccessibilityCustomRotorItemResult(targetElement: views[nextIndex], targetRange: nil)
guard let element = elements[nextIndex] as? NSObjectProtocol else { return nil }
return UIAccessibilityCustomRotorItemResult(targetElement: element, targetRange: nil)
}
//append rotor
accessibilityCustomRotors?.append(newRotor)
}
/// Loads all of the custom rotors for the screen.
public func loadCustomRotors() {
customRotors.forEach { addCustomRotor(with: $0.name, for: $0.trait) }
}
}
public extension UIView {
/// Gets all of the Views that has the matching accessibilityTrait.
/// - Parameter trait: This is the trailt for the accessibilityTrait property of a view.
/// - Returns: An array of RotorItemResult
func accessibleElements(with trait: UIAccessibilityTraits) -> [UIView] {
var elements: [UIView] = []
//add your self if you meet the requirements
func accessibleElements(with trait: UIAccessibilityTraits) -> [Any] {
var elements: [Any] = []
if isAccessibilityElement, accessibilityTraits.contains(trait) {
elements.append(self)
}
//loop through your subviews
if let customAccessibilityElements = accessibilityElements {
elements.append(contentsOf: customAccessibilityElements.filter { element in
if let element = element as? UIAccessibilityElement {
return element.accessibilityTraits.contains(trait)
}
return false
})
}
subviews.forEach { elements.append(contentsOf: $0.accessibleElements(with: trait)) }
return elements
}
}

View File

@ -150,7 +150,7 @@ public class SurfacePickerSelectorView: PickerSelectorView<Surface>{
}
}
public class TextPositionPickerSelectorView: PickerSelectorView<TextPosition>{
public class TextPositionPickerSelectorView: PickerSelectorView<TextAlignment>{
init(picker: UIPickerView? = nil){
super.init(title: "left", picker: picker, items: [.left, .right])
}

View File

@ -300,6 +300,7 @@ public class BaseViewController<Component: UIView>: UIViewController, Initable ,
var activeTextField: UITextField?
/// Called once when a view is initialized and is used to Setup additional UI or other constants and configurations.
open func setup() {
if let textFields = allTextFields()?.filter({ $0.isKind(of: TextField.self) == false || $0.isKind(of: NumericField.self) }) {

View File

@ -48,9 +48,9 @@ class ButtonGroupViewController: BaseViewController<ButtonGroup> {
}
lazy var buttonPositionSelectorView = {
PickerSelectorView<ButtonGroup.ButtonPosition>(title: "",
PickerSelectorView<ButtonGroup.Alignment>(title: "",
picker: self.picker,
items: ButtonGroup.ButtonPosition.allCases)
items: ButtonGroup.Alignment.allCases)
}()
lazy var rowQuantitySelectorView = {
@ -128,25 +128,25 @@ class ButtonGroupViewController: BaseViewController<ButtonGroup> {
.numberPublisher
.sink { [weak self] number in
if let number {
self?.component.buttonWidth = number.cgFloatValue
self?.smallButtonGroup.buttonWidth = number.cgFloatValue
self?.component.childWidth = .value(number.cgFloatValue)
self?.smallButtonGroup.childWidth = .value(number.cgFloatValue)
self?.percentageTextField.text = ""
} else {
self?.component.buttonWidth = nil
self?.component.childWidth = nil
self?.smallButtonGroup.childWidth = nil
}
}.store(in: &subscribers)
percentageTextField
.numberPublisher
.sink { [weak self] number in
let rowQty = self?.component.rowQuantity ?? 0
if let number, number.intValue <= 100, rowQty > 0 {
self?.component.buttonPercentage = number.cgFloatValue
self?.smallButtonGroup.buttonPercentage = number.cgFloatValue
if let number {
self?.component.childWidth = .percentage(number.cgFloatValue)
self?.smallButtonGroup.childWidth = .percentage(number.cgFloatValue)
self?.widthTextField.text = ""
} else {
self?.component.buttonPercentage = nil
self?.smallButtonGroup.buttonPercentage = nil
self?.component.childWidth = nil
self?.smallButtonGroup.childWidth = nil
}
}.store(in: &subscribers)
@ -155,7 +155,7 @@ class ButtonGroupViewController: BaseViewController<ButtonGroup> {
func setupModel() {
//setup UI
surfacePickerSelectorView.text = component.surface.rawValue
buttonPositionSelectorView.text = component.buttonPosition.rawValue
buttonPositionSelectorView.text = component.alignment.rawValue
disabledSwitch.isOn = !component.isEnabled
rowQuantitySelectorView.text = RowQuantity(quantity: component.rowQuantity).rawValue
widthTextField.text = ""
@ -172,8 +172,8 @@ class ButtonGroupViewController: BaseViewController<ButtonGroup> {
}
buttonPositionSelectorView.onPickerDidSelect = { [weak self] item in
self?.component.buttonPosition = item
self?.smallButtonGroup.buttonPosition = item
self?.component.alignment = item
self?.smallButtonGroup.alignment = item
}
rowQuantitySelectorView.onPickerDidSelect = { [weak self] item in
@ -184,8 +184,8 @@ class ButtonGroupViewController: BaseViewController<ButtonGroup> {
self?.percentageTextField.text = ""
} else {
self?.widthTextField.text = ""
self?.component.buttonWidth = nil
self?.smallButtonGroup.buttonWidth = nil
self?.component.childWidth = nil
self?.smallButtonGroup.childWidth = nil
}
if UIDevice.isIPad {

View File

@ -59,7 +59,7 @@ class CheckboxGroupViewController: BaseViewController<CheckboxGroup> {
component.onChange = { [weak self] group in
guard let label = self?.actionLabel else { return }
let selected = group.selectedHandlers?
let selected = group.selectedItems?
.compactMap{"\($0.labelText!)"}
.joined(separator: "\r") ?? "none selected"
@ -78,14 +78,14 @@ class CheckboxGroupViewController: BaseViewController<CheckboxGroup> {
}
func setupModel() {
var checkbox1 = CheckboxGroup.CheckboxModel()
var checkbox1 = CheckboxGroup.CheckboxItemModel()
checkbox1.inputId = "model1"
checkbox1.value = "model 1 Value"
checkbox1.labelText = "iPhone 11 Bundle 1"
checkbox1.childText = "Apple iPhone 11 - 64 GB\nOtterbox Case Red\nScreen Protector"
checkbox1.errorText = "Please Choose 1"
var checkbox2 = CheckboxGroup.CheckboxModel()
var checkbox2 = CheckboxGroup.CheckboxItemModel()
checkbox2.inputId = "model2"
checkbox2.value = "model 2 Value"
checkbox2.labelText = "iPhone 11 Bundle 2"
@ -104,7 +104,7 @@ class CheckboxGroupViewController: BaseViewController<CheckboxGroup> {
}
var checkbox: CheckboxItem? {
component.selectorViews.first
component.items.first
}
//Picker
@ -122,14 +122,14 @@ extension CheckboxGroupViewController: ComponentSampleable {
static func makeSample() -> ComponentSample {
let component = Self.makeComponent()
var checkbox1 = CheckboxGroup.CheckboxModel()
var checkbox1 = CheckboxGroup.CheckboxItemModel()
checkbox1.inputId = "model1"
checkbox1.value = "model 1 Value"
checkbox1.labelText = "iPhone 11 Bundle 1"
checkbox1.childText = "Apple iPhone 11 - 64 GB\nOtterbox Case Red\nScreen Protector"
checkbox1.errorText = "Please Choose 1"
var checkbox2 = CheckboxGroup.CheckboxModel()
var checkbox2 = CheckboxGroup.CheckboxItemModel()
checkbox2.inputId = "model2"
checkbox2.value = "model 2 Value"
checkbox2.labelText = "iPhone 11 Bundle 2"

View File

@ -117,7 +117,7 @@ class InputFieldViewController: BaseViewController<InputField> {
}
func setupModel() {
component.type = .text
component.fieldType = .text
component.width = 328
component.labelText = "Street Address"
component.helperText = "For example: 123 Verizon St"
@ -171,7 +171,7 @@ class InputFieldViewController: BaseViewController<InputField> {
extension InputFieldViewController: ComponentSampleable {
static func makeSample() -> ComponentSample {
let component = Self.makeComponent()
component.type = .text
component.fieldType = .text
component.width = 328
component.labelText = "Street Address"
component.helperText = "For example: 123 Verizon St"

View File

@ -17,10 +17,10 @@ class LabelViewController: BaseViewController<Label> {
picker: self.picker)
}()
lazy var textPositionPickerSelectorView = {
PickerSelectorView(title: TextPosition.left.rawValue,
lazy var textAlignmentPickerSelectorView = {
PickerSelectorView(title: TextAlignment.left.rawValue,
picker: self.picker,
items: TextPosition.allCases)
items: TextAlignment.allCases)
}()
lazy var fontCategoryPickerSelectorView = {
@ -102,6 +102,8 @@ class LabelViewController: BaseViewController<Label> {
}.store(in: &subscribers)
}
let sampleLabel = Label()
override func viewDidLoad() {
super.viewDidLoad()
@ -109,7 +111,6 @@ class LabelViewController: BaseViewController<Label> {
let fullText = "Here is a sample of text that has an inline text link that you can click on!"
let linkText = "inline text link"
let sampleLabel = Label()
sampleLabel.textStyle = .titleLarge
sampleLabel.text = fullText
@ -153,7 +154,7 @@ class LabelViewController: BaseViewController<Label> {
scaledLineHeightRow = addFormRow(label: "Use Scaled LineHeight", view: useScaledLineHeight)
checkForScaledFonts()
addFormRow(label: "Text Position", view: textPositionPickerSelectorView)
addFormRow(label: "Text Alignment", view: textAlignmentPickerSelectorView)
addFormRow(label: "Font Category", view: fontCategoryPickerSelectorView)
addFormRow(label: "Text Size", view: textSizePickerSelectorView)
addFormRow(label: "Text", view: textField)
@ -161,6 +162,7 @@ class LabelViewController: BaseViewController<Label> {
disabledSwitch.onChange = { [weak self] sender in
self?.component.isEnabled = !sender.isOn
self?.sampleLabel.isEnabled = !sender.isOn
}
boldSwitch
@ -326,8 +328,8 @@ class LabelViewController: BaseViewController<Label> {
self?.contentTopView.backgroundColor = item.color
}
textPositionPickerSelectorView.onPickerDidSelect = { [weak self] item in
self?.component.textPosition = item
textAlignmentPickerSelectorView.onPickerDidSelect = { [weak self] item in
self?.component.textAlignment = item.value
}
textSizePickerSelectorView.onPickerDidSelect = { [weak self] item in

View File

@ -85,7 +85,6 @@ class MenuViewController: UITableViewController, TooltipLaunchable {
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),
MenuComponent(title: "TextArea", completed: false, viewController: TextAreaViewController.self),

View File

@ -17,7 +17,6 @@ class NotificationViewController: BaseViewController<VDS.Notification> {
let firstButtonTextField = TextField()
let secondButtonTextField = TextField()
let hideCloseButtonToggle = Toggle()
let fullBleedToggle = Toggle()
let titleDefaultText = "This is title"
let subtitleDefaultText = "This is subtitle"
@ -53,13 +52,12 @@ class NotificationViewController: BaseViewController<VDS.Notification> {
override func setupForm() {
super.setupForm()
addFormRow(label: "Surface", view: surfacePickerSelectorView)
addFormRow(label: "Type", view: notificationTypePickerSelectorView)
addFormRow(label: "Style", view: notificationTypePickerSelectorView)
addFormRow(label: "Layout", view: layoutTypePickerSelectorView)
addFormRow(label: "Title", view: titleTextField)
addFormRow(label: "SubTitle", view: subTitleTextField)
addFormRow(label: "Hide Button Group", view: buttonGroupToggle)
addFormRow(label: "Hide Close Button", view: hideCloseButtonToggle)
addFormRow(label: "Full bleed", view: fullBleedToggle)
addFormRow(label: "Action", view: label)
addFormRow(label: "First Button Text", view: firstButtonTextField)
addFormRow(label: "Second Button Text", view: secondButtonTextField)
@ -107,9 +105,6 @@ class NotificationViewController: BaseViewController<VDS.Notification> {
self?.component.hideCloseButton = toggle.isOn
}
fullBleedToggle.onChange = { [weak self] toggle in
self?.component.fullBleed = toggle.isOn
}
}
func setupPicker() {
@ -119,7 +114,7 @@ class NotificationViewController: BaseViewController<VDS.Notification> {
}
notificationTypePickerSelectorView.onPickerDidSelect = { [weak self] item in
self?.component.type = item
self?.component.style = item
}
layoutTypePickerSelectorView.onPickerDidSelect = { [weak self] item in

View File

@ -67,15 +67,15 @@ class RadioBoxGroupViewController: BaseViewController<RadioBoxGroup>{
func setupModel(){
var radioBox1 = RadioBoxGroup.RadioBoxModel()
var radioBox1 = RadioBoxGroup.RadioBoxItemModel()
radioBox1.inputId = "model1"
radioBox1.selected = true
radioBox1.value = "model 1 Value"
radioBox1.text = "iPhone 11 Bundle 1"
radioBox1.subText = "Apple iPhone 11 - 64 GB\nOtterbox Case Red\nScreen Protector"
//radioBox1.subText = "Apple iPhone 11 - 64 GB\nOtterbox Case Red\nScreen Protector"
radioBox1.subTextRight = "Right Text"
var radioBox2 = RadioBoxGroup.RadioBoxModel()
var radioBox2 = RadioBoxGroup.RadioBoxItemModel()
radioBox2.inputId = "model2"
radioBox2.value = "model 2 Value"
radioBox2.text = "iPhone 11 Bundle 2"
@ -84,7 +84,7 @@ class RadioBoxGroupViewController: BaseViewController<RadioBoxGroup>{
component.selectorModels = [radioBox1, radioBox2]
component.onChange = { [weak self] group in
let newText = "Selected:\r\(group.selectedHandler?.text ?? "none")"
let newText = "Selected:\r\(group.selectedItem?.text ?? "none")"
self?.actionLabel.text = newText
}
@ -97,7 +97,7 @@ class RadioBoxGroupViewController: BaseViewController<RadioBoxGroup>{
}
var radioBox: RadioBoxItem? {
component.selectorViews.first
component.items.first
}
//Picker
@ -115,7 +115,7 @@ extension RadioBoxGroupViewController: ComponentSampleable {
static func makeSample() -> ComponentSample {
let component = Self.makeComponent()
var radioBox1 = RadioBoxGroup.RadioBoxModel()
var radioBox1 = RadioBoxGroup.RadioBoxItemModel()
radioBox1.inputId = "model1"
radioBox1.selected = true
radioBox1.value = "model 1 Value"
@ -123,7 +123,7 @@ extension RadioBoxGroupViewController: ComponentSampleable {
radioBox1.subText = "Apple iPhone 11 - 64 GB\nOtterbox Case Red\nScreen Protector"
radioBox1.subTextRight = "Right Text"
var radioBox2 = RadioBoxGroup.RadioBoxModel()
var radioBox2 = RadioBoxGroup.RadioBoxItemModel()
radioBox2.inputId = "model2"
radioBox2.value = "model 2 Value"
radioBox2.text = "iPhone 11 Bundle 2"

View File

@ -58,19 +58,19 @@ class RadioButtonGroupViewController: BaseViewController<RadioButtonGroup> {
}
func setupModel(){
var radioButton1 = RadioButtonGroup.RadioButtonModel()
var radioButton1 = RadioButtonGroup.RadioButtonItemModel()
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()
var radioButton2 = RadioButtonGroup.RadioButtonItemModel()
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()
var radioButton3 = RadioButtonGroup.RadioButtonItemModel()
radioButton3.inputId = "model3"
radioButton3.value = "model 3 Value"
radioButton3.labelText = "iPhone 11 Bundle 3"
@ -79,7 +79,7 @@ class RadioButtonGroupViewController: BaseViewController<RadioButtonGroup> {
component.selectorModels = [radioButton1, radioButton2, radioButton3]
component.onChange = { [weak self] group in
let newText = "Selected:\r\(group.selectedHandler?.labelText ?? "none")"
let newText = "Selected:\r\(group.selectedItem?.labelText ?? "none")"
self?.showErrorSwitch.isOn = group.showError
self?.actionLabel.text = newText
}
@ -93,7 +93,7 @@ class RadioButtonGroupViewController: BaseViewController<RadioButtonGroup> {
}
var radioButton: RadioButtonItem? {
component.selectorViews.first
component.items.first
}
//Picker
@ -113,19 +113,19 @@ extension RadioButtonGroupViewController: ComponentSampleable {
static func makeSample() -> ComponentSample {
let component = Self.makeComponent()
var radioButton1 = RadioButtonGroup.RadioButtonModel()
var radioButton1 = RadioButtonGroup.RadioButtonItemModel()
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()
var radioButton2 = RadioButtonGroup.RadioButtonItemModel()
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()
var radioButton3 = RadioButtonGroup.RadioButtonItemModel()
radioButton3.inputId = "model3"
radioButton3.value = "model 3 Value"
radioButton3.labelText = "iPhone 11 Bundle 3"

View File

@ -1,158 +0,0 @@
//
// RadioSwatchGroupViewController.swift
// VDSSample
//
// Created by Matt Bruce on 8/30/22.
//
import Foundation
import UIKit
import VDS
import VDSColorTokens
import Combine
class RadioSwatchGroupViewController: BaseViewController<RadioSwatchGroup> {
var disabledSwitch = Toggle()
var strikeThroughSwitch = Toggle()
override func viewDidLoad() {
super.viewDidLoad()
addContentTopView(view: component)
setupPicker()
setupModel()
}
override func setupForm() {
super.setupForm()
addFormRow(label: "Disabled", view: disabledSwitch)
addFormRow(label: "Surface", view: surfacePickerSelectorView)
addFormRow(label: "Strikethrough", view: strikeThroughSwitch)
disabledSwitch.onChange = { [weak self] sender in
self?.component.isEnabled = !sender.isOn
}
strikeThroughSwitch.onChange = { [weak self] sender in
self?.component.selectorViews.first?.strikethrough = sender.isOn
self?.component.reload()
}
}
func setupModel(){
var radioSwatch1 = RadioSwatchGroup.RadioSwatchModel()
radioSwatch1.fillImage = UIImage(named: "imageSwatch")
radioSwatch1.text = "Image"
radioSwatch1.inputId = "radioSwatch1"
var radioSwatch2 = RadioSwatchGroup.RadioSwatchModel()
radioSwatch2.primaryColor = .red
radioSwatch2.secondaryColor = .blue
radioSwatch2.text = "Red/Blue"
radioSwatch2.inputId = "radioSwatch2"
var radioSwatch3 = RadioSwatchGroup.RadioSwatchModel()
radioSwatch3.primaryColor = .green
radioSwatch3.text = "Green"
radioSwatch3.inputId = "radioSwatch3"
var radioSwatch4 = RadioSwatchGroup.RadioSwatchModel()
radioSwatch4.primaryColor = .orange
radioSwatch4.text = "Orange"
radioSwatch4.inputId = "radioSwatch4"
var radioSwatch5 = RadioSwatchGroup.RadioSwatchModel()
radioSwatch5.primaryColor = .brown
radioSwatch5.text = "Brown"
radioSwatch5.inputId = "radioSwatch5"
var radioSwatch6 = RadioSwatchGroup.RadioSwatchModel()
radioSwatch6.primaryColor = .yellow
radioSwatch6.text = "Yellow"
radioSwatch6.inputId = "radioSwatch6"
var radioSwatch7 = RadioSwatchGroup.RadioSwatchModel()
radioSwatch7.primaryColor = .purple
radioSwatch7.text = "Puple"
radioSwatch7.inputId = "radioSwatch7"
var radioSwatch8 = RadioSwatchGroup.RadioSwatchModel()
radioSwatch8.primaryColor = .systemPink
radioSwatch8.text = "Pink"
radioSwatch8.inputId = "radioSwatch8"
component.selectorModels = [radioSwatch1, radioSwatch2, radioSwatch3, radioSwatch4, radioSwatch5, radioSwatch6, radioSwatch7, radioSwatch8]
component.onChange = { group in
print("Selected: \(group.selectedHandler?.text ?? "none")")
}
//set UI values
surfacePickerSelectorView.text = component.surface.rawValue
disabledSwitch.isOn = !component.isEnabled
}
//Picker
func setupPicker(){
surfacePickerSelectorView.onPickerDidSelect = { [weak self] item in
self?.component.surface = item
self?.contentTopView.backgroundColor = item.color
}
}
}
extension RadioSwatchGroupViewController: ComponentSampleable {
static func makeSample() -> ComponentSample {
let component = Self.makeComponent()
var radioSwatch1 = RadioSwatchGroup.RadioSwatchModel()
radioSwatch1.fillImage = UIImage(named: "imageSwatch")
radioSwatch1.text = "Image"
radioSwatch1.inputId = "radioSwatch1"
var radioSwatch2 = RadioSwatchGroup.RadioSwatchModel()
radioSwatch2.primaryColor = .red
radioSwatch2.secondaryColor = .blue
radioSwatch2.text = "Red/Blue"
radioSwatch2.inputId = "radioSwatch2"
var radioSwatch3 = RadioSwatchGroup.RadioSwatchModel()
radioSwatch3.primaryColor = .green
radioSwatch3.text = "Green"
radioSwatch3.inputId = "radioSwatch3"
var radioSwatch4 = RadioSwatchGroup.RadioSwatchModel()
radioSwatch4.primaryColor = .orange
radioSwatch4.text = "Orange"
radioSwatch4.inputId = "radioSwatch4"
var radioSwatch5 = RadioSwatchGroup.RadioSwatchModel()
radioSwatch5.primaryColor = .brown
radioSwatch5.text = "Brown"
radioSwatch5.inputId = "radioSwatch5"
var radioSwatch6 = RadioSwatchGroup.RadioSwatchModel()
radioSwatch6.primaryColor = .yellow
radioSwatch6.text = "Yellow"
radioSwatch6.inputId = "radioSwatch6"
var radioSwatch7 = RadioSwatchGroup.RadioSwatchModel()
radioSwatch7.primaryColor = .purple
radioSwatch7.text = "Puple"
radioSwatch7.inputId = "radioSwatch7"
var radioSwatch8 = RadioSwatchGroup.RadioSwatchModel()
radioSwatch8.primaryColor = .systemPink
radioSwatch8.text = "Pink"
radioSwatch8.inputId = "radioSwatch8"
component.selectorModels = [radioSwatch1, radioSwatch2, radioSwatch3, radioSwatch4, radioSwatch5, radioSwatch6, radioSwatch7, radioSwatch8]
return ComponentSample(component: component)
}
}

View File

@ -96,8 +96,8 @@ class TileletViewController: BaseViewController<Tilelet> {
textWidthTextField
.numberPublisher
.sink { [weak self] number in
if let number = number?.cgFloatValue, number > 50.0 {
self?.component.textWidth = number
if let number {
self?.component.textWidth = .value(number.cgFloatValue)
self?.textPercentageTextField.text = ""
} else {
self?.component.textWidth = nil
@ -107,11 +107,11 @@ class TileletViewController: BaseViewController<Tilelet> {
textPercentageTextField
.numberPublisher
.sink { [weak self] number in
if let number, number.intValue > 15 && number.intValue <= 100 {
self?.component.textPercentage = number.cgFloatValue
if let number {
self?.component.textWidth = .percentage(number.cgFloatValue)
self?.textWidthTextField.text = ""
} else {
self?.component.textPercentage = nil
self?.component.textWidth = nil
}
}.store(in: &subscribers)

View File

@ -12,10 +12,10 @@ import VDSColorTokens
class TitleLockupViewController: BaseViewController<TitleLockup> {
lazy var textPositionPickerSelectorView = {
lazy var textAlignmentPickerSelectorView = {
PickerSelectorView(title: "left",
picker: self.picker,
items: TitleLockup.TextPosition.allCases)
items: TitleLockup.TextAlignment.allCases)
}()
lazy var titleStandardStylePickerSelectorView = {
@ -53,7 +53,7 @@ class TitleLockupViewController: BaseViewController<TitleLockup> {
override func setupForm(){
super.setupForm()
addFormRow(label: "Surface", view: surfacePickerSelectorView)
addFormRow(label: "Text Position", view: textPositionPickerSelectorView)
addFormRow(label: "Text Alignment", view: textAlignmentPickerSelectorView)
addFormRow(label: "Title is Bold", view: titleIsBold)
addFormRow(label: "Eyebrow is Bold", view: eyebrowIsBold)
@ -105,7 +105,7 @@ class TitleLockupViewController: BaseViewController<TitleLockup> {
//setup UI
surfacePickerSelectorView.text = component.surface.rawValue
textPositionPickerSelectorView.text = component.textPosition.rawValue
textAlignmentPickerSelectorView.text = TextAlignment.left.rawValue
otherStandardStylePickerSelectorView.text = subTitleModel.standardStyle.rawValue
titleStandardStylePickerSelectorView.text = titleModel.standardStyle.rawValue
subtitleColorPickerSelectorView.text = subTitleModel.textColor.rawValue
@ -166,8 +166,8 @@ class TitleLockupViewController: BaseViewController<TitleLockup> {
self?.contentTopView.backgroundColor = item.color
}
textPositionPickerSelectorView.onPickerDidSelect = { [weak self] item in
self?.component.textPosition = item
textAlignmentPickerSelectorView.onPickerDidSelect = { [weak self] item in
self?.component.textAlignment = item
}
titleStandardStylePickerSelectorView.onPickerDidSelect = { [weak self] item in

View File

@ -22,10 +22,10 @@ class TrailingTooltipLabelViewController: BaseViewController<TrailingTooltipLabe
picker: self.picker)
}()
lazy var textPositionPickerSelectorView = {
PickerSelectorView(title: TextPosition.left.rawValue,
lazy var textAlignmentPickerSelectorView = {
PickerSelectorView(title: TextAlignment.left.rawValue,
picker: self.picker,
items: TextPosition.allCases)
items: TextAlignment.allCases)
}()
var boldSwitch = Toggle()
@ -51,7 +51,7 @@ class TrailingTooltipLabelViewController: BaseViewController<TrailingTooltipLabe
addFormRow(label: "Disabled", view: disabledSwitch)
addFormRow(label: "Bold", view: boldSwitch)
addFormRow(label: "Surface", view: surfacePickerSelectorView)
addFormRow(label: "Text Position", view: textPositionPickerSelectorView)
addFormRow(label: "Text Alignment", view: textAlignmentPickerSelectorView)
addFormRow(label: "Font Category", view: fontCategoryPickerSelectorView)
addFormRow(label: "Text Size", view: textSizePickerSelectorView)
addFormRow(label: "Text", view: textField)
@ -154,8 +154,8 @@ class TrailingTooltipLabelViewController: BaseViewController<TrailingTooltipLabe
self?.contentTopView.backgroundColor = item.color
}
textPositionPickerSelectorView.onPickerDidSelect = { [weak self] item in
self?.component.labelTextPosition = item
textAlignmentPickerSelectorView.onPickerDidSelect = { [weak self] item in
self?.component.labelTextAlignment = item
}
textSizePickerSelectorView.onPickerDidSelect = { [weak self] item in