From 8663b583c8deca54ad94f66ef0eeb3595d39bd8c Mon Sep 17 00:00:00 2001 From: Aleksey Belouosv Date: Thu, 17 Oct 2019 18:31:45 +0300 Subject: [PATCH] [iOS] limit min header image height --- .../Catalog/PaidRouteViewController.swift | 37 +- .../Catalog/PaidRouteViewController.xib | 506 +++++++++--------- 2 files changed, 280 insertions(+), 263 deletions(-) diff --git a/iphone/Maps/Bookmarks/Catalog/PaidRouteViewController.swift b/iphone/Maps/Bookmarks/Catalog/PaidRouteViewController.swift index 96a58afe39..b574e9c797 100644 --- a/iphone/Maps/Bookmarks/Catalog/PaidRouteViewController.swift +++ b/iphone/Maps/Bookmarks/Catalog/PaidRouteViewController.swift @@ -7,14 +7,15 @@ protocol PaidRouteViewControllerDelegate: AnyObject { } class PaidRouteViewController: MWMViewController { - @IBOutlet weak var previewImageView: UIImageView! - @IBOutlet weak var productNameLabel: UILabel! - @IBOutlet weak var routeTitleLabel: UILabel! - @IBOutlet weak var routeAuthorLabel: UILabel! - @IBOutlet weak var subscribeButton: UIButton! - @IBOutlet weak var buyButton: UIButton! - @IBOutlet weak var loadingIndicator: UIActivityIndicatorView! - @IBOutlet weak var loadingView: UIView! + @IBOutlet var scrollView: UIScrollView! + @IBOutlet var previewImageView: UIImageView! + @IBOutlet var productNameLabel: UILabel! + @IBOutlet var routeTitleLabel: UILabel! + @IBOutlet var routeAuthorLabel: UILabel! + @IBOutlet var subscribeButton: UIButton! + @IBOutlet var buyButton: UIButton! + @IBOutlet var loadingIndicator: UIActivityIndicatorView! + @IBOutlet var loadingView: UIView! weak var delegate: PaidRouteViewControllerDelegate? @@ -23,6 +24,7 @@ class PaidRouteViewController: MWMViewController { private let name: String private let author: String? private let imageUrl: URL? + private var adjustScroll = true private var product: IStoreProduct? private var subscription: ISubscription? @@ -119,6 +121,25 @@ class PaidRouteViewController: MWMViewController { return .lightContent } + override func viewDidAppear(_ animated: Bool) { + super.viewDidAppear(animated) + adjustScroll = false + } + + override func viewDidLayoutSubviews() { + super.viewDidLayoutSubviews() + guard adjustScroll else { + return + } + if previewImageView.height < 222 { + let adjustment = 222 - previewImageView.height + scrollView.contentInset = UIEdgeInsets(top: adjustment, left: 0, bottom: 0, right: 0) + scrollView.contentOffset = CGPoint(x: 0, y: -adjustment) + } else { + scrollView.contentInset = UIEdgeInsets(top: 1, left: 0, bottom: 0, right: 0) + } + } + private func pingServer(_ completion: @escaping (_ success: Bool) -> Void) { MWMBookmarksManager.shared().ping { (success) in completion(success) diff --git a/iphone/Maps/Bookmarks/Catalog/PaidRouteViewController.xib b/iphone/Maps/Bookmarks/Catalog/PaidRouteViewController.xib index 734abd9a39..86163a12a6 100644 --- a/iphone/Maps/Bookmarks/Catalog/PaidRouteViewController.xib +++ b/iphone/Maps/Bookmarks/Catalog/PaidRouteViewController.xib @@ -1,11 +1,9 @@ - - - - + + - + @@ -19,256 +17,272 @@ + - + - + - - + + - - + + - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + +