From 71db6f02e5dc663949e639eaa8b65c85ed0e3a58 Mon Sep 17 00:00:00 2001 From: Alexey Belousov Date: Wed, 27 Jun 2018 17:56:50 +0300 Subject: [PATCH] [iOS] add UI for booking hot offers --- iphone/Maps/Core/Search/MWMSearch.h | 1 + iphone/Maps/Core/Search/MWMSearch.mm | 70 ++++++++++-------- .../Search/Cells/Hot Offers/Contents.json | 6 ++ .../ic_hot_offer.imageset/Contents.json | 12 +++ .../ic_hot_offer.imageset/ic_hot_offer.pdf | Bin 0 -> 5144 bytes .../UI/Search/TableView/MWMSearchCommonCell.h | 1 + .../Search/TableView/MWMSearchCommonCell.mm | 5 ++ .../Search/TableView/MWMSearchCommonCell.xib | 24 +++--- .../TableView/MWMSearchTableViewController.mm | 3 +- 9 files changed, 82 insertions(+), 40 deletions(-) create mode 100644 iphone/Maps/Images.xcassets/Search/Cells/Hot Offers/Contents.json create mode 100644 iphone/Maps/Images.xcassets/Search/Cells/Hot Offers/ic_hot_offer.imageset/Contents.json create mode 100644 iphone/Maps/Images.xcassets/Search/Cells/Hot Offers/ic_hot_offer.imageset/ic_hot_offer.pdf 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 0000000000000000000000000000000000000000..ba6807854634f3a538cb2962ac165799e845aa9b GIT binary patch literal 5144 zcmai&1yod9_rQsf7^IXA8Dc<0n53i|1f*l=n4wERQa}(zN*V+NBm|N4fszB#s60m6 zAcP^LL!?LlgHQj@_q}he@2&BXJNJM%cHm5 zy+9-g3i5Vv1Io&RAUYT?XMY!vI8kH>f~dQC_+xyDZx4Haj4H;_8;t?U%LD!VeKGc) zz#vjgrtW=i$+OY>VL)p;CWDf1`UAZ?fuh66yh-IRFc8@=hf z@+B!`vWdue|AHT_U{62o_H8-3DCRaANubAAdgJZUU5}fx*PE`M+eoY}3Or{8&Q@)k z*9`G^Ji9Xp-i!S+ghytU^&W=TI-YrkzbT=Mdr_wR;@dBsu#cnN!lCtwi!Xu5*O>|Y zPvb7WsIFDhV&fG%)ZKTlqS|LH&s82SE?fpX;n=>yK3J0)ZGLM{Nq(O&Qvm?DSxxFq zO}?tR0`M$2ifW#AFUSa<;9X3!^s_O09%WuS-kN!sZxX&uxX_jomu{(Ix`E{D9}Q13 zq2QBaYf3Moj$o<+^33N}D$#5kNeplMbmtp$wD?xW-i%BrVT$EPrEJphHKO$M3M^Zm zaEg2=3t?4n60GX1&XlDXbz=gp_L1M0?EYlZN>KeQ{W!ITo91KU1wo;?#2^BjHC`fQ zvuI9qA*v^5%+JhGT*4Y4J>UY{RJOj?32b|LX9qu+^^NSbO969_E(gkPAy zItpt`Jq)Tv$m{AtYINVwp+^q0Kh3z}Qj|?11Lny>@lh3=ZqJ5?M$kAz@XIm$R7}fq z+dQ34y}kf#qCm+!DIKuLyIaKVSzCa#1gZ>4mkApC{6*wZeEOd8N(DWY9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fj2_KoH~NpE4vu{9k%Vq!e+( z^dEZSh=0o@PM7?bp1-fXs|UvS$8npHYY1`vh`S;~Z*OAIoCXGQBDK7nyonL?S6h`B zL$YwBxU@JDE+Gj+L!G3hrO-|iQg8 - + - + - - - 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: