diff options
author | Ilya Grechuhin <i.grechuhin@gmail.com> | 2017-10-26 16:30:13 +0300 |
---|---|---|
committer | Vlad Mihaylenko <vxmihaylenko@gmail.com> | 2017-10-26 17:23:49 +0300 |
commit | 7128f40f91533d0cb053b048aaadd7be602917f6 (patch) | |
tree | 0ba59d8550ec535dd51eeca8c97600cce41261c9 | |
parent | 08b1027eec0ee967a4a13a345f9fc6ede8ce5bf2 (diff) |
[release-76-ios-xc] [ios] Fixed «0 days ago» review label.
-rw-r--r-- | iphone/Maps/UI/PlacePage/PlacePageLayout/Preview/MWMPPPreviewLayoutHelper.mm | 2 | ||||
-rw-r--r-- | iphone/Maps/UI/PlacePage/UGCViewModel/MWMUGCViewModel.mm | 24 |
2 files changed, 9 insertions, 17 deletions
diff --git a/iphone/Maps/UI/PlacePage/PlacePageLayout/Preview/MWMPPPreviewLayoutHelper.mm b/iphone/Maps/UI/PlacePage/PlacePageLayout/Preview/MWMPPPreviewLayoutHelper.mm index 92f0a15fd8..08ed5b49bd 100644 --- a/iphone/Maps/UI/PlacePage/PlacePageLayout/Preview/MWMPPPreviewLayoutHelper.mm +++ b/iphone/Maps/UI/PlacePage/PlacePageLayout/Preview/MWMPPPreviewLayoutHelper.mm @@ -248,7 +248,7 @@ array<Class, 8> const kPreviewCells = {{[_MWMPPPTitle class], [reviewCell configWithRating:data.ugc.summaryRating canAddReview:data.ugc.isUGCUpdateEmpty reviewsCount:data.ugc.totalReviewsCount - priceSetter:^(UILabel * pricingLabel) { + priceSetter:^(UILabel * _Nonnull pricingLabel) { pricingLabel.text = @""; } onAddReview:^{ diff --git a/iphone/Maps/UI/PlacePage/UGCViewModel/MWMUGCViewModel.mm b/iphone/Maps/UI/PlacePage/UGCViewModel/MWMUGCViewModel.mm index 45d84233b7..82ea328d9d 100644 --- a/iphone/Maps/UI/PlacePage/UGCViewModel/MWMUGCViewModel.mm +++ b/iphone/Maps/UI/PlacePage/UGCViewModel/MWMUGCViewModel.mm @@ -30,7 +30,6 @@ MWMUGCRatingValueType * ratingValueType(float rating) @interface MWMUGCViewModel () @property(copy, nonatomic) MWMVoidBlock refreshCallback; -@property(nonatomic) NSDateComponentsFormatter * formatter; @end @implementation MWMUGCViewModel @@ -99,7 +98,7 @@ MWMUGCRatingValueType * ratingValueType(float rating) { auto const & review = m_ugcUpdate; return [[MWMUGCYourReview alloc] - initWithDate:[self daysAgo:review.m_time] + initWithDate:[self reviewDate:review.m_time] text:@(review.m_text.m_text.c_str()) ratings:starsRatings(review.m_ratings)]; } @@ -109,28 +108,21 @@ MWMUGCRatingValueType * ratingValueType(float rating) auto const & review = m_ugc.m_reviews[idx]; return [[MWMUGCReview alloc] initWithTitle:@(review.m_author.c_str()) - date:[self daysAgo:review.m_time] + date:[self reviewDate:review.m_time] text:@(review.m_text.m_text.c_str()) rating:ratingValueType(review.m_rating)]; } #pragma mark - Propertis -- (NSString *)daysAgo:(ugc::Time const &) time +- (NSString *)reviewDate:(ugc::Time const &) time { using namespace std::chrono; - NSDate * reviewDate = [NSDate dateWithTimeIntervalSince1970:duration_cast<seconds>(time.time_since_epoch()).count()]; - return [self.formatter stringFromDate:reviewDate toDate:[NSDate date]]; + auto reviewDate = [NSDate dateWithTimeIntervalSince1970:duration_cast<seconds>(time.time_since_epoch()).count()]; + auto formatter = [[NSDateFormatter alloc] init]; + formatter.dateStyle = NSDateFormatterLongStyle; + formatter.timeStyle = NSDateFormatterNoStyle; + return [formatter stringFromDate:reviewDate]; } -- (NSDateComponentsFormatter *)formatter -{ - if (!_formatter) - { - _formatter = [[NSDateComponentsFormatter alloc] init]; - _formatter.unitsStyle = NSDateComponentsFormatterUnitsStyleFull; - _formatter.allowedUnits = NSCalendarUnitYear | NSCalendarUnitMonth | NSCalendarUnitDay; - } - return _formatter; -} @end |