[iOS] display dates and guests pickers in popvers on iPad

This commit is contained in:
Aleksey Belousov 2020-07-24 14:29:44 +03:00 committed by Alexander Boriskov
parent 7bacce495a
commit c885b11710
4 changed files with 16 additions and 5 deletions

View file

@ -37,7 +37,7 @@ import DatePicker
}
override var modalPresentationStyle: UIModalPresentationStyle {
get { return .custom }
get { return alternativeSizeClass(iPhone: .custom, iPad: .popover) }
set { }
}

View file

@ -32,7 +32,7 @@
<rect key="frame" x="0.0" y="0.0" width="375" height="100"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" verticalHuggingPriority="251" text="Check in" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="k4A-Dw-iVQ">
<rect key="frame" x="16" y="10" width="284" height="24"/>
<rect key="frame" x="16" y="10" width="339" height="24"/>
<fontDescription key="fontDescription" type="boldSystem" pointSize="20"/>
<color key="textColor" white="0.13233090753424659" alpha="1" colorSpace="calibratedWhite"/>
<nil key="highlightedColor"/>
@ -41,8 +41,8 @@
<userDefinedRuntimeAttribute type="string" keyPath="styleName" value="bold20:blackPrimaryText"/>
</userDefinedRuntimeAttributes>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="13 days" textAlignment="right" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="YMA-Ha-iZz">
<rect key="frame" x="304" y="12.5" width="55" height="19.5"/>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="" textAlignment="right" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="YMA-Ha-iZz">
<rect key="frame" x="359" y="22" width="0.0" height="0.0"/>
<fontDescription key="fontDescription" type="system" pointSize="16"/>
<color key="textColor" white="0.56319563356164382" alpha="1" colorSpace="calibratedWhite"/>
<nil key="highlightedColor"/>

View file

@ -28,13 +28,20 @@
infantsStepper.maxValue = 20
}
override func viewDidLayoutSubviews() {
super.viewDidLayoutSubviews()
preferredContentSize = view.systemLayoutSizeFitting(UIView.layoutFittingCompressedSize,
withHorizontalFittingPriority: .required,
verticalFittingPriority: .fittingSizeLevel)
}
override var transitioningDelegate: UIViewControllerTransitioningDelegate? {
get { return transitioning }
set { }
}
override var modalPresentationStyle: UIModalPresentationStyle {
get { return .custom }
get { return alternativeSizeClass(iPhone: .custom, iPad: .popover) }
set { }
}

View file

@ -130,6 +130,8 @@ using Observers = NSHashTable<Observer>;
[self.searchTextField resignFirstResponder];
DatePickerViewController *controller = [[DatePickerViewController alloc] init];
controller.delegate = self;
controller.popoverPresentationController.sourceView = self.searchBarView;
controller.popoverPresentationController.permittedArrowDirections = UIPopoverArrowDirectionUp;
[[MapViewController sharedController] presentViewController:controller animated:YES completion:nil];
}
@ -137,6 +139,8 @@ using Observers = NSHashTable<Observer>;
[self.searchTextField resignFirstResponder];
GuestsPickerViewController *controller = [[GuestsPickerViewController alloc] init];
controller.delegate = self;
controller.popoverPresentationController.sourceView = self.searchBarView;
controller.popoverPresentationController.permittedArrowDirections = UIPopoverArrowDirectionUp;
[[MapViewController sharedController] presentViewController:controller animated:YES completion:nil];
}