diff --git a/iphone/Maps/Bookmarks/Catalog/Subscription/BaseSubscriptionViewController.swift b/iphone/Maps/Bookmarks/Catalog/Subscription/BaseSubscriptionViewController.swift index 13ac12c832..0f24a640cc 100644 --- a/iphone/Maps/Bookmarks/Catalog/Subscription/BaseSubscriptionViewController.swift +++ b/iphone/Maps/Bookmarks/Catalog/Subscription/BaseSubscriptionViewController.swift @@ -12,6 +12,7 @@ class BaseSubscriptionViewController: MWMViewController { @objc var onSubscribe: MWMVoidBlock? @objc var onCancel: MWMVoidBlock? @objc var source: String = kStatWebView + private let transitioning = FadeTransitioning() override var supportedInterfaceOrientations: UIInterfaceOrientationMask { get { return [.portrait] } @@ -24,10 +25,10 @@ class BaseSubscriptionViewController: MWMViewController { override init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: Bundle?) { super.init(nibName: nibNameOrNil, bundle: nibBundleOrNil) if UIDevice.current.userInterfaceIdiom == .pad { - self.modalTransitionStyle = .coverVertical - self.modalPresentationStyle = .formSheet + transitioningDelegate = transitioning + modalPresentationStyle = .custom } else { - self.modalPresentationStyle = .fullScreen + modalPresentationStyle = .fullScreen } } @@ -42,7 +43,6 @@ class BaseSubscriptionViewController: MWMViewController { override func viewDidLoad() { super.viewDidLoad() subscriptionManager?.addListener(self) - self.presentationController?.delegate = self; } func configure(buttons: [SubscriptionPeriod: BookmarksSubscriptionButton], diff --git a/iphone/Maps/Classes/Components/Modal/IPadModalPresentationController.swift b/iphone/Maps/Classes/Components/Modal/IPadModalPresentationController.swift new file mode 100644 index 0000000000..f4ec04d1af --- /dev/null +++ b/iphone/Maps/Classes/Components/Modal/IPadModalPresentationController.swift @@ -0,0 +1,34 @@ +final class IPadModalPresentationController: DimmedModalPresentationController { +override var frameOfPresentedViewInContainerView: CGRect { + guard let containerView = containerView else { return CGRect.zero } + let screenSize = UIScreen.main.bounds + let contentSize = presentedViewController.preferredContentSize + let r = alternative(iPhone: containerView.bounds, + iPad: CGRect(x: screenSize.width/2 - contentSize.width/2, + y: screenSize.height/2 - contentSize.height/2, + width: contentSize.width, + height: contentSize.height)) + return r + } + + override func containerViewWillLayoutSubviews() { + presentedView?.frame = frameOfPresentedViewInContainerView + } + + override func presentationTransitionWillBegin() { + super.presentationTransitionWillBegin() + presentedViewController.view.layer.cornerRadius = 8 + presentedViewController.view.clipsToBounds = true + guard let containerView = containerView, let presentedView = presentedView else { return } + containerView.addSubview(presentedView) + presentedView.frame = frameOfPresentedViewInContainerView + } + + override func dismissalTransitionDidEnd(_ completed: Bool) { + super.presentationTransitionDidEnd(completed) + guard let presentedView = presentedView else { return } + if completed { + presentedView.removeFromSuperview() + } + } +} diff --git a/iphone/Maps/Classes/CustomViews/MapViewControls/PromoButton/PromoCoordinator.swift b/iphone/Maps/Classes/CustomViews/MapViewControls/PromoButton/PromoCoordinator.swift index 24b23f0d01..c0b10259ae 100644 --- a/iphone/Maps/Classes/CustomViews/MapViewControls/PromoButton/PromoCoordinator.swift +++ b/iphone/Maps/Classes/CustomViews/MapViewControls/PromoButton/PromoCoordinator.swift @@ -22,7 +22,6 @@ import UIKit private func presentPromoDiscoveryOnboarding(completion: @escaping () -> Void) { let vc = PromoDiscoveryBuilder.build(rootViewController: mapViewController, campaign: campaign) - vc.modalPresentationStyle = .fullScreen mapViewController?.present(vc, animated: true, completion: { completion() }) diff --git a/iphone/Maps/Maps.xcodeproj/project.pbxproj b/iphone/Maps/Maps.xcodeproj/project.pbxproj index 8f175802e1..a4c2522f99 100644 --- a/iphone/Maps/Maps.xcodeproj/project.pbxproj +++ b/iphone/Maps/Maps.xcodeproj/project.pbxproj @@ -573,6 +573,7 @@ 6B653B951C7F2DE4007BEFC5 /* cuisine-strings in Resources */ = {isa = PBXBuildFile; fileRef = 6B653B931C7F2DE4007BEFC5 /* cuisine-strings */; }; 6B9978361C89A316003B8AA0 /* editor.config in Resources */ = {isa = PBXBuildFile; fileRef = 6B9978341C89A316003B8AA0 /* editor.config */; }; 7BD07E4A8D71CA41F082BEC7 /* Pods_MAPS_ME.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 58E5736C23FC4E77509C9946 /* Pods_MAPS_ME.framework */; }; + 9917D1852397ECC800A7E06E /* IPadModalPresentationController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9917D1842397ECC800A7E06E /* IPadModalPresentationController.swift */; }; 991CE2BF2371D349009EB02A /* PromoCampaignManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 991CE2BA2371D349009EB02A /* PromoCampaignManager.swift */; }; 991CE2C02371D349009EB02A /* PromoCampaign.swift in Sources */ = {isa = PBXBuildFile; fileRef = 991CE2BB2371D349009EB02A /* PromoCampaign.swift */; }; 991CE2C22371D349009EB02A /* PromoDiscoveryCampaign.swift in Sources */ = {isa = PBXBuildFile; fileRef = 991CE2BE2371D349009EB02A /* PromoDiscoveryCampaign.swift */; }; @@ -1644,6 +1645,7 @@ 8D1107310486CEB800E47090 /* MAPSME.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = MAPSME.plist; plistStructureDefinitionIdentifier = "com.apple.xcode.plist.structure-definition.iphone.info-plist"; sourceTree = ""; }; 978D4A30199A11E600D72CA7 /* faq.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; name = faq.html; path = ../../data/faq.html; sourceTree = ""; }; 97A5967E19B9CD47007A963F /* copyright.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; name = copyright.html; path = ../../data/copyright.html; sourceTree = ""; }; + 9917D1842397ECC800A7E06E /* IPadModalPresentationController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = IPadModalPresentationController.swift; sourceTree = ""; }; 991CE2BA2371D349009EB02A /* PromoCampaignManager.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PromoCampaignManager.swift; sourceTree = ""; }; 991CE2BB2371D349009EB02A /* PromoCampaign.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PromoCampaign.swift; sourceTree = ""; }; 991CE2BE2371D349009EB02A /* PromoDiscoveryCampaign.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PromoDiscoveryCampaign.swift; sourceTree = ""; }; @@ -3626,6 +3628,7 @@ 47E3C7242111E41B008B3B27 /* DimmedModalPresentationController.swift */, 47E3C7262111E5A8008B3B27 /* AlertPresentationController.swift */, CD4A1F122305872700F2A6B6 /* PromoBookingPresentationController.swift */, + 9917D1842397ECC800A7E06E /* IPadModalPresentationController.swift */, 47E3C7282111E614008B3B27 /* FadeInAnimatedTransitioning.swift */, 47E3C72A2111E62A008B3B27 /* FadeOutAnimatedTransitioning.swift */, 47E3C72C2111E6A2008B3B27 /* FadeTransitioning.swift */, @@ -5798,6 +5801,7 @@ 340475711E081A4600C92850 /* MWMSettings.mm in Sources */, 33046832219C57180041F3A8 /* CategorySettingsViewController.swift in Sources */, 3404165C1E7C29AE00E2B6D6 /* PhotosInteractionAnimator.swift in Sources */, + 9917D1852397ECC800A7E06E /* IPadModalPresentationController.swift in Sources */, 993F550E237C622700545511 /* DeepLinkCataloguePathStrategy.swift in Sources */, 34E50DE01F6FCBA1008EED49 /* UGCAddReviewCell.swift in Sources */, 3404756E1E081A4600C92850 /* MWMSearch.mm in Sources */, diff --git a/iphone/Maps/UI/Welcome/WelcomeView/WelcomeViewController.swift b/iphone/Maps/UI/Welcome/WelcomeView/WelcomeViewController.swift index caae066e26..dd4e108254 100644 --- a/iphone/Maps/UI/Welcome/WelcomeView/WelcomeViewController.swift +++ b/iphone/Maps/UI/Welcome/WelcomeView/WelcomeViewController.swift @@ -19,6 +19,7 @@ class WelcomeViewController: MWMViewController, UIAdaptivePresentationController @IBOutlet private var closeButton: UIButton! @IBOutlet private var closeButtonHeightConstraint: NSLayoutConstraint! static var presentationSize = CGSize(width: 520, height: 600) + private let transitioning = FadeTransitioning() var isCloseButtonHidden: Bool = false { didSet{ @@ -28,9 +29,12 @@ class WelcomeViewController: MWMViewController, UIAdaptivePresentationController required init?(coder: NSCoder) { super.init(coder: coder) - self.modalTransitionStyle = .coverVertical - self.modalPresentationStyle = .formSheet - self.presentationController?.delegate = self; + if UIDevice.current.userInterfaceIdiom == .pad { + transitioningDelegate = transitioning + modalPresentationStyle = .custom + } else { + modalPresentationStyle = .fullScreen + } } override func viewDidLoad() {