From a7d27241b4668d38b17ca20d4be85c5d4da4d4de Mon Sep 17 00:00:00 2001 From: Arsentiy Milchakov Date: Thu, 27 Sep 2018 16:52:46 +0300 Subject: [PATCH] [ios] fix for empty rating --- iphone/Maps/UI/PlacePage/MWMPlacePageData.mm | 8 ++++++-- .../Preview/MWMPPPreviewLayoutHelper.mm | 4 +++- .../PlacePageLayout/Preview/PPPReview.swift | 13 +++++++------ .../UI/PlacePage/UGCViewModel/MWMUGCViewModel.h | 1 + .../UI/PlacePage/UGCViewModel/MWMUGCViewModel.mm | 1 + 5 files changed, 18 insertions(+), 9 deletions(-) diff --git a/iphone/Maps/UI/PlacePage/MWMPlacePageData.mm b/iphone/Maps/UI/PlacePage/MWMPlacePageData.mm index ee65e4175e..42ff78249d 100644 --- a/iphone/Maps/UI/PlacePage/MWMPlacePageData.mm +++ b/iphone/Maps/UI/PlacePage/MWMPlacePageData.mm @@ -154,8 +154,12 @@ NSString * const kUserDefaultsLatLonAsDMSKey = @"UserDefaultsLatLonAsDMS"; if (!self.ugc.isUGCEmpty) { - length = 2; - it = sections.insert(it, Sections::UGCRating) + 1; + length = 1; + if (!self.ugc.isAggregatedRatingEmpty) + { + it = sections.insert(it, Sections::UGCRating) + 1; + length++; + } if (self.ugc.isUGCUpdateEmpty) { it = sections.insert(it, Sections::UGCAddReview) + 1; diff --git a/iphone/Maps/UI/PlacePage/PlacePageLayout/Preview/MWMPPPreviewLayoutHelper.mm b/iphone/Maps/UI/PlacePage/PlacePageLayout/Preview/MWMPPPreviewLayoutHelper.mm index 2217704879..7096acde56 100644 --- a/iphone/Maps/UI/PlacePage/PlacePageLayout/Preview/MWMPPPreviewLayoutHelper.mm +++ b/iphone/Maps/UI/PlacePage/PlacePageLayout/Preview/MWMPPPreviewLayoutHelper.mm @@ -237,6 +237,7 @@ std::array const kPreviewCells = {{[_MWMPPPTitle class], { [reviewCell configWithRating:data.bookingRating canAddReview:NO + isReviewedByUser:NO reviewsCount:0 price:data.bookingPricing discount:data.bookingDiscount @@ -250,7 +251,8 @@ std::array const kPreviewCells = {{[_MWMPPPTitle class], { NSAssert(data.ugc, @""); [reviewCell configWithRating:data.ugc.summaryRating - canAddReview:data.ugc.isUGCUpdateEmpty + canAddReview:YES + isReviewedByUser:!data.ugc.isUGCUpdateEmpty reviewsCount:data.ugc.totalReviewsCount price:@"" discount:0 diff --git a/iphone/Maps/UI/PlacePage/PlacePageLayout/Preview/PPPReview.swift b/iphone/Maps/UI/PlacePage/PlacePageLayout/Preview/PPPReview.swift index dfeddc6b80..78c593a243 100644 --- a/iphone/Maps/UI/PlacePage/PlacePageLayout/Preview/PPPReview.swift +++ b/iphone/Maps/UI/PlacePage/PlacePageLayout/Preview/PPPReview.swift @@ -32,6 +32,7 @@ final class PPPReview: MWMTableViewCell { @objc func config(rating: UGCRatingValueType, canAddReview: Bool, + isReviewedByUser: Bool, reviewsCount: UInt, price: String, discount: Int, @@ -56,7 +57,7 @@ final class PPPReview: MWMTableViewCell { ratingSummaryView.value = rating.value ratingSummaryView.type = rating.type ratingSummaryView.backgroundOpacity = 0.05 - if canAddReview { + if canAddReview && !isReviewedByUser { addReviewButton.isHidden = false addReviewButton.layer.cornerRadius = addReviewButton.height / 2 } else { @@ -65,15 +66,15 @@ final class PPPReview: MWMTableViewCell { pricingLabel.isHidden = true reviewsLabel.isHidden = false if rating.type == .noValue { - if canAddReview { - ratingSummaryView.noValueImage = #imageLiteral(resourceName: "ic_12px_rating_normal") - ratingSummaryView.noValueColor = UIColor.blackSecondaryText() - reviewsLabel.text = L("placepage_no_reviews") - } else { + if isReviewedByUser { ratingSummaryView.noValueImage = #imageLiteral(resourceName: "ic_12px_radio_on") ratingSummaryView.noValueColor = UIColor.linkBlue() reviewsLabel.text = L("placepage_reviewed") pricingLabel.isHidden = false + } else { + ratingSummaryView.noValueImage = #imageLiteral(resourceName: "ic_12px_rating_normal") + ratingSummaryView.noValueColor = UIColor.blackSecondaryText() + reviewsLabel.text = L("placepage_no_reviews") } } else { ratingSummaryView.defaultConfig() diff --git a/iphone/Maps/UI/PlacePage/UGCViewModel/MWMUGCViewModel.h b/iphone/Maps/UI/PlacePage/UGCViewModel/MWMUGCViewModel.h index e5ed1c4d95..7bb78616b3 100644 --- a/iphone/Maps/UI/PlacePage/UGCViewModel/MWMUGCViewModel.h +++ b/iphone/Maps/UI/PlacePage/UGCViewModel/MWMUGCViewModel.h @@ -36,6 +36,7 @@ enum class ReviewRow - (BOOL)isUGCEmpty; - (BOOL)isUGCUpdateEmpty; +- (BOOL)isAggregatedRatingEmpty; - (NSUInteger)ratingCellsCount; - (NSUInteger)addReviewCellsCount; diff --git a/iphone/Maps/UI/PlacePage/UGCViewModel/MWMUGCViewModel.mm b/iphone/Maps/UI/PlacePage/UGCViewModel/MWMUGCViewModel.mm index a90f21f538..b521f387e9 100644 --- a/iphone/Maps/UI/PlacePage/UGCViewModel/MWMUGCViewModel.mm +++ b/iphone/Maps/UI/PlacePage/UGCViewModel/MWMUGCViewModel.mm @@ -76,6 +76,7 @@ MWMUGCRatingValueType * ratingValueType(float rating) - (BOOL)isUGCEmpty { return static_cast(m_ugc.IsEmpty()); } - (BOOL)isUGCUpdateEmpty { return static_cast(m_ugcUpdate.IsEmpty()); } +- (BOOL)isAggregatedRatingEmpty { return m_ugc.m_totalRating == kIncorrectRating; } - (NSUInteger)ratingCellsCount { return 1; } - (NSUInteger)addReviewCellsCount { return 1; } - (NSUInteger)totalReviewsCount { return static_cast(m_ugc.m_basedOn); }