[iOS] fix scroll and popover issues in PP on iPad

https://jira.mail.ru/browse/MAPSME-13134
This commit is contained in:
Aleksey Belousov 2020-03-11 17:35:28 +03:00 committed by Alexander Boriskov
parent 6de57c8421
commit c246720bb3
7 changed files with 26 additions and 14 deletions

View file

@ -1,10 +1,13 @@
protocol ActionBarViewControllerDelegate: AnyObject {
func actionBarDidPressButton(_ type: ActionBarButtonType)
func actionBar(_ actionBar: ActionBarViewController, dPressButton type: ActionBarButtonType)
}
class ActionBarViewController: UIViewController {
@IBOutlet var stackView: UIStackView!
var downloadButton: ActionBarButton? = nil
var popoverSourceView: UIView? {
stackView.arrangedSubviews.last
}
var placePageData: PlacePageData!
var isRoutePlanning = false
@ -165,10 +168,15 @@ class ActionBarViewController: UIViewController {
actionSheet.addAction(UIAlertAction(title: titleForButton(button, placePageData.partnerIndex, false),
style: .default,
handler: { [weak self] _ in
self?.delegate?.actionBarDidPressButton(button)
guard let self = self else { return }
self.delegate?.actionBar(self, dPressButton: button)
}))
}
actionSheet.addAction(UIAlertAction(title: L("cancel"), style: .cancel))
if let popover = actionSheet.popoverPresentationController, let sourceView = stackView.arrangedSubviews.last {
popover.sourceView = sourceView
popover.sourceRect = sourceView.bounds
}
present(actionSheet, animated: true)
}
}
@ -179,6 +187,6 @@ extension ActionBarViewController: ActionBarButtonDelegate {
showMore()
return
}
delegate?.actionBarDidPressButton(type)
delegate?.actionBar(self, dPressButton: type)
}
}

View file

@ -190,7 +190,7 @@ extension PlacePageInteractor: PlacePageBookmarkViewControllerDelegate {
// MARK: - ActionBarViewControllerDelegate
extension PlacePageInteractor: ActionBarViewControllerDelegate {
func actionBarDidPressButton(_ type: ActionBarButtonType) {
func actionBar(_ actionBar: ActionBarViewController, dPressButton type: ActionBarButtonType) {
switch type {
case .booking:
MWMPlacePageManagerHelper.book(placePageData)
@ -228,7 +228,9 @@ extension PlacePageInteractor: ActionBarViewControllerDelegate {
case .routeTo:
MWMPlacePageManagerHelper.route(to: placePageData)
case .share:
MWMPlacePageManagerHelper.share(placePageData)
let shareVC = MWMActivityViewController.share(forPlacePage: placePageData)
shareVC!.present(inParentViewController: actionBar, anchorView: actionBar.popoverSourceView)
Statistics.logEvent(kStatEventName(kStatPlacePage, kStatShare))
case .avoidToll:
MWMPlacePageManagerHelper.avoidToll()
case .avoidDirty:

View file

@ -21,7 +21,7 @@ enum PlacePageState {
protocol IPlacePageLayout: class {
var presenter: PlacePagePresenterProtocol? { get set }
var viewControllers: [UIViewController] { get }
var actionBar: UIViewController? { get }
var actionBar: ActionBarViewController? { get }
var adState: AdBannerState { get set }
func calculateSteps(inScrollView scrollView: UIScrollView) -> [PlacePageState]

View file

@ -10,7 +10,7 @@ class PlacePageCommonLayout: NSObject, IPlacePageLayout {
return configureViewControllers()
}()
var actionBar: UIViewController? {
var actionBar: ActionBarViewController? {
return actionBarViewController
}

View file

@ -8,7 +8,7 @@ class PlacePageElevationLayout: IPlacePageLayout {
return configureViewControllers()
}()
var actionBar: UIViewController? = nil
var actionBar: ActionBarViewController? = nil
var adState: AdBannerState = .unset
lazy var previewViewController: PlacePagePreviewViewController = {

View file

@ -96,6 +96,10 @@ extension PlacePageViewController: PlacePageViewProtocol {
}
func scrollTo(_ point: CGPoint) {
if traitCollection.horizontalSizeClass != .compact || beginDragging {
return
}
UIView.animate(withDuration: kDefaultAnimationDuration) { [weak scrollView] in
scrollView?.contentOffset = point
}

View file

@ -1,9 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="15705" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="Wns-nH-AQU">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="15702" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="Wns-nH-AQU">
<device id="retina6_1" orientation="portrait" appearance="light"/>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="15706"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="15704"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
@ -108,9 +108,7 @@
<constraint firstItem="Tqh-46-Yrm" firstAttribute="centerX" secondItem="utd-Jy-pE5" secondAttribute="centerX" id="0T0-4t-4m2"/>
<constraint firstItem="utd-Jy-pE5" firstAttribute="bottom" secondItem="65S-M4-TnM" secondAttribute="bottom" priority="100" id="2E3-5i-6An"/>
<constraint firstAttribute="bottom" secondItem="rL1-9E-4b7" secondAttribute="bottom" id="4fw-Xu-gAG"/>
<constraint firstItem="rbx-Oj-jeo" firstAttribute="leading" secondItem="utd-Jy-pE5" secondAttribute="leading" id="5Sh-l6-Icd">
<variation key="heightClass=regular-widthClass=regular" constant="75"/>
</constraint>
<constraint firstItem="rbx-Oj-jeo" firstAttribute="leading" secondItem="utd-Jy-pE5" secondAttribute="leading" id="5Sh-l6-Icd"/>
<constraint firstItem="utd-Jy-pE5" firstAttribute="bottom" secondItem="QKu-4A-UgP" secondAttribute="bottom" priority="100" id="6ko-rI-S5u"/>
<constraint firstItem="Tqh-46-Yrm" firstAttribute="centerY" secondItem="utd-Jy-pE5" secondAttribute="centerY" id="7pv-5d-X2W"/>
<constraint firstItem="utd-Jy-pE5" firstAttribute="trailing" secondItem="rbx-Oj-jeo" secondAttribute="trailing" id="9M9-8P-Hzb"/>
@ -1122,7 +1120,7 @@
<inferredMetricsTieBreakers>
<segue reference="sMq-pa-AId"/>
<segue reference="4Cc-99-mlN"/>
<segue reference="gFM-Ca-ARt"/>
<segue reference="OEF-kR-jKi"/>
<segue reference="0A8-4b-0A2"/>
</inferredMetricsTieBreakers>
</document>