[iOS] fix promo in place page

https://jira.mail.ru/browse/MAPSME-11871
https://jira.mail.ru/browse/MAPSME-11876
This commit is contained in:
Aleksey Belouosv 2019-09-27 14:15:54 +03:00 committed by Aleksey Belousov
parent d1cf07a2f8
commit 5ba4a002e9
13 changed files with 56 additions and 125 deletions

View file

@ -72,6 +72,5 @@ class Info;
- (id<MWMBookingInfoHolder>)bookingInfoHolder;
- (void)showAdditionalViewsIfNeeded;
- (void)didBecomeActive;
@end

View file

@ -601,8 +601,4 @@ extern NSString * const kAlohalyticsTapEventKey;
[Statistics logEvent:eventName withParameters:params];
}
- (void)didBecomeActive {
[self.placePageManager didBecomeActive];
}
@end

View file

@ -305,7 +305,6 @@ NSString * const kHotelFacilitiesSegue = @"Map2FacilitiesSegue";
{
if (!self.welcomePageController)
[self.controlsManager showAdditionalViewsIfNeeded];
[self.controlsManager didBecomeActive];
}
- (void)viewDidLayoutSubviews

View file

@ -387,8 +387,6 @@
472C40E5232A7B9F009AA777 /* CatalogSingleItemCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = 472C40E3232A7B9F009AA777 /* CatalogSingleItemCell.xib */; };
472C40E8232BA810009AA777 /* CatalogPromoItem.m in Sources */ = {isa = PBXBuildFile; fileRef = 472C40E7232BA810009AA777 /* CatalogPromoItem.m */; };
472C40EB232BAE20009AA777 /* CatalogPromoItem+Core.mm in Sources */ = {isa = PBXBuildFile; fileRef = 472C40EA232BAE20009AA777 /* CatalogPromoItem+Core.mm */; };
472C40EE232BC4E5009AA777 /* EmptyTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 472C40EC232BC4E5009AA777 /* EmptyTableViewCell.swift */; };
472C40EF232BC4E5009AA777 /* EmptyTableViewCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = 472C40ED232BC4E5009AA777 /* EmptyTableViewCell.xib */; };
472E3F472146BCD30020E412 /* SubscriptionManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 472E3F462146BCD30020E412 /* SubscriptionManager.swift */; };
472E3F4A2146C4CD0020E412 /* MWMPurchaseManager.mm in Sources */ = {isa = PBXBuildFile; fileRef = 472E3F492146C4CD0020E412 /* MWMPurchaseManager.mm */; };
472E3F4C2147D5700020E412 /* Subscription.swift in Sources */ = {isa = PBXBuildFile; fileRef = 472E3F4B2147D5700020E412 /* Subscription.swift */; };
@ -1487,8 +1485,6 @@
472C40E7232BA810009AA777 /* CatalogPromoItem.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = CatalogPromoItem.m; sourceTree = "<group>"; };
472C40E9232BAE20009AA777 /* CatalogPromoItem+Core.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "CatalogPromoItem+Core.h"; sourceTree = "<group>"; };
472C40EA232BAE20009AA777 /* CatalogPromoItem+Core.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = "CatalogPromoItem+Core.mm"; sourceTree = "<group>"; };
472C40EC232BC4E5009AA777 /* EmptyTableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EmptyTableViewCell.swift; sourceTree = "<group>"; };
472C40ED232BC4E5009AA777 /* EmptyTableViewCell.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = EmptyTableViewCell.xib; sourceTree = "<group>"; };
472E3F462146BCD30020E412 /* SubscriptionManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SubscriptionManager.swift; sourceTree = "<group>"; };
472E3F482146C4CD0020E412 /* MWMPurchaseManager.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MWMPurchaseManager.h; sourceTree = "<group>"; };
472E3F492146C4CD0020E412 /* MWMPurchaseManager.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = MWMPurchaseManager.mm; sourceTree = "<group>"; };
@ -3560,8 +3556,6 @@
472C40E7232BA810009AA777 /* CatalogPromoItem.m */,
472C40E9232BAE20009AA777 /* CatalogPromoItem+Core.h */,
472C40EA232BAE20009AA777 /* CatalogPromoItem+Core.mm */,
472C40EC232BC4E5009AA777 /* EmptyTableViewCell.swift */,
472C40ED232BC4E5009AA777 /* EmptyTableViewCell.xib */,
);
path = CatalogPromo;
sourceTree = "<group>";
@ -4929,7 +4923,6 @@
6741A9591BF340DE002C974C /* 05_khmeros.ttf in Resources */,
34AB66801FC5AA330078E451 /* MWMiPhoneRoutePreview.xib in Resources */,
F6D67CEB2069318B0032FD38 /* PPPSearchSimilarButton.xib in Resources */,
472C40EF232BC4E5009AA777 /* EmptyTableViewCell.xib in Resources */,
F61757F11FC731F5000AD0D0 /* DiscoveryOnlineTemplateCell.xib in Resources */,
6741A95B1BF340DE002C974C /* 06_code2000.ttf in Resources */,
F603E05E1FDE9703006B84D6 /* DiscoverySearchCollectionHolderCell.xib in Resources */,
@ -5334,7 +5327,6 @@
3404F48B202894EA0090E401 /* BMCViewController.swift in Sources */,
349D1ABC1E2D05EF004A2006 /* SearchBar.swift in Sources */,
F6E2FD7A1E097BA00083EBEC /* MWMMapDownloaderDefaultDataSource.mm in Sources */,
472C40EE232BC4E5009AA777 /* EmptyTableViewCell.swift in Sources */,
34E50DF81F6FCC96008EED49 /* UGCReviewCell.swift in Sources */,
F6E2FF3F1E097BA00083EBEC /* MWMSearchTableViewController.mm in Sources */,
F6E2FDE01E097BA00083EBEC /* MWMEditorViewController.mm in Sources */,

View file

@ -141,6 +141,8 @@ enum class PromoCatalogRow
using NewSectionsAreReady = void (^)(NSRange const & range, MWMPlacePageData * data, BOOL isSection);
} // namespace place_page
typedef void (^RefreshPromoCallbackBlock)(NSIndexSet *insertedSections);
@class MWMGalleryItemModel;
@class MWMUGCViewModel;
@class MWMUGCReviewModel;
@ -156,7 +158,7 @@ using NewSectionsAreReady = void (^)(NSRange const & range, MWMPlacePageData * d
@property(copy, nonatomic) place_page::NewSectionsAreReady sectionsAreReadyCallback;
@property(copy, nonatomic) MWMVoidBlock bannerIsReadyCallback;
@property(copy, nonatomic) MWMVoidBlock bookingDataUpdatedCallback;
@property(copy, nonatomic) MWMVoidBlock refreshPromoCallback;
@property(copy, nonatomic) RefreshPromoCallbackBlock refreshPromoCallback;
@property(nonatomic, readonly) MWMUGCViewModel * ugc;
@property(nonatomic, readonly) MWMDiscoveryCityGalleryObjects *promoGallery;
@property(nonatomic, readonly) NSInteger bookingDiscount;

View file

@ -93,13 +93,10 @@ NSString * const kUserDefaultsLatLonAsDMSKey = @"UserDefaultsLatLonAsDMS";
m_sections.push_back(Sections::Preview);
[self fillPreviewSection];
if (self.isPromoCatalog) {
m_sections.push_back(Sections::PromoCatalog);
if ([[self placeDescription] length] && ![[self bookmarkDescription] length] && !self.isPromoCatalog) {
m_sections.push_back(Sections::Description);
}
if ([[self placeDescription] length] && ![[self bookmarkDescription] length])
m_sections.push_back(Sections::Description);
// It's bookmark.
if (m_info.IsBookmark())
m_sections.push_back(Sections::Bookmark);
@ -447,7 +444,7 @@ NSString * const kUserDefaultsLatLonAsDMSKey = @"UserDefaultsLatLonAsDMS";
}
- (NSInteger)bookmarkSectionPosition {
if (self.isPromoCatalog) {
if (self.promoGallery != nil) {
return 2;
} else {
return 1;
@ -878,7 +875,7 @@ NSString * const kUserDefaultsLatLonAsDMSKey = @"UserDefaultsLatLonAsDMS";
#pragma mark - Promo Gallery
- (void)fillPromoCatalogSection {
if (!self.isPromoCatalog) {
if (!self.isPromoCatalog || self.isBookmark || [self bookmarkDescription].length > 0) {
return;
}
@ -902,33 +899,57 @@ NSString * const kUserDefaultsLatLonAsDMSKey = @"UserDefaultsLatLonAsDMS";
kStatError: kStatNoInternet
}];
} else {
auto const resultHandler = [self](promo::CityGallery const & cityGallery) {
self.promoGallery = [[MWMDiscoveryCityGalleryObjects alloc] initWithGalleryResults:cityGallery];
m_promoCatalogRows.push_back(PromoCatalogRow::Guides);
[Statistics logEvent:kStatPlacepageSponsoredShow
withParameters:@{
kStatProvider: kStatMapsmeGuides,
kStatPlacement: self.isLargeToponim ? kStatPlacePageToponims : kStatPlacePageSightSeeing,
kStatState: kStatOnline,
kStatCount: @(cityGallery.m_items.size())
}];
if (self.refreshPromoCallback) {
self.refreshPromoCallback();
__weak __typeof(self) weakSelf = self;
auto const resultHandler = [weakSelf](promo::CityGallery const & cityGallery) {
__strong __typeof(self) self = weakSelf;
if (self == nil) {
return;
}
if (cityGallery.IsEmpty()) {
if ([[self placeDescription] length] && ![[self bookmarkDescription] length]) {
m_sections.insert(m_sections.begin() + 1, Sections::Description);
if (self.refreshPromoCallback) {
self.refreshPromoCallback([NSIndexSet indexSetWithIndex:1]);
}
}
} else {
self.promoGallery = [[MWMDiscoveryCityGalleryObjects alloc] initWithGalleryResults:cityGallery];
m_sections.insert(m_sections.begin() + 1, Sections::PromoCatalog);
m_promoCatalogRows.push_back(PromoCatalogRow::Guides);
[Statistics logEvent:kStatPlacepageSponsoredShow
withParameters:@{
kStatProvider: kStatMapsmeGuides,
kStatPlacement: self.isLargeToponim ? kStatPlacePageToponims : kStatPlacePageSightSeeing,
kStatState: kStatOnline,
kStatCount: @(cityGallery.m_items.size())
}];
NSMutableIndexSet *insertedSections = [NSMutableIndexSet indexSetWithIndex:1];
if (self.promoGallery.count > 1 && [[self placeDescription] length] && ![[self bookmarkDescription] length]) {
NSInteger infoIndex = self.isBookmark ? 3 : 2;
m_sections.insert(m_sections.begin() + infoIndex, Sections::Description);
[insertedSections addIndex:infoIndex];
}
if (self.refreshPromoCallback) {
self.refreshPromoCallback([insertedSections copy]);
}
}
};
auto const errorHandler = [self, row]() {
m_promoCatalogRows.push_back(row);
[Statistics logEvent:kStatPlacepageSponsoredError
withParameters:@{
kStatProvider: kStatMapsmeGuides,
kStatPlacement: self.isLargeToponim ? kStatPlacePageToponims : kStatPlacePageSightSeeing,
kStatError: kStatDownloadError
}];
if (self.refreshPromoCallback) {
self.refreshPromoCallback();
auto const errorHandler = [weakSelf]() {
__strong __typeof(self) self = weakSelf;
if (self == nil) {
return;
}
if ([[self placeDescription] length] && ![[self bookmarkDescription] length]) {
m_sections.insert(m_sections.begin() + 1, Sections::Description);
if (self.refreshPromoCallback) {
self.refreshPromoCallback([NSIndexSet indexSetWithIndex:1]);
}
}
};
auto appInfo = AppInfo.sharedInfo;
auto locale = appInfo.twoLetterLanguageId.UTF8String;
if (m_info.GetSponsoredType() == SponsoredType::PromoCatalogCity) {
@ -942,10 +963,6 @@ NSString * const kUserDefaultsLatLonAsDMSKey = @"UserDefaultsLatLonAsDMS";
errorHandler);
}
}
if (self.refreshPromoCallback) {
self.refreshPromoCallback();
}
}
- (MWMDiscoveryGuideViewModel *)guideAtIndex:(NSUInteger)index {

View file

@ -89,12 +89,6 @@ void RegisterEventIfPossible(eye::MapObject::Event::Type const type, place_page:
@implementation MWMPlacePageManager
- (void)didBecomeActive {
if (self.layout) {
[self.layout reloadPromoIfNeeded];
}
}
- (void)showReview:(place_page::Info const &)info
{
[self show:info];

View file

@ -55,6 +55,5 @@ struct HotelFacility;
- (BOOL)isPPShown;
- (void)dismiss;
- (void)mwm_refreshUI;
- (void)didBecomeActive;
@end

View file

@ -1,2 +0,0 @@
@objc class EmptyTableViewCell: UITableViewCell {
}

View file

@ -1,41 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="14490.70" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
<device id="retina6_1" orientation="portrait">
<adaptation id="fullscreen"/>
</device>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="14490.49"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<objects>
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner"/>
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
<tableViewCell contentMode="scaleToFill" selectionStyle="default" indentationWidth="10" rowHeight="0.0" id="KGk-i7-Jjw" customClass="EmptyTableViewCell" customModule="maps_me" customModuleProvider="target">
<rect key="frame" x="0.0" y="0.0" width="320" height="1.1920928955078125e-07"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" ambiguous="YES" tableViewCell="KGk-i7-Jjw" id="H2p-sc-9uM">
<rect key="frame" x="0.0" y="-0.49999988079071045" width="320" height="0.49999988079071045"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="pmb-Cs-neF">
<rect key="frame" x="0.0" y="0.0" width="320" height="0.0"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<constraints>
<constraint firstAttribute="height" id="9XA-ED-KXN"/>
</constraints>
</view>
</subviews>
<constraints>
<constraint firstItem="pmb-Cs-neF" firstAttribute="leading" secondItem="H2p-sc-9uM" secondAttribute="leading" id="Bi3-hh-QTf"/>
<constraint firstAttribute="bottom" secondItem="pmb-Cs-neF" secondAttribute="bottom" id="Cd5-f8-eKa"/>
<constraint firstItem="pmb-Cs-neF" firstAttribute="top" secondItem="H2p-sc-9uM" secondAttribute="top" id="FdP-AO-caV"/>
<constraint firstAttribute="trailing" secondItem="pmb-Cs-neF" secondAttribute="trailing" id="kZL-kY-OP9"/>
</constraints>
</tableViewCellContentView>
<viewLayoutGuide key="safeArea" id="njF-e1-oar"/>
<point key="canvasLocation" x="-1.4492753623188408" y="62.946428571428569"/>
</tableViewCell>
</objects>
</document>

View file

@ -44,7 +44,6 @@ enum class NodeStatus;
- (UIView *)shareAnchor;
- (void)reloadBookmarkSection:(BOOL)isBookmark;
- (void)reloadPromoIfNeeded;
- (void)rotateDirectionArrowToAngle:(CGFloat)angle;
- (void)setDistanceToObject:(NSString *)distance;

View file

@ -109,7 +109,6 @@ std::map<MetainfoRows, Class> const kMetaInfoCells = {
[tv registerWithCellClass:[MWMUGCAddReviewCell class]];
[tv registerWithCellClass:[MWMUGCYourReviewCell class]];
[tv registerWithCellClass:[MWMUGCReviewCell class]];
[tv registerWithCellClass:[EmptyTableViewCell class]];
[tv registerWithCellClass:[MWMDiscoveryGuideCollectionHolderCell class]];
[tv registerWithCellClass:[CatalogSingleItemCell class]];
@ -230,21 +229,6 @@ std::map<MetainfoRows, Class> const kMetaInfoCells = {
}];
}
- (void)reloadPromoIfNeeded {
auto data = self.data;
if (!data)
return;
if (!data.isPromoCatalog)
return;
if (data.promoCatalogRows.size() == 1 && data.promoCatalogRows[0] == place_page::PromoCatalogRow::Guides) {
return;
}
__weak __typeof__(self) weakSelf = self;
network_policy::CallPartnersApi([weakSelf](auto const & canUseNetwork) {
[weakSelf.data reguestPromoCatalog:canUseNetwork];
});
}
#pragma mark - Downloader event
- (void)processDownloaderEventWithStatus:(storage::NodeStatus)status progress:(CGFloat)progress
@ -636,11 +620,6 @@ std::map<MetainfoRows, Class> const kMetaInfoCells = {
case Sections::PromoCatalog:
{
auto rows = self.data.promoCatalogRows;
if (rows.empty() || rows[indexPath.row] != PromoCatalogRow::Guides || self.data.promoGallery.count == 0) {
Class cls = [EmptyTableViewCell class];
EmptyTableViewCell * cell = (EmptyTableViewCell *)[tableView dequeueReusableCellWithCellClass:cls indexPath:indexPath];
return cell;
}
if (self.data.promoGallery.count == 1) {
CatalogSingleItemCell *cell = (CatalogSingleItemCell *)
[tableView dequeueReusableCellWithCellClass:CatalogSingleItemCell.class indexPath:indexPath];
@ -834,11 +813,9 @@ std::map<MetainfoRows, Class> const kMetaInfoCells = {
[self.previewLayoutHelper insertRowAtTheEnd];
};
data.refreshPromoCallback = ^{
data.refreshPromoCallback = ^(NSIndexSet *insertedSections) {
__strong __typeof(self) self = ws;
auto tv = self.placePageView.tableView;
[tv reloadSections:[NSIndexSet indexSetWithIndex:1]
withRowAnimation:UITableViewRowAnimationFade];
[self.placePageView.tableView insertSections:insertedSections withRowAnimation:UITableViewRowAnimationNone];
};
[self.actionBar configureWithData:data];

View file

@ -15,7 +15,7 @@
</connections>
</placeholder>
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
<view contentMode="scaleToFill" id="iN0-l3-epB" customClass="MWMPPView" propertyAccessControl="all">
<view contentMode="scaleToFill" id="iN0-l3-epB" customClass="MWMPPView">
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>