Merge pull request #5504 from VladiMihaylenko/rich-pp

[ios] Tuned rich page.
This commit is contained in:
Arsentiy Milchakov 2017-03-02 18:27:18 +03:00 committed by GitHub
commit c226d24d3c
7 changed files with 45 additions and 27 deletions

View file

@ -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<booking::HotelFacility> const &)facilities;
- (vector<booking::HotelReview> const &)reviews;
- (NSUInteger)numberOfReviews;
- (NSURL *)URLToAllReviews;
- (NSArray<MWMGalleryItemModel *> *)photos;
// Banner

View file

@ -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<booking::HotelFacility> const &)facilities { return m_hotelInfo.m_facilities; }
- (vector<booking::HotelReview> 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<MWMGalleryItemModel *> *)photos
{
NSMutableArray<MWMGalleryItemModel *> * res = [@[] mutableCopy];

View file

@ -301,7 +301,7 @@
- (void)showAllReviews
{
// TODO: Open reviews url.
[[MapViewController controller] openUrl:self.data.URLToAllReviews];
}
- (void)showPhotoAtIndex:(NSUInteger)index

View file

@ -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

View file

@ -15,7 +15,7 @@
<rect key="frame" x="0.0" y="0.0" width="375" height="44"/>
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="x5g-my-EeP" id="2f0-Qh-gMq">
<rect key="frame" x="0.0" y="0.0" width="375" height="43"/>
<rect key="frame" x="0.0" y="0.0" width="375" height="43.5"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="natural" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="ILZ-NI-VZb">
@ -59,6 +59,7 @@
<constraint firstAttribute="trailing" secondItem="ILZ-NI-VZb" secondAttribute="trailing" constant="16" id="u9S-uq-2ZH"/>
</constraints>
</tableViewCellContentView>
<inset key="separatorInset" minX="10" minY="0.0" maxX="0.0" maxY="0.0"/>
<connections>
<outlet property="button" destination="n7r-xF-fbc" id="3nI-UG-vie"/>
<outlet property="buttonZeroHeight" destination="VFr-Uh-l7q" id="QC8-Cm-oAX"/>

View file

@ -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;

View file

@ -433,11 +433,25 @@ map<MetainfoRows, Class> const kMetaInfoCells = {
}
case Sections::HotelDescription:
{
Class cls = [MWMPPHotelDescriptionCell class];
auto c = static_cast<MWMPPHotelDescriptionCell *>(
[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<MWMPPHotelDescriptionCell *>(
[tableView dequeueReusableCellWithCellClass:cls indexPath:indexPath]);
[c configWith:data.hotelDescription delegate:self];
return c;
}
case HotelDescriptionRow::ShowMore:
{
Class cls = [MWMPlacePageButtonCell class];
auto c = static_cast<MWMPlacePageButtonCell *>([tableView dequeueReusableCellWithCellClass:cls indexPath:indexPath]);
[c configForRow:ButtonsRows::BookingShowMoreOnSite withDelegate:delegate];
return c;
}
}
}
}
}