From ce30835d7690f497b3cb9855ff3878f465d8a561 Mon Sep 17 00:00:00 2001 From: Alexander Date: Thu, 12 Mar 2020 16:33:30 +0300 Subject: [PATCH] [iOS] Add close button to preview header in PP https://jira.mail.ru/browse/MAPSME-13393 --- .../Common/PlacePagePreviewData.h | 1 + .../Common/PlacePagePreviewData.mm | 1 + .../Maps/Core/Theme/PlacePageStyleSheet.swift | 28 +++ .../ic_clear_24.imageset/Contents.json | 26 +++ .../ic_clear_24.imageset/Vector.png | Bin 0 -> 311 bytes .../ic_clear_24.imageset/Vector@2x.png | Bin 0 -> 674 bytes .../ic_clear_24.imageset/Vector@3x.png | Bin 0 -> 1105 bytes iphone/Maps/Maps.xcodeproj/project.pbxproj | 24 ++ .../PlacePageHeaderBuilder.swift | 16 ++ .../PlacePageHeaderPresenter.swift | 54 +++++ .../PlacePageHeader/PlacePageHeaderView.swift | 10 + .../PlacePageHeaderViewController.swift | 40 ++++ .../PlacePagePreviewViewController.swift | 29 ++- iphone/Maps/UI/PlacePage/PlacePage.storyboard | 221 +++++++++--------- .../UI/PlacePage/PlacePageInteractor.swift | 12 + .../Layouts/IPlacePageLayout.swift | 4 + .../Layouts/PlacePageCommonLayout.swift | 15 +- .../Layouts/PlacePageElevationLayout.swift | 10 +- .../UI/PlacePage/PlacePagePresenter.swift | 38 ++- .../PlacePage/PlacePageViewController.swift | 44 +++- iphone/Maps/UI/Storyboard/Main.storyboard | 2 +- 21 files changed, 438 insertions(+), 137 deletions(-) create mode 100644 iphone/Maps/Images.xcassets/Place Page/ic_clear_24.imageset/Contents.json create mode 100644 iphone/Maps/Images.xcassets/Place Page/ic_clear_24.imageset/Vector.png create mode 100644 iphone/Maps/Images.xcassets/Place Page/ic_clear_24.imageset/Vector@2x.png create mode 100644 iphone/Maps/Images.xcassets/Place Page/ic_clear_24.imageset/Vector@3x.png create mode 100644 iphone/Maps/UI/PlacePage/Components/PlacePageHeader/PlacePageHeaderBuilder.swift create mode 100644 iphone/Maps/UI/PlacePage/Components/PlacePageHeader/PlacePageHeaderPresenter.swift create mode 100644 iphone/Maps/UI/PlacePage/Components/PlacePageHeader/PlacePageHeaderView.swift create mode 100644 iphone/Maps/UI/PlacePage/Components/PlacePageHeader/PlacePageHeaderViewController.swift diff --git a/iphone/CoreApi/CoreApi/PlacePageData/Common/PlacePagePreviewData.h b/iphone/CoreApi/CoreApi/PlacePageData/Common/PlacePagePreviewData.h index b5914fea2c..97184ce75c 100644 --- a/iphone/CoreApi/CoreApi/PlacePageData/Common/PlacePagePreviewData.h +++ b/iphone/CoreApi/CoreApi/PlacePageData/Common/PlacePagePreviewData.h @@ -29,6 +29,7 @@ NS_ASSUME_NONNULL_BEGIN @property(nonatomic, readonly, nullable) NSString *title; @property(nonatomic, readonly, nullable) NSString *subtitle; +@property(nonatomic, readonly, nullable) NSString *coordinates; @property(nonatomic, readonly, nullable) NSString *address; @property(nonatomic, readonly, nullable) NSString *pricing; @property(nonatomic, readonly, nullable) NSNumber *rawPricing; diff --git a/iphone/CoreApi/CoreApi/PlacePageData/Common/PlacePagePreviewData.mm b/iphone/CoreApi/CoreApi/PlacePageData/Common/PlacePagePreviewData.mm index 943e7c06a1..06be0f691b 100644 --- a/iphone/CoreApi/CoreApi/PlacePageData/Common/PlacePagePreviewData.mm +++ b/iphone/CoreApi/CoreApi/PlacePageData/Common/PlacePagePreviewData.mm @@ -66,6 +66,7 @@ static PlacePageDataHotelType convertHotelType(std::optional (Void) in + s.backgroundColor = colors.white + s.cornerRadius = 10 + s.clip = true + } + + theme.add(styleName: "PPNavigationBarView") { (s) -> (Void) in + s.backgroundColor = colors.white + s.shadowColor = UIColor.black + s.shadowOffset = CGSize(width: 0, height: -1) + s.shadowOpacity = 1 + s.shadowOpacity = 0.6 + s.clip = false + } + + theme.add(styleName: "PPBackgroundView") { (s) -> (Void) in + s.backgroundColor = colors.white + s.cornerRadius = 10 + s.shadowColor = UIColor.black + s.shadowOffset = CGSize(width: 0, height: 1) + s.shadowOpacity = 0.6 + s.shadowRadius = 2 + } + + theme.add(styleName: "PPCloseButton") { (s) -> (Void) in + s.tintColor = colors.blackDividers + } } } diff --git a/iphone/Maps/Images.xcassets/Place Page/ic_clear_24.imageset/Contents.json b/iphone/Maps/Images.xcassets/Place Page/ic_clear_24.imageset/Contents.json new file mode 100644 index 0000000000..4d58903fb9 --- /dev/null +++ b/iphone/Maps/Images.xcassets/Place Page/ic_clear_24.imageset/Contents.json @@ -0,0 +1,26 @@ +{ + "images" : [ + { + "idiom" : "universal", + "filename" : "Vector.png", + "scale" : "1x" + }, + { + "idiom" : "universal", + "filename" : "Vector@2x.png", + "scale" : "2x" + }, + { + "idiom" : "universal", + "filename" : "Vector@3x.png", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + }, + "properties" : { + "template-rendering-intent" : "template" + } +} \ No newline at end of file diff --git a/iphone/Maps/Images.xcassets/Place Page/ic_clear_24.imageset/Vector.png b/iphone/Maps/Images.xcassets/Place Page/ic_clear_24.imageset/Vector.png new file mode 100644 index 0000000000000000000000000000000000000000..b7f8a1fcaafc415eedcda68fd609b9eb3f7ff18e GIT binary patch literal 311 zcmeAS@N?(olHy`uVBq!ia0vp^A|TAc1|)ksWqE-VXMsm#F#`j)FbFd;%$g$s6l5$8 za(7}_cTVOdki(Mh=(ox(!v-9#f$AU9zOub!JIi*G z?WEdEHMvGXBc|3c{0MsabASDsx?x8Xl`>pM$_Lf!FnyRK%SzZg7S{an^LB{Ts5 D81Qma literal 0 HcmV?d00001 diff --git a/iphone/Maps/Images.xcassets/Place Page/ic_clear_24.imageset/Vector@2x.png b/iphone/Maps/Images.xcassets/Place Page/ic_clear_24.imageset/Vector@2x.png new file mode 100644 index 0000000000000000000000000000000000000000..ef070358af6c9399bd8e86461e499517c9edf5db GIT binary patch literal 674 zcmV;T0$u%yP)=oL8-A1j68MuOFN;B+_6_4p6aE1MonY26@#Bs=D=$`~_>81`Nygl!_ zra%)HQNv-5;I?p)f1<+9?MaF!U>Ckf5Dmqp4Z#(>e!BPQbNp5lIYQZEsVje2JBMi_l8dWkd6IC58oHbZ zdI-%O1?^SDCa%H)@C3`91{=SMh?MECA$aZPiN@QxjqhuSe`I94(9H;F_y7O^07*qo IM6N<$g1(m{sQ>@~ literal 0 HcmV?d00001 diff --git a/iphone/Maps/Images.xcassets/Place Page/ic_clear_24.imageset/Vector@3x.png b/iphone/Maps/Images.xcassets/Place Page/ic_clear_24.imageset/Vector@3x.png new file mode 100644 index 0000000000000000000000000000000000000000..6d8cd89949044f60c5fad1c7cab160b3f11e4387 GIT binary patch literal 1105 zcmV-X1g`suP)NXK~AKATq=Ncz@!0R(f}L{+&K*d(!l-MJ=t@{ z_#sQO&;Dk1jCNglS0t1m^tZJ%MiI^`@pZVq^V$|VCbE4Gs+(Y1m{BsN1tzp0zF z>`^^8G#;_S0b867!BQ#(^F=cn?wGCPknKyWD_HCq#?6}TqD)&*A~vLPjoT_7NRQ_v zf3U1eD;mF8VV~`)c<_l}ZrykMV>^41$e56S60%3;`cdUsKDmM&3Tb47o@alDJF}cm zO7CGqTqQPw9jd~gZ3Rnx!d|olu&Atpb67w%SXNL~_!8TP-G@tDbQZ#n6*Yi%qE&;h z0CvMpT6vOpbOC!NoVK)q;XaJ{sy%japFIhw$oDH(ur(aPXD z*B~h9ZVmhBT*OAS>Pf61f=^$N&K>(eDn&e%yR0k3=QriDzw64T<)neRolTBEOMt5R`C81kdiAJ|#g>~101=Hx=wOC=jN8MwT z3hoVbi)vYyUb^%O-Ox&GPog(L>kj@=`eEVlx^=W1GaYLHwWRo!NHll|dyG&+I_i`mpr(w={l4><O5;XaSDEbF+FmitU3Vr(RIXh932FpOkdX0wNaNy`TlT2x zWMxh(-Q0CTdMu0usq4qO0<}rJk%^Y~ZR6I%#;j%PKt$isFp&TyZ PlacePageHeaderViewController { + let storyboard = UIStoryboard.instance(.placePage) + let viewController = storyboard.instantiateViewController(ofType: PlacePageHeaderViewController.self); + let presenter = PlacePageHeaderPresenter(view: viewController, + placePagePreviewData: data, + delegate: delegate, + headerType: headerType) + + viewController.presenter = presenter + + return viewController + } +} diff --git a/iphone/Maps/UI/PlacePage/Components/PlacePageHeader/PlacePageHeaderPresenter.swift b/iphone/Maps/UI/PlacePage/Components/PlacePageHeader/PlacePageHeaderPresenter.swift new file mode 100644 index 0000000000..fdd903d3e4 --- /dev/null +++ b/iphone/Maps/UI/PlacePage/Components/PlacePageHeader/PlacePageHeaderPresenter.swift @@ -0,0 +1,54 @@ +protocol PlacePageHeaderPresenterProtocol: class { + func configure() + func onClosePress() + func onExpandPress() +} + +protocol PlacePageHeaderViewControllerDelegate: AnyObject { + func previewDidPressClose() + func previewDidPressExpand() +} + +class PlacePageHeaderPresenter { + enum HeaderType { + case flexible + case fixed + } + + private weak var view: PlacePageHeaderViewProtocol? + private let placePagePreviewData: PlacePagePreviewData + private weak var delegate: PlacePageHeaderViewControllerDelegate? + private let headerType: HeaderType + + init(view: PlacePageHeaderViewProtocol, + placePagePreviewData: PlacePagePreviewData, + delegate: PlacePageHeaderViewControllerDelegate?, + headerType: HeaderType) { + self.view = view + self.delegate = delegate + self.placePagePreviewData = placePagePreviewData + self.headerType = headerType + } +} + +extension PlacePageHeaderPresenter: PlacePageHeaderPresenterProtocol { + func configure() { + view?.setTitle(placePagePreviewData.title ?? "") + switch headerType { + case .flexible: + view?.setViewStyle("PPHeaderView") + view?.setExpandButtonEnabled(true) + case .fixed: + view?.setViewStyle("PPNavigationBarView") + view?.setExpandButtonEnabled(false) + } + } + + func onClosePress() { + delegate?.previewDidPressClose() + } + + func onExpandPress() { + delegate?.previewDidPressExpand() + } +} diff --git a/iphone/Maps/UI/PlacePage/Components/PlacePageHeader/PlacePageHeaderView.swift b/iphone/Maps/UI/PlacePage/Components/PlacePageHeader/PlacePageHeaderView.swift new file mode 100644 index 0000000000..7336e8ce3d --- /dev/null +++ b/iphone/Maps/UI/PlacePage/Components/PlacePageHeader/PlacePageHeaderView.swift @@ -0,0 +1,10 @@ +class PlacePageHeaderView: UIView { + override func point(inside point: CGPoint, with event: UIEvent?) -> Bool { + for subview in subviews { + if !subview.isHidden && subview.isUserInteractionEnabled && subview.point(inside: convert(point, to: subview), with: event) { + return true + } + } + return false + } +} diff --git a/iphone/Maps/UI/PlacePage/Components/PlacePageHeader/PlacePageHeaderViewController.swift b/iphone/Maps/UI/PlacePage/Components/PlacePageHeader/PlacePageHeaderViewController.swift new file mode 100644 index 0000000000..a4a23eae77 --- /dev/null +++ b/iphone/Maps/UI/PlacePage/Components/PlacePageHeader/PlacePageHeaderViewController.swift @@ -0,0 +1,40 @@ +protocol PlacePageHeaderViewProtocol: class { + var presenter: PlacePageHeaderPresenterProtocol? { get set } + func setTitle(_ title: String) + func setViewStyle(_ style: String) + func setExpandButtonEnabled(_ val: Bool) +} + +class PlacePageHeaderViewController: UIViewController { + var presenter: PlacePageHeaderPresenterProtocol? + + @IBOutlet private var titleLabel: UILabel! + @IBOutlet private var expandButton: UIButton! + + override func viewDidLoad() { + super.viewDidLoad() + presenter?.configure() + } + + @IBAction func onExpandButtonPressed(_ sender: Any) { + presenter?.onExpandPress() + } + + @IBAction private func onCloseButtonPressed(_ sender: Any) { + presenter?.onClosePress() + } +} + +extension PlacePageHeaderViewController: PlacePageHeaderViewProtocol { + func setTitle(_ title: String) { + titleLabel.text = title + } + + func setViewStyle(_ style: String) { + view.setStyleAndApply(style) + } + + func setExpandButtonEnabled(_ val: Bool) { + expandButton.isHidden = !val + } +} diff --git a/iphone/Maps/UI/PlacePage/Components/PlacePagePreviewViewController.swift b/iphone/Maps/UI/PlacePage/Components/PlacePagePreviewViewController.swift index 9662565754..e25d2315cc 100644 --- a/iphone/Maps/UI/PlacePage/Components/PlacePagePreviewViewController.swift +++ b/iphone/Maps/UI/PlacePage/Components/PlacePagePreviewViewController.swift @@ -11,8 +11,6 @@ protocol PlacePagePreviewViewControllerDelegate: AnyObject { class PlacePagePreviewViewController: UIViewController { @IBOutlet var stackView: UIStackView! - @IBOutlet var titleLabel: UILabel! - @IBOutlet var titleContainerView: UIStackView! @IBOutlet var popularView: UIView! @IBOutlet var subtitleLabel: UILabel! @IBOutlet var subtitleContainerView: UIStackView! @@ -34,7 +32,6 @@ class PlacePagePreviewViewController: UIViewController { @IBOutlet var scheduleContainerView: UIStackView! @IBOutlet var searchSimilarContainerView: UIStackView! - @IBOutlet var titleDirectionView: DirectionView! @IBOutlet var subtitleDirectionView: DirectionView! @IBOutlet var addressDirectionView: DirectionView! @@ -53,19 +50,22 @@ class PlacePagePreviewViewController: UIViewController { override func viewDidLoad() { super.viewDidLoad() + let subtitleString = NSMutableAttributedString() + if placePagePreviewData.isPopular { + subtitleString.append(NSAttributedString(string: L("popular_place"), + attributes: [.foregroundColor : UIColor.linkBlue(), + .font : UIFont.regular14()])) + } - if let title = placePagePreviewData.title { - titleLabel.text = title - directionView = titleDirectionView - } else { - titleContainerView.isHidden = true - } - if let subtitle = placePagePreviewData.subtitle { - subtitleLabel.text = subtitle - directionView = subtitleDirectionView - } else { - subtitleContainerView.isHidden = true + if let subtitle = placePagePreviewData.subtitle ?? placePagePreviewData.coordinates { + subtitleString.append(NSAttributedString(string: placePagePreviewData.isPopular ? " • " + subtitle : subtitle, + attributes: [.foregroundColor : UIColor.blackSecondaryText(), + .font : UIFont.regular14()])) } + + directionView = subtitleDirectionView + subtitleLabel.attributedText = subtitleString + if let address = placePagePreviewData.address { addressLabel.text = address directionView = addressDirectionView @@ -78,7 +78,6 @@ class PlacePagePreviewViewController: UIViewController { } else { priceLabel.isHidden = true } - popularView.isHidden = !placePagePreviewData.isPopular searchSimilarContainerView.isHidden = placePagePreviewData.hotelType == .none configSchedule() configUgc() diff --git a/iphone/Maps/UI/PlacePage/PlacePage.storyboard b/iphone/Maps/UI/PlacePage/PlacePage.storyboard index bb7c2be8a1..89a458cdea 100644 --- a/iphone/Maps/UI/PlacePage/PlacePage.storyboard +++ b/iphone/Maps/UI/PlacePage/PlacePage.storyboard @@ -22,37 +22,7 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + @@ -126,20 +96,11 @@ - - + + - - - + - - - - - + - + - +