Add simple controls for exercising the states

parent 0b0f2137
Pipeline #700 canceled with stages
......@@ -128,6 +128,45 @@
<rect key="frame" x="16" y="44" width="382" height="651"/>
<color key="backgroundColor" red="0.57965375782876882" green="0.79642258872084581" blue="1" alpha="0.48630061619718312" colorSpace="custom" customColorSpace="displayP3"/>
</view>
<stackView opaque="NO" contentMode="scaleToFill" axis="vertical" alignment="top" spacing="8" translatesAutoresizingMaskIntoConstraints="NO" id="LDz-sm-ngY">
<rect key="frame" x="125" y="776" width="164" height="70"/>
<subviews>
<stackView opaque="NO" contentMode="scaleToFill" spacing="8" translatesAutoresizingMaskIntoConstraints="NO" id="WJ1-mu-hiR">
<rect key="frame" x="0.0" y="0.0" width="164" height="31"/>
<subviews>
<switch opaque="NO" contentMode="scaleToFill" horizontalHuggingPriority="750" verticalHuggingPriority="750" contentHorizontalAlignment="center" contentVerticalAlignment="center" on="YES" translatesAutoresizingMaskIntoConstraints="NO" id="Q1K-oo-63r">
<rect key="frame" x="0.0" y="0.0" width="51" height="31"/>
<connections>
<action selector="layoutGuidesSwitchValueChanged:" destination="BYZ-38-t0r" eventType="valueChanged" id="klQ-fl-FoF"/>
</connections>
</switch>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Layout guides" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="JLG-R3-9T9">
<rect key="frame" x="57" y="0.0" width="107" height="31"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
</subviews>
</stackView>
<stackView opaque="NO" contentMode="scaleToFill" spacing="8" translatesAutoresizingMaskIntoConstraints="NO" id="BSN-CC-aRE">
<rect key="frame" x="0.0" y="39" width="157" height="31"/>
<subviews>
<switch opaque="NO" contentMode="scaleToFill" horizontalHuggingPriority="750" verticalHuggingPriority="750" contentHorizontalAlignment="center" contentVerticalAlignment="center" on="YES" translatesAutoresizingMaskIntoConstraints="NO" id="daB-oY-R25">
<rect key="frame" x="0.0" y="0.0" width="51" height="31"/>
<connections>
<action selector="blockerStateSwitchValueChanged:" destination="BYZ-38-t0r" eventType="valueChanged" id="YGo-6Y-vXW"/>
</connections>
</switch>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Blocker state" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="suB-hY-ChF">
<rect key="frame" x="57" y="0.0" width="100" height="31"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
</subviews>
</stackView>
</subviews>
</stackView>
</subviews>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<constraints>
......@@ -139,8 +178,10 @@
<constraint firstItem="1c7-hR-87O" firstAttribute="width" secondItem="Da0-nj-Gxr" secondAttribute="width" multiplier="6/16" id="7hw-bi-Upw"/>
<constraint firstItem="97y-ZH-spg" firstAttribute="width" secondItem="Da0-nj-Gxr" secondAttribute="width" id="8uI-jm-Dd8"/>
<constraint firstItem="P7i-RA-bJJ" firstAttribute="width" secondItem="Da0-nj-Gxr" secondAttribute="width" multiplier="5/16" id="9Hu-aP-DLy"/>
<constraint firstItem="LDz-sm-ngY" firstAttribute="centerX" secondItem="6Tk-OE-BBY" secondAttribute="centerX" id="Ash-Tb-LyQ"/>
<constraint firstItem="Da0-nj-Gxr" firstAttribute="top" secondItem="6Tk-OE-BBY" secondAttribute="top" id="Cv4-HS-o34"/>
<constraint firstItem="1c7-hR-87O" firstAttribute="leading" secondItem="4IP-2x-4dT" secondAttribute="trailing" id="GHF-dX-uMq"/>
<constraint firstItem="6Tk-OE-BBY" firstAttribute="bottom" secondItem="LDz-sm-ngY" secondAttribute="bottom" constant="16" id="LcT-LT-Ehl"/>
<constraint firstItem="97y-ZH-spg" firstAttribute="top" secondItem="1c7-hR-87O" secondAttribute="bottom" id="MJT-wk-mLn"/>
<constraint firstItem="Q2i-Mp-9LN" firstAttribute="top" secondItem="cUA-A3-7ag" secondAttribute="bottom" constant="137.33333333333329" id="NXs-Xe-lgq">
<variation key="heightClass=compact" constant="0.0"/>
......@@ -191,11 +232,11 @@
<mask key="constraints">
<exclude reference="awo-9B-XZJ"/>
<include reference="d3N-cH-IU0"/>
<exclude reference="TVf-IT-10a"/>
<exclude reference="7hw-bi-Upw"/>
<include reference="RtY-Mi-eeG"/>
<exclude reference="tco-CA-aF8"/>
<include reference="xj5-Zc-HyR"/>
<exclude reference="TVf-IT-10a"/>
<exclude reference="WMX-7Z-izQ"/>
<include reference="1Eb-4u-XsL"/>
<exclude reference="3dy-d4-0kQ"/>
......@@ -218,6 +259,7 @@
</variation>
</view>
<connections>
<outlet property="blockerStateSwitch" destination="daB-oY-R25" id="dq9-xS-PHk"/>
<outlet property="layoutElementStatusBadge" destination="1c7-hR-87O" id="l0S-99-fev"/>
<outlet property="layoutElementStatusText" destination="Q2i-Mp-9LN" id="oGX-Fl-a1u"/>
<outlet property="layoutGuideBase" destination="Da0-nj-Gxr" id="dC6-i4-NGQ"/>
......@@ -225,13 +267,14 @@
<outlet property="layoutGuideStatusBadgeLeftMargin" destination="4IP-2x-4dT" id="Iru-7T-kOv"/>
<outlet property="layoutGuideStatusBadgeRightMargin" destination="P7i-RA-bJJ" id="V1N-i3-BdK"/>
<outlet property="layoutGuideTopMargin" destination="cUA-A3-7ag" id="tcC-MA-PXM"/>
<outlet property="layoutGuidesSwitch" destination="Q1K-oo-63r" id="hbD-Lg-LWy"/>
<outlet property="statusImageView" destination="e5t-G8-1L2" id="gV2-J1-pzu"/>
<outlet property="statusTextView" destination="PB8-0H-gLc" id="eHF-sm-ZO0"/>
</connections>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="dkx-z0-nzr" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="136.80000000000001" y="133.5832083958021"/>
<point key="canvasLocation" x="136.23188405797103" y="133.25892857142856"/>
</scene>
</scenes>
<resources>
......
......@@ -27,6 +27,9 @@ class ViewController: UIViewController, UITextViewDelegate {
@IBOutlet weak var statusTextView: UITextView!
@IBOutlet weak var statusImageView: LDAlignmentImageView!
@IBOutlet weak var layoutGuidesSwitch: UISwitch!
@IBOutlet weak var blockerStateSwitch: UISwitch!
@IBOutlet weak var layoutGuideBase: UIView!
@IBOutlet weak var layoutGuideTopMargin: UIView!
@IBOutlet weak var layoutGuideStatusBadgeLeftMargin: UIView!
......@@ -42,10 +45,10 @@ class ViewController: UIViewController, UITextViewDelegate {
// Hard code the blocker state for the spike.
let blockerEnabled = true
var blockerEnabled = true
// Enable layout guides to debug layout and responsiveness.
let showLayoutGuides = false
var showLayoutGuides = false
let betterFonts: [BetterFontSize:BetterFontSet] = [
......@@ -82,15 +85,7 @@ class ViewController: UIViewController, UITextViewDelegate {
blockerEnabledShieldImage = UIImage(named: "Enabled")
// Should we show layout guides?
if (!showLayoutGuides) {
// Hide the layout guides and reset the background colours on the layout elements.
let layoutGuides = [layoutGuideBase, layoutGuideTopMargin, layoutGuideStatusBadgeLeftMargin, layoutGuideStatusBadgeRightMargin, layoutGuideBottomMargin]
let layoutElements = [layoutElementStatusBadge, layoutElementStatusText]
for layoutGuide in layoutGuides { layoutGuide!.isHidden = true }
// TODO: Should we use transparent for this to make the rotations look nicer?
for layoutElement in layoutElements { layoutElement!.backgroundColor = UIColor.clear }
}
updateLayoutGuides()
// Update the status text and badge for the first time.
updateStatus()
......@@ -226,6 +221,42 @@ class ViewController: UIViewController, UITextViewDelegate {
statusImageView.imageHorizontalAlignment = statusImageViewHorizontalAlignment
}
//
// MARK: - Spike interface
//
func updateSwitches() {
layoutGuidesSwitch.setOn(showLayoutGuides, animated: false)
blockerStateSwitch.setOn(blockerEnabled, animated: false)
}
func updateLayoutGuides() {
let layoutGuides = [layoutGuideBase, layoutGuideTopMargin, layoutGuideStatusBadgeLeftMargin, layoutGuideStatusBadgeRightMargin, layoutGuideBottomMargin]
let layoutElements = [layoutElementStatusBadge, layoutElementStatusText]
if (showLayoutGuides) {
for layoutGuide in layoutGuides { layoutGuide!.isHidden = false }
} else {
// Hide the layout guides and reset the background colours on the layout elements.
for layoutGuide in layoutGuides { layoutGuide!.isHidden = true }
for layoutElement in layoutElements { layoutElement!.backgroundColor = UIColor.clear }
}
}
@IBAction func layoutGuidesSwitchValueChanged(_ sender: UISwitch) {
showLayoutGuides = sender.isOn
updateLayoutGuides()
}
@IBAction func blockerStateSwitchValueChanged(_ sender: UISwitch) {
blockerEnabled = sender.isOn
updateStatus()
}
//
// MARK: - Notification handlers
//
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment