From 9bd5a5d4b5a9b1174f5e0b7e61f4ee3129e90657 Mon Sep 17 00:00:00 2001 From: VladiMihaylenko Date: Thu, 2 Mar 2017 16:57:20 +0300 Subject: [PATCH] [ios] Tuned rich page. --- iphone/Maps/UI/PlacePage/MWMPlacePageData.h | 7 ++++-- iphone/Maps/UI/PlacePage/MWMPlacePageData.mm | 15 ++++-------- .../Maps/UI/PlacePage/MWMPlacePageManager.mm | 2 +- .../BookingCells/PPHotelDescriptionCell.swift | 11 ++++----- .../BookingCells/PPHotelDescriptionCell.xib | 3 ++- .../ButtonCell/MWMPlacePageButtonCell.mm | 10 ++++++-- .../PlacePageLayout/MWMPlacePageLayout.mm | 24 +++++++++++++++---- 7 files changed, 45 insertions(+), 27 deletions(-) diff --git a/iphone/Maps/UI/PlacePage/MWMPlacePageData.h b/iphone/Maps/UI/PlacePage/MWMPlacePageData.h index 0f8d8ad5a7..25cf18c8e3 100644 --- a/iphone/Maps/UI/PlacePage/MWMPlacePageData.h +++ b/iphone/Maps/UI/PlacePage/MWMPlacePageData.h @@ -32,7 +32,8 @@ enum class PreviewRows enum class HotelDescriptionRow { - Regular + Regular, + ShowMore }; enum class HotelPhotosRow @@ -75,7 +76,8 @@ enum class ButtonsRows AddPlace, HotelDescription, BookingShowMoreFacilities, - BookingShowMoreReviews + BookingShowMoreOnSite, + BookingShowMoreReviews, }; enum class OpeningHours @@ -125,6 +127,7 @@ using NewSectionsReady = void(^)(NSRange const & range); - (vector const &)facilities; - (vector const &)reviews; - (NSUInteger)numberOfReviews; +- (NSURL *)URLToAllReviews; - (NSArray *)photos; // Banner diff --git a/iphone/Maps/UI/PlacePage/MWMPlacePageData.mm b/iphone/Maps/UI/PlacePage/MWMPlacePageData.mm index 32517cbe65..5d040d2744 100644 --- a/iphone/Maps/UI/PlacePage/MWMPlacePageData.mm +++ b/iphone/Maps/UI/PlacePage/MWMPlacePageData.mm @@ -191,10 +191,10 @@ using namespace place_page; { it = sections.insert(it, Sections::HotelDescription) + 1; m_hotelDescriptionRows.emplace_back(HotelDescriptionRow::Regular); + m_hotelDescriptionRows.emplace_back(HotelDescriptionRow::ShowMore); length++; } - auto constexpr maxNumberOfHotelCellsInPlacePage = 3UL; auto const & facilities = hotelInfo.m_facilities; if (!facilities.empty()) @@ -202,6 +202,7 @@ using namespace place_page; it = sections.insert(it, Sections::HotelFacilities) + 1; auto & facilitiesRows = self->m_hotelFacilitiesRows; auto const size = facilities.size(); + auto constexpr maxNumberOfHotelCellsInPlacePage = 3UL; if (size > maxNumberOfHotelCellsInPlacePage) { @@ -224,15 +225,8 @@ using namespace place_page; auto & reviewsRows = self->m_hotelReviewsRows; reviewsRows.emplace_back(HotelReviewsRow::Header); - if (size > maxNumberOfHotelCellsInPlacePage) - { - reviewsRows.insert(reviewsRows.begin() + 1, maxNumberOfHotelCellsInPlacePage, HotelReviewsRow::Regular); - reviewsRows.emplace_back(HotelReviewsRow::ShowMore); - } - else - { - reviewsRows.insert(reviewsRows.begin() + 1, size, HotelReviewsRow::Regular); - } + reviewsRows.insert(reviewsRows.end(), size, HotelReviewsRow::Regular); + reviewsRows.emplace_back(HotelReviewsRow::ShowMore); length++; } @@ -382,6 +376,7 @@ using namespace place_page; - (vector const &)facilities { return m_hotelInfo.m_facilities; } - (vector const &)reviews { return m_hotelInfo.m_reviews; } - (NSUInteger)numberOfReviews { return m_hotelInfo.m_scoreCount; } +- (NSURL *)URLToAllReviews { return [NSURL URLWithString:@(m_info.GetSponsoredReviewUrl().c_str())]; } - (NSArray *)photos { NSMutableArray * res = [@[] mutableCopy]; diff --git a/iphone/Maps/UI/PlacePage/MWMPlacePageManager.mm b/iphone/Maps/UI/PlacePage/MWMPlacePageManager.mm index 516f602a4e..813dc7c3e4 100644 --- a/iphone/Maps/UI/PlacePage/MWMPlacePageManager.mm +++ b/iphone/Maps/UI/PlacePage/MWMPlacePageManager.mm @@ -301,7 +301,7 @@ - (void)showAllReviews { - // TODO: Open reviews url. + [[MapViewController controller] openUrl:self.data.URLToAllReviews]; } - (void)showPhotoAtIndex:(NSUInteger)index diff --git a/iphone/Maps/UI/PlacePage/PlacePageLayout/Content/BookingCells/PPHotelDescriptionCell.swift b/iphone/Maps/UI/PlacePage/PlacePageLayout/Content/BookingCells/PPHotelDescriptionCell.swift index a81491fe54..97678c70d9 100644 --- a/iphone/Maps/UI/PlacePage/PlacePageLayout/Content/BookingCells/PPHotelDescriptionCell.swift +++ b/iphone/Maps/UI/PlacePage/PlacePageLayout/Content/BookingCells/PPHotelDescriptionCell.swift @@ -17,20 +17,19 @@ final class PPHotelDescriptionCell: MWMTableViewCell let isCompact = descriptionText.height > kMaximumDescriptionHeight; if (isCompact) { compactModeConstraints.forEach { $0.priority = UILayoutPriorityDefaultHigh } - } else { - hideButton() } + hideButton(!isCompact) setNeedsLayout() } - private func hideButton() { - button.isHidden = true - buttonZeroHeight.priority = UILayoutPriorityDefaultHigh + private func hideButton(_ isHidden:Bool = true) { + button.isHidden = isHidden + buttonZeroHeight.priority = isHidden ? UILayoutPriorityDefaultHigh : UILayoutPriorityDefaultLow } @IBAction private func tap() { - compactModeConstraints.forEach { $0.isActive = false } + compactModeConstraints.forEach { $0.priority = UILayoutPriorityDefaultLow } hideButton() setNeedsLayout() UIView.animate(withDuration: kDefaultAnimationDuration, animations: { [weak self] in diff --git a/iphone/Maps/UI/PlacePage/PlacePageLayout/Content/BookingCells/PPHotelDescriptionCell.xib b/iphone/Maps/UI/PlacePage/PlacePageLayout/Content/BookingCells/PPHotelDescriptionCell.xib index 47e3aae419..a26c6781e5 100644 --- a/iphone/Maps/UI/PlacePage/PlacePageLayout/Content/BookingCells/PPHotelDescriptionCell.xib +++ b/iphone/Maps/UI/PlacePage/PlacePageLayout/Content/BookingCells/PPHotelDescriptionCell.xib @@ -15,7 +15,7 @@ - + + diff --git a/iphone/Maps/UI/PlacePage/PlacePageLayout/Content/ButtonCell/MWMPlacePageButtonCell.mm b/iphone/Maps/UI/PlacePage/PlacePageLayout/Content/ButtonCell/MWMPlacePageButtonCell.mm index b7a22f1be2..7625522a48 100644 --- a/iphone/Maps/UI/PlacePage/PlacePageLayout/Content/ButtonCell/MWMPlacePageButtonCell.mm +++ b/iphone/Maps/UI/PlacePage/PlacePageLayout/Content/ButtonCell/MWMPlacePageButtonCell.mm @@ -41,12 +41,17 @@ title = L(@"placepage_add_business_button"); break; case ButtonsRows::HotelDescription: - title = L(@"details"); + title = L(@"details_on_bookingcom"); break; case ButtonsRows::BookingShowMoreFacilities: - case ButtonsRows::BookingShowMoreReviews: title = L(@"booking_show_more"); break; + case ButtonsRows::BookingShowMoreReviews: + title = L(@"reviews_on_bookingcom"); + break; + case ButtonsRows::BookingShowMoreOnSite: + title = L(@"more_on_bookingcom"); + break; } [self.titleButton setTitle:title forState:UIControlStateNormal]; @@ -63,6 +68,7 @@ case ButtonsRows::AddPlace: [d addPlace]; break; case ButtonsRows::EditPlace: [d editPlace]; break; case ButtonsRows::AddBusiness: [d addBusiness]; break; + case ButtonsRows::BookingShowMoreOnSite: case ButtonsRows::HotelDescription: [d book:YES]; break; case ButtonsRows::BookingShowMoreFacilities: [d showAllFacilities]; break; case ButtonsRows::BookingShowMoreReviews: [d showAllReviews]; break; diff --git a/iphone/Maps/UI/PlacePage/PlacePageLayout/MWMPlacePageLayout.mm b/iphone/Maps/UI/PlacePage/PlacePageLayout/MWMPlacePageLayout.mm index b13f0e1788..c9f7df13b0 100644 --- a/iphone/Maps/UI/PlacePage/PlacePageLayout/MWMPlacePageLayout.mm +++ b/iphone/Maps/UI/PlacePage/PlacePageLayout/MWMPlacePageLayout.mm @@ -433,11 +433,25 @@ map const kMetaInfoCells = { } case Sections::HotelDescription: { - Class cls = [MWMPPHotelDescriptionCell class]; - auto c = static_cast( - [tableView dequeueReusableCellWithCellClass:cls indexPath:indexPath]); - [c configWith:data.hotelDescription delegate:self]; - return c; + auto const row = data.descriptionRows[indexPath.row]; + switch (row) + { + case HotelDescriptionRow::Regular: + { + Class cls = [MWMPPHotelDescriptionCell class]; + auto c = static_cast( + [tableView dequeueReusableCellWithCellClass:cls indexPath:indexPath]); + [c configWith:data.hotelDescription delegate:self]; + return c; + } + case HotelDescriptionRow::ShowMore: + { + Class cls = [MWMPlacePageButtonCell class]; + auto c = static_cast([tableView dequeueReusableCellWithCellClass:cls indexPath:indexPath]); + [c configForRow:ButtonsRows::BookingShowMoreOnSite withDelegate:delegate]; + return c; + } + } } } }