updated for label viewcontroller

This commit is contained in:
Matt Bruce 2022-08-16 18:16:04 -05:00
parent b69db764b5
commit 790f440b38
6 changed files with 429 additions and 60 deletions

View File

@ -43,6 +43,7 @@
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 */; };
EAB1D2D428AC409F00DAE764 /* LabelViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = EAB1D2D328AC409F00DAE764 /* LabelViewController.swift */; };
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 */; };
@ -101,6 +102,7 @@
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>"; };
EAB1D2D328AC409F00DAE764 /* LabelViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LabelViewController.swift; sourceTree = "<group>"; };
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>"; };
@ -216,6 +218,7 @@
EAB1D2C428A6B11D00DAE764 /* TestViewController.swift */,
EAB1D2C828AAAA1D00DAE764 /* ModelViewController.swift */,
EAB1D2CA28AAB9E200DAE764 /* TemplateViewController.swift */,
EAB1D2D328AC409F00DAE764 /* LabelViewController.swift */,
);
path = ViewControllers;
sourceTree = "<group>";
@ -371,6 +374,7 @@
EAB1D2C528A6B11D00DAE764 /* TestViewController.swift in Sources */,
EAB1D2C928AAAA1D00DAE764 /* ModelViewController.swift in Sources */,
EAF7F09C2899B92400B287F5 /* CheckboxViewController.swift in Sources */,
EAB1D2D428AC409F00DAE764 /* LabelViewController.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};

View File

@ -62,8 +62,8 @@ class TextSizePicker: PickerBase<TypographicalStyle.FontSize> {
}
}
class FontWeightPicker: PickerBase<TypographicalStyle.FontWeight> {
class FontCategoryPicker: PickerBase<TypographicalStyle.FontCategory> {
init(){
super.init(items: [.regular, .bold])
super.init(items: TypographicalStyle.FontCategory.allCases)
}
}

View File

@ -28,7 +28,7 @@
<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="c3f-mr-N3r">
<rect key="frame" x="16" y="20" width="350" height="360"/>
<rect key="frame" x="16" y="20" width="350" height="351"/>
<subviews>
<stackView opaque="NO" contentMode="scaleToFill" distribution="fillEqually" translatesAutoresizingMaskIntoConstraints="NO" id="sYT-73-bQM">
<rect key="frame" x="0.0" y="0.0" width="350" height="31"/>
@ -98,10 +98,27 @@
</subviews>
</stackView>
<stackView opaque="NO" contentMode="scaleToFill" axis="vertical" distribution="fillProportionally" spacing="10" translatesAutoresizingMaskIntoConstraints="NO" id="gUv-8I-tB2">
<rect key="frame" x="0.0" y="132" width="350" height="228"/>
<rect key="frame" x="0.0" y="132" width="350" height="219"/>
<subviews>
<stackView opaque="NO" contentMode="scaleToFill" distribution="fillEqually" translatesAutoresizingMaskIntoConstraints="NO" id="bYq-HL-Jpd">
<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="Bold" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="9xd-PC-FVd">
<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="shb-mc-ZxL">
<rect key="frame" x="175" y="0.0" width="177" height="31"/>
<connections>
<action selector="boldChanged:" destination="Y6W-OH-hqX" eventType="valueChanged" id="gd8-xW-jJH"/>
</connections>
</switch>
</subviews>
</stackView>
<stackView opaque="NO" contentMode="scaleToFill" distribution="fillEqually" translatesAutoresizingMaskIntoConstraints="NO" id="HDF-F1-Y7n">
<rect key="frame" x="0.0" y="0.0" width="350" height="40"/>
<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="Text Size" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="dBg-3x-IqG">
<rect key="frame" x="0.0" y="0.0" width="175" height="40"/>
@ -134,7 +151,7 @@
</subviews>
</stackView>
<stackView opaque="NO" contentMode="scaleToFill" distribution="fillEqually" translatesAutoresizingMaskIntoConstraints="NO" id="IIX-zl-vox">
<rect key="frame" x="0.0" y="50" width="350" height="40"/>
<rect key="frame" x="0.0" y="91" width="350" height="40"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Text Position" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="GsO-G8-26m">
<rect key="frame" x="0.0" y="0.0" width="175" height="40"/>
@ -166,41 +183,8 @@
</stackView>
</subviews>
</stackView>
<stackView opaque="NO" contentMode="scaleToFill" distribution="fillEqually" translatesAutoresizingMaskIntoConstraints="NO" id="MKe-eB-YxN">
<rect key="frame" x="0.0" y="100" width="350" height="40"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Font Weight" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="JnH-Xv-Nay">
<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="R4n-Bm-pdW">
<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="regular" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="7fh-Gk-yxd">
<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="0lc-Qg-B5X">
<rect key="frame" x="87.5" y="0.0" width="87.5" height="40"/>
<constraints>
<constraint firstAttribute="height" constant="40" id="0v3-gr-uSI"/>
</constraints>
<state key="normal" title="Button"/>
<buttonConfiguration key="configuration" style="filled" title="Select"/>
<connections>
<action selector="fontWeightClick:" destination="Y6W-OH-hqX" eventType="touchUpInside" id="C0e-iS-xPh"/>
</connections>
</button>
</subviews>
</stackView>
</subviews>
</stackView>
<stackView opaque="NO" contentMode="scaleToFill" distribution="fillEqually" translatesAutoresizingMaskIntoConstraints="NO" id="ODW-e4-K6y">
<rect key="frame" x="0.0" y="150" width="350" height="34"/>
<rect key="frame" x="0.0" y="141" width="350" height="34"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Off Text" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="6b0-7z-Ikg">
<rect key="frame" x="0.0" y="0.0" width="175" height="34"/>
@ -219,7 +203,7 @@
</subviews>
</stackView>
<stackView opaque="NO" contentMode="scaleToFill" distribution="fillEqually" translatesAutoresizingMaskIntoConstraints="NO" id="GOJ-8q-h10">
<rect key="frame" x="0.0" y="194" width="350" height="34"/>
<rect key="frame" x="0.0" y="185" width="350" height="34"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="On Text" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Hmn-3u-I1z">
<rect key="frame" x="0.0" y="0.0" width="175" height="34"/>
@ -268,7 +252,6 @@
</constraints>
</view>
<connections>
<outlet property="fontWeightLabel" destination="7fh-Gk-yxd" id="9HJ-2H-tud"/>
<outlet property="picker" destination="b1e-eg-qNX" id="iDm-KA-4bE"/>
<outlet property="showTextStack" destination="gUv-8I-tB2" id="3u1-5J-A5o"/>
<outlet property="surfaceLabel" destination="IaL-6H-bLF" id="2TM-Ne-rdp"/>
@ -467,7 +450,7 @@
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="Oec-kV-gky" userLabel="First Responder" customClass="UIResponder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="-3880" y="-313"/>
<point key="canvasLocation" x="-3945" y="-313"/>
</scene>
<!--Radio Button View Controller-->
<scene sceneID="dZR-JE-vBA">
@ -635,7 +618,223 @@
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="eCF-B0-LZF" userLabel="First Responder" customClass="UIResponder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="-3880" y="-313"/>
<point key="canvasLocation" x="-3075" y="-313"/>
</scene>
<!--Label View Controller-->
<scene sceneID="tjX-7m-s31">
<objects>
<viewController storyboardIdentifier="label" id="5DL-pF-pcR" customClass="LabelViewController" customModule="VDSSample" customModuleProvider="target" sceneMemberID="viewController">
<view key="view" contentMode="scaleToFill" id="fAA-BO-yYK">
<rect key="frame" x="0.0" y="0.0" width="414" height="896"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<stackView opaque="NO" contentMode="scaleToFill" axis="vertical" spacing="15" translatesAutoresizingMaskIntoConstraints="NO" id="Nb4-Pl-Uaf">
<rect key="frame" x="16" y="55" width="382" height="786"/>
<subviews>
<view contentMode="scaleToFill" ambiguous="YES" translatesAutoresizingMaskIntoConstraints="NO" id="2AQ-Xy-Qoc" 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="Xlq-T6-ZY7" 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="KWq-vB-Ueq">
<rect key="frame" x="16" y="20" width="350" height="266"/>
<subviews>
<stackView opaque="NO" contentMode="scaleToFill" distribution="fillEqually" translatesAutoresizingMaskIntoConstraints="NO" id="POT-9I-FIf">
<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="mOG-cQ-PuB">
<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="pAl-jo-Vst">
<rect key="frame" x="175" y="0.0" width="177" height="31"/>
<connections>
<action selector="disabledChanged:" destination="5DL-pF-pcR" eventType="valueChanged" id="e2R-dx-QDI"/>
</connections>
</switch>
</subviews>
</stackView>
<stackView opaque="NO" contentMode="scaleToFill" distribution="fillEqually" translatesAutoresizingMaskIntoConstraints="NO" id="pVU-EQ-8ih">
<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="sQv-Ve-qkL">
<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="BBz-Zn-dKf">
<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="zhx-cG-0tG">
<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="NcV-DU-Wic">
<rect key="frame" x="87.5" y="0.0" width="87.5" height="40"/>
<constraints>
<constraint firstAttribute="height" constant="40" id="9e8-AZ-dkt"/>
</constraints>
<state key="normal" title="Button"/>
<buttonConfiguration key="configuration" style="filled" title="Select"/>
<connections>
<action selector="surfaceClick:" destination="5DL-pF-pcR" eventType="touchUpInside" id="nIj-8P-fhb"/>
</connections>
</button>
</subviews>
</stackView>
</subviews>
</stackView>
<stackView opaque="NO" contentMode="scaleToFill" distribution="fillEqually" translatesAutoresizingMaskIntoConstraints="NO" id="AXS-AR-uJl">
<rect key="frame" x="0.0" y="91" width="350" height="31"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Bold" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="YxH-HJ-Pgb">
<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="eJt-J6-WUl">
<rect key="frame" x="175" y="0.0" width="177" height="31"/>
<connections>
<action selector="boldChanged:" destination="5DL-pF-pcR" eventType="valueChanged" id="zec-NS-6wO"/>
</connections>
</switch>
</subviews>
</stackView>
<stackView opaque="NO" contentMode="scaleToFill" distribution="fillEqually" translatesAutoresizingMaskIntoConstraints="NO" id="HOS-S3-3hP">
<rect key="frame" x="0.0" y="132" width="350" height="40"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Category" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="g0Y-1t-WmH">
<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="g8W-bk-ctT">
<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="feature" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="D1s-MB-lnH">
<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="8Je-Bd-UFI">
<rect key="frame" x="87.5" y="0.0" width="87.5" height="40"/>
<constraints>
<constraint firstAttribute="height" constant="40" id="NSu-df-NNP"/>
</constraints>
<state key="normal" title="Button"/>
<buttonConfiguration key="configuration" style="filled" title="Select"/>
<connections>
<action selector="fontCategoryClick:" destination="5DL-pF-pcR" eventType="touchUpInside" id="Bd0-Rq-p4L"/>
</connections>
</button>
</subviews>
</stackView>
</subviews>
</stackView>
<stackView opaque="NO" contentMode="scaleToFill" distribution="fillEqually" translatesAutoresizingMaskIntoConstraints="NO" id="1OP-ga-kKh">
<rect key="frame" x="0.0" y="182" width="350" height="40"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Text Size" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Fc7-6l-yG8">
<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="zFp-FF-IB8">
<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="small" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="goi-YT-sE6">
<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="nb4-Ju-Oma">
<rect key="frame" x="87.5" y="0.0" width="87.5" height="40"/>
<constraints>
<constraint firstAttribute="height" constant="40" id="IoZ-tH-fGi"/>
</constraints>
<state key="normal" title="Button"/>
<buttonConfiguration key="configuration" style="filled" title="Select"/>
<connections>
<action selector="textSizeClick:" destination="5DL-pF-pcR" eventType="touchUpInside" id="sNI-Pi-YeB"/>
</connections>
</button>
</subviews>
</stackView>
</subviews>
</stackView>
<stackView opaque="NO" contentMode="scaleToFill" distribution="fillEqually" translatesAutoresizingMaskIntoConstraints="NO" id="NCy-mv-9Fy">
<rect key="frame" x="0.0" y="232" 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="cFw-HP-kIK" userLabel="Text">
<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" text="Label Component" borderStyle="roundedRect" textAlignment="natural" minimumFontSize="17" translatesAutoresizingMaskIntoConstraints="NO" id="Aue-Rd-7RT">
<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="textDidEnd:" destination="5DL-pF-pcR" eventType="editingDidEnd" id="6bP-oa-A2X"/>
</connections>
</textField>
</subviews>
</stackView>
</subviews>
</stackView>
</subviews>
<color key="backgroundColor" systemColor="systemBackgroundColor"/>
<constraints>
<constraint firstAttribute="trailing" secondItem="KWq-vB-Ueq" secondAttribute="trailing" constant="16" id="ZMx-cF-t0R"/>
<constraint firstItem="KWq-vB-Ueq" firstAttribute="top" secondItem="Xlq-T6-ZY7" secondAttribute="top" constant="20" id="duK-7G-bg7"/>
<constraint firstItem="KWq-vB-Ueq" firstAttribute="leading" secondItem="Xlq-T6-ZY7" secondAttribute="leading" constant="16" id="n2j-aT-elS"/>
</constraints>
</view>
</subviews>
</stackView>
<pickerView contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="lsp-NL-mq9">
<rect key="frame" x="0.0" y="646" width="414" height="216"/>
</pickerView>
</subviews>
<viewLayoutGuide key="safeArea" id="X7i-GC-VoV"/>
<color key="backgroundColor" systemColor="systemBackgroundColor"/>
<constraints>
<constraint firstItem="Nb4-Pl-Uaf" firstAttribute="leading" secondItem="X7i-GC-VoV" secondAttribute="leading" constant="16" id="04O-e5-vsb"/>
<constraint firstItem="lsp-NL-mq9" firstAttribute="leading" secondItem="X7i-GC-VoV" secondAttribute="leading" id="GAg-Lx-JzS"/>
<constraint firstItem="X7i-GC-VoV" firstAttribute="bottom" secondItem="Nb4-Pl-Uaf" secondAttribute="bottom" constant="21" id="RiE-GH-LFc"/>
<constraint firstItem="X7i-GC-VoV" firstAttribute="bottom" secondItem="lsp-NL-mq9" secondAttribute="bottom" id="nYg-6v-dMv"/>
<constraint firstItem="Nb4-Pl-Uaf" firstAttribute="top" secondItem="X7i-GC-VoV" secondAttribute="top" constant="11" id="riX-Ux-cff"/>
<constraint firstItem="X7i-GC-VoV" firstAttribute="trailing" secondItem="Nb4-Pl-Uaf" secondAttribute="trailing" constant="16" id="u2s-r8-QMw"/>
<constraint firstItem="lsp-NL-mq9" firstAttribute="trailing" secondItem="X7i-GC-VoV" secondAttribute="trailing" id="zGC-GQ-5RJ"/>
</constraints>
</view>
<connections>
<outlet property="boldswitch" destination="eJt-J6-WUl" id="Tju-vR-LDg"/>
<outlet property="containerView" destination="2AQ-Xy-Qoc" id="sB8-sb-lLN"/>
<outlet property="disabledSwitch" destination="pAl-jo-Vst" id="j3O-E6-Trh"/>
<outlet property="fontCategoryLabel" destination="D1s-MB-lnH" id="OA7-aq-B2X"/>
<outlet property="picker" destination="lsp-NL-mq9" id="g68-Pm-vbO"/>
<outlet property="surfaceLabel" destination="zhx-cG-0tG" id="bbl-Ah-T8U"/>
<outlet property="textField" destination="Aue-Rd-7RT" id="A1q-B3-jHd"/>
<outlet property="textSizeLabel" destination="goi-YT-sE6" id="oZZ-YQ-HaC"/>
</connections>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="MIQ-mQ-kBx" userLabel="First Responder" customClass="UIResponder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="-2158" y="-313"/>
</scene>
</scenes>
<resources>

View File

@ -0,0 +1,174 @@
//
// LabelViewController.swift
// VDSSample
//
// Created by Matt Bruce on 8/16/22.
//
import Foundation
import UIKit
import VDS
import VDSColorTokens
class LabelViewController: ModelViewController<DefaultLabelModel>, StoryboardInitable {
deinit {
print("\(Self.self) deinit")
}
enum PickerType {
case surface, textSize, fontCategory
}
static var storyboardId: String = "label"
static var storyboardName: String = "Components"
@IBOutlet weak var containerView: UIView!
@IBOutlet weak var picker: UIPickerView!
@IBOutlet weak var surfaceLabel: UILabel!
@IBOutlet weak var textSizeLabel: UILabel!
@IBOutlet weak var fontCategoryLabel: UILabel!
@IBOutlet weak var boldswitch: UISwitch!
@IBOutlet weak var disabledSwitch: UISwitch!
@IBOutlet weak var textField: UITextField!
private var isBold: Bool = false
var label: Label!
override func viewDidLoad() {
super.viewDidLoad()
label = Label()
label.translatesAutoresizingMaskIntoConstraints = false
containerView.addSubview(label)
label.topAnchor.constraint(equalTo: containerView.topAnchor, constant: 20).isActive = true
label.leadingAnchor.constraint(equalTo: containerView.leadingAnchor, constant: 20).isActive = true
label.trailingAnchor.constraint(equalTo: containerView.trailingAnchor, constant: -20).isActive = true
label.bottomAnchor.constraint(equalTo: containerView.bottomAnchor, constant: -20).isActive = true
view.addGestureRecognizer(UITapGestureRecognizer(target: self.view, action: #selector(UIView.endEditing(_:))))
setupPicker()
setupModel()
}
func setupModel() {
var defaultModel = DefaultLabelModel()
defaultModel.text = "Label Component"
defaultModel.typograpicalStyle = .FeatureSmall
model = defaultModel
label
.handlerPublisher()
.sink { [weak self] viewModel in
self?.model = viewModel
}.store(in: &subscribers)
//setup UI
surfaceLabel.text = model.surface.rawValue
disabledSwitch.isOn = model.disabled
boldswitch.isOn = isBold
textField.text = model.text
//set the font
fontCategory = .feature
fontCategoryLabel.text = "Feature"
textSize = .small
textSizeLabel.text = "Small"
}
override func updateView(viewModel: DefaultLabelModel) {
label.set(with: viewModel)
}
@IBAction func disabledChanged(_ sender: UISwitch) {
label.isEnabled = !sender.isOn
}
@IBAction func boldChanged(_ sender: UISwitch) {
isBold = sender.isOn
updateLabelStyle()
}
@IBAction func textDidEnd(_ sender: UITextField) {
label.text = sender.text ?? "Label Component"
sender.resignFirstResponder()
}
@IBAction func surfaceClick(_ sender: Any) {
pickerType = .surface
}
@IBAction func textSizeClick(_ sender: Any) {
pickerType = .textSize
}
@IBAction func fontCategoryClick(_ sender: Any) {
pickerType = .fontCategory
}
//Picker
var surfacePicker = SurfacePicker()
var textSizePicker = TextSizePicker()
var fontCategoryPicker = FontCategoryPicker()
var pickerType: PickerType = .surface {
didSet {
func update(object: UIPickerViewDelegate & UIPickerViewDataSource){
picker.delegate = object
picker.dataSource = object
}
switch pickerType{
case .surface:
update(object: surfacePicker)
case .textSize:
update(object: textSizePicker)
case .fontCategory:
update(object: fontCategoryPicker)
}
picker.reloadAllComponents()
picker.selectRow(0, inComponent: 0, animated: false)
picker.isHidden = false
}
}
private var fontCategory: TypographicalStyle.FontCategory = .feature {
didSet {
fontCategoryLabel.text = fontCategory.rawValue
textSizePicker.items = fontCategory.sizes
textSize = textSizePicker.items[0]
updateLabelStyle()
}
}
private var textSize: TypographicalStyle.FontSize = .large {
didSet {
textSizeLabel.text = textSize.rawValue
updateLabelStyle()
}
}
func updateLabelStyle(){
if let style = fontCategory.style(for: textSize, isBold: isBold) {
label.model.typograpicalStyle = style
}
}
func setupPicker(){
picker.isHidden = true
surfacePicker.onPickerDidSelect = { [weak self] item in
self?.label.surface = item
self?.containerView.backgroundColor = item.color
self?.surfaceLabel.text = item.rawValue
}
textSizePicker.onPickerDidSelect = { [weak self] item in
self?.textSize = item
}
fontCategoryPicker.onPickerDidSelect = { [weak self] item in
self?.fontCategory = item
}
}
}

View File

@ -19,6 +19,7 @@ protocol Initable {
class MenuViewController: UITableViewController {
let items: [MenuComponent] = [
MenuComponent(title: "Label", viewController: LabelViewController.self),
MenuComponent(title: "Toggle", viewController: ToggleViewController.self),
MenuComponent(title: "Checkbox", viewController: CheckboxViewController.self),
MenuComponent(title: "RadioButton", viewController: RadioButtonViewController.self),

View File

@ -16,7 +16,7 @@ class ToggleViewController: UIViewController, StoryboardInitable {
}
enum PickerType {
case surface, textSize, textPosition, fontWeight
case surface, textSize, textPosition
}
static var storyboardId: String = "toggle"
static var storyboardName: String = "Components"
@ -26,7 +26,6 @@ class ToggleViewController: UIViewController, StoryboardInitable {
@IBOutlet weak var surfaceLabel: UILabel!
@IBOutlet weak var textSizeLabel: UILabel!
@IBOutlet weak var textPositionLabel: UILabel!
@IBOutlet weak var fontWeightLabel: UILabel!
@IBOutlet weak var showTextStack: UIStackView!
var toggle: Toggle!
@ -55,6 +54,10 @@ class ToggleViewController: UIViewController, StoryboardInitable {
toggle.disabled = sender.isOn
}
@IBAction func boldChanged(_ sender: UISwitch) {
toggle.isBold = sender.isOn
}
@IBAction func offTextDidEnd(_ sender: UITextField) {
toggle.offText = sender.text ?? "Off"
sender.resignFirstResponder()
@ -76,16 +79,11 @@ class ToggleViewController: UIViewController, StoryboardInitable {
@IBAction func textPositionClick(_ sender: Any) {
pickerType = .textPosition
}
@IBAction func fontWeightClick(_ sender: Any) {
pickerType = .fontWeight
}
//Picker
var surfacePicker = SurfacePicker()
var textSizePicker = TextSizePicker()
var textPositionPicker = TextPositionPicker()
var fontWeightPicker = FontWeightPicker()
var pickerType: PickerType = .surface {
didSet {
@ -101,8 +99,6 @@ class ToggleViewController: UIViewController, StoryboardInitable {
update(object: textSizePicker)
case .textPosition:
update(object: textPositionPicker)
case .fontWeight:
update(object: fontWeightPicker)
}
picker.reloadAllComponents()
picker.selectRow(0, inComponent: 0, animated: false)
@ -117,12 +113,7 @@ class ToggleViewController: UIViewController, StoryboardInitable {
self?.toggleContainerView.backgroundColor = item.color
self?.surfaceLabel.text = item.rawValue
}
fontWeightPicker.onPickerDidSelect = { [weak self] item in
self?.toggle.fontWeight = item
self?.fontWeightLabel.text = item.rawValue
}
textSizePicker.onPickerDidSelect = { [weak self] item in
self?.toggle.fontSize = item
self?.textSizeLabel.text = item.rawValue