forked from organicmaps/organicmaps
commit
c45d174a56
79 changed files with 802 additions and 1141 deletions
|
@ -1,14 +1,10 @@
|
|||
|
||||
#import "AddSetVC.h"
|
||||
#import "UIViewController+Navigation.h"
|
||||
#import "AddSetTableViewCell.h"
|
||||
#import "SwiftBridge.h"
|
||||
#import "UIViewController+Navigation.h"
|
||||
|
||||
#include "Framework.h"
|
||||
|
||||
#define TEXT_FIELD_TAG 666
|
||||
|
||||
static NSString * const kAddSetCellTableViewCell = @"AddSetTableViewCell";
|
||||
|
||||
@interface AddSetVC () <AddSetTableViewCellProtocol>
|
||||
|
||||
@property (nonatomic) AddSetTableViewCell * cell;
|
||||
|
@ -29,8 +25,7 @@ static NSString * const kAddSetCellTableViewCell = @"AddSetTableViewCell";
|
|||
self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemSave target:self action:@selector(onSaveClicked)];
|
||||
[(UIViewController *)self showBackButton];
|
||||
self.title = L(@"add_new_set");
|
||||
[self.tableView registerNib:[UINib nibWithNibName:kAddSetCellTableViewCell bundle:nil]
|
||||
forCellReuseIdentifier:kAddSetCellTableViewCell];
|
||||
[self.tableView registerWithCellClass:[AddSetTableViewCell class]];
|
||||
}
|
||||
|
||||
- (void)onSaveClicked
|
||||
|
@ -53,7 +48,8 @@ static NSString * const kAddSetCellTableViewCell = @"AddSetTableViewCell";
|
|||
|
||||
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
|
||||
{
|
||||
self.cell = (AddSetTableViewCell *)[tableView dequeueReusableCellWithIdentifier:kAddSetCellTableViewCell];
|
||||
self.cell = static_cast<AddSetTableViewCell *>(
|
||||
[tableView dequeueReusableCellWithCellClass:[AddSetTableViewCell class] indexPath:indexPath]);
|
||||
self.cell.delegate = self;
|
||||
return self.cell;
|
||||
}
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
#import "MapViewController.h"
|
||||
#import "MapsAppDelegate.h"
|
||||
#import "Statistics.h"
|
||||
#import "SwiftBridge.h"
|
||||
|
||||
#include "Framework.h"
|
||||
|
||||
|
@ -53,8 +54,7 @@ extern NSString * const kBookmarksChangedNotification = @"BookmarksChangedNotifi
|
|||
- (void)viewDidLoad
|
||||
{
|
||||
[super viewDidLoad];
|
||||
[self.tableView registerNib:[UINib nibWithNibName:[MWMBookmarkNameCell className] bundle:nil]
|
||||
forCellReuseIdentifier:[MWMBookmarkNameCell className]];
|
||||
[self.tableView registerWithCellClass:[MWMBookmarkNameCell class]];
|
||||
}
|
||||
|
||||
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
|
||||
|
@ -110,7 +110,8 @@ extern NSString * const kBookmarksChangedNotification = @"BookmarksChangedNotifi
|
|||
{
|
||||
if (indexPath.row == 0)
|
||||
{
|
||||
cell = [tableView dequeueReusableCellWithIdentifier:[MWMBookmarkNameCell className]];
|
||||
cell = [tableView dequeueReusableCellWithCellClass:[MWMBookmarkNameCell class]
|
||||
indexPath:indexPath];
|
||||
[static_cast<MWMBookmarkNameCell *>(cell) configWithName:@(cat->GetName().c_str()) delegate:self];
|
||||
}
|
||||
else
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
#import "AddSetVC.h"
|
||||
#import "SelectSetVC.h"
|
||||
#import "AddSetVC.h"
|
||||
#import "SwiftBridge.h"
|
||||
#import "UIViewController+Navigation.h"
|
||||
|
||||
#include "Framework.h"
|
||||
|
@ -55,7 +56,8 @@
|
|||
|
||||
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
|
||||
{
|
||||
UITableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:[UITableViewCell className]];
|
||||
Class cls = [UITableViewCell class];
|
||||
auto cell = [tableView dequeueReusableCellWithCellClass:cls indexPath:indexPath];
|
||||
if (indexPath.section == 0)
|
||||
{
|
||||
cell.textLabel.text = L(@"add_new_set");
|
||||
|
|
5
iphone/Maps/Categories/Bundle+Init.swift
Normal file
5
iphone/Maps/Categories/Bundle+Init.swift
Normal file
|
@ -0,0 +1,5 @@
|
|||
extension Bundle {
|
||||
func load(viewClass: AnyClass, owner: Any? = nil, options: [AnyHashable : Any]? = nil) -> [Any]? {
|
||||
return loadNibNamed(toString(viewClass), owner: owner, options: options)
|
||||
}
|
||||
}
|
9
iphone/Maps/Categories/UICollectionView+Cells.swift
Normal file
9
iphone/Maps/Categories/UICollectionView+Cells.swift
Normal file
|
@ -0,0 +1,9 @@
|
|||
extension UICollectionView {
|
||||
func register(cellClass: AnyClass) {
|
||||
register(UINib(cellClass), forCellWithReuseIdentifier: toString(cellClass))
|
||||
}
|
||||
|
||||
func dequeueReusableCell(withCellClass cellClass: AnyClass, indexPath: IndexPath) -> UICollectionViewCell {
|
||||
return dequeueReusableCell(withReuseIdentifier: toString(cellClass), for: indexPath)
|
||||
}
|
||||
}
|
5
iphone/Maps/Categories/UINib+Init.swift
Normal file
5
iphone/Maps/Categories/UINib+Init.swift
Normal file
|
@ -0,0 +1,5 @@
|
|||
extension UINib {
|
||||
convenience init(_ viewClass: AnyClass, bundle: Bundle? = nil) {
|
||||
self.init(nibName: toString(viewClass), bundle: bundle)
|
||||
}
|
||||
}
|
13
iphone/Maps/Categories/UITableView+Cells.swift
Normal file
13
iphone/Maps/Categories/UITableView+Cells.swift
Normal file
|
@ -0,0 +1,13 @@
|
|||
extension UITableView {
|
||||
func register(cellClass: AnyClass) {
|
||||
register(UINib(cellClass), forCellReuseIdentifier: toString(cellClass))
|
||||
}
|
||||
|
||||
func dequeueReusableCell(withCellClass cellClass: AnyClass) -> UITableViewCell? {
|
||||
return dequeueReusableCell(withIdentifier: toString(cellClass))
|
||||
}
|
||||
|
||||
func dequeueReusableCell(withCellClass cellClass: AnyClass, indexPath: IndexPath) -> UITableViewCell {
|
||||
return dequeueReusableCell(withIdentifier: toString(cellClass), for: indexPath)
|
||||
}
|
||||
}
|
3
iphone/Maps/Categories/UIView+Id.swift
Normal file
3
iphone/Maps/Categories/UIView+Id.swift
Normal file
|
@ -0,0 +1,3 @@
|
|||
extension UIView {
|
||||
static func stringId() -> String { return toString(self) }
|
||||
}
|
|
@ -14,7 +14,6 @@
|
|||
|
||||
namespace
|
||||
{
|
||||
NSString * const kCellIdentifier = @"MWMDownloaderDialogCell";
|
||||
NSString * const kDownloadTransitMapAlertNibName = @"MWMDownloadTransitMapAlert";
|
||||
NSString * const kStatisticsEvent = @"Map download Alert";
|
||||
|
||||
|
@ -106,7 +105,7 @@ CGFloat const kAnimationDuration = .05;
|
|||
|
||||
- (void)configure
|
||||
{
|
||||
[self.dialogsTableView registerNib:[UINib nibWithNibName:kCellIdentifier bundle:nil] forCellReuseIdentifier:kCellIdentifier];
|
||||
[self.dialogsTableView registerWithCellClass:[MWMDownloaderDialogCell class]];
|
||||
self.listExpanded = NO;
|
||||
CALayer * containerViewLayer = self.containerView.layer;
|
||||
containerViewLayer.shouldRasterize = YES;
|
||||
|
@ -323,7 +322,9 @@ CGFloat const kAnimationDuration = .05;
|
|||
|
||||
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
|
||||
{
|
||||
MWMDownloaderDialogCell * cell = (MWMDownloaderDialogCell *)[tableView dequeueReusableCellWithIdentifier:kCellIdentifier];
|
||||
Class cls = [MWMDownloaderDialogCell class];
|
||||
auto cell = static_cast<MWMDownloaderDialogCell *>(
|
||||
[tableView dequeueReusableCellWithCellClass:cls indexPath:indexPath]);
|
||||
cell.titleLabel.text = self.countriesNames[indexPath.row];
|
||||
return cell;
|
||||
}
|
||||
|
|
|
@ -1,11 +1,6 @@
|
|||
#import "MWMCircularProgress.h"
|
||||
#import "MWMCircularProgressView.h"
|
||||
|
||||
namespace
|
||||
{
|
||||
UINib * const progressViewNib =
|
||||
[UINib nibWithNibName:@"MWMCircularProgress" bundle:[NSBundle mainBundle]];
|
||||
} // namespace
|
||||
#import "SwiftBridge.h"
|
||||
|
||||
@interface MWMCircularProgressView ()
|
||||
|
||||
|
@ -53,7 +48,7 @@ UINib * const progressViewNib =
|
|||
self = [super init];
|
||||
if (self)
|
||||
{
|
||||
[progressViewNib instantiateWithOwner:self options:nil];
|
||||
[[[UINib alloc] init:[self class] bundle:nil] instantiateWithOwner:self options:nil];
|
||||
[parentView.subviews makeObjectsPerformSelector:@selector(removeFromSuperview)];
|
||||
[parentView addSubview:self.rootView];
|
||||
self.state = MWMCircularProgressStateNormal;
|
||||
|
|
|
@ -65,8 +65,7 @@ CGFloat constexpr kAdditionalHeight = 20.;
|
|||
self.autoresizingMask = UIViewAutoresizingFlexibleWidth;
|
||||
self.layer.shouldRasterize = YES;
|
||||
self.layer.rasterizationScale = UIScreen.mainScreen.scale;
|
||||
[self.collectionView registerNib:[UINib nibWithNibName:[MWMRoutePointCell className] bundle:nil]
|
||||
forCellWithReuseIdentifier:[MWMRoutePointCell className]];
|
||||
[self.collectionView registerWithCellClass:[MWMRoutePointCell class]];
|
||||
[self setupProgresses];
|
||||
|
||||
[self.backButton matchInterfaceOrientation];
|
||||
|
@ -464,9 +463,9 @@ CGFloat constexpr kAdditionalHeight = 20.;
|
|||
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView
|
||||
cellForItemAtIndexPath:(NSIndexPath *)indexPath
|
||||
{
|
||||
MWMRoutePointCell * cell =
|
||||
[collectionView dequeueReusableCellWithReuseIdentifier:[MWMRoutePointCell className]
|
||||
forIndexPath:indexPath];
|
||||
Class cls = [MWMRoutePointCell class];
|
||||
auto cell = static_cast<MWMRoutePointCell *>(
|
||||
[collectionView dequeueReusableCellWithCellClass:cls indexPath:indexPath]);
|
||||
cell.number.text = @(indexPath.row + 1).stringValue;
|
||||
if (indexPath.row == 0)
|
||||
{
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
#import "MWMNetworkPolicy.h"
|
||||
#import "MWMRoutePoint.h"
|
||||
#import "MWMTaxiPreviewCell.h"
|
||||
#import "SwiftBridge.h"
|
||||
|
||||
#include "Framework.h"
|
||||
|
||||
|
@ -83,8 +84,7 @@ using namespace uber;
|
|||
collectionView.delegate = self;
|
||||
collectionView.showsVerticalScrollIndicator = NO;
|
||||
collectionView.showsHorizontalScrollIndicator = NO;
|
||||
auto name = [MWMTaxiPreviewCell className];
|
||||
[collectionView registerNib:[UINib nibWithNibName:name bundle:nil] forCellWithReuseIdentifier:name];
|
||||
[collectionView registerWithCellClass:[MWMTaxiPreviewCell class]];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
@ -183,8 +183,9 @@ using namespace uber;
|
|||
|
||||
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
|
||||
{
|
||||
MWMTaxiPreviewCell * cell = [collectionView dequeueReusableCellWithReuseIdentifier:[MWMTaxiPreviewCell className]
|
||||
forIndexPath:indexPath];
|
||||
Class cls = [MWMTaxiPreviewCell class];
|
||||
auto cell = static_cast<MWMTaxiPreviewCell *>(
|
||||
[collectionView dequeueReusableCellWithCellClass:cls indexPath:indexPath]);
|
||||
[cell configWithProduct:m_products[indexPath.row]];
|
||||
|
||||
return cell;
|
||||
|
|
|
@ -1,3 +0,0 @@
|
|||
extension MWMTableViewCell {
|
||||
static func cellId() -> String { return String(describing: self) }
|
||||
}
|
|
@ -11,8 +11,13 @@ func iPadSpecific( _ f: () -> Void) {
|
|||
f()
|
||||
}
|
||||
}
|
||||
|
||||
func iPhoneSpecific( _ f: () -> Void) {
|
||||
if !IPAD() {
|
||||
f()
|
||||
}
|
||||
}
|
||||
|
||||
func toString(_ cls: AnyClass) -> String {
|
||||
return String(describing: cls)
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -9,3 +9,9 @@
|
|||
isEnabled:(BOOL)isEnabled;
|
||||
|
||||
@end
|
||||
|
||||
@interface MWMBottomMenuCollectionViewPortraitCell : MWMBottomMenuCollectionViewCell
|
||||
@end
|
||||
|
||||
@interface MWMBottomMenuCollectionViewLandscapeCell : MWMBottomMenuCollectionViewCell
|
||||
@end
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
#import "MWMBottomMenuCollectionViewCell.h"
|
||||
#import "MWMCommon.h"
|
||||
#import "SwiftBridge.h"
|
||||
#import "UIImageView+Coloring.h"
|
||||
|
||||
@interface MWMBottomMenuCollectionViewCell ()
|
||||
|
@ -54,3 +55,9 @@
|
|||
}
|
||||
|
||||
@end
|
||||
|
||||
@implementation MWMBottomMenuCollectionViewPortraitCell
|
||||
@end
|
||||
|
||||
@implementation MWMBottomMenuCollectionViewLandscapeCell
|
||||
@end
|
||||
|
|
|
@ -1,22 +1,27 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="10117" systemVersion="15G31" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES">
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="11762" systemVersion="16D32" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES">
|
||||
<device id="retina4_7" orientation="portrait">
|
||||
<adaptation id="fullscreen"/>
|
||||
</device>
|
||||
<dependencies>
|
||||
<deployment identifier="iOS"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="10085"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="11757"/>
|
||||
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
|
||||
</dependencies>
|
||||
<customFonts key="customFonts">
|
||||
<mutableArray key="HelveticaNeue.ttc">
|
||||
<array key="HelveticaNeue.ttc">
|
||||
<string>HelveticaNeue-Medium</string>
|
||||
</mutableArray>
|
||||
</array>
|
||||
</customFonts>
|
||||
<objects>
|
||||
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner"/>
|
||||
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
|
||||
<collectionViewCell clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" id="gTV-IL-0wX" customClass="MWMBottomMenuCollectionViewCell">
|
||||
<collectionViewCell clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" restorationIdentifier="MWMBottomMenuCollectionViewLandscapeCell" id="gTV-IL-0wX" customClass="MWMBottomMenuCollectionViewLandscapeCell">
|
||||
<rect key="frame" x="0.0" y="0.0" width="108" height="64"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<view key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center">
|
||||
<rect key="frame" x="0.0" y="0.0" width="108" height="64"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
|
||||
<subviews>
|
||||
<imageView userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="ic_menu_download" translatesAutoresizingMaskIntoConstraints="NO" id="8oJ-8z-qRL">
|
||||
<rect key="frame" x="40" y="12" width="28" height="28"/>
|
||||
|
@ -31,7 +36,7 @@
|
|||
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="center" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="5Uc-o1-PsF">
|
||||
<rect key="frame" x="42" y="40" width="25" height="12"/>
|
||||
<fontDescription key="fontDescription" name="HelveticaNeue" family="Helvetica Neue" pointSize="10"/>
|
||||
<color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="calibratedRGB"/>
|
||||
<color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
|
||||
<nil key="highlightedColor"/>
|
||||
<userDefinedRuntimeAttributes>
|
||||
<userDefinedRuntimeAttribute type="string" keyPath="fontName" value="regular10"/>
|
||||
|
@ -43,13 +48,14 @@
|
|||
<subviews>
|
||||
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" text="3" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="FT9-8n-RZm" userLabel="DownloadBadgeCount">
|
||||
<rect key="frame" x="0.0" y="0.0" width="32" height="20"/>
|
||||
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
|
||||
<color key="backgroundColor" red="0.0" green="0.0" blue="0.0" alpha="0.0" colorSpace="custom" customColorSpace="sRGB"/>
|
||||
<fontDescription key="fontDescription" name="HelveticaNeue-Medium" family="Helvetica Neue" pointSize="14"/>
|
||||
<color key="textColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
|
||||
<color key="textColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
|
||||
<nil key="highlightedColor"/>
|
||||
</label>
|
||||
</subviews>
|
||||
<color key="backgroundColor" red="1" green="0.0" blue="0.0" alpha="1" colorSpace="calibratedRGB"/>
|
||||
<color key="backgroundColor" red="1" green="0.0" blue="0.0" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
|
||||
<constraints>
|
||||
<constraint firstAttribute="height" constant="20" id="Y5v-7h-SGf"/>
|
||||
<constraint firstAttribute="width" constant="32" id="ubK-0L-pDn"/>
|
||||
|
@ -63,7 +69,6 @@
|
|||
</userDefinedRuntimeAttributes>
|
||||
</view>
|
||||
</subviews>
|
||||
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
|
||||
</view>
|
||||
<constraints>
|
||||
<constraint firstItem="8oJ-8z-qRL" firstAttribute="top" secondItem="gTV-IL-0wX" secondAttribute="top" constant="12" id="2cM-2D-sow"/>
|
||||
|
|
|
@ -1,22 +1,27 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="9532" systemVersion="15D21" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES">
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="11762" systemVersion="16D32" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES">
|
||||
<device id="retina4_7" orientation="portrait">
|
||||
<adaptation id="fullscreen"/>
|
||||
</device>
|
||||
<dependencies>
|
||||
<deployment identifier="iOS"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="9530"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="11757"/>
|
||||
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
|
||||
</dependencies>
|
||||
<customFonts key="customFonts">
|
||||
<mutableArray key="HelveticaNeue.ttc">
|
||||
<array key="HelveticaNeue.ttc">
|
||||
<string>HelveticaNeue-Medium</string>
|
||||
</mutableArray>
|
||||
</array>
|
||||
</customFonts>
|
||||
<objects>
|
||||
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner"/>
|
||||
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
|
||||
<collectionViewCell clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" id="gTV-IL-0wX" customClass="MWMBottomMenuCollectionViewCell">
|
||||
<collectionViewCell clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" restorationIdentifier="MWMBottomMenuCollectionViewPortraitCell" id="gTV-IL-0wX" customClass="MWMBottomMenuCollectionViewPortraitCell">
|
||||
<rect key="frame" x="0.0" y="0.0" width="320" height="52"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<view key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center">
|
||||
<rect key="frame" x="0.0" y="0.0" width="320" height="52"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
|
||||
<subviews>
|
||||
<imageView userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="ic_menu_download" translatesAutoresizingMaskIntoConstraints="NO" id="8oJ-8z-qRL">
|
||||
<rect key="frame" x="16" y="12" width="28" height="28"/>
|
||||
|
@ -31,7 +36,7 @@
|
|||
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="5Uc-o1-PsF">
|
||||
<rect key="frame" x="60" y="16" width="42" height="20"/>
|
||||
<fontDescription key="fontDescription" name="HelveticaNeue" family="Helvetica Neue" pointSize="17"/>
|
||||
<color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="calibratedRGB"/>
|
||||
<color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
|
||||
<nil key="highlightedColor"/>
|
||||
<userDefinedRuntimeAttributes>
|
||||
<userDefinedRuntimeAttribute type="string" keyPath="fontName" value="regular16"/>
|
||||
|
@ -43,13 +48,13 @@
|
|||
<subviews>
|
||||
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="3" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="FT9-8n-RZm" userLabel="DownloadBadgeCount">
|
||||
<rect key="frame" x="0.0" y="0.0" width="32" height="20"/>
|
||||
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
|
||||
<color key="backgroundColor" red="0.0" green="0.0" blue="0.0" alpha="0.0" colorSpace="custom" customColorSpace="sRGB"/>
|
||||
<fontDescription key="fontDescription" name="HelveticaNeue-Medium" family="Helvetica Neue" pointSize="14"/>
|
||||
<color key="textColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
|
||||
<color key="textColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
|
||||
<nil key="highlightedColor"/>
|
||||
</label>
|
||||
</subviews>
|
||||
<color key="backgroundColor" red="1" green="0.0" blue="0.0" alpha="1" colorSpace="calibratedRGB"/>
|
||||
<color key="backgroundColor" red="1" green="0.0" blue="0.0" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
|
||||
<constraints>
|
||||
<constraint firstAttribute="trailing" secondItem="FT9-8n-RZm" secondAttribute="trailing" id="Ge3-P2-idS"/>
|
||||
<constraint firstAttribute="bottom" secondItem="FT9-8n-RZm" secondAttribute="bottom" id="Kgn-y3-dBT"/>
|
||||
|
@ -68,7 +73,7 @@
|
|||
</view>
|
||||
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="4OJ-wN-dY4" userLabel="Separator">
|
||||
<rect key="frame" x="60" y="51" width="260" height="1"/>
|
||||
<color key="backgroundColor" red="0.0" green="0.0" blue="0.0" alpha="0.12" colorSpace="calibratedRGB"/>
|
||||
<color key="backgroundColor" red="0.0" green="0.0" blue="0.0" alpha="0.12" colorSpace="custom" customColorSpace="sRGB"/>
|
||||
<constraints>
|
||||
<constraint firstAttribute="height" constant="1" id="tDM-AP-ern"/>
|
||||
</constraints>
|
||||
|
@ -77,7 +82,6 @@
|
|||
</userDefinedRuntimeAttributes>
|
||||
</view>
|
||||
</subviews>
|
||||
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
|
||||
</view>
|
||||
<constraints>
|
||||
<constraint firstAttribute="trailing" secondItem="con-tP-3dJ" secondAttribute="trailing" constant="16" id="9uE-rh-b7G"/>
|
||||
|
|
|
@ -35,9 +35,6 @@ extern NSString * const kSearchStateKey;
|
|||
|
||||
namespace
|
||||
{
|
||||
NSString * const kCollectionCellPortrait = @"MWMBottomMenuCollectionViewPortraitCell";
|
||||
NSString * const kCollectionCelllandscape = @"MWMBottomMenuCollectionViewLandscapeCell";
|
||||
|
||||
CGFloat constexpr kLayoutThreshold = 420.0;
|
||||
NSTimeInterval constexpr kRoutingDiminishInterval = 5.0;
|
||||
} // namespace
|
||||
|
@ -124,10 +121,9 @@ typedef NS_ENUM(NSUInteger, MWMBottomMenuViewCell) {
|
|||
- (void)viewDidLoad
|
||||
{
|
||||
[super viewDidLoad];
|
||||
[self.buttonsCollectionView registerNib:[UINib nibWithNibName:kCollectionCellPortrait bundle:nil]
|
||||
forCellWithReuseIdentifier:kCollectionCellPortrait];
|
||||
[self.buttonsCollectionView registerNib:[UINib nibWithNibName:kCollectionCelllandscape bundle:nil]
|
||||
forCellWithReuseIdentifier:kCollectionCelllandscape];
|
||||
UICollectionView * bcv = self.buttonsCollectionView;
|
||||
[bcv registerWithCellClass:[MWMBottomMenuCollectionViewPortraitCell class]];
|
||||
[bcv registerWithCellClass:[MWMBottomMenuCollectionViewLandscapeCell class]];
|
||||
MWMBottomMenuLayout * cvLayout =
|
||||
(MWMBottomMenuLayout *)self.buttonsCollectionView.collectionViewLayout;
|
||||
cvLayout.layoutThreshold = kLayoutThreshold;
|
||||
|
@ -299,10 +295,10 @@ typedef NS_ENUM(NSUInteger, MWMBottomMenuViewCell) {
|
|||
cellForItemAtIndexPath:(nonnull NSIndexPath *)indexPath
|
||||
{
|
||||
BOOL const isWideMenu = self.view.width > kLayoutThreshold;
|
||||
MWMBottomMenuCollectionViewCell * cell =
|
||||
[collectionView dequeueReusableCellWithReuseIdentifier:isWideMenu ? kCollectionCelllandscape
|
||||
: kCollectionCellPortrait
|
||||
forIndexPath:indexPath];
|
||||
Class cls = isWideMenu ? [MWMBottomMenuCollectionViewLandscapeCell class]
|
||||
: [MWMBottomMenuCollectionViewPortraitCell class];
|
||||
auto cell = static_cast<MWMBottomMenuCollectionViewCell *>(
|
||||
[collectionView dequeueReusableCellWithCellClass:cls indexPath:indexPath]);
|
||||
NSInteger item = indexPath.item;
|
||||
if (isInterfaceRightToLeft())
|
||||
item = [self collectionView:collectionView numberOfItemsInSection:indexPath.section] - item - 1;
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
- (instancetype)initWithDelegate:(id<MWMMapDownloaderProtocol, MWMMapDownloaderButtonTableViewCellProtocol>)delegate mode:(mwm::DownloaderMode)mode;
|
||||
- (NSString *)parentCountryId;
|
||||
- (NSString *)countryIdForIndexPath:(NSIndexPath *)indexPath;
|
||||
- (NSString *)cellIdentifierForIndexPath:(NSIndexPath *)indexPath;
|
||||
- (Class)cellClassForIndexPath:(NSIndexPath *)indexPath;
|
||||
- (void)fillCell:(UITableViewCell *)cell atIndexPath:(NSIndexPath *)indexPath;
|
||||
- (BOOL)isButtonCell:(NSInteger)section;
|
||||
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
#import "MWMCommon.h"
|
||||
#import "MWMMapDownloaderDataSource.h"
|
||||
#import "MWMCommon.h"
|
||||
#import "MWMMapDownloaderLargeCountryTableViewCell.h"
|
||||
#import "MWMMapDownloaderPlaceTableViewCell.h"
|
||||
#import "MWMMapDownloaderSubplaceTableViewCell.h"
|
||||
#import "MWMMapDownloaderTypes.h"
|
||||
#import "SwiftBridge.h"
|
||||
|
||||
#include "Framework.h"
|
||||
|
||||
|
@ -57,8 +58,9 @@ using namespace storage;
|
|||
|
||||
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
|
||||
{
|
||||
NSString * reuseIdentifier = [self cellIdentifierForIndexPath:indexPath];
|
||||
MWMMapDownloaderTableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:reuseIdentifier];
|
||||
Class cls = [self cellClassForIndexPath:indexPath];
|
||||
auto cell = static_cast<MWMMapDownloaderTableViewCell *>(
|
||||
[tableView dequeueReusableCellWithCellClass:cls indexPath:indexPath]);
|
||||
[self fillCell:cell atIndexPath:indexPath];
|
||||
return cell;
|
||||
}
|
||||
|
@ -91,11 +93,7 @@ using namespace storage;
|
|||
return @(kInvalidCountryId.c_str());
|
||||
}
|
||||
|
||||
- (NSString *)cellIdentifierForIndexPath:(NSIndexPath *)indexPath
|
||||
{
|
||||
return nil;
|
||||
}
|
||||
|
||||
- (Class)cellClassForIndexPath:(NSIndexPath *)indexPath { return nil; }
|
||||
- (NSString *)searchMatchedResultForCountryId:(NSString *)countryId
|
||||
{
|
||||
return nil;
|
||||
|
|
|
@ -1,17 +1,14 @@
|
|||
#import "MWMMapDownloaderDefaultDataSource.h"
|
||||
#import "MWMCommon.h"
|
||||
#import "MWMMapDownloaderButtonTableViewCell.h"
|
||||
#import "MWMMapDownloaderDefaultDataSource.h"
|
||||
#import "MWMMapDownloaderLargeCountryTableViewCell.h"
|
||||
#import "MWMMapDownloaderPlaceTableViewCell.h"
|
||||
#import "MWMStorage.h"
|
||||
#import "Statistics.h"
|
||||
#import "SwiftBridge.h"
|
||||
|
||||
#include "Framework.h"
|
||||
|
||||
extern NSString * const kCountryCellIdentifier;
|
||||
extern NSString * const kSubplaceCellIdentifier;
|
||||
extern NSString * const kPlaceCellIdentifier;
|
||||
extern NSString * const kLargeCountryCellIdentifier;
|
||||
extern NSString * const kButtonCellIdentifier;
|
||||
|
||||
namespace
|
||||
{
|
||||
auto compareStrings = ^NSComparisonResult(NSString * s1, NSString * s2)
|
||||
|
@ -136,7 +133,9 @@ using namespace mwm;
|
|||
{
|
||||
if ([self isButtonCell:indexPath.section])
|
||||
{
|
||||
MWMMapDownloaderButtonTableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:kButtonCellIdentifier];
|
||||
Class cls = [MWMMapDownloaderButtonTableViewCell class];
|
||||
auto cell = static_cast<MWMMapDownloaderButtonTableViewCell *>(
|
||||
[tableView dequeueReusableCellWithCellClass:cls indexPath:indexPath]);
|
||||
cell.delegate = self.delegate;
|
||||
return cell;
|
||||
}
|
||||
|
@ -206,15 +205,17 @@ using namespace mwm;
|
|||
return nsCountryId;
|
||||
}
|
||||
|
||||
- (NSString *)cellIdentifierForIndexPath:(NSIndexPath *)indexPath
|
||||
- (Class)cellClassForIndexPath:(NSIndexPath *)indexPath
|
||||
{
|
||||
auto const & s = GetFramework().GetStorage();
|
||||
TCountriesVec children;
|
||||
s.GetChildren([self countryIdForIndexPath:indexPath].UTF8String, children);
|
||||
BOOL const haveChildren = !children.empty();
|
||||
if (haveChildren)
|
||||
return kLargeCountryCellIdentifier;
|
||||
return self.isParentRoot ? kCountryCellIdentifier : kPlaceCellIdentifier;
|
||||
return [MWMMapDownloaderLargeCountryTableViewCell class];
|
||||
if (self.isParentRoot)
|
||||
return [MWMMapDownloaderTableViewCell class];
|
||||
return [MWMMapDownloaderPlaceTableViewCell class];
|
||||
}
|
||||
|
||||
#pragma mark - Helpers
|
||||
|
|
|
@ -4,8 +4,6 @@
|
|||
|
||||
#include "Framework.h"
|
||||
|
||||
extern NSString * const kAdsCellIdentifier;
|
||||
|
||||
namespace
|
||||
{
|
||||
auto constexpr extraSection = MWMMapDownloaderDataSourceExtraSection::Ads;
|
||||
|
@ -69,11 +67,11 @@ auto constexpr extraSection = MWMMapDownloaderDataSourceExtraSection::Ads;
|
|||
|
||||
#pragma mark - MWMMapDownloaderDataSource
|
||||
|
||||
- (NSString *)cellIdentifierForIndexPath:(NSIndexPath *)indexPath
|
||||
- (Class)cellClassForIndexPath:(NSIndexPath *)indexPath
|
||||
{
|
||||
if ([self isExtraSection:extraSection atIndex:indexPath.section])
|
||||
return kAdsCellIdentifier;
|
||||
return [super cellIdentifierForIndexPath:indexPath];
|
||||
return [MWMMapDownloaderAdsTableViewCell class];
|
||||
return [super cellClassForIndexPath:indexPath];
|
||||
}
|
||||
|
||||
- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath
|
||||
|
|
|
@ -1,14 +1,12 @@
|
|||
#import "MWMMapDownloaderSearchDataSource.h"
|
||||
#import "MWMMapDownloaderLargeCountryTableViewCell.h"
|
||||
#import "MWMMapDownloaderPlaceTableViewCell.h"
|
||||
#import "MWMMapDownloaderSubplaceTableViewCell.h"
|
||||
|
||||
#include "Framework.h"
|
||||
|
||||
using namespace storage;
|
||||
|
||||
extern NSString * const kCountryCellIdentifier;
|
||||
extern NSString * const kSubplaceCellIdentifier;
|
||||
extern NSString * const kPlaceCellIdentifier;
|
||||
extern NSString * const kLargeCountryCellIdentifier;
|
||||
|
||||
@interface MWMMapDownloaderSearchDataSource ()
|
||||
|
||||
@property (copy, nonatomic) NSArray<NSString *> * searchCountryIds;
|
||||
|
@ -66,7 +64,7 @@ extern NSString * const kLargeCountryCellIdentifier;
|
|||
return @(kInvalidCountryId.c_str());
|
||||
}
|
||||
|
||||
- (NSString *)cellIdentifierForIndexPath:(NSIndexPath *)indexPath
|
||||
- (Class)cellClassForIndexPath:(NSIndexPath *)indexPath
|
||||
{
|
||||
auto const & s = GetFramework().GetStorage();
|
||||
NSString * countryId = [self countryIdForIndexPath:indexPath];
|
||||
|
@ -74,16 +72,16 @@ extern NSString * const kLargeCountryCellIdentifier;
|
|||
s.GetChildren(countryId.UTF8String, children);
|
||||
BOOL const haveChildren = !children.empty();
|
||||
if (haveChildren)
|
||||
return kLargeCountryCellIdentifier;
|
||||
return [MWMMapDownloaderLargeCountryTableViewCell class];
|
||||
NodeAttrs nodeAttrs;
|
||||
s.GetNodeAttrs(countryId.UTF8String, nodeAttrs);
|
||||
NSString * nodeLocalName = @(nodeAttrs.m_nodeLocalName.c_str());
|
||||
NSString * matchedResult = [self searchMatchedResultForCountryId:countryId];
|
||||
if (![nodeLocalName isEqualToString:matchedResult])
|
||||
return kSubplaceCellIdentifier;
|
||||
return [MWMMapDownloaderSubplaceTableViewCell class];
|
||||
if (nodeAttrs.m_parentInfo.size() == 1 && nodeAttrs.m_parentInfo[0].m_id == s.GetRootId())
|
||||
return kCountryCellIdentifier;
|
||||
return kPlaceCellIdentifier;
|
||||
return [MWMMapDownloaderTableViewCell class];
|
||||
return [MWMMapDownloaderPlaceTableViewCell class];
|
||||
}
|
||||
|
||||
- (NSString *)searchMatchedResultForCountryId:(NSString *)countryId
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#import "MWMCommon.h"
|
||||
#import "MWMAlertViewController.h"
|
||||
#import "MWMButton.h"
|
||||
#import "MWMCommon.h"
|
||||
#import "MWMFrameworkListener.h"
|
||||
#import "MWMMapDownloaderAdsTableViewCell.h"
|
||||
#import "MWMMapDownloaderCellHeader.h"
|
||||
|
@ -18,19 +18,13 @@
|
|||
#import "MWMToast.h"
|
||||
#import "MapsAppDelegate.h"
|
||||
#import "Statistics.h"
|
||||
#import "SwiftBridge.h"
|
||||
#import "UIViewController+Navigation.h"
|
||||
|
||||
#include "Framework.h"
|
||||
|
||||
#include "storage/index.hpp"
|
||||
|
||||
extern NSString * const kAdsCellIdentifier = @"MWMMapDownloaderAdsTableViewCell";
|
||||
extern NSString * const kButtonCellIdentifier = @"MWMMapDownloaderButtonTableViewCell";
|
||||
extern NSString * const kCountryCellIdentifier = @"MWMMapDownloaderTableViewCell";
|
||||
extern NSString * const kLargeCountryCellIdentifier = @"MWMMapDownloaderLargeCountryTableViewCell";
|
||||
extern NSString * const kPlaceCellIdentifier = @"MWMMapDownloaderPlaceTableViewCell";
|
||||
extern NSString * const kSubplaceCellIdentifier = @"MWMMapDownloaderSubplaceTableViewCell";
|
||||
|
||||
namespace
|
||||
{
|
||||
|
||||
|
@ -225,20 +219,16 @@ using namespace mwm;
|
|||
|
||||
#pragma mark - Table
|
||||
|
||||
- (void)registerCellWithIdentifier:(NSString *)identifier
|
||||
{
|
||||
[self.tableView registerNib:[UINib nibWithNibName:identifier bundle:nil] forCellReuseIdentifier:identifier];
|
||||
}
|
||||
|
||||
- (void)configTable
|
||||
{
|
||||
self.tableView.separatorColor = [UIColor blackDividers];
|
||||
[self registerCellWithIdentifier:kAdsCellIdentifier];
|
||||
[self registerCellWithIdentifier:kButtonCellIdentifier];
|
||||
[self registerCellWithIdentifier:kCountryCellIdentifier];
|
||||
[self registerCellWithIdentifier:kLargeCountryCellIdentifier];
|
||||
[self registerCellWithIdentifier:kPlaceCellIdentifier];
|
||||
[self registerCellWithIdentifier:kSubplaceCellIdentifier];
|
||||
UITableView * tv = self.tableView;
|
||||
tv.separatorColor = [UIColor blackDividers];
|
||||
[tv registerWithCellClass:[MWMMapDownloaderAdsTableViewCell class]];
|
||||
[tv registerWithCellClass:[MWMMapDownloaderButtonTableViewCell class]];
|
||||
[tv registerWithCellClass:[MWMMapDownloaderTableViewCell class]];
|
||||
[tv registerWithCellClass:[MWMMapDownloaderLargeCountryTableViewCell class]];
|
||||
[tv registerWithCellClass:[MWMMapDownloaderPlaceTableViewCell class]];
|
||||
[tv registerWithCellClass:[MWMMapDownloaderSubplaceTableViewCell class]];
|
||||
}
|
||||
|
||||
#pragma mark - MWMMyTargetDelegate
|
||||
|
@ -416,15 +406,15 @@ using namespace mwm;
|
|||
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
|
||||
{
|
||||
[tableView deselectRowAtIndexPath:indexPath animated:YES];
|
||||
NSString * identifier = [self.dataSource cellIdentifierForIndexPath:indexPath];
|
||||
if ([identifier isEqualToString:kLargeCountryCellIdentifier])
|
||||
Class cls = [self.dataSource cellClassForIndexPath:indexPath];
|
||||
if ([MWMMapDownloaderLargeCountryTableViewCell class] == cls)
|
||||
{
|
||||
NSAssert(self.dataSource != nil, @"Datasource is nil.");
|
||||
NSString * countyId = [self.dataSource countryIdForIndexPath:indexPath];
|
||||
NSAssert(countyId != nil, @"CountryId is nil.");
|
||||
[self openNodeSubtree:countyId.UTF8String];
|
||||
}
|
||||
else if ([identifier isEqualToString:kAdsCellIdentifier])
|
||||
else if ([MWMMapDownloaderAdsTableViewCell class] == cls)
|
||||
{
|
||||
[[MWMMyTarget manager] handleBannerClickAtIndex:indexPath.row withController:self];
|
||||
}
|
||||
|
@ -436,8 +426,8 @@ using namespace mwm;
|
|||
|
||||
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
|
||||
{
|
||||
NSString * reuseIdentifier = [self.dataSource cellIdentifierForIndexPath:indexPath];
|
||||
if ([reuseIdentifier isEqualToString:kAdsCellIdentifier])
|
||||
Class cls = [self.dataSource cellClassForIndexPath:indexPath];
|
||||
if ([MWMMapDownloaderAdsTableViewCell class] == cls)
|
||||
{
|
||||
MWMMapDownloaderExtendedDataSourceWithAds * adDataSource =
|
||||
static_cast<MWMMapDownloaderExtendedDataSourceWithAds *>(self.dataSource);
|
||||
|
@ -451,7 +441,8 @@ using namespace mwm;
|
|||
{
|
||||
if ([self.dataSource isButtonCell:indexPath.section])
|
||||
return [MWMMapDownloaderButtonTableViewCell estimatedHeight];
|
||||
Class<MWMMapDownloaderTableViewCellProtocol> cellClass = NSClassFromString([self.dataSource cellIdentifierForIndexPath:indexPath]);
|
||||
Class<MWMMapDownloaderTableViewCellProtocol> cellClass =
|
||||
[self.dataSource cellClassForIndexPath:indexPath];
|
||||
return [cellClass estimatedHeight];
|
||||
}
|
||||
|
||||
|
@ -486,8 +477,8 @@ using namespace mwm;
|
|||
return;
|
||||
if ([self.dataSource isButtonCell:indexPath.section])
|
||||
return;
|
||||
NSString * identifier = [self.dataSource cellIdentifierForIndexPath:indexPath];
|
||||
if ([identifier isEqualToString:kAdsCellIdentifier])
|
||||
Class cls = [self.dataSource cellClassForIndexPath:indexPath];
|
||||
if ([MWMMapDownloaderAdsTableViewCell class] == cls)
|
||||
return;
|
||||
[self showActionSheetForRowAtIndexPath:indexPath];
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
#import "MWMBookmarkColorViewController.h"
|
||||
#import "Statistics.h"
|
||||
#import "SwiftBridge.h"
|
||||
#import "UIViewController+Navigation.h"
|
||||
|
||||
#include "std/array.hpp"
|
||||
|
@ -55,7 +56,8 @@ array<NSString *, 9> const kBookmarkColorsVariant
|
|||
|
||||
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
|
||||
{
|
||||
UITableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:[UITableViewCell className]];
|
||||
auto cell =
|
||||
[tableView dequeueReusableCellWithCellClass:[UITableViewCell class] indexPath:indexPath];
|
||||
NSString * currentColor = kBookmarkColorsVariant[indexPath.row];
|
||||
cell.textLabel.text = ios_bookmark_ui_helper::LocalizedTitleForBookmarkColor(currentColor);
|
||||
BOOL const isSelected = [currentColor isEqualToString:self.bookmarkColor];
|
||||
|
|
|
@ -80,16 +80,10 @@ enum RowInMetaInfo
|
|||
|
||||
- (void)registerCells
|
||||
{
|
||||
auto registerClass = ^ (Class c)
|
||||
{
|
||||
NSString * className = NSStringFromClass(c);
|
||||
[self.tableView registerNib:[UINib nibWithNibName:className bundle:nil]
|
||||
forCellReuseIdentifier:className];
|
||||
};
|
||||
|
||||
registerClass([MWMButtonCell class]);
|
||||
registerClass([MWMBookmarkTitleCell class]);
|
||||
registerClass([MWMNoteCell class]);
|
||||
UITableView * tv = self.tableView;
|
||||
[tv registerWithCellClass:[MWMButtonCell class]];
|
||||
[tv registerWithCellClass:[MWMBookmarkTitleCell class]];
|
||||
[tv registerWithCellClass:[MWMNoteCell class]];
|
||||
}
|
||||
|
||||
- (void)onSave
|
||||
|
@ -147,13 +141,16 @@ enum RowInMetaInfo
|
|||
{
|
||||
case Title:
|
||||
{
|
||||
MWMBookmarkTitleCell * cell = [tableView dequeueReusableCellWithIdentifier:[MWMBookmarkTitleCell className]];
|
||||
Class cls = [MWMBookmarkTitleCell class];
|
||||
auto cell = static_cast<MWMBookmarkTitleCell *>(
|
||||
[tableView dequeueReusableCellWithCellClass:cls indexPath:indexPath]);
|
||||
[cell configureWithName:self.cachedTitle delegate:self];
|
||||
return cell;
|
||||
}
|
||||
case Color:
|
||||
{
|
||||
UITableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:[UITableViewCell className]];
|
||||
Class cls = [UITableViewCell class];
|
||||
auto cell = [tableView dequeueReusableCellWithCellClass:cls indexPath:indexPath];
|
||||
cell.textLabel.text = ios_bookmark_ui_helper::LocalizedTitleForBookmarkColor(self.cachedColor);
|
||||
cell.imageView.image = ios_bookmark_ui_helper::ImageForBookmarkColor(self.cachedColor, YES);
|
||||
cell.imageView.layer.cornerRadius = cell.imageView.width / 2;
|
||||
|
@ -162,7 +159,8 @@ enum RowInMetaInfo
|
|||
}
|
||||
case Category:
|
||||
{
|
||||
UITableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:[UITableViewCell className]];
|
||||
Class cls = [UITableViewCell class];
|
||||
auto cell = [tableView dequeueReusableCellWithCellClass:cls indexPath:indexPath];
|
||||
cell.textLabel.text = self.cachedCategory;
|
||||
cell.imageView.image = [UIImage imageNamed:@"ic_folder"];
|
||||
cell.imageView.mwm_coloring = MWMImageColoringBlack;
|
||||
|
@ -182,7 +180,9 @@ enum RowInMetaInfo
|
|||
}
|
||||
else
|
||||
{
|
||||
self.cachedNote = [tableView dequeueReusableCellWithIdentifier:[MWMNoteCell className]];
|
||||
Class cls = [MWMNoteCell class];
|
||||
self.cachedNote = static_cast<MWMNoteCell *>(
|
||||
[tableView dequeueReusableCellWithCellClass:cls indexPath:indexPath]);
|
||||
[self.cachedNote configWithDelegate:self noteText:self.cachedDescription
|
||||
placeholder:L(@"placepage_personal_notes_hint")];
|
||||
return self.cachedNote;
|
||||
|
@ -191,7 +191,9 @@ enum RowInMetaInfo
|
|||
case Delete:
|
||||
{
|
||||
NSAssert(indexPath.row == 0, @"Incorrect row!");
|
||||
MWMButtonCell * cell = [tableView dequeueReusableCellWithIdentifier:[MWMButtonCell className]];
|
||||
Class cls = [MWMButtonCell class];
|
||||
auto cell = static_cast<MWMButtonCell *>(
|
||||
[tableView dequeueReusableCellWithCellClass:cls indexPath:indexPath]);
|
||||
[cell configureWithDelegate:self title:L(@"placepage_delete_bookmark_button")];
|
||||
return cell;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
@objc(MWMEditorAdditionalNamePlaceholderTableViewCell)
|
||||
final class EditorAdditionalNamePlaceholderTableViewCell: MWMTableViewCell {
|
||||
}
|
|
@ -1,6 +1,6 @@
|
|||
#import "MWMTableViewCell.h"
|
||||
|
||||
@protocol MWMButtonCellDelegate <NSObject>
|
||||
@protocol MWMButtonCellDelegate<NSObject>
|
||||
|
||||
- (void)cellSelect:(UITableViewCell *)cell;
|
||||
|
|
@ -2,8 +2,8 @@
|
|||
|
||||
@interface MWMButtonCell ()
|
||||
|
||||
@property (weak, nonatomic) IBOutlet UIButton * button;
|
||||
@property (weak, nonatomic) id<MWMButtonCellDelegate> delegate;
|
||||
@property(weak, nonatomic) IBOutlet UIButton * button;
|
||||
@property(weak, nonatomic) id<MWMButtonCellDelegate> delegate;
|
||||
|
||||
@end
|
||||
|
||||
|
@ -15,9 +15,5 @@
|
|||
self.delegate = delegate;
|
||||
}
|
||||
|
||||
- (IBAction)buttonTap
|
||||
{
|
||||
[self.delegate cellSelect:self];
|
||||
}
|
||||
|
||||
- (IBAction)buttonTap { [self.delegate cellSelect:self]; }
|
||||
@end
|
|
@ -2,20 +2,12 @@
|
|||
|
||||
@interface MWMEditorAddAdditionalNameTableViewCell ()
|
||||
|
||||
@property (weak, nonatomic) id<MWMEditorAdditionalName> delegate;
|
||||
@property(weak, nonatomic) id<MWMEditorAdditionalName> delegate;
|
||||
|
||||
@end
|
||||
|
||||
@implementation MWMEditorAddAdditionalNameTableViewCell
|
||||
|
||||
- (void)configWithDelegate:(id<MWMEditorAdditionalName>)delegate
|
||||
{
|
||||
self.delegate = delegate;
|
||||
}
|
||||
|
||||
- (IBAction)addLanguageTap
|
||||
{
|
||||
[self.delegate editAdditionalNameLanguage:NSNotFound];
|
||||
}
|
||||
|
||||
- (void)configWithDelegate:(id<MWMEditorAdditionalName>)delegate { self.delegate = delegate; }
|
||||
- (IBAction)addLanguageTap { [self.delegate editAdditionalNameLanguage:NSNotFound]; }
|
||||
@end
|
|
@ -1,28 +1,32 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="10117" systemVersion="15F34" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES">
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="11762" systemVersion="16D32" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES">
|
||||
<device id="retina4_7" orientation="portrait">
|
||||
<adaptation id="fullscreen"/>
|
||||
</device>
|
||||
<dependencies>
|
||||
<deployment identifier="iOS"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="10085"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="11757"/>
|
||||
<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" selectionStyle="none" indentationWidth="10" rowHeight="16" id="7Br-fC-W0o">
|
||||
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" selectionStyle="none" indentationWidth="10" rowHeight="16" id="7Br-fC-W0o" customClass="MWMEditorAdditionalNamePlaceholderTableViewCell">
|
||||
<rect key="frame" x="0.0" y="0.0" width="320" height="16"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="7Br-fC-W0o" id="58c-Uv-d0K">
|
||||
<rect key="frame" x="0.0" y="0.0" width="320" height="16"/>
|
||||
<rect key="frame" x="0.0" y="0.0" width="320" height="15"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<subviews>
|
||||
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="tYH-si-HMY">
|
||||
<rect key="frame" x="0.0" y="0.0" width="320" height="16"/>
|
||||
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
|
||||
<rect key="frame" x="0.0" y="0.0" width="320" height="15"/>
|
||||
<color key="backgroundColor" red="0.0" green="0.0" blue="0.0" alpha="0.0" colorSpace="custom" customColorSpace="sRGB"/>
|
||||
<constraints>
|
||||
<constraint firstAttribute="height" priority="750" constant="16" id="A96-CL-Yji"/>
|
||||
</constraints>
|
||||
</view>
|
||||
</subviews>
|
||||
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
|
||||
<color key="backgroundColor" red="0.0" green="0.0" blue="0.0" alpha="0.0" colorSpace="custom" customColorSpace="sRGB"/>
|
||||
<constraints>
|
||||
<constraint firstItem="tYH-si-HMY" firstAttribute="leading" secondItem="58c-Uv-d0K" secondAttribute="leading" id="GTY-XA-kVU"/>
|
||||
<constraint firstAttribute="trailing" secondItem="tYH-si-HMY" secondAttribute="trailing" id="VOL-Tl-l3w"/>
|
|
@ -5,7 +5,7 @@
|
|||
|
||||
@interface MWMEditorAdditionalNameTableViewCell : MWMTableViewCell
|
||||
|
||||
@property (nonatomic, readonly) NSInteger code;
|
||||
@property(nonatomic, readonly) NSInteger code;
|
||||
|
||||
- (void)configWithDelegate:(id<MWMEditorAdditionalName>)delegate
|
||||
langCode:(NSInteger)langCode
|
|
@ -2,13 +2,13 @@
|
|||
|
||||
@interface MWMEditorAdditionalNameTableViewCell ()
|
||||
|
||||
@property (weak, nonatomic) IBOutlet UILabel * languageLabel;
|
||||
@property (weak, nonatomic) IBOutlet UIButton * languageButton;
|
||||
@property (weak, nonatomic) IBOutlet UITextField * textField;
|
||||
@property(weak, nonatomic) IBOutlet UILabel * languageLabel;
|
||||
@property(weak, nonatomic) IBOutlet UIButton * languageButton;
|
||||
@property(weak, nonatomic) IBOutlet UITextField * textField;
|
||||
|
||||
@property (nonatomic, readwrite) NSInteger code;
|
||||
@property(nonatomic, readwrite) NSInteger code;
|
||||
|
||||
@property (weak, nonatomic) id<MWMEditorAdditionalName> delegate;
|
||||
@property(weak, nonatomic) id<MWMEditorAdditionalName> delegate;
|
||||
|
||||
@end
|
||||
|
||||
|
@ -28,11 +28,7 @@
|
|||
self.textField.keyboardType = keyboardType;
|
||||
}
|
||||
|
||||
- (IBAction)changeLanguageTap
|
||||
{
|
||||
[self.delegate editAdditionalNameLanguage:self.code];
|
||||
}
|
||||
|
||||
- (IBAction)changeLanguageTap { [self.delegate editAdditionalNameLanguage:self.code]; }
|
||||
#pragma mark - UITextFieldDelegate
|
||||
|
||||
- (void)textFieldDidEndEditing:(UITextField *)textField
|
|
@ -4,6 +4,8 @@
|
|||
|
||||
@interface MWMEditorCategoryCell : MWMTableViewCell
|
||||
|
||||
- (void)configureWithDelegate:(id<MWMEditorCellProtocol>)delegate detailTitle:(NSString *)detail isCreating:(BOOL)isCreating;
|
||||
- (void)configureWithDelegate:(id<MWMEditorCellProtocol>)delegate
|
||||
detailTitle:(NSString *)detail
|
||||
isCreating:(BOOL)isCreating;
|
||||
|
||||
@end
|
|
@ -4,21 +4,23 @@
|
|||
|
||||
namespace
|
||||
{
|
||||
CGFloat const kDetailShortRightSpace = 16;
|
||||
} // namespace
|
||||
CGFloat const kDetailShortRightSpace = 16;
|
||||
} // namespace
|
||||
|
||||
@interface MWMEditorCategoryCell ()
|
||||
|
||||
@property (weak, nonatomic) IBOutlet UIImageView * accessoryIcon;
|
||||
@property (weak, nonatomic) IBOutlet UILabel * detail;
|
||||
@property (weak, nonatomic) IBOutlet NSLayoutConstraint * detailRightSpace;
|
||||
@property (weak, nonatomic) id<MWMEditorCellProtocol> delegate;
|
||||
@property(weak, nonatomic) IBOutlet UIImageView * accessoryIcon;
|
||||
@property(weak, nonatomic) IBOutlet UILabel * detail;
|
||||
@property(weak, nonatomic) IBOutlet NSLayoutConstraint * detailRightSpace;
|
||||
@property(weak, nonatomic) id<MWMEditorCellProtocol> delegate;
|
||||
|
||||
@end
|
||||
|
||||
@implementation MWMEditorCategoryCell
|
||||
|
||||
- (void)configureWithDelegate:(id<MWMEditorCellProtocol>)delegate detailTitle:(NSString *)detail isCreating:(BOOL)isCreating
|
||||
- (void)configureWithDelegate:(id<MWMEditorCellProtocol>)delegate
|
||||
detailTitle:(NSString *)detail
|
||||
isCreating:(BOOL)isCreating
|
||||
{
|
||||
self.delegate = delegate;
|
||||
self.detail.text = detail;
|
|
@ -3,11 +3,11 @@
|
|||
|
||||
@interface MWMEditorSwitchTableViewCell ()
|
||||
|
||||
@property (weak, nonatomic) IBOutlet UIImageView * icon;
|
||||
@property (weak, nonatomic) IBOutlet UILabel * label;
|
||||
@property (weak, nonatomic) IBOutlet UISwitch * switchControl;
|
||||
@property(weak, nonatomic) IBOutlet UIImageView * icon;
|
||||
@property(weak, nonatomic) IBOutlet UILabel * label;
|
||||
@property(weak, nonatomic) IBOutlet UISwitch * switchControl;
|
||||
|
||||
@property (weak, nonatomic) id<MWMEditorCellProtocol> delegate;
|
||||
@property(weak, nonatomic) id<MWMEditorCellProtocol> delegate;
|
||||
|
||||
@end
|
||||
|
|
@ -20,6 +20,6 @@
|
|||
keyboardType:(UIKeyboardType)keyboardType
|
||||
capitalization:(UITextAutocapitalizationType)capitalization;
|
||||
|
||||
@property (weak, nonatomic, readonly) IBOutlet UITextField * textField;
|
||||
@property(weak, nonatomic, readonly) IBOutlet UITextField * textField;
|
||||
|
||||
@end
|
|
@ -1,25 +1,25 @@
|
|||
#import "MWMEditorCommon.h"
|
||||
#import "MWMEditorTextTableViewCell.h"
|
||||
#import "MWMEditorCommon.h"
|
||||
#import "UIImageView+Coloring.h"
|
||||
#import "UITextField+RuntimeAttributes.h"
|
||||
|
||||
namespace
|
||||
{
|
||||
CGFloat const kErrorLabelDefaultTopSpace = 4.;
|
||||
} // namespace
|
||||
CGFloat const kErrorLabelDefaultTopSpace = 4.;
|
||||
} // namespace
|
||||
|
||||
@interface MWMEditorTextTableViewCell () <UITextFieldDelegate>
|
||||
@interface MWMEditorTextTableViewCell ()<UITextFieldDelegate>
|
||||
|
||||
@property (weak, nonatomic) IBOutlet UIImageView * icon;
|
||||
@property (weak, nonatomic, readwrite) IBOutlet UITextField * textField;
|
||||
@property (weak, nonatomic) IBOutlet UILabel * errorLabel;
|
||||
@property(weak, nonatomic) IBOutlet UIImageView * icon;
|
||||
@property(weak, nonatomic, readwrite) IBOutlet UITextField * textField;
|
||||
@property(weak, nonatomic) IBOutlet UILabel * errorLabel;
|
||||
|
||||
@property (weak, nonatomic) IBOutlet NSLayoutConstraint * errorLabelTopSpace;
|
||||
@property (weak, nonatomic) IBOutlet NSLayoutConstraint * labelHeight;
|
||||
@property(weak, nonatomic) IBOutlet NSLayoutConstraint * errorLabelTopSpace;
|
||||
@property(weak, nonatomic) IBOutlet NSLayoutConstraint * labelHeight;
|
||||
|
||||
@property (weak, nonatomic) id<MWMEditorCellProtocol> delegate;
|
||||
@property(weak, nonatomic) id<MWMEditorCellProtocol> delegate;
|
||||
|
||||
@property (nonatomic) BOOL isValid;
|
||||
@property(nonatomic) BOOL isValid;
|
||||
|
||||
@end
|
||||
|
||||
|
@ -30,10 +30,16 @@ namespace
|
|||
text:(NSString *)text
|
||||
placeholder:(NSString *)placeholder
|
||||
keyboardType:(UIKeyboardType)keyboardType
|
||||
capitalization:(UITextAutocapitalizationType)capitalization
|
||||
capitalization:(UITextAutocapitalizationType)capitalization
|
||||
{
|
||||
[self configWithDelegate:delegate icon:icon text:text placeholder:placeholder
|
||||
errorMessage:nil isValid:YES keyboardType:keyboardType capitalization:capitalization];
|
||||
[self configWithDelegate:delegate
|
||||
icon:icon
|
||||
text:text
|
||||
placeholder:placeholder
|
||||
errorMessage:nil
|
||||
isValid:YES
|
||||
keyboardType:keyboardType
|
||||
capitalization:capitalization];
|
||||
}
|
||||
|
||||
- (void)configWithDelegate:(id<MWMEditorCellProtocol>)delegate
|
||||
|
@ -43,7 +49,7 @@ namespace
|
|||
errorMessage:(NSString *)errorMessage
|
||||
isValid:(BOOL)isValid
|
||||
keyboardType:(UIKeyboardType)keyboardType
|
||||
capitalization:(UITextAutocapitalizationType)capitalization
|
||||
capitalization:(UITextAutocapitalizationType)capitalization
|
||||
{
|
||||
self.delegate = delegate;
|
||||
self.icon.image = icon;
|
||||
|
@ -51,8 +57,9 @@ namespace
|
|||
self.icon.hidden = (icon == nil);
|
||||
|
||||
self.textField.text = text;
|
||||
self.textField.attributedPlaceholder = [[NSAttributedString alloc] initWithString:placeholder attributes:
|
||||
@{NSForegroundColorAttributeName : [UIColor blackHintText]}];
|
||||
self.textField.attributedPlaceholder = [[NSAttributedString alloc]
|
||||
initWithString:placeholder
|
||||
attributes:@{NSForegroundColorAttributeName : [UIColor blackHintText]}];
|
||||
self.errorLabel.text = errorMessage;
|
||||
self.textField.keyboardType = keyboardType;
|
||||
self.textField.backgroundColor = [UIColor clearColor];
|
||||
|
@ -89,7 +96,9 @@ namespace
|
|||
|
||||
#pragma mark - UITextFieldDelegate
|
||||
|
||||
- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string
|
||||
- (BOOL)textField:(UITextField *)textField
|
||||
shouldChangeCharactersInRange:(NSRange)range
|
||||
replacementString:(NSString *)string
|
||||
{
|
||||
[self changeInvalidCellState];
|
||||
return YES;
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
@class MWMNoteCell;
|
||||
|
||||
@protocol MWMNoteCelLDelegate <NSObject>
|
||||
@protocol MWMNoteCelLDelegate<NSObject>
|
||||
|
||||
- (void)cellShouldChangeSize:(MWMNoteCell *)cell text:(NSString *)text;
|
||||
- (void)cell:(MWMNoteCell *)cell didFinishEditingWithText:(NSString *)text;
|
||||
|
@ -11,7 +11,8 @@
|
|||
|
||||
@interface MWMNoteCell : MWMTableViewCell
|
||||
|
||||
- (void)configWithDelegate:(id<MWMNoteCelLDelegate>)delegate noteText:(NSString *)text
|
||||
- (void)configWithDelegate:(id<MWMNoteCelLDelegate>)delegate
|
||||
noteText:(NSString *)text
|
||||
placeholder:(NSString *)placeholder;
|
||||
- (CGFloat)cellHeight;
|
||||
- (void)updateTextViewForHeight:(CGFloat)height;
|
|
@ -1,19 +1,19 @@
|
|||
#import "MWMTextView.h"
|
||||
#import "MWMNoteCell.h"
|
||||
#import "MWMTextView.h"
|
||||
|
||||
namespace
|
||||
{
|
||||
CGFloat const kTopTextViewOffset = 12.;
|
||||
NSString * const kTextViewContentSizeKeyPath = @"contentSize";
|
||||
CGFloat const kMinimalTextViewHeight = 104.;
|
||||
|
||||
|
||||
} // namespace
|
||||
|
||||
@interface MWMNoteCell () <UITextViewDelegate>
|
||||
@interface MWMNoteCell ()<UITextViewDelegate>
|
||||
|
||||
@property (weak, nonatomic) IBOutlet MWMTextView * textView;
|
||||
@property (weak, nonatomic) IBOutlet NSLayoutConstraint * textViewHeight;
|
||||
@property (weak, nonatomic) id<MWMNoteCelLDelegate> delegate;
|
||||
@property(weak, nonatomic) IBOutlet MWMTextView * textView;
|
||||
@property(weak, nonatomic) IBOutlet NSLayoutConstraint * textViewHeight;
|
||||
@property(weak, nonatomic) id<MWMNoteCelLDelegate> delegate;
|
||||
|
||||
@end
|
||||
|
||||
|
@ -21,12 +21,14 @@ static void * kContext = &kContext;
|
|||
|
||||
@implementation MWMNoteCell
|
||||
|
||||
- (void)configWithDelegate:(id<MWMNoteCelLDelegate>)delegate noteText:(NSString *)text
|
||||
- (void)configWithDelegate:(id<MWMNoteCelLDelegate>)delegate
|
||||
noteText:(NSString *)text
|
||||
placeholder:(NSString *)placeholder
|
||||
{
|
||||
self.delegate = delegate;
|
||||
self.textView.text = text;
|
||||
self.textView.keyboardAppearance = [UIColor isNightMode] ? UIKeyboardAppearanceDark : UIKeyboardAppearanceDefault;
|
||||
self.textView.keyboardAppearance =
|
||||
[UIColor isNightMode] ? UIKeyboardAppearanceDark : UIKeyboardAppearanceDefault;
|
||||
self.textView.placeholder = placeholder;
|
||||
}
|
||||
|
||||
|
@ -67,32 +69,16 @@ static void * kContext = &kContext;
|
|||
[super observeValueForKeyPath:keyPath ofObject:object change:change context:context];
|
||||
}
|
||||
|
||||
- (CGFloat)cellHeight
|
||||
{
|
||||
return self.textViewHeight.constant + 2 * kTopTextViewOffset;
|
||||
}
|
||||
|
||||
- (CGFloat)textViewContentHeight
|
||||
{
|
||||
return self.textView.contentSize.height;
|
||||
}
|
||||
|
||||
+ (CGFloat)minimalHeight
|
||||
{
|
||||
return kMinimalTextViewHeight;
|
||||
}
|
||||
|
||||
- (CGFloat)cellHeight { return self.textViewHeight.constant + 2 * kTopTextViewOffset; }
|
||||
- (CGFloat)textViewContentHeight { return self.textView.contentSize.height; }
|
||||
+ (CGFloat)minimalHeight { return kMinimalTextViewHeight; }
|
||||
- (void)textViewDidEndEditing:(UITextView *)textView
|
||||
{
|
||||
[self.delegate cell:self didFinishEditingWithText:textView.text];
|
||||
[self unregisterObserver];
|
||||
}
|
||||
|
||||
- (void)textViewDidBeginEditing:(UITextView *)textView
|
||||
{
|
||||
[self registerObserver];
|
||||
}
|
||||
|
||||
- (void)textViewDidBeginEditing:(UITextView *)textView { [self registerObserver]; }
|
||||
- (void)unregisterObserver
|
||||
{
|
||||
[self.textView removeObserver:self forKeyPath:kTextViewContentSizeKeyPath context:kContext];
|
||||
|
@ -100,7 +86,10 @@ static void * kContext = &kContext;
|
|||
|
||||
- (void)registerObserver
|
||||
{
|
||||
[self.textView addObserver:self forKeyPath:kTextViewContentSizeKeyPath options:NSKeyValueObservingOptionNew context:kContext];
|
||||
[self.textView addObserver:self
|
||||
forKeyPath:kTextViewContentSizeKeyPath
|
||||
options:NSKeyValueObservingOptionNew
|
||||
context:kContext];
|
||||
}
|
||||
|
||||
@end
|
|
@ -3,6 +3,7 @@
|
|||
#import "MWMKeyboard.h"
|
||||
#import "MWMTableViewCell.h"
|
||||
#import "MWMToast.h"
|
||||
#import "SwiftBridge.h"
|
||||
|
||||
#include "indexer/cuisines.hpp"
|
||||
#include "indexer/search_string_utils.hpp"
|
||||
|
@ -193,8 +194,8 @@ vector<string> SliceKeys(vector<pair<string, string>> const & v)
|
|||
- (UITableViewCell * _Nonnull)tableView:(UITableView * _Nonnull)tableView
|
||||
cellForRowAtIndexPath:(NSIndexPath * _Nonnull)indexPath
|
||||
{
|
||||
UITableViewCell * cell =
|
||||
[self.tableView dequeueReusableCellWithIdentifier:[UITableViewCell className]];
|
||||
auto cell =
|
||||
[tableView dequeueReusableCellWithCellClass:[UITableViewCell class] indexPath:indexPath];
|
||||
NSInteger const index = indexPath.row;
|
||||
|
||||
auto const & dataSource = [self dataSourceForSection:indexPath.section];
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
#import "MWMStreetEditorViewController.h"
|
||||
#import "MapViewController.h"
|
||||
#import "Statistics.h"
|
||||
#import "SwiftBridge.h"
|
||||
#import "UIViewController+Navigation.h"
|
||||
|
||||
#include "std/algorithm.hpp"
|
||||
|
@ -55,32 +56,32 @@ vector<MWMPlacePageCellType> const kSectionAddressCellTypes{
|
|||
vector<MWMPlacePageCellType> const kSectionNoteCellTypes{MWMPlacePageCellTypeNote};
|
||||
vector<MWMPlacePageCellType> const kSectionButtonCellTypes{MWMPlacePageCellTypeReportButton};
|
||||
|
||||
MWMPlacePageCellTypeValueMap const kCellType2ReuseIdentifier{
|
||||
{MWMPlacePageCellTypeCategory, "MWMEditorCategoryCell"},
|
||||
{MWMPlacePageCellTypeAdditionalName, "MWMEditorAdditionalNameTableViewCell"},
|
||||
{MWMPlacePageCellTypeAddAdditionalName, "MWMEditorAddAdditionalNameTableViewCell"},
|
||||
using MWMPlacePageCellTypeClassMap = map<MWMPlacePageCellType, Class>;
|
||||
MWMPlacePageCellTypeClassMap const kCellType2Class{
|
||||
{MWMPlacePageCellTypeCategory, [MWMEditorCategoryCell class]},
|
||||
{MWMPlacePageCellTypeAdditionalName, [MWMEditorAdditionalNameTableViewCell class]},
|
||||
{MWMPlacePageCellTypeAddAdditionalName, [MWMEditorAddAdditionalNameTableViewCell class]},
|
||||
{MWMPlacePageCellTypeAddAdditionalNamePlaceholder,
|
||||
"MWMEditorAdditionalNamePlaceholderTableViewCell"},
|
||||
{MWMPlacePageCellTypeStreet, "MWMEditorSelectTableViewCell"},
|
||||
{MWMPlacePageCellTypeBuilding, "MWMEditorTextTableViewCell"},
|
||||
{MWMPlacePageCellTypeZipCode, "MWMEditorTextTableViewCell"},
|
||||
{MWMPlacePageCellTypeBuildingLevels, "MWMEditorTextTableViewCell"},
|
||||
{MWMPlacePageCellTypeOpenHours, "MWMPlacePageOpeningHoursCell"},
|
||||
{MWMPlacePageCellTypePhoneNumber, "MWMEditorTextTableViewCell"},
|
||||
{MWMPlacePageCellTypeWebsite, "MWMEditorTextTableViewCell"},
|
||||
{MWMPlacePageCellTypeEmail, "MWMEditorTextTableViewCell"},
|
||||
{MWMPlacePageCellTypeOperator, "MWMEditorTextTableViewCell"},
|
||||
{MWMPlacePageCellTypeCuisine, "MWMEditorSelectTableViewCell"},
|
||||
{MWMPlacePageCellTypeWiFi, "MWMEditorSwitchTableViewCell"},
|
||||
{MWMPlacePageCellTypeNote, "MWMNoteCell"},
|
||||
{MWMPlacePageCellTypeReportButton, "MWMButtonCell"}};
|
||||
[MWMEditorAdditionalNamePlaceholderTableViewCell class]},
|
||||
{MWMPlacePageCellTypeStreet, [MWMEditorSelectTableViewCell class]},
|
||||
{MWMPlacePageCellTypeBuilding, [MWMEditorTextTableViewCell class]},
|
||||
{MWMPlacePageCellTypeZipCode, [MWMEditorTextTableViewCell class]},
|
||||
{MWMPlacePageCellTypeBuildingLevels, [MWMEditorTextTableViewCell class]},
|
||||
{MWMPlacePageCellTypeOpenHours, [MWMPlacePageOpeningHoursCell class]},
|
||||
{MWMPlacePageCellTypePhoneNumber, [MWMEditorTextTableViewCell class]},
|
||||
{MWMPlacePageCellTypeWebsite, [MWMEditorTextTableViewCell class]},
|
||||
{MWMPlacePageCellTypeEmail, [MWMEditorTextTableViewCell class]},
|
||||
{MWMPlacePageCellTypeOperator, [MWMEditorTextTableViewCell class]},
|
||||
{MWMPlacePageCellTypeCuisine, [MWMEditorSelectTableViewCell class]},
|
||||
{MWMPlacePageCellTypeWiFi, [MWMEditorSwitchTableViewCell class]},
|
||||
{MWMPlacePageCellTypeNote, [MWMNoteCell class]},
|
||||
{MWMPlacePageCellTypeReportButton, [MWMButtonCell class]}};
|
||||
|
||||
NSString * reuseIdentifier(MWMPlacePageCellType cellType)
|
||||
Class cellClass(MWMPlacePageCellType cellType)
|
||||
{
|
||||
auto const it = kCellType2ReuseIdentifier.find(cellType);
|
||||
BOOL const haveCell = (it != kCellType2ReuseIdentifier.end());
|
||||
ASSERT(haveCell, ());
|
||||
return haveCell ? @(it->second.c_str()) : @"";
|
||||
auto const it = kCellType2Class.find(cellType);
|
||||
ASSERT(it != kCellType2Class.end(), ());
|
||||
return it->second;
|
||||
}
|
||||
|
||||
void cleanupAdditionalLanguages(vector<osm::LocalizedName> const & names,
|
||||
|
@ -150,13 +151,7 @@ vector<MWMPlacePageCellType> cellsForProperties(vector<osm::Props> const & props
|
|||
void registerCellsForTableView(vector<MWMPlacePageCellType> const & cells, UITableView * tv)
|
||||
{
|
||||
for (auto const c : cells)
|
||||
{
|
||||
NSString * identifier = reuseIdentifier(c);
|
||||
if (UINib * nib = [UINib nibWithNibName:identifier bundle:nil])
|
||||
[tv registerNib:nib forCellReuseIdentifier:identifier];
|
||||
else
|
||||
ASSERT(false, ("Incorrect cell"));
|
||||
}
|
||||
[tv registerWithCellClass:cellClass(c)];
|
||||
}
|
||||
} // namespace
|
||||
|
||||
|
@ -166,7 +161,7 @@ void registerCellsForTableView(vector<MWMPlacePageCellType> const & cells, UITab
|
|||
MWMStreetEditorProtocol, MWMObjectsCategorySelectorDelegate, MWMNoteCelLDelegate,
|
||||
MWMEditorAdditionalName, MWMButtonCellDelegate, MWMEditorAdditionalNamesProtocol>
|
||||
|
||||
@property(nonatomic) NSMutableDictionary<NSString *, UITableViewCell *> * offscreenCells;
|
||||
@property(nonatomic) NSMutableDictionary<Class, UITableViewCell *> * offscreenCells;
|
||||
@property(nonatomic) NSMutableArray<NSIndexPath *> * invalidCells;
|
||||
@property(nonatomic) MWMEditorAdditionalNamesHeader * additionalNamesHeader;
|
||||
@property(nonatomic) MWMEditorNotesFooter * notesFooter;
|
||||
|
@ -370,13 +365,13 @@ void registerCellsForTableView(vector<MWMPlacePageCellType> const & cells, UITab
|
|||
|
||||
#pragma mark - Offscreen cells
|
||||
|
||||
- (UITableViewCell *)offscreenCellForIdentifier:(NSString *)reuseIdentifier
|
||||
- (UITableViewCell *)offscreenCellForClass:(Class)cls
|
||||
{
|
||||
UITableViewCell * cell = self.offscreenCells[reuseIdentifier];
|
||||
auto cell = self.offscreenCells[cls];
|
||||
if (!cell)
|
||||
{
|
||||
cell = [[[NSBundle mainBundle] loadNibNamed:reuseIdentifier owner:nil options:nil] firstObject];
|
||||
self.offscreenCells[reuseIdentifier] = cell;
|
||||
cell = [[[NSBundle mainBundle] loadWithViewClass:cls owner:nil options:nil] firstObject];
|
||||
self.offscreenCells[cls] = cell;
|
||||
}
|
||||
return cell;
|
||||
}
|
||||
|
@ -451,9 +446,9 @@ void registerCellsForTableView(vector<MWMPlacePageCellType> const & cells, UITab
|
|||
return m_cells[m_sections[indexPath.section]][indexPath.row];
|
||||
}
|
||||
|
||||
- (NSString *)cellIdentifierForIndexPath:(NSIndexPath *)indexPath
|
||||
- (Class)cellClassForIndexPath:(NSIndexPath *)indexPath
|
||||
{
|
||||
return reuseIdentifier([self cellTypeForIndexPath:indexPath]);
|
||||
return cellClass([self cellTypeForIndexPath:indexPath]);
|
||||
}
|
||||
|
||||
#pragma mark - Fill cells with data
|
||||
|
@ -687,8 +682,8 @@ void registerCellsForTableView(vector<MWMPlacePageCellType> const & cells, UITab
|
|||
- (UITableViewCell * _Nonnull)tableView:(UITableView * _Nonnull)tableView
|
||||
cellForRowAtIndexPath:(NSIndexPath * _Nonnull)indexPath
|
||||
{
|
||||
NSString * reuseIdentifier = [self cellIdentifierForIndexPath:indexPath];
|
||||
UITableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:reuseIdentifier];
|
||||
Class cls = [self cellClassForIndexPath:indexPath];
|
||||
auto cell = [tableView dequeueReusableCellWithCellClass:cls indexPath:indexPath];
|
||||
[self fillCell:cell atIndexPath:indexPath];
|
||||
return cell;
|
||||
}
|
||||
|
@ -708,9 +703,8 @@ void registerCellsForTableView(vector<MWMPlacePageCellType> const & cells, UITab
|
|||
- (CGFloat)tableView:(UITableView * _Nonnull)tableView
|
||||
heightForRowAtIndexPath:(NSIndexPath * _Nonnull)indexPath
|
||||
{
|
||||
NSString * reuseIdentifier = [self cellIdentifierForIndexPath:indexPath];
|
||||
|
||||
UITableViewCell * cell = [self offscreenCellForIdentifier:reuseIdentifier];
|
||||
Class cls = [self cellClassForIndexPath:indexPath];
|
||||
auto cell = [self offscreenCellForClass:cls];
|
||||
[self fillCell:cell atIndexPath:indexPath];
|
||||
MWMPlacePageCellType const cellType = [self cellTypeForIndexPath:indexPath];
|
||||
switch (cellType)
|
||||
|
@ -821,7 +815,7 @@ void registerCellsForTableView(vector<MWMPlacePageCellType> const & cells, UITab
|
|||
|
||||
- (void)cellShouldChangeSize:(MWMNoteCell *)cell text:(NSString *)text
|
||||
{
|
||||
self.offscreenCells[reuseIdentifier(MWMPlacePageCellTypeNote)] = cell;
|
||||
self.offscreenCells[cellClass(MWMPlacePageCellTypeNote)] = cell;
|
||||
self.note = text;
|
||||
[self.tableView refresh];
|
||||
NSIndexPath * ip = [self.tableView indexPathForCell:cell];
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
#import "MWMTableViewCell.h"
|
||||
#import "MWMToast.h"
|
||||
#import "Statistics.h"
|
||||
#import "SwiftBridge.h"
|
||||
#import "UIViewController+Navigation.h"
|
||||
|
||||
#include "LocaleTranslator.h"
|
||||
|
@ -171,8 +172,8 @@ string locale()
|
|||
- (UITableViewCell *)tableView:(UITableView *)tableView
|
||||
cellForRowAtIndexPath:(NSIndexPath *)indexPath
|
||||
{
|
||||
UITableViewCell * cell =
|
||||
[tableView dequeueReusableCellWithIdentifier:[UITableViewCell className]];
|
||||
auto cell =
|
||||
[tableView dequeueReusableCellWithCellClass:[UITableViewCell class] indexPath:indexPath];
|
||||
cell.textLabel.text =
|
||||
@([self dataSourceForSection:indexPath.section][indexPath.row].first.c_str());
|
||||
if ([indexPath isEqual:self.selectedIndexPath])
|
||||
|
|
|
@ -1,18 +1,26 @@
|
|||
#import "MWMOpeningHoursEditorViewController.h"
|
||||
#import "MWMOpeningHoursAddClosedTableViewCell.h"
|
||||
#import "MWMOpeningHoursAddScheduleTableViewCell.h"
|
||||
#import "MWMOpeningHoursAllDayTableViewCell.h"
|
||||
#import "MWMOpeningHoursClosedSpanTableViewCell.h"
|
||||
#import "MWMOpeningHoursDaysSelectorTableViewCell.h"
|
||||
#import "MWMOpeningHoursDeleteScheduleTableViewCell.h"
|
||||
#import "MWMOpeningHoursModel.h"
|
||||
#import "MWMOpeningHoursSection.h"
|
||||
#import "MWMOpeningHoursTimeSelectorTableViewCell.h"
|
||||
#import "MWMOpeningHoursTimeSpanTableViewCell.h"
|
||||
#import "MWMTextView.h"
|
||||
#import "SwiftBridge.h"
|
||||
|
||||
extern NSDictionary * const kMWMOpeningHoursEditorTableCells = @{
|
||||
@(MWMOpeningHoursEditorDaysSelectorCell) : @"MWMOpeningHoursDaysSelectorTableViewCell",
|
||||
@(MWMOpeningHoursEditorAllDayCell) : @"MWMOpeningHoursAllDayTableViewCell",
|
||||
@(MWMOpeningHoursEditorTimeSpanCell) : @"MWMOpeningHoursTimeSpanTableViewCell",
|
||||
@(MWMOpeningHoursEditorTimeSelectorCell) : @"MWMOpeningHoursTimeSelectorTableViewCell",
|
||||
@(MWMOpeningHoursEditorClosedSpanCell) : @"MWMOpeningHoursClosedSpanTableViewCell",
|
||||
@(MWMOpeningHoursEditorAddClosedCell) : @"MWMOpeningHoursAddClosedTableViewCell",
|
||||
@(MWMOpeningHoursEditorDeleteScheduleCell) : @"MWMOpeningHoursDeleteScheduleTableViewCell",
|
||||
@(MWMOpeningHoursEditorAddScheduleCell) : @"MWMOpeningHoursAddScheduleTableViewCell",
|
||||
@(MWMOpeningHoursEditorDaysSelectorCell) : [MWMOpeningHoursDaysSelectorTableViewCell class],
|
||||
@(MWMOpeningHoursEditorAllDayCell) : [MWMOpeningHoursAllDayTableViewCell class],
|
||||
@(MWMOpeningHoursEditorTimeSpanCell) : [MWMOpeningHoursTimeSpanTableViewCell class],
|
||||
@(MWMOpeningHoursEditorTimeSelectorCell) : [MWMOpeningHoursTimeSelectorTableViewCell class],
|
||||
@(MWMOpeningHoursEditorClosedSpanCell) : [MWMOpeningHoursClosedSpanTableViewCell class],
|
||||
@(MWMOpeningHoursEditorAddClosedCell) : [MWMOpeningHoursAddClosedTableViewCell class],
|
||||
@(MWMOpeningHoursEditorDeleteScheduleCell) : [MWMOpeningHoursDeleteScheduleTableViewCell class],
|
||||
@(MWMOpeningHoursEditorAddScheduleCell) : [MWMOpeningHoursAddScheduleTableViewCell class],
|
||||
};
|
||||
|
||||
@interface MWMOpeningHoursEditorViewController ()<UITableViewDelegate, UITableViewDataSource,
|
||||
|
@ -61,10 +69,8 @@ extern NSDictionary * const kMWMOpeningHoursEditorTableCells = @{
|
|||
- (void)configTable
|
||||
{
|
||||
[kMWMOpeningHoursEditorTableCells
|
||||
enumerateKeysAndObjectsUsingBlock:^(id _Nonnull key, NSString * identifier,
|
||||
BOOL * _Nonnull stop) {
|
||||
[self.tableView registerNib:[UINib nibWithNibName:identifier bundle:nil]
|
||||
forCellReuseIdentifier:identifier];
|
||||
enumerateKeysAndObjectsUsingBlock:^(id _Nonnull key, Class cls, BOOL * _Nonnull stop) {
|
||||
[self.tableView registerWithCellClass:cls];
|
||||
}];
|
||||
}
|
||||
|
||||
|
@ -108,13 +114,6 @@ extern NSDictionary * const kMWMOpeningHoursEditorTableCells = @{
|
|||
return MWMOpeningHoursEditorAddScheduleCell;
|
||||
}
|
||||
|
||||
- (NSString *)cellIdentifierForIndexPath:(NSIndexPath *)indexPath
|
||||
{
|
||||
NSString * identifier = kMWMOpeningHoursEditorTableCells[@([self cellKeyForIndexPath:indexPath])];
|
||||
NSAssert(identifier, @"Identifier can not be nil");
|
||||
return identifier;
|
||||
}
|
||||
|
||||
- (CGFloat)heightForRowAtIndexPath:(NSIndexPath * _Nonnull)indexPath
|
||||
{
|
||||
CGFloat const width = self.view.width;
|
||||
|
@ -140,8 +139,8 @@ extern NSDictionary * const kMWMOpeningHoursEditorTableCells = @{
|
|||
- (UITableViewCell * _Nonnull)tableView:(UITableView * _Nonnull)tableView
|
||||
cellForRowAtIndexPath:(NSIndexPath * _Nonnull)indexPath
|
||||
{
|
||||
UITableViewCell * cell =
|
||||
[tableView dequeueReusableCellWithIdentifier:[self cellIdentifierForIndexPath:indexPath]];
|
||||
Class cls = kMWMOpeningHoursEditorTableCells[@([self cellKeyForIndexPath:indexPath])];
|
||||
auto cell = [tableView dequeueReusableCellWithCellClass:cls indexPath:indexPath];
|
||||
return cell;
|
||||
}
|
||||
|
||||
|
|
|
@ -96,9 +96,8 @@ using namespace osmoh;
|
|||
|
||||
- (CGFloat)heightForRow:(NSUInteger)row withWidth:(CGFloat)width
|
||||
{
|
||||
NSString * className = kMWMOpeningHoursEditorTableCells[@([self cellKeyForRow:row])];
|
||||
NSAssert(className, @"Invalid class name");
|
||||
return [NSClassFromString(className) heightForWidth:width];
|
||||
Class cls = kMWMOpeningHoursEditorTableCells[@([self cellKeyForRow:row])];
|
||||
return [cls heightForWidth:width];
|
||||
}
|
||||
|
||||
- (void)fillCell:(MWMOpeningHoursTableViewCell * _Nonnull)cell
|
||||
|
|
|
@ -1,10 +1,6 @@
|
|||
#import "MWMStreetEditorEditTableViewCell.h"
|
||||
#import "MWMStreetEditorViewController.h"
|
||||
|
||||
namespace
|
||||
{
|
||||
NSString * const kStreetEditorEditCell = @"MWMStreetEditorEditTableViewCell";
|
||||
} // namespace
|
||||
#import "MWMStreetEditorEditTableViewCell.h"
|
||||
#import "SwiftBridge.h"
|
||||
|
||||
@interface MWMStreetEditorViewController () <MWMStreetEditorEditCellProtocol>
|
||||
{
|
||||
|
@ -75,9 +71,9 @@ namespace
|
|||
|
||||
- (void)configTable
|
||||
{
|
||||
[self.tableView registerNib:[UINib nibWithNibName:kStreetEditorEditCell bundle:nil]
|
||||
forCellReuseIdentifier:kStreetEditorEditCell];
|
||||
[self.tableView registerClass:[MWMTableViewSubtitleCell class] forCellReuseIdentifier:[MWMTableViewSubtitleCell className]];
|
||||
UITableView * tv = self.tableView;
|
||||
[tv registerWithCellClass:[MWMStreetEditorEditTableViewCell class]];
|
||||
[tv registerWithCellClass:[MWMTableViewSubtitleCell class]];
|
||||
}
|
||||
|
||||
#pragma mark - Actions
|
||||
|
@ -152,18 +148,22 @@ namespace
|
|||
UITableViewCell * cell = nil;
|
||||
if (m_streets.empty())
|
||||
{
|
||||
cell = [tableView dequeueReusableCellWithIdentifier:kStreetEditorEditCell];
|
||||
cell = [tableView dequeueReusableCellWithCellClass:[MWMStreetEditorEditTableViewCell class]
|
||||
indexPath:indexPath];
|
||||
}
|
||||
else
|
||||
{
|
||||
if (indexPath.section == 0)
|
||||
{
|
||||
NSString * identifier = m_streets[indexPath.row].m_localizedName.empty() ? [UITableViewCell className] : [MWMTableViewSubtitleCell className];
|
||||
cell = [tableView dequeueReusableCellWithIdentifier:identifier];
|
||||
Class cls = m_streets[indexPath.row].m_localizedName.empty()
|
||||
? [UITableViewCell class]
|
||||
: [MWMTableViewSubtitleCell class];
|
||||
cell = [tableView dequeueReusableCellWithCellClass:cls indexPath:indexPath];
|
||||
}
|
||||
else
|
||||
{
|
||||
cell = [tableView dequeueReusableCellWithIdentifier:kStreetEditorEditCell];
|
||||
cell = [tableView dequeueReusableCellWithCellClass:[MWMStreetEditorEditTableViewCell class]
|
||||
indexPath:indexPath];
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -3,50 +3,10 @@
|
|||
#import "MWMOpeningHours.h"
|
||||
#import "MWMPlacePageData.h"
|
||||
#import "MWMTableViewCell.h"
|
||||
#import "SwiftBridge.h"
|
||||
|
||||
#include "std/array.hpp"
|
||||
|
||||
namespace
|
||||
{
|
||||
array<NSString *, 2> const kCells = {{@"_MWMOHHeaderCell", @"_MWMOHSubCell"}};
|
||||
|
||||
NSAttributedString * richStringFromDay(osmoh::Day const & day, BOOL isClosedNow)
|
||||
{
|
||||
auto const richString = ^NSMutableAttributedString * (NSString * str, UIFont * font, UIColor * color)
|
||||
{
|
||||
return [[NSMutableAttributedString alloc] initWithString:str
|
||||
attributes:@{NSFontAttributeName : font,
|
||||
NSForegroundColorAttributeName : color}];
|
||||
};
|
||||
|
||||
auto str = richString(day.TodayTime(), [UIFont regular17], day.m_isOpen ? [UIColor blackPrimaryText] :
|
||||
[UIColor red]);
|
||||
if (day.m_isOpen)
|
||||
{
|
||||
auto lineBreak = [[NSAttributedString alloc] initWithString:@"\n"];
|
||||
|
||||
if (day.m_breaks.length)
|
||||
{
|
||||
[str appendAttributedString:lineBreak];
|
||||
[str appendAttributedString:richString(day.m_breaks, [UIFont regular13], [UIColor blackSecondaryText])];
|
||||
}
|
||||
|
||||
if (isClosedNow)
|
||||
{
|
||||
[str appendAttributedString:lineBreak];
|
||||
[str appendAttributedString:richString(L(@"closed_now"), [UIFont regular13], [UIColor red])];
|
||||
}
|
||||
|
||||
auto paragraphStyle = [[NSMutableParagraphStyle alloc] init];
|
||||
paragraphStyle.lineSpacing = 4;
|
||||
|
||||
[str addAttributes:@{NSParagraphStyleAttributeName : paragraphStyle} range:{0, str.length}];
|
||||
}
|
||||
return str;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
@interface MWMPlacePageData()
|
||||
|
||||
- (vector<place_page::MetainfoRows> &)mutableMetainfoRows;
|
||||
|
@ -97,6 +57,48 @@ NSAttributedString * richStringFromDay(osmoh::Day const & day, BOOL isClosedNow)
|
|||
|
||||
@end
|
||||
|
||||
namespace
|
||||
{
|
||||
array<Class, 2> const kCells = {{[_MWMOHHeaderCell class], [_MWMOHSubCell class]}};
|
||||
|
||||
NSAttributedString * richStringFromDay(osmoh::Day const & day, BOOL isClosedNow)
|
||||
{
|
||||
auto const richString =
|
||||
^NSMutableAttributedString *(NSString * str, UIFont * font, UIColor * color)
|
||||
{
|
||||
return [[NSMutableAttributedString alloc]
|
||||
initWithString:str
|
||||
attributes:@{NSFontAttributeName : font, NSForegroundColorAttributeName : color}];
|
||||
};
|
||||
|
||||
auto str = richString(day.TodayTime(), [UIFont regular17],
|
||||
day.m_isOpen ? [UIColor blackPrimaryText] : [UIColor red]);
|
||||
if (day.m_isOpen)
|
||||
{
|
||||
auto lineBreak = [[NSAttributedString alloc] initWithString:@"\n"];
|
||||
|
||||
if (day.m_breaks.length)
|
||||
{
|
||||
[str appendAttributedString:lineBreak];
|
||||
[str appendAttributedString:richString(day.m_breaks, [UIFont regular13],
|
||||
[UIColor blackSecondaryText])];
|
||||
}
|
||||
|
||||
if (isClosedNow)
|
||||
{
|
||||
[str appendAttributedString:lineBreak];
|
||||
[str appendAttributedString:richString(L(@"closed_now"), [UIFont regular13], [UIColor red])];
|
||||
}
|
||||
|
||||
auto paragraphStyle = [[NSMutableParagraphStyle alloc] init];
|
||||
paragraphStyle.lineSpacing = 4;
|
||||
|
||||
[str addAttributes:@{ NSParagraphStyleAttributeName : paragraphStyle } range:{0, str.length}];
|
||||
}
|
||||
return str;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
@interface MWMOpeningHoursLayoutHelper()
|
||||
{
|
||||
|
@ -127,8 +129,8 @@ NSAttributedString * richStringFromDay(osmoh::Day const & day, BOOL isClosedNow)
|
|||
|
||||
- (void)registerCells
|
||||
{
|
||||
for (auto name : kCells)
|
||||
[self.tableView registerNib:[UINib nibWithNibName:name bundle:nil] forCellReuseIdentifier:name];
|
||||
for (Class cls : kCells)
|
||||
[self.tableView registerWithCellClass:cls];
|
||||
}
|
||||
|
||||
- (void)configWithData:(MWMPlacePageData *)data
|
||||
|
@ -146,7 +148,9 @@ NSAttributedString * richStringFromDay(osmoh::Day const & day, BOOL isClosedNow)
|
|||
|
||||
if (self.data.metainfoRows[indexPath.row] == place_page::MetainfoRows::OpeningHours)
|
||||
{
|
||||
_MWMOHHeaderCell * cell = [tableView dequeueReusableCellWithIdentifier:[_MWMOHHeaderCell className]];
|
||||
Class cls = [_MWMOHHeaderCell class];
|
||||
auto cell = static_cast<_MWMOHHeaderCell *>(
|
||||
[tableView dequeueReusableCellWithCellClass:cls indexPath:indexPath]);
|
||||
|
||||
if (m_days.size() > 1)
|
||||
{
|
||||
|
@ -189,7 +193,9 @@ NSAttributedString * richStringFromDay(osmoh::Day const & day, BOOL isClosedNow)
|
|||
}
|
||||
else
|
||||
{
|
||||
_MWMOHSubCell * cell = [tableView dequeueReusableCellWithIdentifier:[_MWMOHSubCell className]];
|
||||
Class cls = [_MWMOHSubCell class];
|
||||
auto cell = static_cast<_MWMOHSubCell *>(
|
||||
[tableView dequeueReusableCellWithCellClass:cls indexPath:indexPath]);
|
||||
cell.days.text = day.m_workingDays;
|
||||
cell.schedule.text = day.m_workingTimes ?: L(@"closed");
|
||||
cell.breaks.text = day.m_breaks;
|
||||
|
|
|
@ -1,13 +0,0 @@
|
|||
#import "MWMTableViewCell.h"
|
||||
|
||||
#import "MWMPlacePageData.h"
|
||||
|
||||
@interface MWMPlacePageInfoCell : MWMTableViewCell
|
||||
|
||||
- (void)configWithRow:(place_page::MetainfoRows)row
|
||||
data:(MWMPlacePageData *)data;
|
||||
|
||||
@property(weak, nonatomic, readonly) IBOutlet UIImageView * icon;
|
||||
@property(weak, nonatomic, readonly) IBOutlet id textContainer;
|
||||
|
||||
@end
|
|
@ -1,13 +1,17 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="9531" systemVersion="15A284" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES">
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="11762" systemVersion="16D32" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" colorMatched="YES">
|
||||
<device id="retina4_7" orientation="portrait">
|
||||
<adaptation id="fullscreen"/>
|
||||
</device>
|
||||
<dependencies>
|
||||
<deployment identifier="iOS"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="9529"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="11757"/>
|
||||
<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="none" indentationWidth="10" reuseIdentifier="PlacePageInfoCell" id="VAd-kw-ZEC" customClass="MWMPlacePageInfoCell">
|
||||
<tableViewCell contentMode="scaleToFill" restorationIdentifier="MWMPlacePageInfoCell" selectionStyle="none" indentationWidth="10" reuseIdentifier="MWMPlacePageInfoCell" id="VAd-kw-ZEC" customClass="MWMPlacePageInfoCell">
|
||||
<rect key="frame" x="0.0" y="0.0" width="320" height="44"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMaxX="YES" flexibleMinY="YES" flexibleMaxY="YES"/>
|
||||
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="VAd-kw-ZEC" id="KHz-zH-ymS">
|
||||
|
@ -25,14 +29,14 @@
|
|||
</userDefinedRuntimeAttributes>
|
||||
</imageView>
|
||||
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" lineBreakMode="tailTruncation" adjustsFontSizeToFit="NO" preferredMaxLayoutWidth="228" translatesAutoresizingMaskIntoConstraints="NO" id="viE-zJ-wsl" customClass="CopyLabel">
|
||||
<rect key="frame" x="60" y="12" width="228" height="20"/>
|
||||
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
|
||||
<rect key="frame" x="60" y="12" width="228" height="19"/>
|
||||
<color key="backgroundColor" red="0.0" green="0.0" blue="0.0" alpha="0.0" colorSpace="custom" customColorSpace="sRGB"/>
|
||||
<gestureRecognizers/>
|
||||
<constraints>
|
||||
<constraint firstAttribute="height" relation="greaterThanOrEqual" priority="750" constant="20" id="26Z-I0-jym"/>
|
||||
</constraints>
|
||||
<fontDescription key="fontDescription" name="HelveticaNeue" family="Helvetica Neue" pointSize="17"/>
|
||||
<color key="textColor" red="0.12941176469999999" green="0.12941176469999999" blue="0.12941176469999999" alpha="1" colorSpace="calibratedRGB"/>
|
||||
<color key="textColor" red="0.12941176469999999" green="0.12941176469999999" blue="0.12941176469999999" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
|
||||
<nil key="highlightedColor"/>
|
||||
<userDefinedRuntimeAttributes>
|
||||
<userDefinedRuntimeAttribute type="string" keyPath="fontName" value="regular16"/>
|
||||
|
@ -50,16 +54,16 @@
|
|||
</userDefinedRuntimeAttributes>
|
||||
</imageView>
|
||||
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="vu9-VL-9jn">
|
||||
<rect key="frame" x="0.0" y="0.0" width="320" height="44"/>
|
||||
<rect key="frame" x="0.0" y="0.0" width="320" height="43"/>
|
||||
<state key="normal">
|
||||
<color key="titleShadowColor" white="0.5" alpha="1" colorSpace="calibratedWhite"/>
|
||||
<color key="titleShadowColor" red="0.5" green="0.5" blue="0.5" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
|
||||
</state>
|
||||
<connections>
|
||||
<action selector="cellTap" destination="VAd-kw-ZEC" eventType="touchUpInside" id="eLw-l7-FXA"/>
|
||||
</connections>
|
||||
</button>
|
||||
</subviews>
|
||||
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
|
||||
<color key="backgroundColor" red="0.0" green="0.0" blue="0.0" alpha="0.0" colorSpace="custom" customColorSpace="sRGB"/>
|
||||
<constraints>
|
||||
<constraint firstItem="xwC-DR-6Il" firstAttribute="leading" secondItem="KHz-zH-ymS" secondAttribute="leading" constant="16" id="4B0-o5-ixn"/>
|
||||
<constraint firstAttribute="bottom" secondItem="viE-zJ-wsl" secondAttribute="bottom" constant="12" id="5Me-Rj-yun"/>
|
||||
|
@ -78,7 +82,7 @@
|
|||
<userDefinedRuntimeAttribute type="string" keyPath="backgroundColorName" value="white"/>
|
||||
</userDefinedRuntimeAttributes>
|
||||
</tableViewCellContentView>
|
||||
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
|
||||
<color key="backgroundColor" red="0.0" green="0.0" blue="0.0" alpha="0.0" colorSpace="custom" customColorSpace="sRGB"/>
|
||||
<gestureRecognizers/>
|
||||
<userDefinedRuntimeAttributes>
|
||||
<userDefinedRuntimeAttribute type="string" keyPath="backgroundColorName" value="white"/>
|
||||
|
@ -95,4 +99,9 @@
|
|||
<resources>
|
||||
<image name="ic_placepage_change" width="24" height="24"/>
|
||||
</resources>
|
||||
<simulatedMetricsContainer key="defaultSimulatedMetrics">
|
||||
<simulatedStatusBarMetrics key="statusBar"/>
|
||||
<simulatedOrientationMetrics key="orientation"/>
|
||||
<simulatedScreenMetrics key="destination" type="retina4_7.fullscreen"/>
|
||||
</simulatedMetricsContainer>
|
||||
</document>
|
|
@ -1,21 +1,25 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="11201" systemVersion="16A323" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" colorMatched="YES">
|
||||
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="11762" systemVersion="16D32" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" colorMatched="YES">
|
||||
<device id="retina4_7" orientation="portrait">
|
||||
<adaptation id="fullscreen"/>
|
||||
</device>
|
||||
<dependencies>
|
||||
<deployment identifier="iOS"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="11161"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="11757"/>
|
||||
<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="none" indentationWidth="10" reuseIdentifier="PlacePageLinkCell" id="DKh-ne-anv" customClass="MWMPlacePageInfoCell">
|
||||
<tableViewCell contentMode="scaleToFill" restorationIdentifier="MWMPlacePageLinkCell" selectionStyle="none" indentationWidth="10" reuseIdentifier="MWMPlacePageLinkCell" id="DKh-ne-anv" customClass="MWMPlacePageLinkCell">
|
||||
<rect key="frame" x="0.0" y="0.0" width="320" height="44"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="DKh-ne-anv" id="M4j-cz-kSo">
|
||||
<frame key="frameInset" width="320" height="43.5"/>
|
||||
<rect key="frame" x="0.0" y="0.0" width="320" height="43"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<subviews>
|
||||
<imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="DT5-2i-vCG">
|
||||
<rect key="frame" x="16" y="8" width="28" height="28"/>
|
||||
<constraints>
|
||||
<constraint firstAttribute="width" constant="28" id="vLS-Ha-Cbl"/>
|
||||
<constraint firstAttribute="height" constant="28" id="vvn-a9-Lfo"/>
|
||||
|
@ -25,6 +29,7 @@
|
|||
</userDefinedRuntimeAttributes>
|
||||
</imageView>
|
||||
<textView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" scrollEnabled="NO" showsHorizontalScrollIndicator="NO" showsVerticalScrollIndicator="NO" editable="NO" translatesAutoresizingMaskIntoConstraints="NO" id="T5l-Sb-Hfo">
|
||||
<rect key="frame" x="60" y="0.0" width="260" height="44"/>
|
||||
<color key="backgroundColor" red="0.0" green="0.0" blue="0.0" alpha="0.0" colorSpace="custom" customColorSpace="sRGB"/>
|
||||
<string key="text">Lorem ipsum dolor sit er elit lamet, consectetaur cillium adipisicing pecu, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Nam liber te conscient to factor tum poen legum odioque civiuda.</string>
|
||||
<fontDescription key="fontDescription" type="system" weight="light" pointSize="16"/>
|
|
@ -0,0 +1,18 @@
|
|||
#import "MWMTableViewCell.h"
|
||||
|
||||
#import "MWMPlacePageData.h"
|
||||
|
||||
@interface MWMPlacePageRegularCell : MWMTableViewCell
|
||||
|
||||
- (void)configWithRow:(place_page::MetainfoRows)row data:(MWMPlacePageData *)data;
|
||||
|
||||
@property(weak, nonatomic, readonly) IBOutlet UIImageView * icon;
|
||||
@property(weak, nonatomic, readonly) IBOutlet id textContainer;
|
||||
|
||||
@end
|
||||
|
||||
@interface MWMPlacePageInfoCell : MWMPlacePageRegularCell
|
||||
@end
|
||||
|
||||
@interface MWMPlacePageLinkCell : MWMPlacePageRegularCell
|
||||
@end
|
|
@ -1,4 +1,4 @@
|
|||
#import "MWMPlacePageInfoCell.h"
|
||||
#import "MWMPlacePageRegularCell.h"
|
||||
#import "MWMCommon.h"
|
||||
#import "MapViewController.h"
|
||||
#import "MapsAppDelegate.h"
|
||||
|
@ -8,7 +8,7 @@
|
|||
#include "platform/measurement_utils.hpp"
|
||||
#include "platform/settings.hpp"
|
||||
|
||||
@interface MWMPlacePageInfoCell ()<UITextViewDelegate>
|
||||
@interface MWMPlacePageRegularCell ()<UITextViewDelegate>
|
||||
|
||||
@property(weak, nonatomic, readwrite) IBOutlet UIImageView * icon;
|
||||
@property(weak, nonatomic, readwrite) IBOutlet id textContainer;
|
||||
|
@ -21,7 +21,7 @@
|
|||
|
||||
@end
|
||||
|
||||
@implementation MWMPlacePageInfoCell
|
||||
@implementation MWMPlacePageRegularCell
|
||||
|
||||
- (void)awakeFromNib
|
||||
{
|
||||
|
@ -172,3 +172,9 @@
|
|||
}
|
||||
|
||||
@end
|
||||
|
||||
@implementation MWMPlacePageInfoCell
|
||||
@end
|
||||
|
||||
@implementation MWMPlacePageLinkCell
|
||||
@end
|
|
@ -6,8 +6,8 @@
|
|||
#import "MWMPlacePageButtonCell.h"
|
||||
#import "MWMPlacePageCellUpdateProtocol.h"
|
||||
#import "MWMPlacePageData.h"
|
||||
#import "MWMPlacePageInfoCell.h"
|
||||
#import "MWMPlacePageLayoutImpl.h"
|
||||
#import "MWMPlacePageRegularCell.h"
|
||||
#import "MWMPlacePageTaxiCell.h"
|
||||
#import "MWMiPadPlacePageLayoutImpl.h"
|
||||
#import "MWMiPhonePlacePageLayoutImpl.h"
|
||||
|
@ -20,23 +20,18 @@
|
|||
|
||||
namespace
|
||||
{
|
||||
array<NSString *, 1> const kBookmarkCells = {{@"MWMBookmarkCell"}};
|
||||
|
||||
using place_page::MetainfoRows;
|
||||
|
||||
map<MetainfoRows, NSString *> const kMetaInfoCells = {
|
||||
{MetainfoRows::Website, @"PlacePageLinkCell"},
|
||||
{MetainfoRows::Address, @"PlacePageInfoCell"},
|
||||
{MetainfoRows::Email, @"PlacePageLinkCell"},
|
||||
{MetainfoRows::Phone, @"PlacePageLinkCell"},
|
||||
{MetainfoRows::Cuisine, @"PlacePageInfoCell"},
|
||||
{MetainfoRows::Operator, @"PlacePageInfoCell"},
|
||||
{MetainfoRows::Coordinate, @"PlacePageInfoCell"},
|
||||
{MetainfoRows::Internet, @"PlacePageInfoCell"},
|
||||
{MetainfoRows::Taxi, @"MWMPlacePageTaxiCell"}};
|
||||
|
||||
array<NSString *, 1> const kButtonsCells = {{@"MWMPlacePageButtonCell"}};
|
||||
|
||||
map<MetainfoRows, Class> const kMetaInfoCells = {
|
||||
{MetainfoRows::Website, [MWMPlacePageLinkCell class]},
|
||||
{MetainfoRows::Address, [MWMPlacePageInfoCell class]},
|
||||
{MetainfoRows::Email, [MWMPlacePageLinkCell class]},
|
||||
{MetainfoRows::Phone, [MWMPlacePageLinkCell class]},
|
||||
{MetainfoRows::Cuisine, [MWMPlacePageInfoCell class]},
|
||||
{MetainfoRows::Operator, [MWMPlacePageInfoCell class]},
|
||||
{MetainfoRows::Coordinate, [MWMPlacePageInfoCell class]},
|
||||
{MetainfoRows::Internet, [MWMPlacePageInfoCell class]},
|
||||
{MetainfoRows::Taxi, [MWMPlacePageTaxiCell class]}};
|
||||
} // namespace
|
||||
|
||||
@interface MWMPlacePageLayout () <UITableViewDataSource,
|
||||
|
@ -99,18 +94,12 @@ array<NSString *, 1> const kButtonsCells = {{@"MWMPlacePageButtonCell"}};
|
|||
- (void)registerCells
|
||||
{
|
||||
auto tv = self.placePageView.tableView;
|
||||
|
||||
[tv registerNib:[UINib nibWithNibName:kButtonsCells[0] bundle:nil]
|
||||
forCellReuseIdentifier:kButtonsCells[0]];
|
||||
[tv registerNib:[UINib nibWithNibName:kBookmarkCells[0] bundle:nil]
|
||||
forCellReuseIdentifier:kBookmarkCells[0]];
|
||||
[tv registerWithCellClass:[MWMPlacePageButtonCell class]];
|
||||
[tv registerWithCellClass:[MWMBookmarkCell class]];
|
||||
|
||||
// Register all meta info cells.
|
||||
for (auto const & pair : kMetaInfoCells)
|
||||
{
|
||||
NSString * name = pair.second;
|
||||
[tv registerNib:[UINib nibWithNibName:name bundle:nil] forCellReuseIdentifier:name];
|
||||
}
|
||||
[tv registerWithCellClass:pair.second];
|
||||
}
|
||||
|
||||
- (void)layoutWithSize:(CGSize const &)size
|
||||
|
@ -314,7 +303,9 @@ array<NSString *, 1> const kButtonsCells = {{@"MWMPlacePageButtonCell"}};
|
|||
}
|
||||
case Sections::Bookmark:
|
||||
{
|
||||
MWMBookmarkCell * c = [tableView dequeueReusableCellWithIdentifier:kBookmarkCells[0]];
|
||||
Class cls = [MWMBookmarkCell class];
|
||||
auto c = static_cast<MWMBookmarkCell *>(
|
||||
[tableView dequeueReusableCellWithCellClass:cls indexPath:indexPath]);
|
||||
[c configureWithText:data.bookmarkDescription
|
||||
updateCellDelegate:self
|
||||
editBookmarkDelegate:delegate
|
||||
|
@ -338,13 +329,17 @@ array<NSString *, 1> const kButtonsCells = {{@"MWMPlacePageButtonCell"}};
|
|||
case MetainfoRows::Internet:
|
||||
case MetainfoRows::Coordinate:
|
||||
{
|
||||
MWMPlacePageInfoCell * c = [tableView dequeueReusableCellWithIdentifier:kMetaInfoCells.at(row)];
|
||||
Class cls = kMetaInfoCells.at(row);
|
||||
auto c = static_cast<MWMPlacePageRegularCell *>(
|
||||
[tableView dequeueReusableCellWithCellClass:cls indexPath:indexPath]);
|
||||
[c configWithRow:row data:data];
|
||||
return c;
|
||||
}
|
||||
case MetainfoRows::Taxi:
|
||||
{
|
||||
MWMPlacePageTaxiCell * c = [tableView dequeueReusableCellWithIdentifier:kMetaInfoCells.at(row)];
|
||||
Class cls = kMetaInfoCells.at(row);
|
||||
auto c = static_cast<MWMPlacePageTaxiCell *>(
|
||||
[tableView dequeueReusableCellWithCellClass:cls indexPath:indexPath]);
|
||||
c.delegate = delegate;
|
||||
return c;
|
||||
}
|
||||
|
@ -352,7 +347,9 @@ array<NSString *, 1> const kButtonsCells = {{@"MWMPlacePageButtonCell"}};
|
|||
}
|
||||
case Sections::Buttons:
|
||||
{
|
||||
MWMPlacePageButtonCell * c = [tableView dequeueReusableCellWithIdentifier:kButtonsCells[0]];
|
||||
Class cls = [MWMPlacePageButtonCell class];
|
||||
auto c = static_cast<MWMPlacePageButtonCell *>(
|
||||
[tableView dequeueReusableCellWithCellClass:cls indexPath:indexPath]);
|
||||
auto const row = data.buttonsRows[indexPath.row];
|
||||
[c configForRow:row withDelegate:delegate];
|
||||
|
||||
|
|
|
@ -1,19 +1,14 @@
|
|||
#import "MWMPPPreviewLayoutHelper.h"
|
||||
#import "MWMCommon.h"
|
||||
#import "MWMDirectionView.h"
|
||||
#import "MWMPlacePageData.h"
|
||||
#import "MWMPPPreviewBannerCell.h"
|
||||
#import "MWMPlacePageData.h"
|
||||
#import "MWMTableViewCell.h"
|
||||
#import "Statistics.h"
|
||||
#import "SwiftBridge.h"
|
||||
|
||||
#include "std/array.hpp"
|
||||
|
||||
namespace
|
||||
{
|
||||
array<NSString *, 8> const kPreviewCells = {{@"_MWMPPPTitle", @"_MWMPPPExternalTitle", @"_MWMPPPSubtitle",
|
||||
@"_MWMPPPSchedule", @"_MWMPPPBooking", @"_MWMPPPAddress", @"_MWMPPPSpace", @"MWMPPPreviewBannerCell"}};
|
||||
} // namespace
|
||||
|
||||
#pragma mark - Base
|
||||
// Base class for avoiding copy-paste in inheriting cells.
|
||||
@interface _MWMPPPCellBase : MWMTableViewCell
|
||||
|
@ -125,6 +120,14 @@ array<NSString *, 8> const kPreviewCells = {{@"_MWMPPPTitle", @"_MWMPPPExternalT
|
|||
@implementation _MWMPPPSpace
|
||||
@end
|
||||
|
||||
namespace
|
||||
{
|
||||
array<Class, 8> const kPreviewCells = {{[_MWMPPPTitle class], [_MWMPPPExternalTitle class],
|
||||
[_MWMPPPSubtitle class], [_MWMPPPSchedule class],
|
||||
[_MWMPPPBooking class], [_MWMPPPAddress class],
|
||||
[_MWMPPPSpace class], [MWMPPPreviewBannerCell class]}};
|
||||
} // namespace
|
||||
|
||||
@interface MWMPPPreviewLayoutHelper ()
|
||||
|
||||
@property(weak, nonatomic) UITableView * tableView;
|
||||
|
@ -160,8 +163,8 @@ array<NSString *, 8> const kPreviewCells = {{@"_MWMPPPTitle", @"_MWMPPPExternalT
|
|||
|
||||
- (void)registerCells
|
||||
{
|
||||
for (auto name : kPreviewCells)
|
||||
[self.tableView registerNib:[UINib nibWithNibName:name bundle:nil] forCellReuseIdentifier:name];
|
||||
for (Class cls : kPreviewCells)
|
||||
[self.tableView registerWithCellClass:cls];
|
||||
}
|
||||
|
||||
- (void)configWithData:(MWMPlacePageData *)data
|
||||
|
@ -180,9 +183,9 @@ array<NSString *, 8> const kPreviewCells = {{@"_MWMPPPTitle", @"_MWMPPPExternalT
|
|||
using namespace place_page;
|
||||
auto tableView = self.tableView;
|
||||
auto const row = data.previewRows[indexPath.row];
|
||||
auto cellName = kPreviewCells[static_cast<size_t>(row)];
|
||||
Class cls = kPreviewCells[static_cast<size_t>(row)];
|
||||
|
||||
auto * c = [tableView dequeueReusableCellWithIdentifier:cellName];
|
||||
auto * c = [tableView dequeueReusableCellWithCellClass:cls indexPath:indexPath];
|
||||
switch(row)
|
||||
{
|
||||
case PreviewRows::Title:
|
||||
|
|
|
@ -1,10 +0,0 @@
|
|||
#import "MWMTableViewCell.h"
|
||||
|
||||
@interface MWMSearchBookmarksCell : MWMTableViewCell
|
||||
|
||||
- (void)configForIndex:(NSInteger)index;
|
||||
|
||||
+ (CGFloat)defaultCellHeight;
|
||||
- (CGFloat)cellHeight;
|
||||
|
||||
@end
|
|
@ -1,91 +0,0 @@
|
|||
#import "BookmarksVC.h"
|
||||
#import "MWMCommon.h"
|
||||
#import "MWMSearchBookmarksCell.h"
|
||||
|
||||
#include "Framework.h"
|
||||
|
||||
@interface MWMSearchBookmarksCell ()
|
||||
|
||||
@property (nonatomic) NSInteger index;
|
||||
@property (nonatomic) BOOL isVisible;
|
||||
@property (nonatomic) NSUInteger count;
|
||||
|
||||
@property (weak, nonatomic) IBOutlet UIButton * visibilityButton;
|
||||
@property (weak, nonatomic) IBOutlet UILabel * titleLabel;
|
||||
@property (weak, nonatomic) IBOutlet UILabel * countLabel;
|
||||
@property (weak, nonatomic) IBOutlet UIImageView * openArrow;
|
||||
|
||||
@end
|
||||
|
||||
@implementation MWMSearchBookmarksCell
|
||||
|
||||
- (void)awakeFromNib
|
||||
{
|
||||
[super awakeFromNib];
|
||||
if (IPAD)
|
||||
self.contentView.backgroundColor = [UIColor white];
|
||||
self.layer.shouldRasterize = YES;
|
||||
self.layer.rasterizationScale = UIScreen.mainScreen.scale;
|
||||
}
|
||||
|
||||
- (void)configForIndex:(NSInteger)index
|
||||
{
|
||||
BookmarkCategory * cat = GetFramework().GetBmCategory(index);
|
||||
self.index = index;
|
||||
self.isVisible = cat->IsVisible();
|
||||
size_t userMarksCount = 0;
|
||||
{
|
||||
BookmarkCategory::Guard guard(*cat);
|
||||
userMarksCount = guard.m_controller.GetUserMarkCount();
|
||||
}
|
||||
self.count = userMarksCount + cat->GetTracksCount();
|
||||
self.titleLabel.text = @(cat->GetName().c_str());
|
||||
}
|
||||
|
||||
- (IBAction)toggleVisibility
|
||||
{
|
||||
self.isVisible = !self.isVisible;
|
||||
BookmarkCategory * cat = GetFramework().GetBmCategory(self.index);
|
||||
{
|
||||
BookmarkCategory::Guard guard(*cat);
|
||||
guard.m_controller.SetIsVisible(self.isVisible);
|
||||
}
|
||||
cat->SaveToKMLFile();
|
||||
}
|
||||
|
||||
- (IBAction)openBookmarks
|
||||
{
|
||||
BookmarksVC * bvc = [[BookmarksVC alloc] initWithCategory:self.index];
|
||||
UINavigationController * rootVC = (UINavigationController *)UIApplication.sharedApplication.delegate.window.rootViewController;
|
||||
[rootVC pushViewController:bvc animated:YES];
|
||||
}
|
||||
|
||||
- (void)setTitle:(NSString *)title
|
||||
{
|
||||
self.titleLabel.text = title;
|
||||
}
|
||||
|
||||
+ (CGFloat)defaultCellHeight
|
||||
{
|
||||
return 44.0;
|
||||
}
|
||||
|
||||
- (CGFloat)cellHeight
|
||||
{
|
||||
return ceil([self.contentView systemLayoutSizeFittingSize:UILayoutFittingCompressedSize].height);
|
||||
}
|
||||
|
||||
#pragma mark - Properties
|
||||
|
||||
- (void)setIsVisible:(BOOL)isVisible
|
||||
{
|
||||
_isVisible = self.visibilityButton.selected = isVisible;
|
||||
}
|
||||
|
||||
- (void)setCount:(NSUInteger)count
|
||||
{
|
||||
_count = count;
|
||||
self.countLabel.text = @(count).stringValue;
|
||||
}
|
||||
|
||||
@end
|
|
@ -1,125 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="10117" systemVersion="15G31" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES">
|
||||
<dependencies>
|
||||
<deployment identifier="iOS"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="10085"/>
|
||||
</dependencies>
|
||||
<objects>
|
||||
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner"/>
|
||||
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
|
||||
<tableViewCell contentMode="scaleToFill" selectionStyle="none" indentationWidth="10" reuseIdentifier="MWMSearchBookmarksCell" id="KGk-i7-Jjw" customClass="MWMSearchBookmarksCell">
|
||||
<rect key="frame" x="0.0" y="0.0" width="320" height="44"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
|
||||
<tableViewCellContentView key="contentView" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="KGk-i7-Jjw" id="H2p-sc-9uM">
|
||||
<rect key="frame" x="0.0" y="0.0" width="320" height="43"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<subviews>
|
||||
<button opaque="NO" contentMode="center" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="aNc-6m-i8r" userLabel="VisibilityButton" customClass="MWMButton">
|
||||
<rect key="frame" x="0.0" y="0.0" width="60" height="44"/>
|
||||
<constraints>
|
||||
<constraint firstAttribute="width" constant="60" id="g2n-JI-FYq"/>
|
||||
</constraints>
|
||||
<state key="normal" image="ic_hide">
|
||||
<color key="titleShadowColor" white="0.5" alpha="1" colorSpace="calibratedWhite"/>
|
||||
</state>
|
||||
<state key="selected" image="ic_show"/>
|
||||
<userDefinedRuntimeAttributes>
|
||||
<userDefinedRuntimeAttribute type="string" keyPath="coloringName" value="MWMBlack"/>
|
||||
</userDefinedRuntimeAttributes>
|
||||
<connections>
|
||||
<action selector="toggleVisibility" destination="KGk-i7-Jjw" eventType="touchUpInside" id="kEx-DN-uuu"/>
|
||||
</connections>
|
||||
</button>
|
||||
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="My Places" textAlignment="natural" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" preferredMaxLayoutWidth="180" translatesAutoresizingMaskIntoConstraints="NO" id="C8a-9A-ijG" userLabel="Title">
|
||||
<rect key="frame" x="60" y="12" width="180" height="20"/>
|
||||
<fontDescription key="fontDescription" name="HelveticaNeue" family="Helvetica Neue" pointSize="17"/>
|
||||
<color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="calibratedRGB"/>
|
||||
<nil key="highlightedColor"/>
|
||||
<userDefinedRuntimeAttributes>
|
||||
<userDefinedRuntimeAttribute type="string" keyPath="fontName" value="regular17"/>
|
||||
<userDefinedRuntimeAttribute type="string" keyPath="colorName" value="blackPrimaryText"/>
|
||||
</userDefinedRuntimeAttributes>
|
||||
</label>
|
||||
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="jI8-wj-W4t" userLabel="Separator">
|
||||
<rect key="frame" x="60" y="43" width="260" height="1"/>
|
||||
<color key="backgroundColor" red="0.0" green="0.0" blue="0.0" alpha="0.12" colorSpace="calibratedRGB"/>
|
||||
<constraints>
|
||||
<constraint firstAttribute="height" constant="1" id="CQ9-Xa-g1C"/>
|
||||
</constraints>
|
||||
<userDefinedRuntimeAttributes>
|
||||
<userDefinedRuntimeAttribute type="string" keyPath="backgroundColorName" value="blackDividers"/>
|
||||
</userDefinedRuntimeAttributes>
|
||||
</view>
|
||||
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="3" textAlignment="right" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="5ca-Zu-8k4" userLabel="BookmarksCount">
|
||||
<rect key="frame" x="244" y="14" width="40" height="16"/>
|
||||
<constraints>
|
||||
<constraint firstAttribute="width" constant="40" id="5tD-8h-iTV"/>
|
||||
<constraint firstAttribute="height" constant="16" id="Ees-st-iT9"/>
|
||||
</constraints>
|
||||
<fontDescription key="fontDescription" name="HelveticaNeue" family="Helvetica Neue" pointSize="14"/>
|
||||
<color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="0.54000000000000004" colorSpace="calibratedRGB"/>
|
||||
<nil key="highlightedColor"/>
|
||||
<userDefinedRuntimeAttributes>
|
||||
<userDefinedRuntimeAttribute type="string" keyPath="fontName" value="regular17"/>
|
||||
<userDefinedRuntimeAttribute type="string" keyPath="colorName" value="blackSecondaryText"/>
|
||||
</userDefinedRuntimeAttributes>
|
||||
</label>
|
||||
<imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="ic_carrot" translatesAutoresizingMaskIntoConstraints="NO" id="obB-B0-hzq" userLabel="OpenArrow">
|
||||
<rect key="frame" x="284" y="8" width="28" height="28"/>
|
||||
<constraints>
|
||||
<constraint firstAttribute="height" constant="28" id="G3F-hb-qym"/>
|
||||
<constraint firstAttribute="width" constant="28" id="c9g-F6-qp8"/>
|
||||
</constraints>
|
||||
<userDefinedRuntimeAttributes>
|
||||
<userDefinedRuntimeAttribute type="boolean" keyPath="MWMBlack" value="YES"/>
|
||||
</userDefinedRuntimeAttributes>
|
||||
</imageView>
|
||||
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="oya-sL-CmM" userLabel="OpenButton">
|
||||
<rect key="frame" x="60" y="0.0" width="260" height="43"/>
|
||||
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
|
||||
<state key="normal">
|
||||
<color key="titleShadowColor" white="0.5" alpha="1" colorSpace="calibratedWhite"/>
|
||||
</state>
|
||||
<connections>
|
||||
<action selector="openBookmarks" destination="KGk-i7-Jjw" eventType="touchUpInside" id="ZFR-Zb-STa"/>
|
||||
</connections>
|
||||
</button>
|
||||
</subviews>
|
||||
<constraints>
|
||||
<constraint firstAttribute="bottom" secondItem="aNc-6m-i8r" secondAttribute="bottom" id="7An-wA-kIp"/>
|
||||
<constraint firstItem="5ca-Zu-8k4" firstAttribute="leading" secondItem="C8a-9A-ijG" secondAttribute="trailing" constant="4" id="A9e-7h-xhc"/>
|
||||
<constraint firstItem="obB-B0-hzq" firstAttribute="leading" secondItem="5ca-Zu-8k4" secondAttribute="trailing" id="MLa-5I-VK8"/>
|
||||
<constraint firstAttribute="centerY" secondItem="5ca-Zu-8k4" secondAttribute="centerY" id="PvB-UY-BHT"/>
|
||||
<constraint firstItem="C8a-9A-ijG" firstAttribute="top" secondItem="H2p-sc-9uM" secondAttribute="top" constant="12" id="RQK-Vh-9QV"/>
|
||||
<constraint firstAttribute="centerY" secondItem="obB-B0-hzq" secondAttribute="centerY" id="RsM-af-CzV"/>
|
||||
<constraint firstItem="jI8-wj-W4t" firstAttribute="top" secondItem="oya-sL-CmM" secondAttribute="bottom" id="SMP-Xq-yYT"/>
|
||||
<constraint firstItem="jI8-wj-W4t" firstAttribute="leading" secondItem="C8a-9A-ijG" secondAttribute="leading" id="Tw3-pC-BHB"/>
|
||||
<constraint firstAttribute="trailing" secondItem="obB-B0-hzq" secondAttribute="trailing" constant="8" id="URM-GC-wU3"/>
|
||||
<constraint firstItem="jI8-wj-W4t" firstAttribute="leading" secondItem="oya-sL-CmM" secondAttribute="leading" id="UpO-nL-Km5"/>
|
||||
<constraint firstAttribute="trailing" secondItem="jI8-wj-W4t" secondAttribute="trailing" id="a3j-02-ixe"/>
|
||||
<constraint firstItem="oya-sL-CmM" firstAttribute="top" secondItem="H2p-sc-9uM" secondAttribute="top" id="dPf-Hy-Y5t"/>
|
||||
<constraint firstAttribute="trailing" secondItem="oya-sL-CmM" secondAttribute="trailing" id="lIR-Mi-9dY"/>
|
||||
<constraint firstAttribute="bottom" secondItem="jI8-wj-W4t" secondAttribute="bottom" id="ozZ-bY-T8b"/>
|
||||
<constraint firstItem="aNc-6m-i8r" firstAttribute="leading" secondItem="H2p-sc-9uM" secondAttribute="leading" id="rPE-bc-2W5"/>
|
||||
<constraint firstItem="oya-sL-CmM" firstAttribute="leading" secondItem="aNc-6m-i8r" secondAttribute="trailing" id="tlg-eC-xfe"/>
|
||||
<constraint firstAttribute="bottom" secondItem="C8a-9A-ijG" secondAttribute="bottom" constant="12" id="uqy-Ik-W0e"/>
|
||||
<constraint firstItem="aNc-6m-i8r" firstAttribute="top" secondItem="H2p-sc-9uM" secondAttribute="top" id="xpT-y7-ntU"/>
|
||||
</constraints>
|
||||
</tableViewCellContentView>
|
||||
<userDefinedRuntimeAttributes>
|
||||
<userDefinedRuntimeAttribute type="string" keyPath="backgroundColorName" value="white"/>
|
||||
</userDefinedRuntimeAttributes>
|
||||
<connections>
|
||||
<outlet property="countLabel" destination="5ca-Zu-8k4" id="USR-pA-xLd"/>
|
||||
<outlet property="openArrow" destination="obB-B0-hzq" id="IMl-hQ-e7y"/>
|
||||
<outlet property="titleLabel" destination="C8a-9A-ijG" id="XUf-wc-IPr"/>
|
||||
<outlet property="visibilityButton" destination="aNc-6m-i8r" id="YkK-Ai-2cV"/>
|
||||
</connections>
|
||||
</tableViewCell>
|
||||
</objects>
|
||||
<resources>
|
||||
<image name="ic_carrot" width="28" height="28"/>
|
||||
<image name="ic_hide" width="28" height="28"/>
|
||||
<image name="ic_show" width="28" height="28"/>
|
||||
</resources>
|
||||
</document>
|
|
@ -1,10 +0,0 @@
|
|||
#import "MWMSearchTabbedCollectionViewCell.h"
|
||||
#import "MWMSearchTabbedViewProtocol.h"
|
||||
|
||||
@interface MWMSearchBookmarksManager : NSObject <UITableViewDataSource, UITableViewDelegate>
|
||||
|
||||
@property (weak, nonatomic) id<MWMSearchTabbedViewProtocol> delegate;
|
||||
|
||||
- (void)attachCell:(MWMSearchTabbedCollectionViewCell *)cell;
|
||||
|
||||
@end
|
|
@ -1,120 +0,0 @@
|
|||
#import "MWMSearchBookmarksManager.h"
|
||||
#import "MWMSearchBookmarksCell.h"
|
||||
#import "MWMSearchNoResults.h"
|
||||
|
||||
#include "Framework.h"
|
||||
|
||||
extern NSString * const kBookmarksChangedNotification;
|
||||
|
||||
static NSString * const kBookmarksCellIdentifier = @"MWMSearchBookmarksCell";
|
||||
|
||||
@interface MWMSearchBookmarksManager ()
|
||||
|
||||
@property(weak, nonatomic) MWMSearchTabbedCollectionViewCell * cell;
|
||||
|
||||
@property(nonatomic) MWMSearchBookmarksCell * sizingCell;
|
||||
@property(nonatomic) MWMSearchNoResults * noResultsView;
|
||||
|
||||
@end
|
||||
|
||||
@implementation MWMSearchBookmarksManager
|
||||
|
||||
- (instancetype)init
|
||||
{
|
||||
self = [super init];
|
||||
if (self)
|
||||
{
|
||||
[NSNotificationCenter.defaultCenter addObserver:self
|
||||
selector:@selector(updateCell)
|
||||
name:kBookmarksChangedNotification
|
||||
object:nil];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)dealloc { [NSNotificationCenter.defaultCenter removeObserver:self]; }
|
||||
- (void)attachCell:(MWMSearchTabbedCollectionViewCell *)cell
|
||||
{
|
||||
self.cell = cell;
|
||||
[self updateCell];
|
||||
}
|
||||
|
||||
- (void)updateCell
|
||||
{
|
||||
MWMSearchTabbedCollectionViewCell * cell = self.cell;
|
||||
if (!cell)
|
||||
return;
|
||||
if (GetFramework().GetBmCategoriesCount() > 0)
|
||||
{
|
||||
[cell removeNoResultsView];
|
||||
UITableView * tableView = cell.tableView;
|
||||
tableView.hidden = NO;
|
||||
tableView.delegate = self;
|
||||
tableView.dataSource = self;
|
||||
[tableView registerNib:[UINib nibWithNibName:kBookmarksCellIdentifier bundle:nil]
|
||||
forCellReuseIdentifier:kBookmarksCellIdentifier];
|
||||
[tableView reloadData];
|
||||
}
|
||||
else
|
||||
{
|
||||
cell.tableView.hidden = YES;
|
||||
[cell addNoResultsView:self.noResultsView];
|
||||
}
|
||||
}
|
||||
|
||||
#pragma mark - UITableViewDataSource
|
||||
|
||||
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
|
||||
{
|
||||
return GetFramework().GetBmCategoriesCount();
|
||||
}
|
||||
|
||||
- (UITableViewCell *)tableView:(UITableView *)tableView
|
||||
cellForRowAtIndexPath:(NSIndexPath *)indexPath
|
||||
{
|
||||
UITableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:kBookmarksCellIdentifier];
|
||||
return cell;
|
||||
}
|
||||
|
||||
#pragma mark - UITableViewDelegate
|
||||
|
||||
- (CGFloat)tableView:(UITableView *)tableView
|
||||
estimatedHeightForRowAtIndexPath:(NSIndexPath *)indexPath
|
||||
{
|
||||
return MWMSearchBookmarksCell.defaultCellHeight;
|
||||
}
|
||||
|
||||
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
|
||||
{
|
||||
[self.sizingCell configForIndex:indexPath.row];
|
||||
return self.sizingCell.cellHeight;
|
||||
}
|
||||
|
||||
- (void)tableView:(UITableView *)tableView
|
||||
willDisplayCell:(MWMSearchBookmarksCell *)cell
|
||||
forRowAtIndexPath:(NSIndexPath *)indexPath
|
||||
{
|
||||
[cell configForIndex:indexPath.row];
|
||||
}
|
||||
|
||||
#pragma mark - Properties
|
||||
|
||||
- (MWMSearchBookmarksCell *)sizingCell
|
||||
{
|
||||
if (!_sizingCell)
|
||||
_sizingCell = [self.cell.tableView dequeueReusableCellWithIdentifier:kBookmarksCellIdentifier];
|
||||
return _sizingCell;
|
||||
}
|
||||
|
||||
- (MWMSearchNoResults *)noResultsView
|
||||
{
|
||||
if (!_noResultsView)
|
||||
{
|
||||
_noResultsView = [MWMSearchNoResults viewWithImage:[UIImage imageNamed:@"img_bookmarks"]
|
||||
title:L(@"search_bookmarks_no_results_title")
|
||||
text:L(@"search_bookmarks_no_results_text")];
|
||||
}
|
||||
return _noResultsView;
|
||||
}
|
||||
|
||||
@end
|
|
@ -2,13 +2,12 @@
|
|||
#import "AppInfo.h"
|
||||
#import "MWMSearchCategoryCell.h"
|
||||
#import "Statistics.h"
|
||||
#import "SwiftBridge.h"
|
||||
|
||||
#include "search/displayed_categories.hpp"
|
||||
|
||||
#include "base/macros.hpp"
|
||||
|
||||
static NSString * const kCellIdentifier = @"MWMSearchCategoryCell";
|
||||
|
||||
@implementation MWMSearchCategoriesManager
|
||||
{
|
||||
vector<string> m_categories;
|
||||
|
@ -32,8 +31,7 @@ static NSString * const kCellIdentifier = @"MWMSearchCategoryCell";
|
|||
tableView.hidden = NO;
|
||||
tableView.delegate = self;
|
||||
tableView.dataSource = self;
|
||||
[tableView registerNib:[UINib nibWithNibName:kCellIdentifier bundle:nil]
|
||||
forCellReuseIdentifier:kCellIdentifier];
|
||||
[tableView registerWithCellClass:[MWMSearchCategoryCell class]];
|
||||
[tableView reloadData];
|
||||
}
|
||||
|
||||
|
@ -47,7 +45,9 @@ static NSString * const kCellIdentifier = @"MWMSearchCategoryCell";
|
|||
- (UITableViewCell *)tableView:(UITableView *)tableView
|
||||
cellForRowAtIndexPath:(NSIndexPath *)indexPath
|
||||
{
|
||||
auto tCell = static_cast<MWMSearchCategoryCell *>([tableView dequeueReusableCellWithIdentifier:kCellIdentifier]);
|
||||
auto tCell = static_cast<MWMSearchCategoryCell *>([tableView
|
||||
dequeueReusableCellWithCellClass:[MWMSearchCategoryCell class]
|
||||
indexPath:indexPath]);
|
||||
[tCell setCategory:@(m_categories[indexPath.row].c_str())];
|
||||
return tCell;
|
||||
}
|
||||
|
|
|
@ -7,13 +7,10 @@
|
|||
#import "MWMSearchNoResults.h"
|
||||
#import "MapsAppDelegate.h"
|
||||
#import "Statistics.h"
|
||||
#import "SwiftBridge.h"
|
||||
|
||||
#include "Framework.h"
|
||||
|
||||
static NSString * const kRequestCellIdentifier = @"MWMSearchHistoryRequestCell";
|
||||
static NSString * const kClearCellIdentifier = @"MWMSearchHistoryClearCell";
|
||||
static NSString * const kMyPositionCellIdentifier = @"MWMSearchHistoryMyPositionCell";
|
||||
|
||||
@interface MWMSearchHistoryManager ()
|
||||
|
||||
@property(weak, nonatomic) MWMSearchTabbedCollectionViewCell * cell;
|
||||
|
@ -51,15 +48,10 @@ static NSString * const kMyPositionCellIdentifier = @"MWMSearchHistoryMyPosition
|
|||
tableView.hidden = NO;
|
||||
tableView.delegate = self;
|
||||
tableView.dataSource = self;
|
||||
[tableView registerNib:[UINib nibWithNibName:kRequestCellIdentifier bundle:nil]
|
||||
forCellReuseIdentifier:kRequestCellIdentifier];
|
||||
[tableView registerNib:[UINib nibWithNibName:kClearCellIdentifier bundle:nil]
|
||||
forCellReuseIdentifier:kClearCellIdentifier];
|
||||
[tableView registerWithCellClass:[MWMSearchHistoryRequestCell class]];
|
||||
[tableView registerWithCellClass:[MWMSearchHistoryClearCell class]];
|
||||
if (isRouteSearch)
|
||||
{
|
||||
[tableView registerNib:[UINib nibWithNibName:kMyPositionCellIdentifier bundle:nil]
|
||||
forCellReuseIdentifier:kMyPositionCellIdentifier];
|
||||
}
|
||||
[tableView registerWithCellClass:[MWMSearchHistoryMyPositionCell class]];
|
||||
[tableView reloadData];
|
||||
}
|
||||
}
|
||||
|
@ -98,14 +90,15 @@ static NSString * const kMyPositionCellIdentifier = @"MWMSearchHistoryMyPosition
|
|||
{
|
||||
if ([self isRequestCell:indexPath])
|
||||
{
|
||||
auto tCell = static_cast<MWMSearchHistoryRequestCell *>([tableView dequeueReusableCellWithIdentifier:kRequestCellIdentifier]);
|
||||
auto tCell = static_cast<MWMSearchHistoryRequestCell *>([tableView
|
||||
dequeueReusableCellWithCellClass:[MWMSearchHistoryRequestCell class]
|
||||
indexPath:indexPath]);
|
||||
[tCell config:[self stringAtIndex:indexPath.row]];
|
||||
return tCell;
|
||||
}
|
||||
UITableViewCell * cell = [tableView
|
||||
dequeueReusableCellWithIdentifier:self.isRouteSearchMode ? kMyPositionCellIdentifier
|
||||
: kClearCellIdentifier];
|
||||
return cell;
|
||||
Class cls = self.isRouteSearchMode ? [MWMSearchHistoryMyPositionCell class]
|
||||
: [MWMSearchHistoryClearCell class];
|
||||
return [tableView dequeueReusableCellWithCellClass:cls indexPath:indexPath];
|
||||
}
|
||||
|
||||
#pragma mark - UITableViewDelegate
|
||||
|
|
|
@ -6,12 +6,12 @@
|
|||
#import "MWMSearchTabbedViewLayout.h"
|
||||
#import "MWMSearchTabbedViewProtocol.h"
|
||||
#import "Statistics.h"
|
||||
#import "SwiftBridge.h"
|
||||
|
||||
#include "Framework.h"
|
||||
|
||||
namespace
|
||||
{
|
||||
NSString * const kCollectionCell = @"MWMSearchTabbedCollectionViewCell";
|
||||
NSString * const kSelectedButtonTagKey = @"MWMSearchTabbedCollectionViewSelectedButtonTag";
|
||||
} // namespace
|
||||
|
||||
|
@ -104,8 +104,7 @@ BOOL isOffsetInButton(CGFloat offset, MWMSearchTabButtonsView * button)
|
|||
|
||||
- (void)setupCollectionView
|
||||
{
|
||||
[self.tablesCollectionView registerNib:[UINib nibWithNibName:kCollectionCell bundle:nil]
|
||||
forCellWithReuseIdentifier:kCollectionCell];
|
||||
[self.tablesCollectionView registerWithCellClass:[MWMSearchTabbedCollectionViewCell class]];
|
||||
((MWMSearchTabbedViewLayout *)self.tablesCollectionView.collectionViewLayout).tablesCount =
|
||||
MWMSearchTabbedViewCellCount;
|
||||
}
|
||||
|
@ -178,9 +177,9 @@ BOOL isOffsetInButton(CGFloat offset, MWMSearchTabButtonsView * button)
|
|||
- (nonnull UICollectionViewCell *)collectionView:(nonnull UICollectionView *)collectionView
|
||||
cellForItemAtIndexPath:(nonnull NSIndexPath *)indexPath
|
||||
{
|
||||
MWMSearchTabbedCollectionViewCell * cell =
|
||||
[collectionView dequeueReusableCellWithReuseIdentifier:kCollectionCell
|
||||
forIndexPath:indexPath];
|
||||
auto cell = static_cast<MWMSearchTabbedCollectionViewCell *>([collectionView
|
||||
dequeueReusableCellWithCellClass:[MWMSearchTabbedCollectionViewCell class]
|
||||
indexPath:indexPath]);
|
||||
MWMSearchTabbedViewCell cellType = static_cast<MWMSearchTabbedViewCell>(indexPath.item);
|
||||
switch (cellType)
|
||||
{
|
||||
|
|
|
@ -6,33 +6,12 @@
|
|||
#import "MWMSearchTableView.h"
|
||||
#import "MapsAppDelegate.h"
|
||||
#import "Statistics.h"
|
||||
|
||||
static NSString * const kTableSuggestionCell = @"MWMSearchSuggestionCell";
|
||||
static NSString * const kTableCommonCell = @"MWMSearchCommonCell";
|
||||
|
||||
namespace
|
||||
{
|
||||
typedef NS_ENUM(NSUInteger, MWMSearchTableCellType) {
|
||||
MWMSearchTableCellTypeSuggestion,
|
||||
MWMSearchTableCellTypeCommon
|
||||
};
|
||||
|
||||
NSString * identifierForType(MWMSearchTableCellType type)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case MWMSearchTableCellTypeSuggestion: return kTableSuggestionCell;
|
||||
case MWMSearchTableCellTypeCommon: return kTableCommonCell;
|
||||
}
|
||||
}
|
||||
} // namespace
|
||||
#import "SwiftBridge.h"
|
||||
|
||||
@interface MWMSearchTableViewController ()<UITableViewDataSource, UITableViewDelegate>
|
||||
|
||||
@property(weak, nonatomic) IBOutlet UITableView * tableView;
|
||||
|
||||
@property(nonatomic) MWMSearchCommonCell * commonSizingCell;
|
||||
|
||||
@property(weak, nonatomic) id<MWMSearchTableViewProtocol> delegate;
|
||||
|
||||
@end
|
||||
|
@ -67,19 +46,16 @@ NSString * identifierForType(MWMSearchTableCellType type)
|
|||
UITableView * tableView = self.tableView;
|
||||
tableView.estimatedRowHeight = 80.;
|
||||
tableView.rowHeight = UITableViewAutomaticDimension;
|
||||
|
||||
[tableView registerNib:[UINib nibWithNibName:kTableSuggestionCell bundle:nil]
|
||||
forCellReuseIdentifier:kTableSuggestionCell];
|
||||
[tableView registerNib:[UINib nibWithNibName:kTableCommonCell bundle:nil]
|
||||
forCellReuseIdentifier:kTableCommonCell];
|
||||
[tableView registerWithCellClass:[MWMSearchSuggestionCell class]];
|
||||
[tableView registerWithCellClass:[MWMSearchCommonCell class]];
|
||||
}
|
||||
|
||||
- (MWMSearchTableCellType)cellTypeForIndexPath:(NSIndexPath *)indexPath
|
||||
- (Class)cellClassForIndexPath:(NSIndexPath *)indexPath
|
||||
{
|
||||
size_t const numSuggests = [MWMSearch suggestionsCount];
|
||||
if (numSuggests > 0 && indexPath.row < numSuggests)
|
||||
return MWMSearchTableCellTypeSuggestion;
|
||||
return MWMSearchTableCellTypeCommon;
|
||||
return [MWMSearchSuggestionCell class];
|
||||
return [MWMSearchCommonCell class];
|
||||
}
|
||||
|
||||
- (search::Result const &)searchResultForIndexPath:(NSIndexPath *)indexPath
|
||||
|
@ -110,49 +86,37 @@ NSString * identifierForType(MWMSearchTableCellType type)
|
|||
- (UITableViewCell *)tableView:(UITableView *)tableView
|
||||
cellForRowAtIndexPath:(NSIndexPath *)indexPath
|
||||
{
|
||||
MWMSearchTableCellType const cellType = [self cellTypeForIndexPath:indexPath];
|
||||
UITableViewCell * cell =
|
||||
[tableView dequeueReusableCellWithIdentifier:identifierForType(cellType)];
|
||||
switch (cellType)
|
||||
Class cls = [self cellClassForIndexPath:indexPath];
|
||||
auto cell = [tableView dequeueReusableCellWithCellClass:cls indexPath:indexPath];
|
||||
if (cls == [MWMSearchSuggestionCell class])
|
||||
{
|
||||
case MWMSearchTableCellTypeSuggestion:
|
||||
[self configSuggestionCell:(MWMSearchSuggestionCell *)cell
|
||||
result:[self searchResultForIndexPath:indexPath]
|
||||
isLastCell:indexPath.row == [MWMSearch suggestionsCount] - 1];
|
||||
break;
|
||||
case MWMSearchTableCellTypeCommon:
|
||||
[(MWMSearchCommonCell *)cell config:[self searchResultForIndexPath:indexPath]];
|
||||
break;
|
||||
auto tCell = static_cast<MWMSearchSuggestionCell *>(cell);
|
||||
[tCell config:[self searchResultForIndexPath:indexPath]];
|
||||
tCell.isLastCell = indexPath.row == [MWMSearch suggestionsCount] - 1;
|
||||
}
|
||||
else if (cls == [MWMSearchCommonCell class])
|
||||
{
|
||||
auto tCell = static_cast<MWMSearchCommonCell *>(cell);
|
||||
[tCell config:[self searchResultForIndexPath:indexPath]];
|
||||
}
|
||||
|
||||
return cell;
|
||||
}
|
||||
|
||||
#pragma mark - Config cells
|
||||
|
||||
- (void)configSuggestionCell:(MWMSearchSuggestionCell *)cell
|
||||
result:(search::Result const &)result
|
||||
isLastCell:(BOOL)isLastCell
|
||||
{
|
||||
[cell config:result];
|
||||
cell.isLastCell = isLastCell;
|
||||
}
|
||||
|
||||
#pragma mark - UITableViewDelegate
|
||||
|
||||
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
|
||||
{
|
||||
MWMSearchTableCellType cellType = [self cellTypeForIndexPath:indexPath];
|
||||
Class cls = [self cellClassForIndexPath:indexPath];
|
||||
id<MWMSearchTableViewProtocol> delegate = self.delegate;
|
||||
search::Result const & result = [self searchResultForIndexPath:indexPath];
|
||||
if (cellType == MWMSearchTableCellTypeSuggestion)
|
||||
if (cls == [MWMSearchSuggestionCell class])
|
||||
{
|
||||
NSString * suggestionString = @(result.GetSuggestionString());
|
||||
[Statistics logEvent:kStatEventName(kStatSearch, kStatSelectResult)
|
||||
withParameters:@{kStatValue : suggestionString, kStatScreen : kStatSearch}];
|
||||
[delegate searchText:suggestionString forInputLocale:nil];
|
||||
}
|
||||
else
|
||||
else if (cls == [MWMSearchCommonCell class])
|
||||
{
|
||||
MWMSearchTextField * textField = delegate.searchTextField;
|
||||
[MWMSearch saveQuery:textField.text forInputLocale:textField.textInputMode.primaryLanguage];
|
||||
|
@ -174,17 +138,7 @@ NSString * identifierForType(MWMSearchTableCellType type)
|
|||
if (!IPAD && [MWMSearch isSearchOnMap])
|
||||
return;
|
||||
|
||||
self.commonSizingCell = nil;
|
||||
[self reloadData];
|
||||
}
|
||||
|
||||
#pragma mark - Properties
|
||||
|
||||
- (MWMSearchCommonCell *)commonSizingCell
|
||||
{
|
||||
if (!_commonSizingCell)
|
||||
_commonSizingCell = [self.tableView dequeueReusableCellWithIdentifier:kTableCommonCell];
|
||||
return _commonSizingCell;
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
|
@ -34,9 +34,9 @@ static NSString * const kUnwingSegueIdentifier = @"UnwindToTTSSettings";
|
|||
- (UITableViewCell *)tableView:(UITableView *)tableView
|
||||
cellForRowAtIndexPath:(NSIndexPath *)indexPath
|
||||
{
|
||||
auto cellId = [SettingsTableViewSelectableCell cellId];
|
||||
Class cls = [SettingsTableViewSelectableCell class];
|
||||
auto cell = static_cast<SettingsTableViewSelectableCell *>(
|
||||
[tableView dequeueReusableCellWithIdentifier:cellId]);
|
||||
[tableView dequeueReusableCellWithCellClass:cls indexPath:indexPath]);
|
||||
[cell
|
||||
configWithTitle:@([[MWMTextToSpeech tts] availableLanguages][indexPath.row].second.c_str())];
|
||||
return cell;
|
||||
|
|
|
@ -108,9 +108,9 @@ using namespace locale_translator;
|
|||
{
|
||||
if (indexPath.row == 0)
|
||||
{
|
||||
auto cellId = [SettingsTableViewSelectableCell cellId];
|
||||
Class cls = [SettingsTableViewSelectableCell class];
|
||||
auto cell = static_cast<SettingsTableViewSelectableCell *>(
|
||||
[tableView dequeueReusableCellWithIdentifier:cellId]);
|
||||
[tableView dequeueReusableCellWithCellClass:cls indexPath:indexPath]);
|
||||
[cell configWithTitle:L(@"duration_disabled")];
|
||||
cell.accessoryType = [MWMTextToSpeech isTTSEnabled] ? UITableViewCellAccessoryNone
|
||||
: UITableViewCellAccessoryCheckmark;
|
||||
|
@ -121,17 +121,17 @@ using namespace locale_translator;
|
|||
NSInteger const row = indexPath.row - 1;
|
||||
if (row == _languages.size())
|
||||
{
|
||||
auto cellId = [SettingsTableViewLinkCell cellId];
|
||||
Class cls = [SettingsTableViewLinkCell class];
|
||||
auto cell = static_cast<SettingsTableViewLinkCell *>(
|
||||
[tableView dequeueReusableCellWithIdentifier:cellId]);
|
||||
[tableView dequeueReusableCellWithCellClass:cls indexPath:indexPath]);
|
||||
[cell configWithTitle:L(@"pref_tts_other_section_title") info:nil];
|
||||
return cell;
|
||||
}
|
||||
else
|
||||
{
|
||||
auto cellId = [SettingsTableViewSelectableCell cellId];
|
||||
Class cls = [SettingsTableViewSelectableCell class];
|
||||
auto cell = static_cast<SettingsTableViewSelectableCell *>(
|
||||
[tableView dequeueReusableCellWithIdentifier:cellId]);
|
||||
[tableView dequeueReusableCellWithCellClass:cls indexPath:indexPath]);
|
||||
pair<string, string> const p = _languages[row];
|
||||
[cell configWithTitle:@(p.second.c_str())];
|
||||
BOOL const isSelected =
|
||||
|
@ -145,9 +145,9 @@ using namespace locale_translator;
|
|||
}
|
||||
else
|
||||
{
|
||||
auto cellId = [SettingsTableViewLinkCell cellId];
|
||||
Class cls = [SettingsTableViewLinkCell class];
|
||||
auto cell = static_cast<SettingsTableViewLinkCell *>(
|
||||
[tableView dequeueReusableCellWithIdentifier:cellId]);
|
||||
[tableView dequeueReusableCellWithCellClass:cls indexPath:indexPath]);
|
||||
[cell configWithTitle:L(@"pref_tts_how_to_set_up_voice") info:nil];
|
||||
return cell;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue