[iOS] After Booking popup fixes

This commit is contained in:
Zoia Pribytkova 2019-08-15 17:13:46 +03:00 committed by Aleksandr Zatsepin
parent a5f747e995
commit 5127664ad1
4 changed files with 74 additions and 28 deletions

View file

@ -0,0 +1,33 @@
final class PromoBookingPresentationController: DimmedModalPresentationController {
let sideMargin: CGFloat = 32.0
let maxWidth: CGFloat = 310.0
override var frameOfPresentedViewInContainerView: CGRect {
let f = super.frameOfPresentedViewInContainerView
let estimatedWidth = min(maxWidth, f.width - (sideMargin * 2.0))
let s = presentedViewController.view.systemLayoutSizeFitting(CGSize(width: estimatedWidth, height: f.height), withHorizontalFittingPriority: .required, verticalFittingPriority: .defaultLow)
let r = CGRect(x: (f.width - s.width) / 2, y: (f.height - s.height) / 2, width: s.width, height: s.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()
}
}
}

View file

@ -589,6 +589,7 @@
BB8123D0212C264700ADE512 /* MetalKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = BB8123CE212C264700ADE512 /* MetalKit.framework */; settings = {ATTRIBUTES = (Weak, ); }; };
BB8123D62130427E00ADE512 /* MetalContextFactory.mm in Sources */ = {isa = PBXBuildFile; fileRef = BB8123D52130427E00ADE512 /* MetalContextFactory.mm */; };
CD08887422B7ABB400C1368D /* MWMDiscoveryCollectionView.mm in Sources */ = {isa = PBXBuildFile; fileRef = CD08887322B7ABB400C1368D /* MWMDiscoveryCollectionView.mm */; };
CD4A1F132305872700F2A6B6 /* PromoBookingPresentationController.swift in Sources */ = {isa = PBXBuildFile; fileRef = CD4A1F122305872700F2A6B6 /* PromoBookingPresentationController.swift */; };
CD6E8677226774C700D1EDF7 /* CPConstants.swift in Sources */ = {isa = PBXBuildFile; fileRef = CD6E8676226774C700D1EDF7 /* CPConstants.swift */; };
CD96C70C22A681C400DB7CFE /* DiscoveryGuideCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = CD96C70A22A681C400DB7CFE /* DiscoveryGuideCell.swift */; };
CD96C70D22A681C400DB7CFE /* DiscoveryGuideCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = CD96C70B22A681C400DB7CFE /* DiscoveryGuideCell.xib */; };
@ -1677,6 +1678,7 @@
CD08887322B7ABB400C1368D /* MWMDiscoveryCollectionView.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = MWMDiscoveryCollectionView.mm; sourceTree = "<group>"; };
CD08888322BCF1C800C1368D /* maps.me rel.entitlements */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.entitlements; path = "maps.me rel.entitlements"; sourceTree = "<group>"; };
CD08888422BCF1C900C1368D /* maps.me full.entitlements */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.entitlements; path = "maps.me full.entitlements"; sourceTree = "<group>"; };
CD4A1F122305872700F2A6B6 /* PromoBookingPresentationController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PromoBookingPresentationController.swift; sourceTree = "<group>"; };
CD6E8676226774C700D1EDF7 /* CPConstants.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CPConstants.swift; sourceTree = "<group>"; };
CD96C70A22A681C400DB7CFE /* DiscoveryGuideCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DiscoveryGuideCell.swift; sourceTree = "<group>"; };
CD96C70B22A681C400DB7CFE /* DiscoveryGuideCell.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = DiscoveryGuideCell.xib; sourceTree = "<group>"; };
@ -3605,6 +3607,7 @@
47EF05B12150383A00EAC269 /* RemoveAds */,
47E3C7242111E41B008B3B27 /* DimmedModalPresentationController.swift */,
47E3C7262111E5A8008B3B27 /* AlertPresentationController.swift */,
CD4A1F122305872700F2A6B6 /* PromoBookingPresentationController.swift */,
47E3C7282111E614008B3B27 /* FadeInAnimatedTransitioning.swift */,
47E3C72A2111E62A008B3B27 /* FadeOutAnimatedTransitioning.swift */,
47E3C72C2111E6A2008B3B27 /* FadeTransitioning.swift */,
@ -5542,6 +5545,7 @@
347752901F7251C7000D46A3 /* UGCAddReviewTextCell.swift in Sources */,
34E50DF01F6FCC41008EED49 /* UGCYourReviewCell.swift in Sources */,
34AB66381FC5AA330078E451 /* RouteManagerCell.swift in Sources */,
CD4A1F132305872700F2A6B6 /* PromoBookingPresentationController.swift in Sources */,
3472B5D3200F501500DC6CD5 /* BackgroundFetchTaskFrameworkType.swift in Sources */,
F6E2FF301E097BA00083EBEC /* MWMSearchCommonCell.mm in Sources */,
F6E2FEA01E097BA00083EBEC /* MWMPlacePageLayout.mm in Sources */,

View file

@ -1,12 +1,25 @@
@objc
class PromoAfterBookingViewController: UIViewController {
private let transitioning = FadeTransitioning<AlertPresentationController>()
private let transitioning = FadeTransitioning<PromoBookingPresentationController>()
private var cityImageUrl: String
private var okClosure: MWMVoidBlock
private var cancelClosure: MWMVoidBlock
private var isOnButtonClosed: Bool = false
@IBOutlet weak var cityImageView: UIImageView!
@IBOutlet var cityImageView: UIImageView!
@IBOutlet var descriptionLabel: UILabel! {
didSet {
let desc = L("popup_booking_download_guides_message")
let paragraphStyle = NSMutableParagraphStyle()
paragraphStyle.lineSpacing = 3
let attributedDesc = NSAttributedString(string: desc, attributes: [
.font : UIFont.regular14(),
.foregroundColor : UIColor.blackSecondaryText(),
.paragraphStyle : paragraphStyle
])
descriptionLabel.attributedText = attributedDesc
}
}
@objc init(cityImageUrl: String, okClosure: @escaping MWMVoidBlock, cancelClosure: @escaping MWMVoidBlock) {
self.cityImageUrl = cityImageUrl

View file

@ -13,6 +13,7 @@
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner" customClass="PromoAfterBookingViewController" customModule="maps_me" customModuleProvider="target">
<connections>
<outlet property="cityImageView" destination="sDQ-mR-Qzk" id="zGI-LE-s8P"/>
<outlet property="descriptionLabel" destination="9tQ-SL-jQU" id="dzJ-7y-L2z"/>
<outlet property="view" destination="BIK-1L-Jgv" id="j5K-AU-y0g"/>
</connections>
</placeholder>
@ -25,7 +26,6 @@
<rect key="frame" x="0.0" y="0.0" width="307" height="128"/>
<constraints>
<constraint firstAttribute="height" constant="128" id="NJk-9b-9g9"/>
<constraint firstAttribute="width" constant="307" id="Rye-Y6-lJx"/>
</constraints>
</imageView>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Booked a hotel?" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="rST-i3-ilM">
@ -44,18 +44,13 @@
<fontDescription key="fontDescription" type="system" pointSize="14"/>
<color key="textColor" white="0.0" alpha="0.54000000000000004" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<nil key="highlightedColor"/>
<userDefinedRuntimeAttributes>
<userDefinedRuntimeAttribute type="string" keyPath="localizedText" value="popup_booking_download_guides_message"/>
<userDefinedRuntimeAttribute type="string" keyPath="colorName" value="blackSecondaryText"/>
<userDefinedRuntimeAttribute type="string" keyPath="fontName" value="regular14"/>
</userDefinedRuntimeAttributes>
</label>
<button opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="s7h-bI-mHW">
<rect key="frame" x="16" y="227" width="275" height="48"/>
<color key="backgroundColor" red="0.11767578125" green="0.58980089430000004" blue="0.94108072916666663" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<constraints>
<constraint firstAttribute="width" constant="275" id="0m8-86-yE0"/>
<constraint firstAttribute="height" constant="48" id="2Aa-Ig-c33"/>
<constraint firstAttribute="width" constant="275" id="2x0-bz-0O5"/>
</constraints>
<fontDescription key="fontDescription" type="system" weight="semibold" pointSize="16"/>
<state key="normal" title="Discover Guides"/>
@ -65,20 +60,19 @@
<integer key="value" value="8"/>
</userDefinedRuntimeAttribute>
<userDefinedRuntimeAttribute type="string" keyPath="fontName" value="bold16"/>
<userDefinedRuntimeAttribute type="string" keyPath="textColorHighlightedName" value="white"/>
<userDefinedRuntimeAttribute type="string" keyPath="textColorName" value="white"/>
<userDefinedRuntimeAttribute type="string" keyPath="backgroundColorName" value="linkBlue"/>
<userDefinedRuntimeAttribute type="string" keyPath="backgroundHighlightedColorName" value="linkBlueHighlighted"/>
<userDefinedRuntimeAttribute type="string" keyPath="textColorHighlightedName" value="whitePrimaryTextHighlighted"/>
<userDefinedRuntimeAttribute type="string" keyPath="textColorName" value="whitePrimaryText"/>
</userDefinedRuntimeAttributes>
<connections>
<action selector="onOk" destination="-1" eventType="touchUpInside" id="fNr-s9-Hg3"/>
</connections>
</button>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="3oa-Vj-n0Q">
<rect key="frame" x="16" y="283" width="275" height="48"/>
<rect key="frame" x="16" y="285" width="275" height="40"/>
<constraints>
<constraint firstAttribute="width" constant="275" id="cwU-Xt-F7y"/>
<constraint firstAttribute="height" constant="48" id="f8G-sC-CzS"/>
<constraint firstAttribute="height" constant="40" id="f8G-sC-CzS"/>
</constraints>
<fontDescription key="fontDescription" type="system" weight="semibold" pointSize="16"/>
<state key="normal" title="Cancel">
@ -89,6 +83,8 @@
<userDefinedRuntimeAttribute type="number" keyPath="layer.cornerRadius">
<integer key="value" value="8"/>
</userDefinedRuntimeAttribute>
<userDefinedRuntimeAttribute type="string" keyPath="textColorHighlightedName" value="blackSecondaryText"/>
<userDefinedRuntimeAttribute type="string" keyPath="textColorName" value="blackSecondaryText"/>
</userDefinedRuntimeAttributes>
<connections>
<action selector="onCancel" destination="-1" eventType="touchUpInside" id="cRZ-PQ-NWh"/>
@ -97,22 +93,22 @@
</subviews>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<constraints>
<constraint firstItem="sDQ-mR-Qzk" firstAttribute="leading" secondItem="KOL-sB-eMa" secondAttribute="leading" id="1gC-m1-Vt8"/>
<constraint firstItem="sDQ-mR-Qzk" firstAttribute="top" secondItem="KOL-sB-eMa" secondAttribute="top" id="2ew-IR-iMY"/>
<constraint firstItem="3oa-Vj-n0Q" firstAttribute="top" secondItem="s7h-bI-mHW" secondAttribute="bottom" constant="8" id="3vS-Sf-cy1"/>
<constraint firstItem="sDQ-mR-Qzk" firstAttribute="leading" secondItem="BIK-1L-Jgv" secondAttribute="leading" id="1gC-m1-Vt8"/>
<constraint firstItem="sDQ-mR-Qzk" firstAttribute="top" secondItem="BIK-1L-Jgv" secondAttribute="top" id="2ew-IR-iMY"/>
<constraint firstItem="3oa-Vj-n0Q" firstAttribute="top" secondItem="s7h-bI-mHW" secondAttribute="bottom" constant="10" id="3vS-Sf-cy1"/>
<constraint firstItem="rST-i3-ilM" firstAttribute="top" secondItem="sDQ-mR-Qzk" secondAttribute="bottom" constant="16" id="6tG-Pi-hDQ"/>
<constraint firstItem="rST-i3-ilM" firstAttribute="leading" secondItem="KOL-sB-eMa" secondAttribute="leading" constant="18" id="75L-G4-PJ4"/>
<constraint firstItem="KOL-sB-eMa" firstAttribute="trailing" secondItem="rST-i3-ilM" secondAttribute="trailing" constant="18" id="9g8-5m-yul"/>
<constraint firstItem="3oa-Vj-n0Q" firstAttribute="leading" secondItem="KOL-sB-eMa" secondAttribute="leading" constant="16" id="FoX-wo-jMZ"/>
<constraint firstItem="rST-i3-ilM" firstAttribute="leading" secondItem="BIK-1L-Jgv" secondAttribute="leading" constant="18" id="75L-G4-PJ4"/>
<constraint firstAttribute="trailing" secondItem="rST-i3-ilM" secondAttribute="trailing" constant="18" id="9g8-5m-yul"/>
<constraint firstItem="3oa-Vj-n0Q" firstAttribute="leading" secondItem="BIK-1L-Jgv" secondAttribute="leading" constant="16" id="FoX-wo-jMZ"/>
<constraint firstItem="s7h-bI-mHW" firstAttribute="top" secondItem="9tQ-SL-jQU" secondAttribute="bottom" constant="20" id="PbO-1K-3bN"/>
<constraint firstItem="9tQ-SL-jQU" firstAttribute="top" secondItem="rST-i3-ilM" secondAttribute="bottom" constant="8" id="Sm7-8W-ZWh"/>
<constraint firstItem="KOL-sB-eMa" firstAttribute="trailing" secondItem="9tQ-SL-jQU" secondAttribute="trailing" constant="18" id="WLR-t2-3Qp"/>
<constraint firstItem="KOL-sB-eMa" firstAttribute="trailing" secondItem="s7h-bI-mHW" secondAttribute="trailing" constant="16" id="hU8-gZ-kny"/>
<constraint firstItem="s7h-bI-mHW" firstAttribute="leading" secondItem="KOL-sB-eMa" secondAttribute="leading" constant="16" id="kGK-rF-oHQ"/>
<constraint firstItem="9tQ-SL-jQU" firstAttribute="leading" secondItem="KOL-sB-eMa" secondAttribute="leading" constant="18" id="kxH-7p-4pU"/>
<constraint firstItem="KOL-sB-eMa" firstAttribute="trailing" secondItem="3oa-Vj-n0Q" secondAttribute="trailing" constant="16" id="qx8-UG-zXp"/>
<constraint firstItem="sDQ-mR-Qzk" firstAttribute="trailing" secondItem="KOL-sB-eMa" secondAttribute="trailing" id="s8H-x9-uGL"/>
<constraint firstItem="KOL-sB-eMa" firstAttribute="bottom" secondItem="3oa-Vj-n0Q" secondAttribute="bottom" constant="8" id="ykg-KU-alf"/>
<constraint firstAttribute="trailing" secondItem="9tQ-SL-jQU" secondAttribute="trailing" constant="18" id="WLR-t2-3Qp"/>
<constraint firstAttribute="trailing" secondItem="s7h-bI-mHW" secondAttribute="trailing" constant="16" id="hU8-gZ-kny"/>
<constraint firstItem="s7h-bI-mHW" firstAttribute="leading" secondItem="BIK-1L-Jgv" secondAttribute="leading" constant="16" id="kGK-rF-oHQ"/>
<constraint firstItem="9tQ-SL-jQU" firstAttribute="leading" secondItem="BIK-1L-Jgv" secondAttribute="leading" constant="18" id="kxH-7p-4pU"/>
<constraint firstAttribute="trailing" secondItem="3oa-Vj-n0Q" secondAttribute="trailing" constant="16" id="qx8-UG-zXp"/>
<constraint firstItem="sDQ-mR-Qzk" firstAttribute="trailing" secondItem="BIK-1L-Jgv" secondAttribute="trailing" id="s8H-x9-uGL"/>
<constraint firstAttribute="bottom" secondItem="3oa-Vj-n0Q" secondAttribute="bottom" constant="14" id="ykg-KU-alf"/>
</constraints>
<freeformSimulatedSizeMetrics key="simulatedDestinationMetrics"/>
<viewLayoutGuide key="safeArea" id="KOL-sB-eMa"/>
@ -122,7 +118,7 @@
<integer key="value" value="8"/>
</userDefinedRuntimeAttribute>
</userDefinedRuntimeAttributes>
<point key="canvasLocation" x="-779" y="-103"/>
<point key="canvasLocation" x="-779.46026986506752" y="-103.2"/>
</view>
</objects>
<resources>