forked from organicmaps/organicmaps
[ios] fix for empty rating
This commit is contained in:
parent
398e8100cc
commit
a7d27241b4
5 changed files with 18 additions and 9 deletions
|
@ -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;
|
||||
|
|
|
@ -237,6 +237,7 @@ std::array<Class, 9> 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<Class, 9> 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
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -36,6 +36,7 @@ enum class ReviewRow
|
|||
|
||||
- (BOOL)isUGCEmpty;
|
||||
- (BOOL)isUGCUpdateEmpty;
|
||||
- (BOOL)isAggregatedRatingEmpty;
|
||||
|
||||
- (NSUInteger)ratingCellsCount;
|
||||
- (NSUInteger)addReviewCellsCount;
|
||||
|
|
|
@ -76,6 +76,7 @@ MWMUGCRatingValueType * ratingValueType(float rating)
|
|||
|
||||
- (BOOL)isUGCEmpty { return static_cast<BOOL>(m_ugc.IsEmpty()); }
|
||||
- (BOOL)isUGCUpdateEmpty { return static_cast<BOOL>(m_ugcUpdate.IsEmpty()); }
|
||||
- (BOOL)isAggregatedRatingEmpty { return m_ugc.m_totalRating == kIncorrectRating; }
|
||||
- (NSUInteger)ratingCellsCount { return 1; }
|
||||
- (NSUInteger)addReviewCellsCount { return 1; }
|
||||
- (NSUInteger)totalReviewsCount { return static_cast<NSUInteger>(m_ugc.m_basedOn); }
|
||||
|
|
Loading…
Add table
Reference in a new issue