diff --git a/iphone/Maps/Bridging-Header.h b/iphone/Maps/Bridging-Header.h index 60222077a5..cf84e81a11 100644 --- a/iphone/Maps/Bridging-Header.h +++ b/iphone/Maps/Bridging-Header.h @@ -25,6 +25,7 @@ #import "BookmarksVC.h" #import "FacebookNativeAdAdapter.h" #import "LocalNotificationManager.h" +#import "CatalogPromoItem.h" #import "CoreNotificationWrapper.h" #import "DeepLinkHelper.h" #import "MapViewController.h" diff --git a/iphone/Maps/Maps.xcodeproj/project.pbxproj b/iphone/Maps/Maps.xcodeproj/project.pbxproj index 037e29da7d..1a277d8e12 100644 --- a/iphone/Maps/Maps.xcodeproj/project.pbxproj +++ b/iphone/Maps/Maps.xcodeproj/project.pbxproj @@ -383,6 +383,12 @@ 4728F69022CE430800E00028 /* BookmarksSubscriptionViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4728F68E22CE430800E00028 /* BookmarksSubscriptionViewController.swift */; }; 4728F69122CE430800E00028 /* BookmarksSubscriptionViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 4728F68F22CE430800E00028 /* BookmarksSubscriptionViewController.xib */; }; 4728F69322CF89A400E00028 /* GradientView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4728F69222CF89A400E00028 /* GradientView.swift */; }; + 472C40E4232A7B9F009AA777 /* CatalogSingleItemCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 472C40E2232A7B9F009AA777 /* CatalogSingleItemCell.swift */; }; + 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 */; }; @@ -1475,6 +1481,14 @@ 4728F68E22CE430800E00028 /* BookmarksSubscriptionViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BookmarksSubscriptionViewController.swift; sourceTree = ""; }; 4728F68F22CE430800E00028 /* BookmarksSubscriptionViewController.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = BookmarksSubscriptionViewController.xib; sourceTree = ""; }; 4728F69222CF89A400E00028 /* GradientView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = GradientView.swift; path = CustomViews/GradientView.swift; sourceTree = ""; }; + 472C40E2232A7B9F009AA777 /* CatalogSingleItemCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CatalogSingleItemCell.swift; sourceTree = ""; }; + 472C40E3232A7B9F009AA777 /* CatalogSingleItemCell.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = CatalogSingleItemCell.xib; sourceTree = ""; }; + 472C40E6232BA810009AA777 /* CatalogPromoItem.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CatalogPromoItem.h; sourceTree = ""; }; + 472C40E7232BA810009AA777 /* CatalogPromoItem.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = CatalogPromoItem.m; sourceTree = ""; }; + 472C40E9232BAE20009AA777 /* CatalogPromoItem+Core.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "CatalogPromoItem+Core.h"; sourceTree = ""; }; + 472C40EA232BAE20009AA777 /* CatalogPromoItem+Core.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = "CatalogPromoItem+Core.mm"; sourceTree = ""; }; + 472C40EC232BC4E5009AA777 /* EmptyTableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EmptyTableViewCell.swift; sourceTree = ""; }; + 472C40ED232BC4E5009AA777 /* EmptyTableViewCell.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = EmptyTableViewCell.xib; sourceTree = ""; }; 472E3F462146BCD30020E412 /* SubscriptionManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SubscriptionManager.swift; sourceTree = ""; }; 472E3F482146C4CD0020E412 /* MWMPurchaseManager.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MWMPurchaseManager.h; sourceTree = ""; }; 472E3F492146C4CD0020E412 /* MWMPurchaseManager.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = MWMPurchaseManager.mm; sourceTree = ""; }; @@ -3537,6 +3551,21 @@ path = TipsAndTricks; sourceTree = ""; }; + 472C40E1232A7B4F009AA777 /* CatalogPromo */ = { + isa = PBXGroup; + children = ( + 472C40E2232A7B9F009AA777 /* CatalogSingleItemCell.swift */, + 472C40E3232A7B9F009AA777 /* CatalogSingleItemCell.xib */, + 472C40E6232BA810009AA777 /* CatalogPromoItem.h */, + 472C40E7232BA810009AA777 /* CatalogPromoItem.m */, + 472C40E9232BAE20009AA777 /* CatalogPromoItem+Core.h */, + 472C40EA232BAE20009AA777 /* CatalogPromoItem+Core.mm */, + 472C40EC232BC4E5009AA777 /* EmptyTableViewCell.swift */, + 472C40ED232BC4E5009AA777 /* EmptyTableViewCell.xib */, + ); + path = CatalogPromo; + sourceTree = ""; + }; 472E3F4221468AF40020E412 /* Subscriptions */ = { isa = PBXGroup; children = ( @@ -4389,6 +4418,7 @@ F6E2FCA81E097B9F0083EBEC /* Content */ = { isa = PBXGroup; children = ( + 472C40E1232A7B4F009AA777 /* CatalogPromo */, 33010DB121B7E0E000925411 /* DescriptionCell */, F68224981E5B0FE100BC1C18 /* BookingCells */, F6E2FCA91E097B9F0083EBEC /* BookmarkCell */, @@ -4899,6 +4929,7 @@ 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 */, @@ -4906,6 +4937,7 @@ 6741A99F1BF340DE002C974C /* 07_roboto_medium.ttf in Resources */, F6E2FE6D1E097BA00083EBEC /* _MWMOHHeaderCell.xib in Resources */, F6E2FE701E097BA00083EBEC /* _MWMOHSubCell.xib in Resources */, + 472C40E5232A7B9F009AA777 /* CatalogSingleItemCell.xib in Resources */, F6E2FEA91E097BA00083EBEC /* _MWMPPPAddress.xib in Resources */, 4716EAC121A6E0570029B886 /* BookmarksVC.xib in Resources */, F6E2FEAC1E097BA00083EBEC /* PPPReview.xib in Resources */, @@ -5302,6 +5334,7 @@ 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 */, @@ -5401,6 +5434,7 @@ 340475531E081A4600C92850 /* MWMCustomFacebookEvents.mm in Sources */, 349D1CE41E3F836900A878FD /* UIViewController+Hierarchy.swift in Sources */, CDB4D4E1222D70DF00104869 /* CarPlayMapViewController.swift in Sources */, + 472C40EB232BAE20009AA777 /* CatalogPromoItem+Core.mm in Sources */, 347039A91FB9A5CF00E47496 /* MWMBookmarksManager.mm in Sources */, F692F3831EA0FAF5001E82EB /* MWMAutoupdateController.mm in Sources */, 34574A671E3B85F80061E839 /* ThemeManager.swift in Sources */, @@ -5473,6 +5507,7 @@ 34BBD65C1F826FD30070CA50 /* AuthorizationiPhonePresentationController.swift in Sources */, 56C74C391C74A3BC00B71B9F /* MWMInputEmailValidator.mm in Sources */, 6741A9F51BF340DE002C974C /* BookmarksVC.mm in Sources */, + 472C40E4232A7B9F009AA777 /* CatalogSingleItemCell.swift in Sources */, B33D21B820E130D000BAD749 /* BookmarksTabViewController.swift in Sources */, 3404754A1E081A4600C92850 /* AppInfo.mm in Sources */, 3358607E217632A2006D11F2 /* BookmarksSharingViewController.swift in Sources */, @@ -5676,6 +5711,7 @@ 34AB661D1FC5AA330078E451 /* MWMTaxiPreviewDataSource.mm in Sources */, F69CE8D61E5C49B4002B5881 /* PPHotelCarouselCell.swift in Sources */, 47B9065321C7FA400079C85E /* MWMImageCache.m in Sources */, + 472C40E8232BA810009AA777 /* CatalogPromoItem.m in Sources */, F6FEA82E1C58F108007223CC /* MWMButton.mm in Sources */, 3445324E1F714FD70059FBCC /* UGCAddReviewController.swift in Sources */, 34B924431DC8A29C0008D971 /* MWMMailViewController.mm in Sources */, diff --git a/iphone/Maps/UI/PlacePage/MWMPlacePageData.mm b/iphone/Maps/UI/PlacePage/MWMPlacePageData.mm index 359443994b..0c24a980ab 100644 --- a/iphone/Maps/UI/PlacePage/MWMPlacePageData.mm +++ b/iphone/Maps/UI/PlacePage/MWMPlacePageData.mm @@ -472,12 +472,7 @@ NSString * const kUserDefaultsLatLonAsDMSKey = @"UserDefaultsLatLonAsDMS"; auto editSession = bmManager.GetEditSession(); auto const * bookmark = editSession.CreateBookmark(std::move(bmData), categoryId); f.FillBookmarkInfo(*bookmark, m_info); - NSUInteger position = [self bookmarkSectionPosition]; - if (self.isPromoCatalog) { - m_sections.insert(m_sections.begin() + position, Sections::Bookmark); - } else { - m_sections.insert(m_sections.begin() + position, Sections::Bookmark); - } + m_sections.insert(m_sections.begin() + [self bookmarkSectionPosition], Sections::Bookmark); } else { @@ -831,7 +826,8 @@ NSString * const kUserDefaultsLatLonAsDMSKey = @"UserDefaultsLatLonAsDMS"; - (BOOL)isOpentable { return m_info.GetSponsoredType() == SponsoredType::Opentable; } - (BOOL)isPartner { return m_info.GetSponsoredType() == SponsoredType::Partner; } - (BOOL)isHolidayObject { return m_info.GetSponsoredType() == SponsoredType::Holiday; } -- (BOOL)isPromoCatalog { return m_info.GetSponsoredType() == SponsoredType::PromoCatalogCity; } +- (BOOL)isPromoCatalog { return m_info.GetSponsoredType() == SponsoredType::PromoCatalogCity + || m_info.GetSponsoredType() == SponsoredType::PromoCatalogSightseeings; } - (BOOL)isBookingSearch { return !m_info.GetBookingSearchUrl().empty(); } - (BOOL)isMyPosition { return m_info.IsMyPosition(); } - (BOOL)isHTMLDescription { return strings::IsHTML(GetPreferredBookmarkStr(m_info.GetBookmarkData().m_description)); } @@ -933,8 +929,16 @@ NSString * const kUserDefaultsLatLonAsDMSKey = @"UserDefaultsLatLonAsDMS"; }; auto appInfo = AppInfo.sharedInfo; auto locale = appInfo.twoLetterLanguageId.UTF8String; - //TODO: set correct UTM - api->GetCityGallery(self.mercator, locale, UTM::LargeToponymsPlacepageGallery, resultHandler, errorHandler); + if (m_info.GetSponsoredType() == SponsoredType::PromoCatalogCity) { + api->GetCityGallery(self.mercator, locale, UTM::LargeToponymsPlacepageGallery, resultHandler, errorHandler); + } else { + api->GetPoiGallery(self.mercator, locale, + m_info.GetRawTypes(), + [MWMFrameworkHelper isWiFiConnected], + UTM::SightseeingsPlacepageGallery, + resultHandler, + errorHandler); + } } if (self.refreshPromoCallback) { diff --git a/iphone/Maps/UI/PlacePage/PlacePageLayout/Content/CatalogPromo/CatalogPromoItem+Core.h b/iphone/Maps/UI/PlacePage/PlacePageLayout/Content/CatalogPromo/CatalogPromoItem+Core.h new file mode 100644 index 0000000000..442f72191d --- /dev/null +++ b/iphone/Maps/UI/PlacePage/PlacePageLayout/Content/CatalogPromo/CatalogPromoItem+Core.h @@ -0,0 +1,13 @@ +#import "CatalogPromoItem.h" + +#include "partners_api/promo_api.hpp" + +NS_ASSUME_NONNULL_BEGIN + +@interface CatalogPromoItem (Core) + +- (instancetype)initWithCoreItem:(promo::CityGallery::Item const &)item; + +@end + +NS_ASSUME_NONNULL_END diff --git a/iphone/Maps/UI/PlacePage/PlacePageLayout/Content/CatalogPromo/CatalogPromoItem+Core.mm b/iphone/Maps/UI/PlacePage/PlacePageLayout/Content/CatalogPromo/CatalogPromoItem+Core.mm new file mode 100644 index 0000000000..73d9afcd51 --- /dev/null +++ b/iphone/Maps/UI/PlacePage/PlacePageLayout/Content/CatalogPromo/CatalogPromoItem+Core.mm @@ -0,0 +1,18 @@ +#import "CatalogPromoItem+Core.h" + +@implementation CatalogPromoItem (Core) + +- (instancetype)initWithCoreItem:(promo::CityGallery::Item const &)item { + self = [super init]; + if (self) { + self.placeTitle = @(item.m_place.m_name.c_str()); + self.placeDescription = @(item.m_place.m_description.c_str()); + self.imageUrl = @(item.m_imageUrl.c_str()); + self.catalogUrl = @(item.m_url.c_str()); + self.guideName = @(item.m_name.c_str()); + self.guideAuthor = @(item.m_author.m_name.c_str()); + } + return self; +} + +@end diff --git a/iphone/Maps/UI/PlacePage/PlacePageLayout/Content/CatalogPromo/CatalogPromoItem.h b/iphone/Maps/UI/PlacePage/PlacePageLayout/Content/CatalogPromo/CatalogPromoItem.h new file mode 100644 index 0000000000..04d250ab0b --- /dev/null +++ b/iphone/Maps/UI/PlacePage/PlacePageLayout/Content/CatalogPromo/CatalogPromoItem.h @@ -0,0 +1,14 @@ +NS_ASSUME_NONNULL_BEGIN + +@interface CatalogPromoItem : NSObject + +@property(nonatomic, copy) NSString *placeTitle; +@property(nonatomic, copy) NSString *placeDescription; +@property(nonatomic, copy) NSString *imageUrl; +@property(nonatomic, copy) NSString *catalogUrl; +@property(nonatomic, copy) NSString *guideName; +@property(nonatomic, copy) NSString *guideAuthor; + +@end + +NS_ASSUME_NONNULL_END diff --git a/iphone/Maps/UI/PlacePage/PlacePageLayout/Content/CatalogPromo/CatalogPromoItem.m b/iphone/Maps/UI/PlacePage/PlacePageLayout/Content/CatalogPromo/CatalogPromoItem.m new file mode 100644 index 0000000000..948891369c --- /dev/null +++ b/iphone/Maps/UI/PlacePage/PlacePageLayout/Content/CatalogPromo/CatalogPromoItem.m @@ -0,0 +1,5 @@ +#import "CatalogPromoItem.h" + +@implementation CatalogPromoItem + +@end diff --git a/iphone/Maps/UI/PlacePage/PlacePageLayout/Content/CatalogPromo/CatalogSingleItemCell.swift b/iphone/Maps/UI/PlacePage/PlacePageLayout/Content/CatalogPromo/CatalogSingleItemCell.swift new file mode 100644 index 0000000000..08c7cd3955 --- /dev/null +++ b/iphone/Maps/UI/PlacePage/PlacePageLayout/Content/CatalogPromo/CatalogSingleItemCell.swift @@ -0,0 +1,41 @@ +@objc class CatalogSingleItemCell: UITableViewCell { + @IBOutlet var placeTitleLabel: UILabel! + @IBOutlet var placeDescriptionLabel: UILabel! + @IBOutlet var guideNameLabel: UILabel! + @IBOutlet var guideAuthorLabel: UILabel! + @IBOutlet var moreButton: UIButton! + @IBOutlet var placeImageView: UIImageView! + @IBOutlet var openCatalogButton: UIButton! + @IBOutlet var moreButtonHeightConstraint: NSLayoutConstraint! + @IBOutlet var guideContainerView: UIView! + + @objc var onMore: MWMVoidBlock? + @objc var onGoToCatalog: MWMVoidBlock? + + override func awakeFromNib() { + super.awakeFromNib() + guideContainerView.layer.borderColor = UIColor.blackDividers()?.cgColor + } + + @objc func config(_ promoItem: CatalogPromoItem) { + placeTitleLabel.text = promoItem.placeTitle + placeDescriptionLabel.text = promoItem.placeDescription + guideNameLabel.text = promoItem.guideName + guideAuthorLabel.text = promoItem.guideAuthor + guard let url = URL(string: promoItem.imageUrl) else { + return + } + placeImageView.wi_setImage(with: url) + } + + @IBAction func onMoreButton(_ sender: UIButton) { + moreButton.isHidden = true + moreButtonHeightConstraint.constant = 0 + placeDescriptionLabel.numberOfLines = 0 + onMore?() + } + + @IBAction func onCatalogButton(_ sender: UIButton) { + onGoToCatalog?() + } +} diff --git a/iphone/Maps/UI/PlacePage/PlacePageLayout/Content/CatalogPromo/CatalogSingleItemCell.xib b/iphone/Maps/UI/PlacePage/PlacePageLayout/Content/CatalogPromo/CatalogSingleItemCell.xib new file mode 100644 index 0000000000..f139c4b36c --- /dev/null +++ b/iphone/Maps/UI/PlacePage/PlacePageLayout/Content/CatalogPromo/CatalogSingleItemCell.xib @@ -0,0 +1,267 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/iphone/Maps/UI/PlacePage/PlacePageLayout/Content/CatalogPromo/EmptyTableViewCell.swift b/iphone/Maps/UI/PlacePage/PlacePageLayout/Content/CatalogPromo/EmptyTableViewCell.swift new file mode 100644 index 0000000000..c8f7446a2b --- /dev/null +++ b/iphone/Maps/UI/PlacePage/PlacePageLayout/Content/CatalogPromo/EmptyTableViewCell.swift @@ -0,0 +1,2 @@ +@objc class EmptyTableViewCell: UITableViewCell { +} diff --git a/iphone/Maps/UI/PlacePage/PlacePageLayout/Content/CatalogPromo/EmptyTableViewCell.xib b/iphone/Maps/UI/PlacePage/PlacePageLayout/Content/CatalogPromo/EmptyTableViewCell.xib new file mode 100644 index 0000000000..ee83eb3df4 --- /dev/null +++ b/iphone/Maps/UI/PlacePage/PlacePageLayout/Content/CatalogPromo/EmptyTableViewCell.xib @@ -0,0 +1,41 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/iphone/Maps/UI/PlacePage/PlacePageLayout/MWMPlacePageLayout.mm b/iphone/Maps/UI/PlacePage/PlacePageLayout/MWMPlacePageLayout.mm index 0706cbdb51..7baeb41998 100644 --- a/iphone/Maps/UI/PlacePage/PlacePageLayout/MWMPlacePageLayout.mm +++ b/iphone/Maps/UI/PlacePage/PlacePageLayout/MWMPlacePageLayout.mm @@ -1,3 +1,4 @@ +#import "CatalogPromoItem+Core.h" #import "MWMPlacePageLayout.h" #import "MWMBookmarkCell.h" #import "MWMDiscoveryCityGalleryObjects.h" @@ -108,8 +109,9 @@ map const kMetaInfoCells = { [tv registerWithCellClass:[MWMUGCAddReviewCell class]]; [tv registerWithCellClass:[MWMUGCYourReviewCell class]]; [tv registerWithCellClass:[MWMUGCReviewCell class]]; - [tv registerWithCellClass:[MWMDiscoveryOnlineTemplateCell class]]; + [tv registerWithCellClass:[EmptyTableViewCell class]]; [tv registerWithCellClass:[MWMDiscoveryGuideCollectionHolderCell class]]; + [tv registerWithCellClass:[CatalogSingleItemCell class]]; // Register all meta info cells. for (auto const & pair : kMetaInfoCells) @@ -634,37 +636,36 @@ map const kMetaInfoCells = { { auto rows = self.data.promoCatalogRows; if (rows.empty() || rows[indexPath.row] != PromoCatalogRow::Guides) { - Class cls = [MWMDiscoveryOnlineTemplateCell class]; - MWMDiscoveryOnlineTemplateCell * cell = (MWMDiscoveryOnlineTemplateCell *)[tableView dequeueReusableCellWithCellClass:cls indexPath:indexPath]; - __weak __typeof__(self) weakSelf = self; - [cell configWithType:MWMDiscoveryOnlineTemplateTypePromo - needSpinner:rows.empty() - canUseNetwork: rows.empty() || rows[indexPath.row] == PromoCatalogRow::GuidesRequestError - tap:^{ - __strong __typeof__(weakSelf) strongSelf = weakSelf; - if (MWMPlatform.networkConnectionType == MWMNetworkConnectionTypeNone) { - NSURL * url = [NSURL URLWithString:UIApplicationOpenSettingsURLString]; - UIApplication * app = UIApplication.sharedApplication; - if ([app canOpenURL:url]) - [app openURL:url options:@{} completionHandler:nil]; - } else { - network_policy::CallPartnersApi([strongSelf](auto const & canUseNetwork) { - [strongSelf.data reguestPromoCatalog:canUseNetwork]; - }, false, true); - } - }]; + 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]; + CatalogPromoItem *item = [[CatalogPromoItem alloc] initWithCoreItem:[data.promoGallery galleryItemAtIndex:0]]; + [cell config:item]; + cell.onMore = ^{ + [tableView beginUpdates]; + [tableView endUpdates]; + }; + cell.onGoToCatalog = ^{ + NSURL *url = [NSURL URLWithString:item.catalogUrl]; + [self.delegate openCatalogForURL:url]; + }; + return cell; + } else { + Class cls = [MWMDiscoveryGuideCollectionHolderCell class]; + MWMDiscoveryGuideCollectionHolderCell *cell = (MWMDiscoveryGuideCollectionHolderCell *) + [tableView dequeueReusableCellWithCellClass:cls indexPath:indexPath]; + MWMDiscoveryCollectionView *collection = (MWMDiscoveryCollectionView *)cell.collectionView; + [cell config]; + collection.delegate = self; + collection.dataSource = self; + collection.itemType = discovery::ItemType::Promo; + [collection reloadData]; return cell; } - Class cls = [MWMDiscoveryGuideCollectionHolderCell class]; - MWMDiscoveryGuideCollectionHolderCell *cell = (MWMDiscoveryGuideCollectionHolderCell *) - [tableView dequeueReusableCellWithCellClass:cls indexPath:indexPath]; - MWMDiscoveryCollectionView *collection = (MWMDiscoveryCollectionView *)cell.collectionView; - [cell config]; - collection.delegate = self; - collection.dataSource = self; - collection.itemType = discovery::ItemType::Promo; - [collection reloadData]; - return cell; } } }