added checkbox vc

Signed-off-by: Matt Bruce <matt.bruce@verizon.com>
This commit is contained in:
Matt Bruce 2022-08-02 15:09:46 -05:00
parent c8f50a7f39
commit f2b426df9a
5 changed files with 288 additions and 3 deletions

View File

@ -25,6 +25,7 @@
EA3C3BC5289968B1000CA526 /* VDS.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = EA3C3BC3289968B1000CA526 /* VDS.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
EAF7F07C2899698800B287F5 /* Components.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = EAF7F07A2899698800B287F5 /* Components.storyboard */; };
EAF7F07D2899698800B287F5 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = EAF7F07B2899698800B287F5 /* Assets.xcassets */; };
EAF7F09C2899B92400B287F5 /* CheckboxViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = EAF7F09B2899B92400B287F5 /* CheckboxViewController.swift */; };
/* End PBXBuildFile section */
/* Begin PBXCopyFilesBuildPhase section */
@ -61,6 +62,7 @@
EA3C3BC3289968B1000CA526 /* VDS.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; path = VDS.framework; sourceTree = BUILT_PRODUCTS_DIR; };
EAF7F07A2899698800B287F5 /* Components.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; path = Components.storyboard; 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>"; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
@ -144,6 +146,7 @@
children = (
EA3C3BB228996775000CA526 /* MenuViewController.swift */,
EA3C3BB328996775000CA526 /* ToggleViewController.swift */,
EAF7F09B2899B92400B287F5 /* CheckboxViewController.swift */,
);
path = ViewControllers;
sourceTree = "<group>";
@ -227,6 +230,7 @@
EA3C3B9D289966EF000CA526 /* AppDelegate.swift in Sources */,
EA3C3B9F289966EF000CA526 /* SceneDelegate.swift in Sources */,
EA3C3BB428996775000CA526 /* PickerBase.swift in Sources */,
EAF7F09C2899B92400B287F5 /* CheckboxViewController.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};

View File

@ -279,7 +279,190 @@
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="Ief-a0-LHa" userLabel="First Responder" customClass="UIResponder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="-2033" y="-308"/>
<point key="canvasLocation" x="-4854" y="-313"/>
</scene>
<!--Checkbox View Controller-->
<scene sceneID="uvX-4a-eq3">
<objects>
<viewController storyboardIdentifier="checkbox" id="lmN-Xq-ewt" customClass="CheckboxViewController" customModule="VDSSample" customModuleProvider="target" sceneMemberID="viewController">
<view key="view" contentMode="scaleToFill" id="BOy-7Z-PS9">
<rect key="frame" x="0.0" y="0.0" width="414" height="896"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<subviews>
<stackView opaque="NO" contentMode="scaleToFill" axis="vertical" spacing="15" translatesAutoresizingMaskIntoConstraints="NO" id="hpQ-m4-0mG">
<rect key="frame" x="16" y="60" width="382" height="786"/>
<subviews>
<view contentMode="scaleToFill" ambiguous="YES" translatesAutoresizingMaskIntoConstraints="NO" id="scQ-pX-VeB" userLabel="Top">
<rect key="frame" x="0.0" y="0.0" width="382" height="100"/>
<color key="backgroundColor" systemColor="systemBackgroundColor"/>
</view>
<view contentMode="scaleToFill" ambiguous="YES" translatesAutoresizingMaskIntoConstraints="NO" id="XSu-xa-jsA" userLabel="Bottom">
<rect key="frame" x="0.0" y="115" width="382" height="671"/>
<subviews>
<stackView opaque="NO" contentMode="scaleToFill" axis="vertical" distribution="fillProportionally" spacing="10" translatesAutoresizingMaskIntoConstraints="NO" id="MRW-0g-0NJ">
<rect key="frame" x="16" y="20" width="350" height="254"/>
<subviews>
<stackView opaque="NO" contentMode="scaleToFill" distribution="fillEqually" translatesAutoresizingMaskIntoConstraints="NO" id="w4N-so-18m">
<rect key="frame" x="0.0" y="0.0" width="350" height="31"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Disabled" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="YMB-vV-642">
<rect key="frame" x="0.0" y="0.0" width="175" height="31"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
<switch opaque="NO" contentMode="scaleToFill" horizontalHuggingPriority="750" verticalHuggingPriority="750" contentHorizontalAlignment="center" contentVerticalAlignment="center" translatesAutoresizingMaskIntoConstraints="NO" id="2Ko-LD-7KV">
<rect key="frame" x="175" y="0.0" width="177" height="31"/>
<connections>
<action selector="disabledChanged:" destination="lmN-Xq-ewt" eventType="touchUpInside" id="dQe-eL-yYZ"/>
</connections>
</switch>
</subviews>
</stackView>
<stackView opaque="NO" contentMode="scaleToFill" distribution="fillEqually" translatesAutoresizingMaskIntoConstraints="NO" id="rhg-PV-y7E">
<rect key="frame" x="0.0" y="41" width="350" height="40"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Surface" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="yeW-xB-inh">
<rect key="frame" x="0.0" y="0.0" width="175" height="40"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
<stackView opaque="NO" contentMode="scaleToFill" distribution="fillEqually" translatesAutoresizingMaskIntoConstraints="NO" id="Omm-F0-HeM">
<rect key="frame" x="175" y="0.0" width="175" height="40"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="light" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="QJe-b9-yOV">
<rect key="frame" x="0.0" y="0.0" width="87.5" height="40"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="era-YD-0an">
<rect key="frame" x="87.5" y="0.0" width="87.5" height="40"/>
<constraints>
<constraint firstAttribute="height" constant="40" id="mUL-Kz-AHv"/>
</constraints>
<state key="normal" title="Button"/>
<buttonConfiguration key="configuration" style="filled" title="Select"/>
<connections>
<action selector="surfaceClick:" destination="lmN-Xq-ewt" eventType="touchUpInside" id="eX5-xp-A0g"/>
</connections>
</button>
</subviews>
</stackView>
</subviews>
</stackView>
<stackView opaque="NO" contentMode="scaleToFill" distribution="fillEqually" translatesAutoresizingMaskIntoConstraints="NO" id="Ajy-km-g0n">
<rect key="frame" x="0.0" y="91" width="350" height="34"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label Text" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="FEh-ea-Te2">
<rect key="frame" x="0.0" y="0.0" width="175" height="34"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
<textField opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" borderStyle="roundedRect" textAlignment="natural" minimumFontSize="17" translatesAutoresizingMaskIntoConstraints="NO" id="L04-kA-ok2">
<rect key="frame" x="175" y="0.0" width="175" height="34"/>
<fontDescription key="fontDescription" type="system" pointSize="14"/>
<textInputTraits key="textInputTraits"/>
<connections>
<action selector="onLabelTextDidEnd:" destination="lmN-Xq-ewt" eventType="editingDidEnd" id="O4v-8h-MF6"/>
</connections>
</textField>
</subviews>
</stackView>
<stackView opaque="NO" contentMode="scaleToFill" distribution="fillEqually" translatesAutoresizingMaskIntoConstraints="NO" id="Umz-Za-DbL">
<rect key="frame" x="0.0" y="135" width="350" height="34"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Child Text" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Vty-Wk-de3">
<rect key="frame" x="0.0" y="0.0" width="175" height="34"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
<textField opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" borderStyle="roundedRect" textAlignment="natural" minimumFontSize="17" translatesAutoresizingMaskIntoConstraints="NO" id="The-la-7yI">
<rect key="frame" x="175" y="0.0" width="175" height="34"/>
<fontDescription key="fontDescription" type="system" pointSize="14"/>
<textInputTraits key="textInputTraits"/>
<connections>
<action selector="onChildTextDidEnd:" destination="lmN-Xq-ewt" eventType="editingDidEnd" id="vbd-bR-UaB"/>
</connections>
</textField>
</subviews>
</stackView>
<stackView opaque="NO" contentMode="scaleToFill" distribution="fillEqually" translatesAutoresizingMaskIntoConstraints="NO" id="BIm-Fc-kLE">
<rect key="frame" x="0.0" y="179" width="350" height="31"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Error" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="4EX-lO-Hoy">
<rect key="frame" x="0.0" y="0.0" width="175" height="31"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
<switch opaque="NO" contentMode="scaleToFill" horizontalHuggingPriority="750" verticalHuggingPriority="750" contentHorizontalAlignment="center" contentVerticalAlignment="center" translatesAutoresizingMaskIntoConstraints="NO" id="GEz-RV-j2l">
<rect key="frame" x="175" y="0.0" width="177" height="31"/>
<connections>
<action selector="showErrorChanged:" destination="lmN-Xq-ewt" eventType="touchUpInside" id="2at-8B-gZL"/>
</connections>
</switch>
</subviews>
</stackView>
<stackView opaque="NO" contentMode="scaleToFill" distribution="fillEqually" translatesAutoresizingMaskIntoConstraints="NO" id="Ucj-3a-R6d">
<rect key="frame" x="0.0" y="220" width="350" height="34"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Error Text" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="c8E-rN-LuU">
<rect key="frame" x="0.0" y="0.0" width="175" height="34"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
<textField opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" borderStyle="roundedRect" textAlignment="natural" minimumFontSize="17" translatesAutoresizingMaskIntoConstraints="NO" id="bTZ-cJ-HFn">
<rect key="frame" x="175" y="0.0" width="175" height="34"/>
<fontDescription key="fontDescription" type="system" pointSize="14"/>
<textInputTraits key="textInputTraits"/>
<connections>
<action selector="onErrorTextDidEnd:" destination="lmN-Xq-ewt" eventType="editingDidEnd" id="OUp-YD-qh4"/>
</connections>
</textField>
</subviews>
</stackView>
</subviews>
</stackView>
</subviews>
<color key="backgroundColor" systemColor="systemBackgroundColor"/>
<constraints>
<constraint firstItem="MRW-0g-0NJ" firstAttribute="top" secondItem="XSu-xa-jsA" secondAttribute="top" constant="20" id="C0y-eV-f3U"/>
<constraint firstItem="MRW-0g-0NJ" firstAttribute="leading" secondItem="XSu-xa-jsA" secondAttribute="leading" constant="16" id="Wpb-Ew-e3q"/>
<constraint firstAttribute="trailing" secondItem="MRW-0g-0NJ" secondAttribute="trailing" constant="16" id="tx9-nO-DIF"/>
</constraints>
</view>
</subviews>
</stackView>
<pickerView contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="fgL-1d-z5o">
<rect key="frame" x="0.0" y="646" width="414" height="216"/>
</pickerView>
</subviews>
<viewLayoutGuide key="safeArea" id="vjw-e9-AAB"/>
<color key="backgroundColor" systemColor="systemBackgroundColor"/>
<constraints>
<constraint firstItem="vjw-e9-AAB" firstAttribute="trailing" secondItem="hpQ-m4-0mG" secondAttribute="trailing" constant="16" id="Hxl-pG-iPX"/>
<constraint firstItem="fgL-1d-z5o" firstAttribute="trailing" secondItem="vjw-e9-AAB" secondAttribute="trailing" id="OdQ-nZ-Oy9"/>
<constraint firstItem="vjw-e9-AAB" firstAttribute="bottom" secondItem="hpQ-m4-0mG" secondAttribute="bottom" constant="16" id="X1V-gZ-SRx"/>
<constraint firstItem="vjw-e9-AAB" firstAttribute="bottom" secondItem="fgL-1d-z5o" secondAttribute="bottom" id="XUy-N0-Cdg"/>
<constraint firstItem="hpQ-m4-0mG" firstAttribute="leading" secondItem="vjw-e9-AAB" secondAttribute="leading" constant="16" id="Y8V-Dk-7gM"/>
<constraint firstItem="fgL-1d-z5o" firstAttribute="leading" secondItem="vjw-e9-AAB" secondAttribute="leading" id="r7h-PN-RR8"/>
<constraint firstItem="hpQ-m4-0mG" firstAttribute="top" secondItem="vjw-e9-AAB" secondAttribute="top" constant="16" id="wVk-8a-K1z"/>
</constraints>
</view>
<connections>
<outlet property="checkboxContainerView" destination="scQ-pX-VeB" id="iK2-ur-gRa"/>
<outlet property="picker" destination="fgL-1d-z5o" id="odl-mn-oGC"/>
<outlet property="surfaceLabel" destination="QJe-b9-yOV" id="rkJ-CZ-ZdE"/>
</connections>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="Oec-kV-gky" userLabel="First Responder" customClass="UIResponder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="-3880" y="-313"/>
</scene>
</scenes>
<resources>

View File

@ -0,0 +1,95 @@
//
// CheckboxViewController.swift
// VDSSample
//
// Created by Matt Bruce on 8/1/22.
//
import Foundation
import UIKit
import VDS
import VDSColorTokens
class CheckboxViewController: UIViewController, StoryboardInitable {
enum PickerType {
case surface
}
static var storyboardId: String = "checkbox"
static var storyboardName: String = "Components"
@IBOutlet weak var checkboxContainerView: UIView!
@IBOutlet weak var picker: UIPickerView!
@IBOutlet weak var surfaceLabel: UILabel!
var checkbox: VDSCheckbox!
override func viewDidLoad() {
super.viewDidLoad()
checkbox = VDSCheckbox()
checkbox.translatesAutoresizingMaskIntoConstraints = false
checkboxContainerView.addSubview(checkbox)
checkbox.leadingAnchor.constraint(equalTo: checkboxContainerView.leadingAnchor, constant: 20).isActive = true
checkbox.bottomAnchor.constraint(equalTo: checkboxContainerView.bottomAnchor, constant: -20).isActive = true
checkbox.topAnchor.constraint(equalTo: checkboxContainerView.topAnchor, constant: 20).isActive = true
view.addGestureRecognizer(UITapGestureRecognizer(target: self.view, action: #selector(UIView.endEditing(_:))))
setupPicker()
}
@IBAction func disabledChanged(_ sender: UISwitch) {
checkbox.disabled = sender.isOn
}
@IBAction func onLabelTextDidEnd(_ sender: UITextField) {
checkbox.labelText = sender.text
sender.resignFirstResponder()
}
@IBAction func onChildTextDidEnd(_ sender: UITextField) {
checkbox.childText = sender.text
sender.resignFirstResponder()
}
@IBAction func showErrorChanged(_ sender: UISwitch) {
checkbox.disabled = sender.isOn
}
@IBAction func onErrorTextDidEnd(_ sender: UITextField) {
checkbox.errorText = sender.text
sender.resignFirstResponder()
}
@IBAction func surfaceClick(_ sender: Any) {
pickerType = .surface
}
//Picker
var surfacePicker = SurfacePicker()
var pickerType: PickerType = .surface {
didSet {
func update(object: UIPickerViewDelegate & UIPickerViewDataSource){
picker.delegate = object
picker.dataSource = object
}
switch pickerType{
case .surface:
update(object: surfacePicker)
}
picker.reloadAllComponents()
picker.selectRow(0, inComponent: 0, animated: false)
picker.isHidden = false
}
}
func setupPicker(){
picker.isHidden = true
surfacePicker.onPickerDidSelect = { item in
self.checkbox.surface = item
self.checkboxContainerView.backgroundColor = item.color
self.surfaceLabel.text = item.rawValue
}
}
}

View File

@ -14,7 +14,10 @@ struct MenuComponent {
}
class MenuViewController: UITableViewController {
let items: [MenuComponent] = [MenuComponent(title: "Toggle", viewController: ToggleViewController.self)]
let items: [MenuComponent] = [
MenuComponent(title: "Toggle", viewController: ToggleViewController.self),
MenuComponent(title: "Checkbox", viewController: CheckboxViewController.self)
]
override func numberOfSections(in tableView: UITableView) -> Int {
1

View File

@ -14,7 +14,7 @@ class ToggleViewController: UIViewController, StoryboardInitable {
enum PickerType {
case surface, textSize, textPosition, fontWeight
}
static var storyboardId: String = "toggle"
static var storyboardId: String = "checkbox"
static var storyboardName: String = "Components"
@IBOutlet weak var toggleContainerView: UIView!