diff --git a/iphone/Maps/Core/Search/MWMSearch.h b/iphone/Maps/Core/Search/MWMSearch.h index 15fdf7a40a..e53d3d519d 100644 --- a/iphone/Maps/Core/Search/MWMSearch.h +++ b/iphone/Maps/Core/Search/MWMSearch.h @@ -31,6 +31,7 @@ struct HotelParams; + (search::ProductInfo const &)productInfoWithContainerIndex:(NSUInteger)index; + (id)adWithContainerIndex:(NSUInteger)index; + (BOOL)isBookingAvailableWithContainerIndex:(NSUInteger)index; ++ (BOOL)isDealAvailableWithContainerIndex:(NSUInteger)index; + (void)update; + (void)clear; diff --git a/iphone/Maps/Core/Search/MWMSearch.mm b/iphone/Maps/Core/Search/MWMSearch.mm index 179b92732c..2870569892 100644 --- a/iphone/Maps/Core/Search/MWMSearch.mm +++ b/iphone/Maps/Core/Search/MWMSearch.mm @@ -54,7 +54,7 @@ using Observers = NSHashTable; search::ViewportSearchParams m_viewportParams; search::Results m_everywhereResults; search::Results m_viewportResults; - std::vector m_bookingAvailableFeatureIDs; + std::unordered_map> m_filterResults; std::vector m_productInfo; } @@ -81,6 +81,31 @@ using Observers = NSHashTable; return self; } +- (void)enableCallbackFor:(booking::filter::Type const)filterType { + auto & tasks = self->m_everywhereParams.m_bookingFilterTasks; + auto availabilityTaskIt = tasks.Find(filterType); + if (availabilityTaskIt != tasks.end()) + { + availabilityTaskIt->m_filterParams.m_callback = + [self, filterType](shared_ptr const & apiParams, + std::vector const & sortedFeatures) + { + auto & t = self->m_everywhereParams.m_bookingFilterTasks; + auto const it = t.Find(filterType); + + if (it == t.end()) + return; + + auto const & p = it->m_filterParams.m_apiParams; + if (p->IsEmpty() || !p->Equals(*apiParams)) + return; + + self->m_filterResults[filterType] = sortedFeatures; + [self onSearchResultsUpdated]; + }; + } +} + - (void)searchEverywhere { self.lastSearchTimestamp += 1; @@ -102,29 +127,8 @@ using Observers = NSHashTable; self.searchCount -= 1; }; - auto & tasks = self->m_everywhereParams.m_bookingFilterTasks; - auto availabilityTaskIt = tasks.Find(booking::filter::Type::Availability); - if (availabilityTaskIt != tasks.end()) - { - // TODO: implement callback for booking::filter::Type::Deals. - availabilityTaskIt->m_filterParams.m_callback = - [self](shared_ptr const & apiParams, - std::vector const & sortedFeatures) - { - auto & t = self->m_everywhereParams.m_bookingFilterTasks; - auto const it = t.Find(booking::filter::Type::Availability); - - if (it == t.end()) - return; - - auto const & p = it->m_filterParams.m_apiParams; - if (p->IsEmpty() || !p->Equals(*apiParams)) - return; - - self->m_bookingAvailableFeatureIDs = sortedFeatures; - [self onSearchResultsUpdated]; - }; - } + [self enableCallbackFor:booking::filter::Type::Availability]; + [self enableCallbackFor:booking::filter::Type::Deals]; GetFramework().SearchEverywhere(m_everywhereParams); self.searchCount += 1; @@ -266,15 +270,23 @@ using Observers = NSHashTable; return [[MWMSearch manager].banners bannerAtIndex:index]; } -+ (BOOL)isBookingAvailableWithContainerIndex:(NSUInteger)index ++ (BOOL)isFeatureAt:(NSUInteger)index in:(std::vector const &)array { auto const & result = [self resultWithContainerIndex:index]; if (result.GetResultType() != search::Result::Type::Feature) return NO; auto const & resultFeatureID = result.GetFeatureID(); - auto const & bookingAvailableIDs = [MWMSearch manager]->m_bookingAvailableFeatureIDs; - return std::binary_search(bookingAvailableIDs.begin(), bookingAvailableIDs.end(), - resultFeatureID); + return std::binary_search(array.begin(), array.end(), resultFeatureID); +} + ++ (BOOL)isBookingAvailableWithContainerIndex:(NSUInteger)index +{ + return [self isFeatureAt:index in:[MWMSearch manager]->m_filterResults[booking::filter::Type::Availability]]; +} + ++ (BOOL)isDealAvailableWithContainerIndex:(NSUInteger)index +{ + return [self isFeatureAt:index in:[MWMSearch manager]->m_filterResults[booking::filter::Type::Deals]]; } + (MWMSearchItemType)resultTypeWithRow:(NSUInteger)row @@ -299,7 +311,7 @@ using Observers = NSHashTable; m_everywhereResults.Clear(); m_viewportResults.Clear(); - m_bookingAvailableFeatureIDs.clear(); + m_filterResults.clear(); m_viewportParams.m_bookingFilterTasks.Clear(); m_everywhereParams.m_bookingFilterTasks.Clear(); diff --git a/iphone/Maps/Images.xcassets/Search/Cells/Hot Offers/Contents.json b/iphone/Maps/Images.xcassets/Search/Cells/Hot Offers/Contents.json new file mode 100644 index 0000000000..da4a164c91 --- /dev/null +++ b/iphone/Maps/Images.xcassets/Search/Cells/Hot Offers/Contents.json @@ -0,0 +1,6 @@ +{ + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/iphone/Maps/Images.xcassets/Search/Cells/Hot Offers/ic_hot_offer.imageset/Contents.json b/iphone/Maps/Images.xcassets/Search/Cells/Hot Offers/ic_hot_offer.imageset/Contents.json new file mode 100644 index 0000000000..6173bf476a --- /dev/null +++ b/iphone/Maps/Images.xcassets/Search/Cells/Hot Offers/ic_hot_offer.imageset/Contents.json @@ -0,0 +1,12 @@ +{ + "images" : [ + { + "idiom" : "universal", + "filename" : "ic_hot_offer.pdf" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/iphone/Maps/Images.xcassets/Search/Cells/Hot Offers/ic_hot_offer.imageset/ic_hot_offer.pdf b/iphone/Maps/Images.xcassets/Search/Cells/Hot Offers/ic_hot_offer.imageset/ic_hot_offer.pdf new file mode 100644 index 0000000000..ba68078546 Binary files /dev/null and b/iphone/Maps/Images.xcassets/Search/Cells/Hot Offers/ic_hot_offer.imageset/ic_hot_offer.pdf differ diff --git a/iphone/Maps/UI/Search/TableView/MWMSearchCommonCell.h b/iphone/Maps/UI/Search/TableView/MWMSearchCommonCell.h index 61d3728c8b..a696041f19 100644 --- a/iphone/Maps/UI/Search/TableView/MWMSearchCommonCell.h +++ b/iphone/Maps/UI/Search/TableView/MWMSearchCommonCell.h @@ -8,6 +8,7 @@ - (void)config:(search::Result const &)result isAvailable:(BOOL)isAvailable + isHotOffer:(BOOL)isHotOffer productInfo:(search::ProductInfo const &)productInfo; @end diff --git a/iphone/Maps/UI/Search/TableView/MWMSearchCommonCell.mm b/iphone/Maps/UI/Search/TableView/MWMSearchCommonCell.mm index ef6e489422..787c23d2dd 100644 --- a/iphone/Maps/UI/Search/TableView/MWMSearchCommonCell.mm +++ b/iphone/Maps/UI/Search/TableView/MWMSearchCommonCell.mm @@ -25,6 +25,8 @@ @property(weak, nonatomic) IBOutlet UIView * availableView; @property(weak, nonatomic) IBOutlet NSLayoutConstraint * availableTypeOffset; @property(weak, nonatomic) IBOutlet UIView * sideAvailableMarker; +@property(weak, nonatomic) IBOutlet UIImageView * hotOfferImageView; +@property(weak, nonatomic) IBOutlet NSLayoutConstraint * priceOffset; @end @@ -32,6 +34,7 @@ - (void)config:(search::Result const &)result isAvailable:(BOOL)isAvailable + isHotOffer:(BOOL)isHotOffer productInfo:(search::ProductInfo const &)productInfo { [super config:result]; @@ -58,6 +61,8 @@ self.availableTypeOffset.priority = UILayoutPriorityDefaultHigh; self.availableView.hidden = !isAvailable; self.sideAvailableMarker.hidden = !isAvailable; + self.hotOfferImageView.hidden = !isHotOffer; + self.priceOffset.priority = isHotOffer ? UILayoutPriorityDefaultLow : UILayoutPriorityDefaultHigh; NSUInteger const starsCount = result.GetStarsCount(); NSString * cuisine = @(result.GetCuisine().c_str()); diff --git a/iphone/Maps/UI/Search/TableView/MWMSearchCommonCell.xib b/iphone/Maps/UI/Search/TableView/MWMSearchCommonCell.xib index 95529557f1..49f681002c 100644 --- a/iphone/Maps/UI/Search/TableView/MWMSearchCommonCell.xib +++ b/iphone/Maps/UI/Search/TableView/MWMSearchCommonCell.xib @@ -1,22 +1,17 @@ - + - + - - - HelveticaNeue - - - + @@ -285,6 +280,9 @@ + @@ -293,13 +291,15 @@ - + + + @@ -315,6 +315,7 @@ + @@ -330,11 +331,13 @@ + + @@ -345,10 +348,11 @@ - + + diff --git a/iphone/Maps/UI/Search/TableView/MWMSearchTableViewController.mm b/iphone/Maps/UI/Search/TableView/MWMSearchTableViewController.mm index 02279b75a0..253474d3c1 100644 --- a/iphone/Maps/UI/Search/TableView/MWMSearchTableViewController.mm +++ b/iphone/Maps/UI/Search/TableView/MWMSearchTableViewController.mm @@ -88,8 +88,9 @@ indexPath:indexPath]); auto const & result = [MWMSearch resultWithContainerIndex:containerIndex]; auto const isBookingAvailable = [MWMSearch isBookingAvailableWithContainerIndex:containerIndex]; + auto const isDealAvailable = [MWMSearch isDealAvailableWithContainerIndex:containerIndex]; auto const & productInfo = [MWMSearch productInfoWithContainerIndex:containerIndex]; - [cell config:result isAvailable:isBookingAvailable productInfo:productInfo]; + [cell config:result isAvailable:isBookingAvailable isHotOffer:isDealAvailable productInfo:productInfo]; return cell; } case MWMSearchItemTypeMopub: