added RadioBoxGroup viewcontroller
Signed-off-by: Matt Bruce <matt.bruce@verizon.com>
This commit is contained in:
parent
94b2c9e533
commit
cd62738818
@ -41,6 +41,7 @@
|
||||
EA3C3BB628996775000CA526 /* MenuViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA3C3BB228996775000CA526 /* MenuViewController.swift */; };
|
||||
EA3C3BB728996775000CA526 /* ToggleViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA3C3BB328996775000CA526 /* ToggleViewController.swift */; };
|
||||
EA89200A28B52934006B9984 /* CheckboxGroupViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA89200928B52934006B9984 /* CheckboxGroupViewController.swift */; };
|
||||
EA89201928B56DF5006B9984 /* RadioBoxGroupViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA89201828B56DF5006B9984 /* RadioBoxGroupViewController.swift */; };
|
||||
EAB1D2C528A6B11D00DAE764 /* TestViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = EAB1D2C428A6B11D00DAE764 /* TestViewController.swift */; };
|
||||
EAB1D2C928AAAA1D00DAE764 /* ModelViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = EAB1D2C828AAAA1D00DAE764 /* ModelViewController.swift */; };
|
||||
EAB1D2CB28AAB9E200DAE764 /* TemplateViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = EAB1D2CA28AAB9E200DAE764 /* TemplateViewController.swift */; };
|
||||
@ -95,6 +96,7 @@
|
||||
EA3C3BBB289968A0000CA526 /* VDSFormControlsTokens.xcframework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcframework; name = VDSFormControlsTokens.xcframework; path = ../SharedFrameworks/VDSFormControlsTokens.xcframework; sourceTree = "<group>"; };
|
||||
EA3C3BC3289968B1000CA526 /* VDS.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; path = VDS.framework; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
EA89200928B52934006B9984 /* CheckboxGroupViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CheckboxGroupViewController.swift; sourceTree = "<group>"; };
|
||||
EA89201828B56DF5006B9984 /* RadioBoxGroupViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RadioBoxGroupViewController.swift; sourceTree = "<group>"; };
|
||||
EAB1D2C428A6B11D00DAE764 /* TestViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TestViewController.swift; sourceTree = "<group>"; };
|
||||
EAB1D2C828AAAA1D00DAE764 /* ModelViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ModelViewController.swift; sourceTree = "<group>"; };
|
||||
EAB1D2CA28AAB9E200DAE764 /* TemplateViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TemplateViewController.swift; sourceTree = "<group>"; };
|
||||
@ -205,15 +207,16 @@
|
||||
EAF7F07F28996A1900B287F5 /* ViewControllers */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
EAF7F09B2899B92400B287F5 /* CheckboxViewController.swift */,
|
||||
EA89200928B52934006B9984 /* CheckboxGroupViewController.swift */,
|
||||
EA3C3BB228996775000CA526 /* MenuViewController.swift */,
|
||||
EAF7F11928A14A0E00B287F5 /* RadioButtonViewController.swift */,
|
||||
EA3C3BB328996775000CA526 /* ToggleViewController.swift */,
|
||||
EAB1D2C428A6B11D00DAE764 /* TestViewController.swift */,
|
||||
EAB1D2C828AAAA1D00DAE764 /* ModelViewController.swift */,
|
||||
EAB1D2CA28AAB9E200DAE764 /* TemplateViewController.swift */,
|
||||
EA89200928B52934006B9984 /* CheckboxGroupViewController.swift */,
|
||||
EAF7F09B2899B92400B287F5 /* CheckboxViewController.swift */,
|
||||
EAB1D2D328AC409F00DAE764 /* LabelViewController.swift */,
|
||||
EAB1D2C828AAAA1D00DAE764 /* ModelViewController.swift */,
|
||||
EA89201828B56DF5006B9984 /* RadioBoxGroupViewController.swift */,
|
||||
EAF7F11928A14A0E00B287F5 /* RadioButtonViewController.swift */,
|
||||
EAB1D2CA28AAB9E200DAE764 /* TemplateViewController.swift */,
|
||||
EAB1D2C428A6B11D00DAE764 /* TestViewController.swift */,
|
||||
EA3C3BB328996775000CA526 /* ToggleViewController.swift */,
|
||||
);
|
||||
path = ViewControllers;
|
||||
sourceTree = "<group>";
|
||||
@ -360,6 +363,7 @@
|
||||
files = (
|
||||
EA3C3BB728996775000CA526 /* ToggleViewController.swift in Sources */,
|
||||
EA3C3BB528996775000CA526 /* StoryboardInitable.swift in Sources */,
|
||||
EA89201928B56DF5006B9984 /* RadioBoxGroupViewController.swift in Sources */,
|
||||
EA3C3BB628996775000CA526 /* MenuViewController.swift in Sources */,
|
||||
EA3C3B9D289966EF000CA526 /* AppDelegate.swift in Sources */,
|
||||
EAF7F11A28A14A0E00B287F5 /* RadioButtonViewController.swift in Sources */,
|
||||
|
||||
@ -1004,6 +1004,194 @@
|
||||
</objects>
|
||||
<point key="canvasLocation" x="-3946" y="376"/>
|
||||
</scene>
|
||||
<!--Radio Box Group View Controller-->
|
||||
<scene sceneID="Jc7-QN-Oyh">
|
||||
<objects>
|
||||
<viewController storyboardIdentifier="radioBoxGroup" id="fgI-TI-C3s" customClass="RadioBoxGroupViewController" customModule="VDSSample" customModuleProvider="target" sceneMemberID="viewController">
|
||||
<view key="view" contentMode="scaleToFill" id="y9n-qS-eZp">
|
||||
<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="2aX-B0-agZ">
|
||||
<rect key="frame" x="16" y="64" width="382" height="782"/>
|
||||
<subviews>
|
||||
<view contentMode="scaleToFill" ambiguous="YES" translatesAutoresizingMaskIntoConstraints="NO" id="z07-or-F30" 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="GcY-Sa-8vI" userLabel="Bottom">
|
||||
<rect key="frame" x="0.0" y="115" width="382" height="667"/>
|
||||
<subviews>
|
||||
<stackView opaque="NO" contentMode="scaleToFill" axis="vertical" distribution="fillProportionally" spacing="10" translatesAutoresizingMaskIntoConstraints="NO" id="8bh-zi-Pgc">
|
||||
<rect key="frame" x="16" y="20" width="350" height="254"/>
|
||||
<subviews>
|
||||
<stackView opaque="NO" contentMode="scaleToFill" distribution="fillEqually" translatesAutoresizingMaskIntoConstraints="NO" id="SAY-nu-uQ0">
|
||||
<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="i4i-uZ-E0F">
|
||||
<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="nbA-JN-JpW">
|
||||
<rect key="frame" x="175" y="0.0" width="177" height="31"/>
|
||||
<connections>
|
||||
<action selector="disabledChanged:" destination="fgI-TI-C3s" eventType="touchUpInside" id="cAf-fp-Ewh"/>
|
||||
</connections>
|
||||
</switch>
|
||||
</subviews>
|
||||
</stackView>
|
||||
<stackView opaque="NO" contentMode="scaleToFill" distribution="fillEqually" translatesAutoresizingMaskIntoConstraints="NO" id="KUo-4P-Vk9">
|
||||
<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="VsL-wo-up8">
|
||||
<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="fyy-pG-Uid">
|
||||
<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="eD1-mB-JZc">
|
||||
<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="60H-9w-O2L">
|
||||
<rect key="frame" x="87.5" y="0.0" width="87.5" height="40"/>
|
||||
<constraints>
|
||||
<constraint firstAttribute="height" constant="40" id="Ptz-ea-anP"/>
|
||||
</constraints>
|
||||
<state key="normal" title="Button"/>
|
||||
<buttonConfiguration key="configuration" style="filled" title="Select"/>
|
||||
<connections>
|
||||
<action selector="surfaceClick:" destination="fgI-TI-C3s" eventType="touchUpInside" id="t2F-l9-8gk"/>
|
||||
</connections>
|
||||
</button>
|
||||
</subviews>
|
||||
</stackView>
|
||||
</subviews>
|
||||
</stackView>
|
||||
<stackView opaque="NO" contentMode="scaleToFill" distribution="fillEqually" translatesAutoresizingMaskIntoConstraints="NO" id="myw-qq-98G">
|
||||
<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="Text" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="dRd-OL-Onj">
|
||||
<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="Gf7-Fp-OfF">
|
||||
<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="onTextDidEnd:" destination="fgI-TI-C3s" eventType="editingDidEnd" id="7fv-jf-K2p"/>
|
||||
</connections>
|
||||
</textField>
|
||||
</subviews>
|
||||
</stackView>
|
||||
<stackView opaque="NO" contentMode="scaleToFill" distribution="fillEqually" translatesAutoresizingMaskIntoConstraints="NO" id="hvp-Xh-K7n">
|
||||
<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="Sub Text" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Eel-y3-NxY">
|
||||
<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="9h6-Tt-xpX">
|
||||
<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="onSubTextDidEnd:" destination="fgI-TI-C3s" eventType="editingDidEnd" id="dAD-Es-4V0"/>
|
||||
</connections>
|
||||
</textField>
|
||||
</subviews>
|
||||
</stackView>
|
||||
<stackView opaque="NO" contentMode="scaleToFill" distribution="fillEqually" translatesAutoresizingMaskIntoConstraints="NO" id="oua-dN-DLE">
|
||||
<rect key="frame" x="0.0" y="179" width="350" height="34"/>
|
||||
<subviews>
|
||||
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Sub Text Right" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="5qv-82-dwP">
|
||||
<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="ILQ-1C-zG3">
|
||||
<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="onSubTextRightDidEnd:" destination="fgI-TI-C3s" eventType="editingDidEnd" id="Lbu-Kq-jhd"/>
|
||||
</connections>
|
||||
</textField>
|
||||
</subviews>
|
||||
</stackView>
|
||||
<stackView opaque="NO" contentMode="scaleToFill" distribution="fillEqually" translatesAutoresizingMaskIntoConstraints="NO" id="sm7-oC-PRd">
|
||||
<rect key="frame" x="0.0" y="223" 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="7Ad-oM-blw">
|
||||
<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="VaV-n7-loR">
|
||||
<rect key="frame" x="175" y="0.0" width="177" height="31"/>
|
||||
<connections>
|
||||
<action selector="showErrorChanged:" destination="fgI-TI-C3s" eventType="touchUpInside" id="COb-cO-UZB"/>
|
||||
</connections>
|
||||
</switch>
|
||||
</subviews>
|
||||
</stackView>
|
||||
</subviews>
|
||||
</stackView>
|
||||
</subviews>
|
||||
<color key="backgroundColor" systemColor="systemBackgroundColor"/>
|
||||
<constraints>
|
||||
<constraint firstItem="8bh-zi-Pgc" firstAttribute="leading" secondItem="GcY-Sa-8vI" secondAttribute="leading" constant="16" id="hOU-GR-dFn"/>
|
||||
<constraint firstAttribute="trailing" secondItem="8bh-zi-Pgc" secondAttribute="trailing" constant="16" id="i2Q-xM-mtq"/>
|
||||
<constraint firstItem="8bh-zi-Pgc" firstAttribute="top" secondItem="GcY-Sa-8vI" secondAttribute="top" constant="20" id="xBv-11-U2Q"/>
|
||||
</constraints>
|
||||
</view>
|
||||
</subviews>
|
||||
</stackView>
|
||||
<pickerView contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="mrl-UK-HAg">
|
||||
<rect key="frame" x="0.0" y="646" width="414" height="216"/>
|
||||
</pickerView>
|
||||
</subviews>
|
||||
<viewLayoutGuide key="safeArea" id="Mxs-Jp-7Nd"/>
|
||||
<color key="backgroundColor" systemColor="systemBackgroundColor"/>
|
||||
<constraints>
|
||||
<constraint firstItem="Mxs-Jp-7Nd" firstAttribute="bottom" secondItem="mrl-UK-HAg" secondAttribute="bottom" id="2KQ-tT-HJG"/>
|
||||
<constraint firstItem="Mxs-Jp-7Nd" firstAttribute="bottom" secondItem="2aX-B0-agZ" secondAttribute="bottom" constant="16" id="8A6-TD-yEk"/>
|
||||
<constraint firstItem="2aX-B0-agZ" firstAttribute="top" secondItem="Mxs-Jp-7Nd" secondAttribute="top" constant="16" id="BI0-mb-XnP"/>
|
||||
<constraint firstItem="Mxs-Jp-7Nd" firstAttribute="trailing" secondItem="2aX-B0-agZ" secondAttribute="trailing" constant="16" id="Qos-fK-bsT"/>
|
||||
<constraint firstItem="2aX-B0-agZ" firstAttribute="leading" secondItem="Mxs-Jp-7Nd" secondAttribute="leading" constant="16" id="Vkh-Wp-gvm"/>
|
||||
<constraint firstItem="mrl-UK-HAg" firstAttribute="leading" secondItem="Mxs-Jp-7Nd" secondAttribute="leading" id="ege-jK-elU"/>
|
||||
<constraint firstItem="mrl-UK-HAg" firstAttribute="trailing" secondItem="Mxs-Jp-7Nd" secondAttribute="trailing" id="w0R-nQ-vfC"/>
|
||||
</constraints>
|
||||
</view>
|
||||
<connections>
|
||||
<outlet property="componentContainerView" destination="z07-or-F30" id="usY-yu-WSx"/>
|
||||
<outlet property="disabledSwitch" destination="nbA-JN-JpW" id="Rp0-hc-vMv"/>
|
||||
<outlet property="picker" destination="mrl-UK-HAg" id="HPf-KF-Ng2"/>
|
||||
<outlet property="showErrorSwitch" destination="VaV-n7-loR" id="H4s-im-CAi"/>
|
||||
<outlet property="subTextField" destination="9h6-Tt-xpX" id="MBl-iC-LGf"/>
|
||||
<outlet property="subTextRightField" destination="ILQ-1C-zG3" id="BtI-sC-Naa"/>
|
||||
<outlet property="surfaceLabel" destination="eD1-mB-JZc" id="H47-W1-s9c"/>
|
||||
<outlet property="textField" destination="Gf7-Fp-OfF" id="IoP-r1-bIa"/>
|
||||
</connections>
|
||||
</viewController>
|
||||
<placeholder placeholderIdentifier="IBFirstResponder" id="jNM-E9-r6H" userLabel="First Responder" customClass="UIResponder" sceneMemberID="firstResponder"/>
|
||||
</objects>
|
||||
<point key="canvasLocation" x="-3075" y="-313"/>
|
||||
</scene>
|
||||
</scenes>
|
||||
<resources>
|
||||
<systemColor name="systemBackgroundColor">
|
||||
|
||||
@ -24,6 +24,7 @@ class MenuViewController: UITableViewController {
|
||||
MenuComponent(title: "Checkbox", viewController: CheckboxViewController.self),
|
||||
MenuComponent(title: "CheckboxGroup", viewController: CheckboxGroupViewController.self),
|
||||
MenuComponent(title: "RadioButton", viewController: RadioButtonViewController.self),
|
||||
MenuComponent(title: "RadioBoxGroup", viewController: RadioBoxGroupViewController.self),
|
||||
MenuComponent(title: "Test Form", viewController: TestViewController.self),
|
||||
MenuComponent(title: "Template", viewController: TemplateViewController.self)
|
||||
]
|
||||
|
||||
150
VDSSample/ViewControllers/RadioBoxGroupViewController.swift
Normal file
150
VDSSample/ViewControllers/RadioBoxGroupViewController.swift
Normal file
@ -0,0 +1,150 @@
|
||||
//
|
||||
// RadioBoxGroupViewController.swift
|
||||
// VDSSample
|
||||
//
|
||||
// Created by Matt Bruce on 8/23/22.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import UIKit
|
||||
import VDS
|
||||
import VDSColorTokens
|
||||
import Combine
|
||||
|
||||
class RadioBoxGroupViewController: ModelViewController<DefaultRadioBoxGroupModel>, StoryboardInitable {
|
||||
deinit {
|
||||
print("\(Self.self) deinit")
|
||||
}
|
||||
|
||||
enum PickerType {
|
||||
case surface
|
||||
}
|
||||
static var storyboardId: String = "radioBoxGroup"
|
||||
static var storyboardName: String = "Components"
|
||||
|
||||
@IBOutlet weak var componentContainerView: UIView!
|
||||
@IBOutlet weak var disabledSwitch: UISwitch!
|
||||
@IBOutlet weak var picker: UIPickerView!
|
||||
@IBOutlet weak var surfaceLabel: UILabel!
|
||||
@IBOutlet weak var textField: UITextField!
|
||||
@IBOutlet weak var subTextField: UITextField!
|
||||
@IBOutlet weak var subTextRightField: UITextField!
|
||||
@IBOutlet weak var showErrorSwitch: UISwitch!
|
||||
|
||||
var radioBoxGroup = RadioBoxGroup()
|
||||
|
||||
override func viewDidLoad() {
|
||||
super.viewDidLoad()
|
||||
view.addGestureRecognizer(UITapGestureRecognizer(target: self.view, action: #selector(UIView.endEditing(_:))))
|
||||
|
||||
componentContainerView.addSubview(radioBoxGroup)
|
||||
radioBoxGroup.leadingAnchor.constraint(equalTo: componentContainerView.leadingAnchor, constant: 10).isActive = true
|
||||
radioBoxGroup.topAnchor.constraint(equalTo: componentContainerView.topAnchor, constant: 20).isActive = true
|
||||
radioBoxGroup.bottomAnchor.constraint(equalTo: componentContainerView.bottomAnchor, constant: -20).isActive = true
|
||||
radioBoxGroup.trailingAnchor.constraint(equalTo: componentContainerView.trailingAnchor, constant: 10).isActive = true
|
||||
setupPicker()
|
||||
setupModel()
|
||||
}
|
||||
|
||||
func setupModel(){
|
||||
var defaultModel = DefaultRadioBoxGroupModel()
|
||||
var model1 = DefaultRadioBoxModel()
|
||||
model1.value = "model 1 Value"
|
||||
model1.text = "iPhone 11 Bundle 1"
|
||||
model1.subText = "Apple iPhone 11 - 64 GB\nOtterbox Case Red\nScreen Protector"
|
||||
model1.subTextRight = "Right Text"
|
||||
|
||||
var model2 = DefaultRadioBoxModel()
|
||||
model2.strikethrough = true
|
||||
model2.value = "model 2 Value"
|
||||
model2.text = "iPhone 11 Bundle 2"
|
||||
model2.subText = "Apple iPhone 11 - 128 GB\nOtterbox Case Black\nScreen Protector"
|
||||
|
||||
defaultModel.selectors = [model1, model2]
|
||||
set(with: defaultModel)
|
||||
|
||||
//update the model
|
||||
radioBoxGroup
|
||||
.handlerPublisher()
|
||||
.sink { [weak self] updatedModel in
|
||||
self?.model = updatedModel
|
||||
self?.showErrorSwitch.isOn = updatedModel.hasError
|
||||
self?.disabledSwitch.isOn = updatedModel.disabled
|
||||
}
|
||||
.store(in: &subscribers)
|
||||
|
||||
//set UI values
|
||||
surfaceLabel.text = model.surface.rawValue
|
||||
disabledSwitch.isOn = model.disabled
|
||||
showErrorSwitch.isOn = model.hasError
|
||||
textField.text = model1.text
|
||||
subTextField.text = model1.subText
|
||||
subTextRightField.text = model1.subTextRight
|
||||
}
|
||||
|
||||
override func updateView(viewModel: ModelType) {
|
||||
print("\(Self.self) updateView(viewModel)")
|
||||
showErrorSwitch.isOn = viewModel.hasError
|
||||
disabledSwitch.isOn = viewModel.disabled
|
||||
radioBoxGroup.set(with: viewModel)
|
||||
}
|
||||
|
||||
var radioBox: RadioBox? {
|
||||
radioBoxGroup.selectorViews.first
|
||||
}
|
||||
@IBAction func disabledChanged(_ sender: UISwitch) {
|
||||
radioBoxGroup.disabled = sender.isOn
|
||||
}
|
||||
|
||||
@IBAction func onTextDidEnd(_ sender: UITextField) {
|
||||
radioBox?.text = sender.text ?? "No value entered"
|
||||
sender.resignFirstResponder()
|
||||
}
|
||||
|
||||
@IBAction func onSubTextDidEnd(_ sender: UITextField) {
|
||||
radioBox?.subText = sender.text
|
||||
sender.resignFirstResponder()
|
||||
}
|
||||
|
||||
@IBAction func onSubTextRightDidEnd(_ sender: UITextField) {
|
||||
radioBox?.subTextRight = sender.text
|
||||
sender.resignFirstResponder()
|
||||
}
|
||||
|
||||
@IBAction func showErrorChanged(_ sender: UISwitch) {
|
||||
radioBoxGroup.hasError = sender.isOn
|
||||
}
|
||||
|
||||
@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 = { [weak self] item in
|
||||
self?.radioBoxGroup.surface = item
|
||||
self?.componentContainerView.backgroundColor = item.color
|
||||
self?.surfaceLabel.text = item.rawValue
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user