[iOS] Fixed date picker and guest picker in horizontal orientation

https://jira.mail.ru/browse/MAPSME-14840
This commit is contained in:
Alexander Boriskov 2020-09-18 13:02:04 +03:00 committed by mpimenov
parent 4d4c0b4af1
commit e517138995
4 changed files with 113 additions and 33 deletions

View file

@ -8,7 +8,8 @@ import UIKit
}
@objc final class DatePickerViewController: UIViewController {
private let transitioning = CoverVerticalModalTransitioning(presentationHeight: 550)
private static let kHeight: CGFloat = 550
private let transitioning = CoverVerticalModalTransitioning(presentationHeight: min(UIScreen.main.bounds.height, kHeight))
@IBOutlet var checkInLabel: UILabel!
@IBOutlet var startDateLabel: UILabel!
@ -59,6 +60,16 @@ import UIKit
@IBAction func onCancel(_ sender: UIButton) {
delegate?.datePickerDidCancel(self)
}
override func traitCollectionDidChange(_ previousTraitCollection: UITraitCollection?) {
super.traitCollectionDidChange(previousTraitCollection)
alternativeSizeClass(iPhone: {
if let superview = view.superview {
view.height = min(UIScreen.main.bounds.height, DatePickerViewController.kHeight)
view.minY = superview.height - view.height
}
}, iPad: {})
}
}
extension DatePickerViewController: DatePickerViewDelegate {

View file

@ -1,9 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="15702" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="15705" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
<device id="retina4_7" orientation="portrait" appearance="light"/>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="15704"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="15706"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
@ -22,11 +22,18 @@
</placeholder>
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
<view clearsContextBeforeDrawing="NO" contentMode="scaleToFill" id="i5M-Pr-FkT">
<rect key="frame" x="0.0" y="0.0" width="375" height="550"/>
<rect key="frame" x="0.0" y="0.0" width="375" height="362"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="x8e-QT-skP">
<rect key="frame" x="0.0" y="0.0" width="375" height="362"/>
<color key="backgroundColor" systemColor="systemBackgroundColor" cocoaTouchSystemColor="whiteColor"/>
<userDefinedRuntimeAttributes>
<userDefinedRuntimeAttribute type="string" keyPath="styleName" value="Background"/>
</userDefinedRuntimeAttributes>
</view>
<stackView opaque="NO" contentMode="scaleToFill" axis="vertical" translatesAutoresizingMaskIntoConstraints="NO" id="9pa-9d-4fr">
<rect key="frame" x="0.0" y="0.0" width="375" height="550"/>
<rect key="frame" x="0.0" y="0.0" width="375" height="362"/>
<subviews>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="5bX-Ze-PaF">
<rect key="frame" x="0.0" y="0.0" width="375" height="100"/>
@ -131,10 +138,10 @@
</userDefinedRuntimeAttributes>
</view>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="0yA-Fx-KRW">
<rect key="frame" x="0.0" y="101" width="375" height="405"/>
<rect key="frame" x="0.0" y="101" width="375" height="217"/>
<subviews>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="86t-e6-Fkb" customClass="DatePickerView" customModule="DatePicker">
<rect key="frame" x="16" y="8" width="343" height="397"/>
<rect key="frame" x="16" y="8" width="343" height="209"/>
<color key="backgroundColor" systemColor="systemBackgroundColor" cocoaTouchSystemColor="whiteColor"/>
</view>
</subviews>
@ -150,7 +157,7 @@
</userDefinedRuntimeAttributes>
</view>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="Fbd-fF-LaJ">
<rect key="frame" x="0.0" y="506" width="375" height="44"/>
<rect key="frame" x="0.0" y="318" width="375" height="44"/>
<subviews>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="rSC-r1-3RH">
<rect key="frame" x="16" y="0.0" width="50" height="44"/>
@ -192,21 +199,52 @@
</userDefinedRuntimeAttributes>
</view>
</subviews>
<constraints>
<constraint firstAttribute="width" constant="350" id="VYH-df-vrF"/>
</constraints>
<variation key="default">
<mask key="constraints">
<exclude reference="VYH-df-vrF"/>
</mask>
</variation>
<variation key="heightClass=compact">
<mask key="constraints">
<include reference="VYH-df-vrF"/>
</mask>
</variation>
</stackView>
</subviews>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<constraints>
<constraint firstItem="fnl-2z-Ty3" firstAttribute="bottom" secondItem="9pa-9d-4fr" secondAttribute="bottom" id="EHv-0h-rwy"/>
<constraint firstItem="9pa-9d-4fr" firstAttribute="top" secondItem="fnl-2z-Ty3" secondAttribute="top" id="FCg-1s-LIu"/>
<constraint firstItem="x8e-QT-skP" firstAttribute="trailing" secondItem="9pa-9d-4fr" secondAttribute="trailing" id="Paj-IM-fVx"/>
<constraint firstItem="9pa-9d-4fr" firstAttribute="leading" secondItem="fnl-2z-Ty3" secondAttribute="leading" id="UwT-LX-lcY"/>
<constraint firstItem="x8e-QT-skP" firstAttribute="top" secondItem="9pa-9d-4fr" secondAttribute="top" id="fgP-Gv-fa5"/>
<constraint firstItem="9pa-9d-4fr" firstAttribute="leading" secondItem="fnl-2z-Ty3" secondAttribute="leading" id="gEd-Xp-SyQ"/>
<constraint firstItem="x8e-QT-skP" firstAttribute="leading" secondItem="9pa-9d-4fr" secondAttribute="leading" id="lAL-GR-KdR"/>
<constraint firstAttribute="bottom" secondItem="x8e-QT-skP" secondAttribute="bottom" id="qt9-m5-Q8k"/>
<constraint firstItem="fnl-2z-Ty3" firstAttribute="trailing" secondItem="9pa-9d-4fr" secondAttribute="trailing" id="vAj-E3-wH0"/>
</constraints>
<freeformSimulatedSizeMetrics key="simulatedDestinationMetrics"/>
<viewLayoutGuide key="safeArea" id="fnl-2z-Ty3"/>
<userDefinedRuntimeAttributes>
<userDefinedRuntimeAttribute type="string" keyPath="styleName" value="Background"/>
</userDefinedRuntimeAttributes>
<point key="canvasLocation" x="138.40000000000001" y="136.73163418290855"/>
<variation key="default">
<mask key="constraints">
<exclude reference="UwT-LX-lcY"/>
<exclude reference="vAj-E3-wH0"/>
</mask>
</variation>
<variation key="heightClass=compact">
<mask key="constraints">
<include reference="UwT-LX-lcY"/>
</mask>
</variation>
<variation key="heightClass=regular">
<mask key="constraints">
<include reference="vAj-E3-wH0"/>
</mask>
</variation>
<point key="canvasLocation" x="138.40000000000001" y="221.28935532233885"/>
</view>
</objects>
</document>

View file

@ -13,7 +13,7 @@
}
@objc final class GuestsPickerViewController: UIViewController {
private let transitioning = CoverVerticalModalTransitioning(presentationHeight: 320)
private let transitioning = CoverVerticalModalTransitioning(presentationHeight: 340)
@IBOutlet var roomsStepper: ValueStepperView!
@IBOutlet var adultsStepper: ValueStepperView!

View file

@ -22,14 +22,21 @@
<rect key="frame" x="0.0" y="0.0" width="414" height="320"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="iE2-RE-OWd">
<rect key="frame" x="0.0" y="0.0" width="414" height="320"/>
<color key="backgroundColor" systemColor="systemBackgroundColor" cocoaTouchSystemColor="whiteColor"/>
<userDefinedRuntimeAttributes>
<userDefinedRuntimeAttribute type="string" keyPath="styleName" value="Background"/>
</userDefinedRuntimeAttributes>
</view>
<stackView opaque="NO" contentMode="scaleToFill" axis="vertical" translatesAutoresizingMaskIntoConstraints="NO" id="3ZC-cU-MNM">
<rect key="frame" x="0.0" y="0.0" width="414" height="320"/>
<subviews>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="xyR-57-dCD">
<rect key="frame" x="0.0" y="0.0" width="414" height="50"/>
<rect key="frame" x="0.0" y="0.0" width="414" height="54"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" text="Family" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="TG5-PM-toX">
<rect key="frame" x="16" y="10" width="382" height="29"/>
<rect key="frame" x="16" y="10" width="382" height="33"/>
<fontDescription key="fontDescription" type="boldSystem" pointSize="20"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
@ -39,7 +46,7 @@
</userDefinedRuntimeAttributes>
</label>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="apc-aI-IJI">
<rect key="frame" x="16" y="49" width="398" height="1"/>
<rect key="frame" x="16" y="53" width="398" height="1"/>
<color key="backgroundColor" systemColor="separatorColor" red="0.23529411759999999" green="0.23529411759999999" blue="0.26274509800000001" alpha="0.28999999999999998" colorSpace="custom" customColorSpace="sRGB"/>
<constraints>
<constraint firstAttribute="height" constant="1" id="BRZ-qD-EIb"/>
@ -61,10 +68,10 @@
</constraints>
</view>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="8cM-v0-O7k">
<rect key="frame" x="0.0" y="50" width="414" height="49"/>
<rect key="frame" x="0.0" y="54" width="414" height="47.5"/>
<subviews>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="9md-9e-Ze0">
<rect key="frame" x="56" y="48" width="358" height="1"/>
<rect key="frame" x="56" y="46.5" width="358" height="1"/>
<color key="backgroundColor" systemColor="separatorColor" red="0.23529411759999999" green="0.23529411759999999" blue="0.26274509800000001" alpha="0.28999999999999998" colorSpace="custom" customColorSpace="sRGB"/>
<constraints>
<constraint firstAttribute="height" constant="1" id="ySS-I1-GZF"/>
@ -74,7 +81,7 @@
</userDefinedRuntimeAttributes>
</view>
<imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="ic_booking_room" translatesAutoresizingMaskIntoConstraints="NO" id="vYB-zA-nJQ">
<rect key="frame" x="16" y="12.5" width="24" height="24"/>
<rect key="frame" x="16" y="12" width="24" height="24"/>
<color key="tintColor" white="0.33333333333333331" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<constraints>
<constraint firstAttribute="height" constant="24" id="6aD-2h-Vgl"/>
@ -85,7 +92,7 @@
</userDefinedRuntimeAttributes>
</imageView>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Rooms" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="gnR-wq-ESo">
<rect key="frame" x="56" y="14" width="234" height="21"/>
<rect key="frame" x="56" y="14" width="234" height="19.5"/>
<fontDescription key="fontDescription" type="system" pointSize="16"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
@ -95,7 +102,7 @@
</userDefinedRuntimeAttributes>
</label>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="UuG-Jq-Ceh" customClass="ValueStepperView" customModule="maps_me" customModuleProvider="target">
<rect key="frame" x="306" y="5.5" width="100" height="38"/>
<rect key="frame" x="306" y="5" width="100" height="38"/>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<constraints>
<constraint firstAttribute="height" constant="38" id="AKR-Yw-d97"/>
@ -122,10 +129,10 @@
</constraints>
</view>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="LZa-Gy-akP">
<rect key="frame" x="0.0" y="99" width="414" height="50"/>
<rect key="frame" x="0.0" y="101.5" width="414" height="47.5"/>
<subviews>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="CqJ-mp-Yqh">
<rect key="frame" x="56" y="49" width="358" height="1"/>
<rect key="frame" x="56" y="46.5" width="358" height="1"/>
<color key="backgroundColor" systemColor="separatorColor" red="0.23529411759999999" green="0.23529411759999999" blue="0.26274509800000001" alpha="0.28999999999999998" colorSpace="custom" customColorSpace="sRGB"/>
<constraints>
<constraint firstAttribute="height" constant="1" id="Fye-yR-j29"/>
@ -135,7 +142,7 @@
</userDefinedRuntimeAttributes>
</view>
<imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="ic_booking_people" translatesAutoresizingMaskIntoConstraints="NO" id="xgI-wP-Ash">
<rect key="frame" x="16" y="13" width="24" height="24"/>
<rect key="frame" x="16" y="12" width="24" height="24"/>
<color key="tintColor" white="0.13233090750000001" alpha="1" colorSpace="calibratedWhite"/>
<constraints>
<constraint firstAttribute="height" constant="24" id="Uq7-1Q-nj7"/>
@ -146,7 +153,7 @@
</userDefinedRuntimeAttributes>
</imageView>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Adults" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="NwB-tL-w2R">
<rect key="frame" x="56" y="14" width="234" height="22"/>
<rect key="frame" x="56" y="14" width="234" height="19.5"/>
<fontDescription key="fontDescription" type="system" pointSize="16"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
@ -156,7 +163,7 @@
</userDefinedRuntimeAttributes>
</label>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="Iih-wx-HWd" customClass="ValueStepperView" customModule="maps_me" customModuleProvider="target">
<rect key="frame" x="306" y="6" width="100" height="38"/>
<rect key="frame" x="306" y="5" width="100" height="38"/>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<constraints>
<constraint firstAttribute="width" constant="100" id="H6l-kr-84N"/>
@ -360,21 +367,45 @@
</userDefinedRuntimeAttributes>
</view>
</subviews>
<constraints>
<constraint firstAttribute="height" constant="320" id="Z4S-Eo-vxK"/>
<constraint firstAttribute="width" constant="350" id="gJY-Sg-qaN"/>
</constraints>
<variation key="default">
<mask key="constraints">
<exclude reference="gJY-Sg-qaN"/>
</mask>
</variation>
<variation key="heightClass=compact">
<mask key="constraints">
<include reference="gJY-Sg-qaN"/>
</mask>
</variation>
</stackView>
</subviews>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<constraints>
<constraint firstItem="iE2-RE-OWd" firstAttribute="trailing" secondItem="3ZC-cU-MNM" secondAttribute="trailing" id="2bX-R0-ETI"/>
<constraint firstItem="fnl-2z-Ty3" firstAttribute="bottom" secondItem="3ZC-cU-MNM" secondAttribute="bottom" id="AzB-Y2-R3U"/>
<constraint firstItem="iE2-RE-OWd" firstAttribute="top" secondItem="3ZC-cU-MNM" secondAttribute="top" id="B0O-V2-7U1"/>
<constraint firstItem="iE2-RE-OWd" firstAttribute="leading" secondItem="3ZC-cU-MNM" secondAttribute="leading" id="DYO-z4-s32"/>
<constraint firstAttribute="bottom" secondItem="iE2-RE-OWd" secondAttribute="bottom" id="Ifr-hn-5ex"/>
<constraint firstItem="3ZC-cU-MNM" firstAttribute="leading" secondItem="fnl-2z-Ty3" secondAttribute="leading" id="VXy-sp-VfJ"/>
<constraint firstItem="3ZC-cU-MNM" firstAttribute="top" secondItem="fnl-2z-Ty3" secondAttribute="top" id="j8c-dC-FdF"/>
<constraint firstItem="fnl-2z-Ty3" firstAttribute="trailing" secondItem="3ZC-cU-MNM" secondAttribute="trailing" id="lj2-YQ-0bF"/>
</constraints>
<freeformSimulatedSizeMetrics key="simulatedDestinationMetrics"/>
<viewLayoutGuide key="safeArea" id="fnl-2z-Ty3"/>
<userDefinedRuntimeAttributes>
<userDefinedRuntimeAttribute type="string" keyPath="styleName" value="Background"/>
</userDefinedRuntimeAttributes>
<point key="canvasLocation" x="137.59999999999999" y="313.94302848575717"/>
<variation key="default">
<mask key="constraints">
<exclude reference="lj2-YQ-0bF"/>
</mask>
</variation>
<variation key="heightClass=regular">
<mask key="constraints">
<include reference="lj2-YQ-0bF"/>
</mask>
</variation>
<point key="canvasLocation" x="134.40000000000001" y="349.92503748125938"/>
</view>
</objects>
<resources>