Skip to content

Commit

Permalink
Fix some autolayout conflicts in small screens
Browse files Browse the repository at this point in the history
  • Loading branch information
antoniocasero committed Oct 9, 2018
1 parent 97c2263 commit 11f9e31
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 23 deletions.
18 changes: 10 additions & 8 deletions Example/Panels/Panels/PanelOptions.storyboard
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@
<nil key="highlightedColor"/>
</label>
<textField opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" placeholder="Some input" textAlignment="center" minimumFontSize="17" translatesAutoresizingMaskIntoConstraints="NO" id="S0h-fX-cB0">
<rect key="frame" x="137.5" y="81" width="100" height="30"/>
<rect key="frame" x="137.5" y="72" width="100" height="30"/>
<color key="backgroundColor" red="0.93725490570000003" green="0.93725490570000003" blue="0.95686274770000002" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<constraints>
<constraint firstAttribute="height" constant="30" id="0EC-nR-bdz"/>
Expand All @@ -87,26 +87,29 @@
<constraints>
<constraint firstAttribute="height" constant="128" id="5wB-gi-jTL"/>
<constraint firstItem="S0h-fX-cB0" firstAttribute="centerX" secondItem="Otu-Nk-Puq" secondAttribute="centerX" id="FE9-sk-i3O"/>
<constraint firstItem="S0h-fX-cB0" firstAttribute="top" secondItem="fds-GF-5tY" secondAttribute="bottom" constant="17" id="IUh-YA-7z7"/>
<constraint firstItem="S0h-fX-cB0" firstAttribute="top" secondItem="fds-GF-5tY" secondAttribute="bottom" constant="8" id="IUh-YA-7z7"/>
<constraint firstItem="fds-GF-5tY" firstAttribute="top" secondItem="b1Y-fS-yC0" secondAttribute="bottom" constant="8" id="NDN-aJ-xek"/>
<constraint firstAttribute="trailing" secondItem="fds-GF-5tY" secondAttribute="trailing" constant="16" id="T3g-E2-zd8"/>
<constraint firstItem="b1Y-fS-yC0" firstAttribute="centerX" secondItem="Otu-Nk-Puq" secondAttribute="centerX" id="Xir-ko-jH0"/>
<constraint firstItem="b1Y-fS-yC0" firstAttribute="top" secondItem="Otu-Nk-Puq" secondAttribute="topMargin" id="Yer-cO-Zdh"/>
<constraint firstAttribute="trailing" secondItem="b1Y-fS-yC0" secondAttribute="trailing" constant="162" id="rd2-86-WoN"/>
<constraint firstItem="fds-GF-5tY" firstAttribute="leading" secondItem="Otu-Nk-Puq" secondAttribute="leading" constant="16" id="x8w-wh-XJV"/>
</constraints>
</view>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="p8H-o1-aIO">
<rect key="frame" x="0.0" y="216" width="375" height="128"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Plenty space to add all kind of options, even textfields, the keyboard will be managed by Panels" textAlignment="natural" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="cTP-d5-67n">
<rect key="frame" x="16" y="41" width="270" height="46.5"/>
<rect key="frame" x="16" y="41" width="293" height="46.5"/>
<fontDescription key="fontDescription" name="HelveticaNeue-Medium" family="Helvetica Neue" pointSize="13"/>
<color key="textColor" white="0.66666666669999997" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<nil key="highlightedColor"/>
</label>
<switch opaque="NO" contentMode="scaleToFill" horizontalHuggingPriority="750" verticalHuggingPriority="750" contentHorizontalAlignment="center" contentVerticalAlignment="center" on="YES" translatesAutoresizingMaskIntoConstraints="NO" id="jZS-lq-llD">
<rect key="frame" x="310" y="49" width="51" height="31"/>
<rect key="frame" x="310" y="41" width="51" height="31"/>
<constraints>
<constraint firstAttribute="height" constant="31" id="AIz-4g-hXD"/>
<constraint firstAttribute="width" constant="49" id="xyn-e1-Bd7"/>
</constraints>
</switch>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="More Options" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="SnX-yy-y8z">
<rect key="frame" x="143" y="8" width="88" height="17"/>
Expand All @@ -117,13 +120,12 @@
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<constraints>
<constraint firstAttribute="height" constant="128" id="3Re-Kx-4v5"/>
<constraint firstItem="jZS-lq-llD" firstAttribute="top" secondItem="SnX-yy-y8z" secondAttribute="bottom" constant="16" id="4JL-np-EIU"/>
<constraint firstItem="SnX-yy-y8z" firstAttribute="centerX" secondItem="p8H-o1-aIO" secondAttribute="centerX" constant="-0.5" id="4hy-2r-HhP"/>
<constraint firstAttribute="trailing" secondItem="SnX-yy-y8z" secondAttribute="trailing" constant="144" id="6eX-Q3-DLU"/>
<constraint firstItem="jZS-lq-llD" firstAttribute="centerY" secondItem="cTP-d5-67n" secondAttribute="centerY" id="9Qo-5b-6ce"/>
<constraint firstItem="cTP-d5-67n" firstAttribute="leading" secondItem="p8H-o1-aIO" secondAttribute="leading" constant="16" id="DPE-Ef-Tbe"/>
<constraint firstAttribute="trailing" secondItem="jZS-lq-llD" secondAttribute="trailing" constant="16" id="EuO-Dg-LIO"/>
<constraint firstAttribute="trailing" secondItem="cTP-d5-67n" secondAttribute="trailing" constant="89" id="MJT-H4-6Mr"/>
<constraint firstItem="SnX-yy-y8z" firstAttribute="top" secondItem="p8H-o1-aIO" secondAttribute="topMargin" id="aod-10-8ER"/>
<constraint firstItem="jZS-lq-llD" firstAttribute="leading" secondItem="cTP-d5-67n" secondAttribute="trailing" constant="1" id="qd5-K8-jvI"/>
<constraint firstItem="cTP-d5-67n" firstAttribute="top" secondItem="SnX-yy-y8z" secondAttribute="bottom" constant="16" id="wsD-ci-Syk"/>
</constraints>
</view>
Expand Down
23 changes: 13 additions & 10 deletions Example/Panels/UI/Base.lproj/Main.storyboard
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="5Qm-tp-Y93" userLabel="Card">
<rect key="frame" x="8" y="68" width="359" height="64"/>
<rect key="frame" x="8" y="72" width="359" height="64"/>
<subviews>
<stackView opaque="NO" contentMode="scaleToFill" axis="vertical" alignment="top" translatesAutoresizingMaskIntoConstraints="NO" id="2iG-DX-4YW">
<rect key="frame" x="16" y="13.5" width="206" height="37.5"/>
Expand All @@ -39,9 +39,9 @@
</subviews>
</stackView>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="9c3-Sq-flP">
<rect key="frame" x="263" y="17" width="80" height="30"/>
<rect key="frame" x="283" y="17" width="60" height="30"/>
<constraints>
<constraint firstAttribute="width" constant="80" id="kcn-l5-6Xt"/>
<constraint firstAttribute="width" relation="greaterThanOrEqual" priority="750" constant="60" id="kcn-l5-6Xt"/>
</constraints>
<state key="normal" title="GO">
<color key="titleShadowColor" red="0.93725490570000003" green="0.93725490570000003" blue="0.95686274770000002" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
Expand All @@ -66,6 +66,7 @@
<constraints>
<constraint firstItem="2iG-DX-4YW" firstAttribute="centerY" secondItem="5Qm-tp-Y93" secondAttribute="centerY" id="NfE-Fg-qVz"/>
<constraint firstAttribute="trailing" secondItem="9c3-Sq-flP" secondAttribute="trailing" constant="16" id="O03-5y-UIu"/>
<constraint firstItem="9c3-Sq-flP" firstAttribute="leading" relation="greaterThanOrEqual" secondItem="ScL-kq-J2i" secondAttribute="trailing" constant="1" id="as8-vg-DKI"/>
<constraint firstItem="9c3-Sq-flP" firstAttribute="centerY" secondItem="5Qm-tp-Y93" secondAttribute="centerY" id="ayL-vs-gWF"/>
<constraint firstAttribute="height" constant="64" id="h3m-51-Q6Y"/>
<constraint firstItem="9c3-Sq-flP" firstAttribute="leading" relation="greaterThanOrEqual" secondItem="5Qm-tp-Y93" secondAttribute="leading" constant="20" symbolic="YES" id="qMu-2e-rGf"/>
Expand All @@ -78,7 +79,7 @@
</userDefinedRuntimeAttributes>
</view>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="1Sp-Uw-5eF" userLabel="Card">
<rect key="frame" x="8" y="140" width="359" height="64"/>
<rect key="frame" x="8" y="144" width="359" height="64"/>
<subviews>
<stackView opaque="NO" contentMode="scaleToFill" axis="vertical" alignment="top" translatesAutoresizingMaskIntoConstraints="NO" id="BqW-Ah-Klu">
<rect key="frame" x="16" y="13.5" width="189" height="37.5"/>
Expand All @@ -98,9 +99,9 @@
</subviews>
</stackView>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="jYk-IX-Gj0">
<rect key="frame" x="263" y="17" width="80" height="30"/>
<rect key="frame" x="283" y="17" width="60" height="30"/>
<constraints>
<constraint firstAttribute="width" constant="80" id="7xe-yH-naW"/>
<constraint firstAttribute="width" relation="greaterThanOrEqual" priority="750" constant="60" id="7xe-yH-naW"/>
</constraints>
<state key="normal" title="GO">
<color key="titleShadowColor" red="0.93725490570000003" green="0.93725490570000003" blue="0.95686274770000002" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
Expand All @@ -123,6 +124,7 @@
</subviews>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<constraints>
<constraint firstItem="jYk-IX-Gj0" firstAttribute="leading" relation="greaterThanOrEqual" secondItem="ncu-mb-Jiu" secondAttribute="trailing" constant="1" id="ELZ-oG-q6g"/>
<constraint firstAttribute="trailing" secondItem="jYk-IX-Gj0" secondAttribute="trailing" constant="16" id="Ghw-MT-7aK"/>
<constraint firstItem="jYk-IX-Gj0" firstAttribute="centerY" secondItem="1Sp-Uw-5eF" secondAttribute="centerY" id="MWa-Uu-14F"/>
<constraint firstItem="jYk-IX-Gj0" firstAttribute="leading" relation="greaterThanOrEqual" secondItem="1Sp-Uw-5eF" secondAttribute="leading" constant="20" symbolic="YES" id="NsA-Xp-IdW"/>
Expand All @@ -137,7 +139,7 @@
</userDefinedRuntimeAttributes>
</view>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="MqO-Mg-ef8" userLabel="Card">
<rect key="frame" x="8" y="212" width="359" height="300"/>
<rect key="frame" x="8" y="216" width="359" height="300"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Extras" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Qah-vw-nXE">
<rect key="frame" x="16" y="16" width="46" height="20.5"/>
Expand Down Expand Up @@ -229,9 +231,9 @@
</subviews>
</stackView>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="OEH-oH-3eW">
<rect key="frame" x="263" y="262" width="80" height="30"/>
<rect key="frame" x="283" y="262" width="60" height="30"/>
<constraints>
<constraint firstAttribute="width" constant="80" id="0DL-nL-Qzp"/>
<constraint firstAttribute="width" relation="greaterThanOrEqual" constant="60" id="0DL-nL-Qzp"/>
</constraints>
<state key="normal" title="GO">
<color key="titleShadowColor" red="0.93725490570000003" green="0.93725490570000003" blue="0.95686274770000002" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
Expand Down Expand Up @@ -266,6 +268,7 @@
<constraint firstItem="iiq-Lv-cCP" firstAttribute="leading" secondItem="MqO-Mg-ef8" secondAttribute="leading" constant="16" id="v4X-iX-Xbk"/>
<constraint firstItem="Qah-vw-nXE" firstAttribute="top" secondItem="MqO-Mg-ef8" secondAttribute="top" constant="16" id="wCB-nc-Ccq"/>
<constraint firstItem="TP4-qv-7gb" firstAttribute="leading" secondItem="MqO-Mg-ef8" secondAttribute="leading" constant="30" id="wWl-Z8-rrr"/>
<constraint firstItem="OEH-oH-3eW" firstAttribute="leading" relation="greaterThanOrEqual" secondItem="MqO-Mg-ef8" secondAttribute="leading" constant="20" symbolic="YES" id="wgQ-Bn-8gS"/>
</constraints>
<userDefinedRuntimeAttributes>
<userDefinedRuntimeAttribute type="number" keyPath="cornerRadius">
Expand All @@ -278,7 +281,7 @@
<color key="tintColor" red="0.0" green="0.47843137250000001" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<constraints>
<constraint firstItem="5Qm-tp-Y93" firstAttribute="leading" secondItem="MqO-Mg-ef8" secondAttribute="leading" id="Ccl-wa-Gd3"/>
<constraint firstItem="5Qm-tp-Y93" firstAttribute="centerY" secondItem="8bC-Xf-vdC" secondAttribute="centerY" multiplier="0.3" id="Ejb-u6-gdf"/>
<constraint firstItem="5Qm-tp-Y93" firstAttribute="top" secondItem="6Tk-OE-BBY" secondAttribute="top" constant="8" id="H0p-gE-S2p"/>
<constraint firstItem="6Tk-OE-BBY" firstAttribute="trailing" secondItem="1Sp-Uw-5eF" secondAttribute="trailing" constant="8" id="Uj7-xi-sP8"/>
<constraint firstItem="MqO-Mg-ef8" firstAttribute="top" secondItem="1Sp-Uw-5eF" secondAttribute="bottom" constant="8" id="ZaP-oW-iEw"/>
<constraint firstItem="1Sp-Uw-5eF" firstAttribute="top" secondItem="5Qm-tp-Y93" secondAttribute="bottom" constant="8" id="c43-vM-8Wx"/>
Expand Down
10 changes: 9 additions & 1 deletion Example/Panels/UI/MaterialPanel.storyboard
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<scenes>
<!--Material View Controller-->
<!--Title-->
<scene sceneID="V5J-hq-u6g">
<objects>
<viewController id="tCn-4d-2e5" customClass="MaterialViewController" customModule="Panels_Example" customModuleProvider="target" sceneMemberID="viewController">
Expand All @@ -31,6 +31,14 @@
</constraints>
<viewLayoutGuide key="safeArea" id="wRw-LW-DOR"/>
</view>
<navigationItem key="navigationItem" title="Title" id="pQy-Y4-gkV">
<barButtonItem key="rightBarButtonItem" title="Close" id="oxn-lJ-KQQ">
<connections>
<action selector="closePanel:" destination="tCn-4d-2e5" id="wK5-Ks-C7i"/>
</connections>
</barButtonItem>
</navigationItem>
<simulatedNavigationBarMetrics key="simulatedTopBarMetrics" prompted="NO"/>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="Bv6-GF-iud" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
Expand Down
2 changes: 1 addition & 1 deletion Example/Panels/ViewControllers/BasicViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class BasicViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
let panel = UIStoryboard.instantiatePanel(identifier: "PanelOptions")
let panelConfiguration = PanelConfiguration(size: .oneThird)
let panelConfiguration = PanelConfiguration(size: .custom(350))
panelManager.show(panel: panel, config: panelConfiguration)
}
}
7 changes: 4 additions & 3 deletions Example/Panels/ViewControllers/MaterialViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,9 @@ class MaterialViewController: UIViewController {
DispatchQueue.main.asyncAfter(deadline: .now() + 1) {
self.panelManager.show(panel: panel, config: panelConfiguration)
}
DispatchQueue.main.asyncAfter(deadline: .now() + 3) {
self.panelManager.dismiss()
}
}

@IBAction func closePanel(_ sender: Any) {
self.panelManager.dismiss()
}
}

0 comments on commit 11f9e31

Please sign in to comment.