diff --git a/iphone/Maps/UI/PlacePage/MWMPlacePageManager.mm b/iphone/Maps/UI/PlacePage/MWMPlacePageManager.mm index ef1c03be64..9145733395 100644 --- a/iphone/Maps/UI/PlacePage/MWMPlacePageManager.mm +++ b/iphone/Maps/UI/PlacePage/MWMPlacePageManager.mm @@ -229,6 +229,7 @@ void logSponsoredEvent(MWMPlacePageData * data, NSString * eventName) { self.ownerViewController.visibleAreaBottomOffset = bound; [[MWMSideButtons buttons] setBottomBound:self.ownerViewController.view.height - bound]; + [self.layout checkCellsVisible]; } - (void)shouldDestroyLayout { self.layout = nil; } diff --git a/iphone/Maps/UI/PlacePage/PlacePageLayout/MWMPlacePageLayout.h b/iphone/Maps/UI/PlacePage/PlacePageLayout/MWMPlacePageLayout.h index 87d3a3f6f3..5fc99da14e 100644 --- a/iphone/Maps/UI/PlacePage/PlacePageLayout/MWMPlacePageLayout.h +++ b/iphone/Maps/UI/PlacePage/PlacePageLayout/MWMPlacePageLayout.h @@ -44,6 +44,7 @@ - (void)processDownloaderEventWithStatus:(storage::NodeStatus)status progress:(CGFloat)progress; +- (void)checkCellsVisible; #pragma mark - iPad only - (void)updateTopBound; diff --git a/iphone/Maps/UI/PlacePage/PlacePageLayout/MWMPlacePageLayout.mm b/iphone/Maps/UI/PlacePage/PlacePageLayout/MWMPlacePageLayout.mm index d9c80dba35..903058bd3b 100644 --- a/iphone/Maps/UI/PlacePage/PlacePageLayout/MWMPlacePageLayout.mm +++ b/iphone/Maps/UI/PlacePage/PlacePageLayout/MWMPlacePageLayout.mm @@ -12,6 +12,7 @@ #import "MWMPlacePageRegularCell.h" #import "MWMiPadPlacePageLayoutImpl.h" #import "MWMiPhonePlacePageLayoutImpl.h" +#import "MapViewController.h" #import "SwiftBridge.h" #include "ugc/types.hpp" @@ -61,6 +62,8 @@ map const kMetaInfoCells = { @property(nonatomic) MWMOpeningHoursLayoutHelper * openingHoursLayoutHelper; @property(nonatomic) NSArray * buttonsSectionIndexPaths; +@property(weak, nonatomic) MWMPlacePageTaxiCell * taxiCell; + @end @implementation MWMPlacePageLayout @@ -157,6 +160,7 @@ map const kMetaInfoCells = { [self.placePageView.tableView reloadData]; [self.layoutImpl onShow]; + [self checkCellsVisible]; dispatch_async(dispatch_get_main_queue(), ^{ [data fillOnlineBookingSections]; @@ -454,6 +458,7 @@ map const kMetaInfoCells = { case taxi::Provider::Yandex: type = MWMPlacePageTaxiProviderYandex; break; } [c configWithType:type delegate:delegate]; + self.taxiCell = c; return c; } case Sections::Buttons: @@ -592,6 +597,45 @@ map const kMetaInfoCells = { } } +- (void)checkCellsVisible +{ + auto data = self.data; + if (!data) + return; + + auto const checkCell = ^(UITableViewCell * cell, MWMVoidBlock onHit) { + if (!cell) + return; + auto taxiBottom = CGPointMake(cell.width / 2, cell.height); + auto mainView = [MapViewController controller].view; + auto actionBar = self.actionBar; + BOOL const isInMainView = + [mainView pointInside:[cell convertPoint:taxiBottom toView:mainView] withEvent:nil]; + BOOL const isInActionBar = + [actionBar pointInside:[cell convertPoint:taxiBottom toView:actionBar] withEvent:nil]; + if (isInMainView && !isInActionBar) + onHit(); + }; + + checkCell(self.taxiCell, ^{ + self.taxiCell = nil; + + auto const & taxiProviders = [data taxiProviders]; + if (taxiProviders.empty()) + { + NSAssert(NO, @"Taxi is shown but providers are empty."); + return; + } + NSString * provider = nil; + switch (taxiProviders.front()) + { + case taxi::Provider::Uber: provider = kStatUber; break; + case taxi::Provider::Yandex: provider = kStatYandex; break; + } + [Statistics logEvent:kStatPlacepageTaxiShow withParameters:@{ @"provider" : provider }]; + }); +} + #pragma mark - MWMPlacePageCellUpdateProtocol - (void)cellUpdated