[iOS][Cross traffic] Guides in the place page

This commit is contained in:
Zoia Pribytkova 2019-06-18 14:58:51 +03:00 committed by Aleksey Belousov
parent 8d4ee84b7b
commit 7b9d3a6249
23 changed files with 296 additions and 76 deletions

View file

@ -50,6 +50,7 @@
+ (UIColor *)border;
+ (UIColor *)colorWithName:(NSString *)colorName;
+ (UIColor *)colorFromHexString:(NSString *)hexString;
+ (void)setNightMode:(BOOL)mode;
+ (BOOL)isNightMode;

View file

@ -113,6 +113,16 @@ UIColor * color(SEL cmd)
@implementation UIColor (MapsMeColor)
// hex string without #
+ (UIColor *)colorFromHexString:(NSString *)hexString
{
unsigned rgbValue = 0;
NSScanner *scanner = [NSScanner scannerWithString:hexString];
[scanner setScanLocation:0];
[scanner scanHexInt:&rgbValue];
return [UIColor colorWithRed:((rgbValue & 0xFF0000) >> 16)/255.0 green:((rgbValue & 0xFF00) >> 8)/255.0 blue:(rgbValue & 0xFF)/255.0 alpha:1.0];
}
+ (void)setNightMode:(BOOL)mode
{
isNightMode = mode;

View file

@ -25,15 +25,6 @@ static inline CGFloat LengthCGPoint(CGPoint point)
@end
@interface UIColor (HexColor)
+ (UIColor *)colorWithColorCode:(NSString *)colorCode;
+ (UIColor *)applicationBackgroundColor;
+ (UIColor *)applicationColor;
+ (UIColor *)navigationBarColor;
@end
@interface UIView (Coordinates)
@property (nonatomic) CGFloat minX;

View file

@ -568,6 +568,7 @@
BB8123CF212C264700ADE512 /* Metal.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = BB8123CD212C264700ADE512 /* Metal.framework */; };
BB8123D0212C264700ADE512 /* MetalKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = BB8123CE212C264700ADE512 /* MetalKit.framework */; };
BB8123D62130427E00ADE512 /* MetalContextFactory.mm in Sources */ = {isa = PBXBuildFile; fileRef = BB8123D52130427E00ADE512 /* MetalContextFactory.mm */; };
CD08887422B7ABB400C1368D /* MWMDiscoveryCollectionView.mm in Sources */ = {isa = PBXBuildFile; fileRef = CD08887322B7ABB400C1368D /* MWMDiscoveryCollectionView.mm */; };
CD96C70C22A681C400DB7CFE /* DiscoveryGuideCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = CD96C70A22A681C400DB7CFE /* DiscoveryGuideCell.swift */; };
CD96C70D22A681C400DB7CFE /* DiscoveryGuideCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = CD96C70B22A681C400DB7CFE /* DiscoveryGuideCell.xib */; };
CD96C71122A6820800DB7CFE /* DiscoveryGuideCollectionHolderCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = CD96C70F22A6820800DB7CFE /* DiscoveryGuideCollectionHolderCell.xib */; };
@ -1604,6 +1605,8 @@
BB8123CE212C264700ADE512 /* MetalKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = MetalKit.framework; path = System/Library/Frameworks/MetalKit.framework; sourceTree = SDKROOT; };
BB8123D42130427E00ADE512 /* MetalContextFactory.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MetalContextFactory.h; sourceTree = "<group>"; };
BB8123D52130427E00ADE512 /* MetalContextFactory.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = MetalContextFactory.mm; sourceTree = "<group>"; };
CD08887222B7ABB400C1368D /* MWMDiscoveryCollectionView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MWMDiscoveryCollectionView.h; sourceTree = "<group>"; };
CD08887322B7ABB400C1368D /* MWMDiscoveryCollectionView.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = MWMDiscoveryCollectionView.mm; sourceTree = "<group>"; };
CD96C70A22A681C400DB7CFE /* DiscoveryGuideCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DiscoveryGuideCell.swift; sourceTree = "<group>"; };
CD96C70B22A681C400DB7CFE /* DiscoveryGuideCell.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = DiscoveryGuideCell.xib; sourceTree = "<group>"; };
CD96C70F22A6820800DB7CFE /* DiscoveryGuideCollectionHolderCell.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = DiscoveryGuideCollectionHolderCell.xib; sourceTree = "<group>"; };
@ -4395,6 +4398,8 @@
CDB92CED229E9CF900EC757C /* MWMDiscoveryMapObjects.mm */,
CD96C71522A7B5DE00DB7CFE /* MWMDiscoveryCityGalleryObjects.h */,
CD96C71622A7B5DE00DB7CFE /* MWMDiscoveryCityGalleryObjects.mm */,
CD08887222B7ABB400C1368D /* MWMDiscoveryCollectionView.h */,
CD08887322B7ABB400C1368D /* MWMDiscoveryCollectionView.mm */,
);
path = Discovery;
sourceTree = "<group>";
@ -5385,6 +5390,7 @@
6741AA291BF340DE002C974C /* ColorPickerView.mm in Sources */,
6741AA2B1BF340DE002C974C /* CircleView.mm in Sources */,
F6E2FEEB1E097BA00083EBEC /* MWMSearchTextField.mm in Sources */,
CD08887422B7ABB400C1368D /* MWMDiscoveryCollectionView.mm in Sources */,
4788739220EE326500F6826B /* VerticallyAlignedButton.swift in Sources */,
3444DFDE1F18A5AF00E73099 /* SideButtonsArea.swift in Sources */,
3451F4EE1F026DAF00A981F2 /* PlacePageTaxiCell.swift in Sources */,

View file

@ -26,11 +26,7 @@ final class DiscoveryGuideCell: UICollectionViewCell {
}
}
@IBOutlet var proContainer: UIView! {
didSet {
proLabel.backgroundColor = UIColor.ratingRed()
}
}
@IBOutlet var proContainer: UIView!
@IBOutlet var detailsButton: UIButton! {
didSet {
@ -81,6 +77,7 @@ final class DiscoveryGuideCell: UICollectionViewCell {
title: String,
subtitle: String,
label: String?,
labelHexColor: String?,
onDetails: @escaping OnDetails) {
setAvatar(avatarURL)
titleLabel.text = title
@ -91,6 +88,11 @@ final class DiscoveryGuideCell: UICollectionViewCell {
return
}
proLabel.text = label
if let labelHexColor = labelHexColor, labelHexColor.count == 6 {
proContainer.backgroundColor = UIColor(fromHexString: labelHexColor) ?? UIColor.ratingRed()
} else {
proContainer.backgroundColor = UIColor.ratingRed()
}
proContainer.isHidden = false
}

View file

@ -19,7 +19,7 @@
<rect key="frame" x="0.0" y="0.0" width="160" height="194"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<subviews>
<imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="PVI-wd-HVI">
<imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="PVI-wd-HVI">
<rect key="frame" x="0.0" y="0.0" width="160" height="80"/>
<constraints>
<constraint firstAttribute="height" constant="80" id="kmH-tC-wJm"/>
@ -36,6 +36,9 @@
<userDefinedRuntimeAttributes>
<userDefinedRuntimeAttribute type="string" keyPath="textColorName" value="linkBlue"/>
</userDefinedRuntimeAttributes>
<connections>
<action selector="detailsAction" destination="gTV-IL-0wX" eventType="touchUpInside" id="LKy-hf-jCB"/>
</connections>
</button>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="7eA-bJ-coY">
<rect key="frame" x="12" y="94" width="136" height="21"/>
@ -99,9 +102,9 @@
</userDefinedRuntimeAttributes>
<connections>
<outlet property="avatar" destination="PVI-wd-HVI" id="zzN-X5-o2N"/>
<outlet property="detailsButton" destination="yJV-Vb-Cna" id="UE3-4n-7dC"/>
<outlet property="detailsButton" destination="yJV-Vb-Cna" id="59U-jr-7vt"/>
<outlet property="proContainer" destination="C9b-m0-Yo8" id="gUI-wn-gtQ"/>
<outlet property="proLabel" destination="vHm-DF-mQY" id="31b-6G-yvb"/>
<outlet property="proLabel" destination="vHm-DF-mQY" id="wIY-CW-Bgr"/>
<outlet property="subtitleLabel" destination="fEh-1z-Iwj" id="anX-gC-URG"/>
<outlet property="titleLabel" destination="7eA-bJ-coY" id="hpL-Ce-BRw"/>
</connections>

View file

@ -0,0 +1,11 @@
#include "map/discovery/discovery_client_params.hpp"
NS_ASSUME_NONNULL_BEGIN
@interface MWMDiscoveryCollectionView : UICollectionView
@property(nonatomic) discovery::ItemType itemType;
@end
NS_ASSUME_NONNULL_END

View file

@ -0,0 +1,5 @@
#import "MWMDiscoveryCollectionView.h"
@implementation MWMDiscoveryCollectionView
@end

View file

@ -311,17 +311,14 @@ struct Callback
case ItemType::LocalExperts:
break;
case ItemType::Promo:
auto bookmarks = [[MWMBookmarksTabViewController alloc] init];
bookmarks.activeTab = ActiveTabCatalog;
promo::CityGallery::Item const &item = [self.viewModel.guides galleryItemAtIndex:index];
NSString *itemPath = @(item.m_url.c_str());
if (!itemPath || itemPath.length == 0) {
return;
}
MWMCatalogWebViewController *catalog = [[MWMCatalogWebViewController alloc] init:[NSURL URLWithString:itemPath]];
NSMutableArray<UIViewController *> * controllers = [self.navigationController.viewControllers mutableCopy];
[controllers addObjectsFromArray:@[bookmarks, catalog]];
[self.navigationController setViewControllers:controllers animated:YES];
NSURL *url = [NSURL URLWithString:itemPath];
[self openCatalogForURL:url];
[self logEvent:kStatPlacepageSponsoredItemSelected
type:type
index:index
@ -338,15 +335,19 @@ struct Callback
case ItemType::LocalExperts:
break;
case ItemType::Promo:
auto bookmarks = [[MWMBookmarksTabViewController alloc] init];
bookmarks.activeTab = ActiveTabCatalog;
NSURL *url = [self.viewModel.guides moreURL];
MWMCatalogWebViewController *catalog = [[MWMCatalogWebViewController alloc] init:url];
NSMutableArray<UIViewController *> * controllers = [self.navigationController.viewControllers mutableCopy];
[controllers addObjectsFromArray:@[bookmarks, catalog]];
[self.navigationController setViewControllers:controllers animated:YES];
[self openCatalogForURL:url];
break;
}
}
- (void)openCatalogForURL:(NSURL *)url {
auto bookmarks = [[MWMBookmarksTabViewController alloc] init];
bookmarks.activeTab = ActiveTabCatalog;
MWMCatalogWebViewController *catalog = [[MWMCatalogWebViewController alloc] init:url];
NSMutableArray<UIViewController *> * controllers = [self.navigationController.viewControllers mutableCopy];
[controllers addObjectsFromArray:@[bookmarks, catalog]];
[self.navigationController setViewControllers:controllers animated:YES];
}
@end

View file

@ -1,11 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="13771" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
<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="retina4_7" orientation="portrait">
<adaptation id="fullscreen"/>
</device>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="13772"/>
<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>
@ -17,11 +17,11 @@
</connections>
</placeholder>
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
<view contentMode="scaleToFill" id="iN0-l3-epB" propertyAccessControl="all">
<view contentMode="scaleToFill" id="iN0-l3-epB">
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<tableView clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" style="grouped" separatorStyle="none" rowHeight="-1" estimatedRowHeight="-1" sectionHeaderHeight="18" sectionFooterHeight="18" translatesAutoresizingMaskIntoConstraints="NO" id="mUK-tO-itf">
<tableView clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" style="grouped" separatorStyle="none" rowHeight="-1" estimatedRowHeight="-1" sectionHeaderHeight="16" sectionFooterHeight="1" translatesAutoresizingMaskIntoConstraints="NO" id="mUK-tO-itf">
<rect key="frame" x="0.0" y="20" width="375" height="647"/>
<color key="backgroundColor" cocoaTouchSystemColor="groupTableViewBackgroundColor"/>
<userDefinedRuntimeAttributes>

View file

@ -1,5 +1,6 @@
#import "MWMDiscoveryTableManager.h"
#import "MWMDiscoveryTapDelegate.h"
#import "MWMDiscoveryCollectionView.h"
#import "MWMDiscoveryControllerViewModel.h"
#import "MWMDiscoveryHotelViewModel.h"
#import "MWMDiscoverySearchViewModel.h"
@ -46,13 +47,6 @@ NSString * StatProvider(ItemType const type)
using namespace discovery;
@interface MWMDiscoveryCollectionView : UICollectionView
@property(nonatomic) ItemType itemType;
@end
@implementation MWMDiscoveryCollectionView
@end
@interface MWMDiscoveryTableManager ()<UITableViewDataSource, UICollectionViewDelegate,
UICollectionViewDataSource>
{
@ -365,7 +359,9 @@ using namespace discovery;
[cell configWithAvatarURL:objectVM.imagePath
title:objectVM.title
subtitle:objectVM.subtitle
label:objectVM.label onDetails:^{
label:objectVM.label
labelHexColor:objectVM.labelHexColor
onDetails:^{
[weakSelf.delegate openURLForItem:ItemType::Promo atIndex:indexPath.row];
}];
return cell;

View file

@ -1,26 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="13771" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
<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="retina4_7" orientation="portrait">
<adaptation id="fullscreen"/>
</device>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="13772"/>
<capability name="Constraints to layout margins" minToolsVersion="6.0"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="14490.49"/>
<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 clipsSubviews="YES" contentMode="scaleToFill" preservesSuperviewLayoutMargins="YES" selectionStyle="none" indentationWidth="10" reuseIdentifier="DiscoveryBookingCollectionHolderCell" rowHeight="245" id="kOb-uR-NfL" customClass="MWMDiscoveryBookingCollectionHolderCell" propertyAccessControl="all">
<rect key="frame" x="0.0" y="0.0" width="375" height="190"/>
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" preservesSuperviewLayoutMargins="YES" selectionStyle="none" indentationWidth="10" reuseIdentifier="DiscoveryBookingCollectionHolderCell" rowHeight="243" id="kOb-uR-NfL" customClass="MWMDiscoveryBookingCollectionHolderCell">
<rect key="frame" x="0.0" y="0.0" width="389" height="188"/>
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" preservesSuperviewLayoutMargins="YES" insetsLayoutMarginsFromSafeArea="NO" tableViewCell="kOb-uR-NfL" id="HJe-Ad-Mjp">
<rect key="frame" x="0.0" y="0.0" width="375" height="189.5"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" ambiguous="YES" preservesSuperviewLayoutMargins="YES" insetsLayoutMarginsFromSafeArea="NO" tableViewCell="kOb-uR-NfL" id="HJe-Ad-Mjp">
<rect key="frame" x="0.0" y="0.0" width="389" height="187.5"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="mVI-Rn-1Ht">
<rect key="frame" x="16" y="12" width="327" height="26.5"/>
<rect key="frame" x="16" y="0.0" width="357" height="48"/>
<constraints>
<constraint firstAttribute="height" constant="48" id="mmI-mG-laf"/>
</constraints>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
@ -30,7 +32,7 @@
</userDefinedRuntimeAttributes>
</label>
<collectionView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" showsHorizontalScrollIndicator="NO" showsVerticalScrollIndicator="NO" dataMode="none" translatesAutoresizingMaskIntoConstraints="NO" id="hb0-w1-X0p" customClass="MWMDiscoveryCollectionView">
<rect key="frame" x="0.0" y="50.5" width="375" height="139"/>
<rect key="frame" x="0.0" y="48" width="389" height="139"/>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<constraints>
<constraint firstAttribute="height" constant="139" id="EJY-mn-vpT"/>
@ -45,12 +47,12 @@
</subviews>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<constraints>
<constraint firstItem="hb0-w1-X0p" firstAttribute="top" secondItem="mVI-Rn-1Ht" secondAttribute="bottom" constant="12" id="2HX-P3-y34"/>
<constraint firstAttribute="trailingMargin" secondItem="mVI-Rn-1Ht" secondAttribute="trailing" constant="16" id="Krm-7b-e90"/>
<constraint firstItem="mVI-Rn-1Ht" firstAttribute="leading" secondItem="HJe-Ad-Mjp" secondAttribute="leading" constant="16" id="O0N-tB-zHS"/>
<constraint firstItem="mVI-Rn-1Ht" firstAttribute="top" secondItem="HJe-Ad-Mjp" secondAttribute="top" constant="12" id="Pjh-uR-2fV"/>
<constraint firstAttribute="trailing" secondItem="mVI-Rn-1Ht" secondAttribute="trailing" constant="16" id="S7G-cU-oCO"/>
<constraint firstAttribute="trailing" secondItem="hb0-w1-X0p" secondAttribute="trailing" id="TZ9-cR-8ob"/>
<constraint firstItem="hb0-w1-X0p" firstAttribute="top" secondItem="mVI-Rn-1Ht" secondAttribute="bottom" id="YL4-At-jDb"/>
<constraint firstAttribute="bottom" secondItem="hb0-w1-X0p" secondAttribute="bottom" id="ekR-z5-imZ"/>
<constraint firstItem="mVI-Rn-1Ht" firstAttribute="top" secondItem="HJe-Ad-Mjp" secondAttribute="top" id="fg4-bl-DPO"/>
<constraint firstItem="hb0-w1-X0p" firstAttribute="leading" secondItem="HJe-Ad-Mjp" secondAttribute="leading" id="uPC-mg-zsI"/>
</constraints>
<userDefinedRuntimeAttributes>
@ -65,7 +67,7 @@
<outlet property="collectionView" destination="hb0-w1-X0p" id="CRZ-o9-rpF"/>
<outlet property="header" destination="mVI-Rn-1Ht" id="0SB-Lz-CRU"/>
</connections>
<point key="canvasLocation" x="-179.5" y="58"/>
<point key="canvasLocation" x="-168.80000000000001" y="56.671664167916049"/>
</tableViewCell>
</objects>
</document>

View file

@ -32,7 +32,7 @@ final class DiscoveryBookingCollectionHolderCell: DiscoveryCollectionHolder {
@objc(MWMDiscoveryGuideCollectionHolderCell)
final class DiscoveryGuideCollectionHolderCell: DiscoveryCollectionHolder {
@objc func config() {
header.text = L("discovery_button_subtitle_guides").uppercased()
header.text = L("gallery_pp_download_guides_title").uppercased()
collectionView.register(cellClass: DiscoveryGuideCell.self)
collectionView.register(cellClass: DiscoveryMoreCell.self)
}

View file

@ -12,15 +12,18 @@
<objects>
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner"/>
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
<tableViewCell contentMode="scaleToFill" selectionStyle="default" indentationWidth="10" reuseIdentifier="DiscoveryGuideCollectionHolderCell" rowHeight="235" id="KGk-i7-Jjw" customClass="MWMDiscoveryGuideCollectionHolderCell">
<rect key="frame" x="0.0" y="0.0" width="391" height="235"/>
<tableViewCell contentMode="scaleToFill" selectionStyle="none" indentationWidth="10" reuseIdentifier="DiscoveryGuideCollectionHolderCell" rowHeight="243" id="KGk-i7-Jjw" customClass="MWMDiscoveryGuideCollectionHolderCell">
<rect key="frame" x="0.0" y="0.0" width="391" height="243"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="KGk-i7-Jjw" id="H2p-sc-9uM">
<rect key="frame" x="0.0" y="0.0" width="391" height="234.5"/>
<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.0" width="391" height="242.5"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="BeQ-ih-VTq">
<rect key="frame" x="16" y="12" width="363" height="15.5"/>
<rect key="frame" x="16" y="0.0" width="363" height="48.5"/>
<constraints>
<constraint firstAttribute="height" constant="48" id="BTa-Cf-S7e"/>
</constraints>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
@ -30,13 +33,13 @@
</userDefinedRuntimeAttributes>
</label>
<collectionView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" showsHorizontalScrollIndicator="NO" showsVerticalScrollIndicator="NO" dataMode="none" translatesAutoresizingMaskIntoConstraints="NO" id="NFk-MT-sfu" customClass="MWMDiscoveryCollectionView">
<rect key="frame" x="0.0" y="39.5" width="391" height="195"/>
<rect key="frame" x="0.0" y="48.5" width="391" height="195"/>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<constraints>
<constraint firstAttribute="height" constant="195" id="Nkd-D4-A27"/>
</constraints>
<collectionViewFlowLayout key="collectionViewLayout" scrollDirection="horizontal" minimumLineSpacing="8" minimumInteritemSpacing="0.0" id="QhS-4e-r8U">
<size key="itemSize" width="160" height="138"/>
<size key="itemSize" width="160" height="194"/>
<size key="headerReferenceSize" width="0.0" height="0.0"/>
<size key="footerReferenceSize" width="0.0" height="0.0"/>
<inset key="sectionInset" minX="8" minY="0.0" maxX="8" maxY="0.0"/>
@ -45,9 +48,9 @@
</subviews>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<constraints>
<constraint firstItem="NFk-MT-sfu" firstAttribute="top" secondItem="BeQ-ih-VTq" secondAttribute="bottom" constant="12" id="1gL-Ci-yMY"/>
<constraint firstItem="NFk-MT-sfu" firstAttribute="leading" secondItem="H2p-sc-9uM" secondAttribute="leading" id="8ct-AF-P13"/>
<constraint firstItem="BeQ-ih-VTq" firstAttribute="top" secondItem="H2p-sc-9uM" secondAttribute="top" constant="12" id="C1z-tx-ppW"/>
<constraint firstItem="NFk-MT-sfu" firstAttribute="top" secondItem="BeQ-ih-VTq" secondAttribute="bottom" id="BZp-GC-k1d"/>
<constraint firstItem="BeQ-ih-VTq" firstAttribute="top" secondItem="H2p-sc-9uM" secondAttribute="top" id="EKm-DI-3UG"/>
<constraint firstItem="BeQ-ih-VTq" firstAttribute="leading" secondItem="H2p-sc-9uM" secondAttribute="leading" constant="16" id="Inc-RA-BDU"/>
<constraint firstAttribute="bottom" secondItem="NFk-MT-sfu" secondAttribute="bottom" id="IsQ-zk-Inu"/>
<constraint firstAttribute="trailing" secondItem="NFk-MT-sfu" secondAttribute="trailing" id="ZFO-zN-y6P"/>

View file

@ -1,12 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="14113" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
<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="retina4_7" orientation="portrait">
<adaptation id="fullscreen"/>
</device>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="14088"/>
<capability name="Constraints to layout margins" minToolsVersion="6.0"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="14490.49"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<objects>
@ -15,12 +14,15 @@
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" preservesSuperviewLayoutMargins="YES" selectionStyle="none" indentationWidth="10" reuseIdentifier="DiscoverySearchCollectionHolderCell" rowHeight="245" id="69d-dp-KY2" customClass="MWMDiscoverySearchCollectionHolderCell">
<rect key="frame" x="0.0" y="0.0" width="375" height="190"/>
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" preservesSuperviewLayoutMargins="YES" insetsLayoutMarginsFromSafeArea="NO" tableViewCell="69d-dp-KY2" id="qeQ-5M-VVb">
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" ambiguous="YES" preservesSuperviewLayoutMargins="YES" insetsLayoutMarginsFromSafeArea="NO" tableViewCell="69d-dp-KY2" id="qeQ-5M-VVb">
<rect key="frame" x="0.0" y="0.0" width="375" height="189.5"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="zLg-Ze-Eru">
<rect key="frame" x="16" y="12" width="327" height="26.5"/>
<rect key="frame" x="16" y="0.0" width="343" height="48"/>
<constraints>
<constraint firstAttribute="height" constant="48" id="fCn-dv-57v"/>
</constraints>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
@ -30,7 +32,7 @@
</userDefinedRuntimeAttributes>
</label>
<collectionView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" showsHorizontalScrollIndicator="NO" showsVerticalScrollIndicator="NO" dataMode="none" translatesAutoresizingMaskIntoConstraints="NO" id="5kQ-Mc-ZYQ" customClass="MWMDiscoveryCollectionView">
<rect key="frame" x="0.0" y="50.5" width="375" height="139"/>
<rect key="frame" x="0.0" y="48" width="375" height="139"/>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<constraints>
<constraint firstAttribute="height" constant="139" id="yin-jq-MTp"/>
@ -45,13 +47,13 @@
</subviews>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<constraints>
<constraint firstItem="zLg-Ze-Eru" firstAttribute="leading" secondItem="qeQ-5M-VVb" secondAttribute="leadingMargin" id="2hQ-HG-sHj"/>
<constraint firstItem="zLg-Ze-Eru" firstAttribute="top" secondItem="qeQ-5M-VVb" secondAttribute="top" constant="12" id="3Ut-Hs-zpi"/>
<constraint firstItem="5kQ-Mc-ZYQ" firstAttribute="top" secondItem="zLg-Ze-Eru" secondAttribute="bottom" constant="12" id="4f5-Um-KLw"/>
<constraint firstAttribute="trailing" secondItem="zLg-Ze-Eru" secondAttribute="trailing" constant="16" id="2rh-09-yYn"/>
<constraint firstItem="zLg-Ze-Eru" firstAttribute="top" secondItem="qeQ-5M-VVb" secondAttribute="top" id="6zc-pP-s96"/>
<constraint firstAttribute="bottom" secondItem="5kQ-Mc-ZYQ" secondAttribute="bottom" id="84B-tR-LtW"/>
<constraint firstAttribute="trailing" secondItem="5kQ-Mc-ZYQ" secondAttribute="trailing" id="V7W-fw-utp"/>
<constraint firstItem="zLg-Ze-Eru" firstAttribute="leading" secondItem="qeQ-5M-VVb" secondAttribute="leading" constant="16" id="YOT-SJ-LcE"/>
<constraint firstItem="5kQ-Mc-ZYQ" firstAttribute="leading" secondItem="qeQ-5M-VVb" secondAttribute="leading" id="btL-Ho-0fu"/>
<constraint firstAttribute="trailingMargin" secondItem="zLg-Ze-Eru" secondAttribute="trailing" constant="16" id="ybg-iI-Axr"/>
<constraint firstItem="5kQ-Mc-ZYQ" firstAttribute="top" secondItem="zLg-Ze-Eru" secondAttribute="bottom" id="dVf-py-a5o"/>
</constraints>
<userDefinedRuntimeAttributes>
<userDefinedRuntimeAttribute type="string" keyPath="backgroundColorName" value="pressBackground"/>

View file

@ -159,6 +159,7 @@ using namespace discovery;
return [[MWMDiscoveryGuideViewModel alloc] initWithTitle:@(item.m_name.c_str())
subtitle:@(item.m_author.m_name.c_str())
label:@(item.m_luxCategory.m_name.c_str())
labelHexColor:@(item.m_luxCategory.m_color.c_str())
imageURL:@(item.m_imageUrl.c_str())];
}

View file

@ -5,11 +5,13 @@ NS_ASSUME_NONNULL_BEGIN
@property(nonatomic, readonly) NSString *title;
@property(nonatomic, readonly) NSString *subtitle;
@property(nonatomic, nullable, readonly) NSString *label;
@property(nonatomic, nullable, readonly) NSString *labelHexColor;
@property(nonatomic, nullable, readonly) NSString *imagePath;
- (instancetype)initWithTitle:(NSString *)title
subtitle:(NSString *)subtitle
label:(nullable NSString *)label
labelHexColor:(nullable NSString *)labelHexColor
imageURL:(nullable NSString *) imagePath;
@end

View file

@ -5,6 +5,7 @@
@property(nonatomic, readwrite) NSString *title;
@property(nonatomic, readwrite) NSString *subtitle;
@property(nonatomic, readwrite) NSString *label;
@property(nonatomic, readwrite) NSString *labelHexColor;
@property(nonatomic, readwrite) NSString *imagePath;
@end
@ -14,12 +15,14 @@
- (instancetype)initWithTitle:(NSString *)title
subtitle:(NSString *)subtitle
label:(NSString *)label
labelHexColor:(NSString *)labelHexColor
imageURL:(NSString *) imagePath {
self = [super init];
if (self) {
self.title = title;
self.subtitle = subtitle;
self.label = label;
self.labelHexColor = labelHexColor;
self.imagePath = imagePath;
}
return self;

View file

@ -34,4 +34,6 @@ typedef UIView * _Nullable (^MWMPlacePageButtonsDismissBlock)(NSInteger);
- (void)showPlaceDescription:(NSString * _Nonnull)htmlString;
- (void)openCatalogForURL:(NSURL * _Nullable)url;
@end

View file

@ -51,7 +51,8 @@ enum class Sections
Buttons,
UGCRating,
UGCAddReview,
UGCReviews
UGCReviews,
PromoCatalog
};
enum class PreviewRows
@ -128,6 +129,13 @@ enum class OpeningHours
Closed,
Unknown
};
enum class PromoCatalogRow
{
Guides,
GuidesNoInternetError,
GuidesRequestError
};
using NewSectionsAreReady = void (^)(NSRange const & range, MWMPlacePageData * data, BOOL isSection);
} // namespace place_page
@ -136,6 +144,8 @@ using NewSectionsAreReady = void (^)(NSRange const & range, MWMPlacePageData * d
@class MWMUGCViewModel;
@class MWMUGCReviewModel;
@class MWMUGCRatingValueType;
@class MWMDiscoveryCityGalleryObjects;
@class MWMDiscoveryGuideViewModel;
@protocol MWMBanner;
/// ViewModel for place page.
@ -145,7 +155,9 @@ 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(nonatomic, readonly) MWMUGCViewModel * ugc;
@property(nonatomic, readonly) MWMDiscoveryCityGalleryObjects *promoGallery;
@property(nonatomic, readonly) NSInteger bookingDiscount;
@property(nonatomic, readonly) BOOL isSmartDeal;
@property(nonatomic, readonly) BOOL isPopular;
@ -228,6 +240,10 @@ using NewSectionsAreReady = void (^)(NSRange const & range, MWMPlacePageData * d
- (NSString *)localAdsURL;
- (void)logLocalAdsEvent:(local_ads::EventType)type;
// Promo Catalog
- (void)fillPromoCatalogSection;
- (MWMDiscoveryGuideViewModel *)guideAtIndex:(NSUInteger)index;
// Table view's data
- (std::vector<place_page::Sections> const &)sections;
- (std::vector<place_page::PreviewRows> const &)previewRows;
@ -238,6 +254,7 @@ using NewSectionsAreReady = void (^)(NSRange const & range, MWMPlacePageData * d
- (std::vector<place_page::MetainfoRows> const &)metainfoRows;
- (std::vector<place_page::AdRows> const &)adRows;
- (std::vector<place_page::ButtonsRows> const &)buttonsRows;
- (std::vector<place_page::PromoCatalogRow> const &)promoCatalogRows;
// Table view metainfo rows
- (NSString *)stringForRow:(place_page::MetainfoRows)row;
@ -250,6 +267,7 @@ using NewSectionsAreReady = void (^)(NSRange const & range, MWMPlacePageData * d
- (BOOL)isOpentable;
- (BOOL)isPartner;
- (BOOL)isHolidayObject;
- (BOOL)isPromoCatalog;
- (BOOL)isBookingSearch;
- (BOOL)isHTMLDescription;
- (BOOL)isMyPosition;

View file

@ -1,6 +1,8 @@
#import "MWMPlacePageData.h"
#import "AppInfo.h"
#import "LocaleTranslator.h"
#import "MWMDiscoveryCityGalleryObjects.h"
#import "MWMDiscoveryGuideViewModel.h"
#import "MWMBannerHelpers.h"
#import "MWMBookmarksManager.h"
#import "MWMNetworkPolicy.h"
@ -18,6 +20,7 @@
#include "partners_api/booking_api.hpp"
#include "partners_api/booking_block_params.hpp"
#include "partners_api/promo_api.hpp"
#include "3party/opening_hours/opening_hours.hpp"
@ -38,6 +41,7 @@ NSString * const kUserDefaultsLatLonAsDMSKey = @"UserDefaultsLatLonAsDMS";
@property(copy, nonatomic) NSArray<MWMGalleryItemModel *> * photos;
@property(nonatomic) NSNumberFormatter * currencyFormatter;
@property(nonatomic, readwrite) MWMUGCViewModel * ugc;
@property(nonatomic, readwrite) MWMDiscoveryCityGalleryObjects *promoGallery;
@property(nonatomic) NSInteger bookingDiscount;
@property(nonatomic) BOOL isSmartDeal;
@ -56,6 +60,7 @@ NSString * const kUserDefaultsLatLonAsDMSKey = @"UserDefaultsLatLonAsDMS";
std::vector<HotelDescriptionRow> m_hotelDescriptionRows;
std::vector<HotelFacilitiesRow> m_hotelFacilitiesRows;
std::vector<HotelReviewsRow> m_hotelReviewsRows;
std::vector<PromoCatalogRow> m_promoCatalogRows;
booking::HotelInfo m_hotelInfo;
}
@ -87,6 +92,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])
m_sections.push_back(Sections::Description);
@ -798,6 +807,7 @@ NSString * const kUserDefaultsLatLonAsDMSKey = @"UserDefaultsLatLonAsDMS";
.c_str());
}
}
- (std::vector<place_page::PromoCatalogRow> const &)promoCatalogRows { return m_promoCatalogRows; }
#pragma mark - Helpers
@ -808,6 +818,7 @@ 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::PromoCatalog; }
- (BOOL)isBookingSearch { return !m_info.GetBookingSearchUrl().empty(); }
- (BOOL)isMyPosition { return m_info.IsMyPosition(); }
- (BOOL)isHTMLDescription { return strings::IsHTML(GetPreferredBookmarkStr(m_info.GetBookmarkData().m_description)); }
@ -854,4 +865,44 @@ NSString * const kUserDefaultsLatLonAsDMSKey = @"UserDefaultsLatLonAsDMS";
return [result componentsJoinedByString:@", "];
}
#pragma mark - Promo Gallery
- (void)fillPromoCatalogSection {
if (!self.isPromoCatalog) {
return;
}
network_policy::CallPartnersApi([self](auto const & canUseNetwork) {
auto const api = GetFramework().GetPromoApi(canUseNetwork);
if (!api)
return;
auto const row = canUseNetwork.CanUse() ? PromoCatalogRow::GuidesRequestError : PromoCatalogRow::GuidesNoInternetError;
auto const resultHandler = [self](promo::CityGallery const & cityGallery) {
self.promoGallery = [[MWMDiscoveryCityGalleryObjects alloc] initWithGalleryResults:cityGallery];
m_promoCatalogRows.push_back(PromoCatalogRow::Guides);
if (self.refreshPromoCallback) {
self.refreshPromoCallback();
}
};
auto const errorHandler = [self, row]() {
m_promoCatalogRows.push_back(row);
if (self.refreshPromoCallback) {
self.refreshPromoCallback();
}
};
auto appInfo = AppInfo.sharedInfo;
auto locale = appInfo.twoLetterLanguageId.UTF8String;
api->GetCityGallery("", locale, resultHandler, errorHandler);
});
}
- (MWMDiscoveryGuideViewModel *)guideAtIndex:(NSUInteger)index {
promo::CityGallery::Item const &item = [self.promoGallery galleryItemAtIndex:index];
return [[MWMDiscoveryGuideViewModel alloc] initWithTitle:@(item.m_name.c_str())
subtitle:@(item.m_author.m_name.c_str())
label:@(item.m_luxCategory.m_name.c_str())
labelHexColor:@(item.m_luxCategory.m_color.c_str())
imageURL:@(item.m_imageUrl.c_str())];
}
@end

View file

@ -768,4 +768,15 @@ void RegisterEventIfPossible(eye::MapObject::Event::Type const type, place_page:
[data setUGCUpdateFrom:model resultHandler:resultHandler];
}
#pragma mark - MWMPlacePagePromoProtocol
- (void)openCatalogForURL:(NSURL *)url {
auto bookmarks = [[MWMBookmarksTabViewController alloc] init];
bookmarks.activeTab = ActiveTabCatalog;
MWMCatalogWebViewController *catalog = [[MWMCatalogWebViewController alloc] init:url];
NSMutableArray<UIViewController *> * controllers = [self.ownerViewController.navigationController.viewControllers mutableCopy];
[controllers addObjectsFromArray:@[bookmarks, catalog]];
[self.ownerViewController.navigationController setViewControllers:controllers animated:YES];
}
@end

View file

@ -1,5 +1,8 @@
#import "MWMPlacePageLayout.h"
#import "MWMBookmarkCell.h"
#import "MWMDiscoveryCityGalleryObjects.h"
#import "MWMDiscoveryCollectionView.h"
#import "MWMDiscoveryGuideViewModel.h"
#import "MWMPlaceDescriptionCell.h"
#import "MWMOpeningHoursLayoutHelper.h"
#import "MWMPPPreviewLayoutHelper.h"
@ -35,7 +38,10 @@ map<MetainfoRows, Class> const kMetaInfoCells = {
{MetainfoRows::Internet, [MWMPlacePageInfoCell class]}};
} // namespace
@interface MWMPlacePageLayout ()<UITableViewDataSource, MWMPlacePageCellUpdateProtocol,
@interface MWMPlacePageLayout ()<UITableViewDataSource,
UICollectionViewDataSource,
UICollectionViewDelegate,
MWMPlacePageCellUpdateProtocol,
MWMPlacePageViewUpdateProtocol>
@property(weak, nonatomic) MWMPlacePageData * data;
@ -102,6 +108,8 @@ map<MetainfoRows, Class> const kMetaInfoCells = {
[tv registerWithCellClass:[MWMUGCAddReviewCell class]];
[tv registerWithCellClass:[MWMUGCYourReviewCell class]];
[tv registerWithCellClass:[MWMUGCReviewCell class]];
[tv registerWithCellClass:[MWMDiscoveryOnlineTemplateCell class]];
[tv registerWithCellClass:[MWMDiscoveryGuideCollectionHolderCell class]];
// Register all meta info cells.
for (auto const & pair : kMetaInfoCells)
@ -118,6 +126,7 @@ map<MetainfoRows, Class> const kMetaInfoCells = {
dispatch_async(dispatch_get_main_queue(), ^{
[data fillOnlineBookingSections];
[data fillPromoCatalogSection];
});
}
@ -297,6 +306,7 @@ map<MetainfoRows, Class> const kMetaInfoCells = {
case Sections::UGCRating: return data.ugc.ratingCellsCount;
case Sections::UGCAddReview: return data.ugc.addReviewCellsCount;
case Sections::UGCReviews: return data.ugc.reviewRows.size();
case Sections::PromoCatalog: return 1;
}
}
@ -593,6 +603,34 @@ map<MetainfoRows, Class> const kMetaInfoCells = {
}
}
}
case Sections::PromoCatalog:
{
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 (!strongSelf) { return; }
NSURL *url = [strongSelf.data.promoGallery moreURL];
[strongSelf.delegate openCatalogForURL:url];
}];
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;
return cell;
}
}
}
@ -735,6 +773,12 @@ map<MetainfoRows, Class> const kMetaInfoCells = {
data.bannerIsReadyCallback = ^{
[self.previewLayoutHelper insertRowAtTheEnd];
};
data.refreshPromoCallback = ^{
auto tv = self.placePageView.tableView;
[tv reloadSections:[NSIndexSet indexSetWithIndex:1]
withRowAnimation:UITableViewRowAnimationFade];
};
[self.actionBar configureWithData:data];
[self.previewLayoutHelper configWithData:data];
@ -749,4 +793,59 @@ map<MetainfoRows, Class> const kMetaInfoCells = {
self.buttonsSectionEnabled = YES;
}
#pragma mark - UICollectionViewDataSource
- (NSInteger)collectionView:(MWMDiscoveryCollectionView *)collectionView
numberOfItemsInSection:(NSInteger)section
{
NSInteger count = self.data.promoGallery.count;
return count > 0 ? count + 1 : 0;
}
- (UICollectionViewCell *)collectionView:(MWMDiscoveryCollectionView *)collectionView
cellForItemAtIndexPath:(NSIndexPath *)indexPath {
auto data = self.data;
if (!data) {
return [[UICollectionViewCell alloc] init];
}
if (indexPath.row == self.data.promoGallery.count) {
Class cls = [MWMDiscoveryMoreCell class];
MWMDiscoveryMoreCell *cell = (MWMDiscoveryMoreCell *)[collectionView
dequeueReusableCellWithCellClass:cls
indexPath:indexPath];
return cell;
}
Class cls = [MWMDiscoveryGuideCell class];
MWMDiscoveryGuideCell *cell = (MWMDiscoveryGuideCell *)
[collectionView dequeueReusableCellWithCellClass:cls indexPath:indexPath];
MWMDiscoveryGuideViewModel *objectVM = [self.data guideAtIndex:indexPath.item];
__weak __typeof__(self) weakSelf = self;
[cell configWithAvatarURL:objectVM.imagePath
title:objectVM.title
subtitle:objectVM.subtitle
label:objectVM.label
labelHexColor:objectVM.labelHexColor
onDetails:^{
__strong __typeof__(weakSelf) strongSelf = weakSelf;
if (!strongSelf) { return; }
promo::CityGallery::Item const &item = [strongSelf.data.promoGallery galleryItemAtIndex:indexPath.row];
NSString *itemPath = @(item.m_url.c_str());
if (!itemPath || itemPath.length == 0) {
return;
}
NSURL *url = [NSURL URLWithString:itemPath];
[strongSelf.delegate openCatalogForURL:url];
}];
return cell;
}
#pragma mark - UICollectionViewDelegate
- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath {
NSURL *url = [self.data.promoGallery moreURL];
[self.delegate openCatalogForURL:url];
}
@end