Repo created

This commit is contained in:
Fr4nz D13trich 2025-11-22 13:58:55 +01:00
parent 4af19165ec
commit 68073add76
12458 changed files with 12350765 additions and 2 deletions

View file

@ -0,0 +1,17 @@
#import "MWMTableViewController.h"
#include "indexer/editable_map_object.hpp"
@protocol MWMEditorAdditionalNamesProtocol <NSObject>
- (void)addAdditionalName:(NSInteger)languageIndex;
@end
@interface MWMEditorAdditionalNamesTableViewController : MWMTableViewController
- (void)configWithDelegate:(id<MWMEditorAdditionalNamesProtocol>)delegate
name:(StringUtf8Multilang const &)name
additionalSkipLanguageCodes:(std::vector<NSInteger>)additionalSkipLanguageCodes;
@end

View file

@ -0,0 +1,93 @@
#import "MWMEditorAdditionalNamesTableViewController.h"
#import "MWMTableViewCell.h"
#import <CoreApi/StringUtils.h>
@interface MWMEditorAdditionalNamesTableViewController ()
@property (weak, nonatomic) id<MWMEditorAdditionalNamesProtocol> delegate;
@end
@implementation MWMEditorAdditionalNamesTableViewController
{
StringUtf8Multilang m_name;
std::vector<StringUtf8Multilang::Lang> m_languages;
std::vector<NSInteger> m_additionalSkipLanguageCodes;
}
#pragma mark - UITableViewDataSource
- (void)configWithDelegate:(id<MWMEditorAdditionalNamesProtocol>)delegate
name:(StringUtf8Multilang const &)name
additionalSkipLanguageCodes:(std::vector<NSInteger>)additionalSkipLanguageCodes
{
self.delegate = delegate;
m_name = name;
m_additionalSkipLanguageCodes = additionalSkipLanguageCodes;
}
- (void)viewDidLoad
{
[super viewDidLoad];
self.title = L(@"choose_language");
}
- (void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
auto const getIndex = [](std::string_view lang) { return StringUtf8Multilang::GetLangIndex(lang); };
StringUtf8Multilang::Languages const & supportedLanguages = StringUtf8Multilang::GetSupportedLanguages();
m_languages.clear();
auto constexpr kDefaultCode = StringUtf8Multilang::kDefaultCode;
for (auto const & language : supportedLanguages)
{
auto const langIndex = getIndex(language.m_code);
if (langIndex != kDefaultCode && m_name.HasString(langIndex))
continue;
auto it = std::find(m_additionalSkipLanguageCodes.begin(), m_additionalSkipLanguageCodes.end(), langIndex);
if (it == m_additionalSkipLanguageCodes.end())
m_languages.push_back(language);
}
std::sort(m_languages.begin(), m_languages.end(),
[&getIndex](StringUtf8Multilang::Lang const & lhs, StringUtf8Multilang::Lang const & rhs) {
// Default name can be changed in advanced mode, but it should be last in list of names.
if (getIndex(lhs.m_code) == kDefaultCode && getIndex(rhs.m_code) != kDefaultCode)
return false;
if (getIndex(lhs.m_code) != kDefaultCode && getIndex(rhs.m_code) == kDefaultCode)
return true;
return std::string(lhs.m_code) < std::string(rhs.m_code);
});
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
MWMTableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:@"ListCellIdentifier"];
NSInteger const index = indexPath.row;
StringUtf8Multilang::Lang const & lang = m_languages[index];
cell.textLabel.text = ToNSString(lang.m_name);
cell.detailTextLabel.text = ToNSString(lang.m_code);
cell.accessoryType = UITableViewCellAccessoryNone;
return cell;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return m_languages.size();
}
#pragma mark - UITableViewDataSource
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
NSInteger const index = indexPath.row;
StringUtf8Multilang::Lang const & language = m_languages[index];
[self.delegate addAdditionalName:StringUtf8Multilang::GetLangIndex(language.m_code)];
[self.navigationController popViewControllerAnimated:YES];
}
@end

View file

@ -0,0 +1,3 @@
@objc(MWMEditorAdditionalNamePlaceholderTableViewCell)
final class EditorAdditionalNamePlaceholderTableViewCell: MWMTableViewCell {
}

View file

@ -0,0 +1,41 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="15702" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES">
<device id="retina4_7" orientation="portrait" appearance="light"/>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="15704"/>
<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" customClass="MWMEditorAdditionalNamePlaceholderTableViewCell" propertyAccessControl="none">
<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"/>
<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" 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" 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"/>
<constraint firstAttribute="bottom" secondItem="tYH-si-HMY" secondAttribute="bottom" id="g0D-w9-dGP"/>
<constraint firstItem="tYH-si-HMY" firstAttribute="top" secondItem="58c-Uv-d0K" secondAttribute="top" id="qyd-oG-Ixi"/>
</constraints>
</tableViewCellContentView>
<userDefinedRuntimeAttributes>
<userDefinedRuntimeAttribute type="string" keyPath="styleName" value="Background"/>
</userDefinedRuntimeAttributes>
<point key="canvasLocation" x="225" y="282"/>
</tableViewCell>
</objects>
</document>

View file

@ -0,0 +1,17 @@
#import "MWMTableViewCell.h"
NS_ASSUME_NONNULL_BEGIN
@protocol MWMButtonCellDelegate <NSObject>
- (void)cellDidPressButton:(UITableViewCell *)cell;
@end
@interface MWMButtonCell : MWMTableViewCell
- (void)configureWithDelegate:(id<MWMButtonCellDelegate>)delegate title:(NSString *)title enabled:(BOOL)enabled;
@end
NS_ASSUME_NONNULL_END

View file

@ -0,0 +1,22 @@
#import "MWMButtonCell.h"
@interface MWMButtonCell ()
@property(nonatomic) IBOutlet UIButton *button;
@property(weak, nonatomic) id<MWMButtonCellDelegate> delegate;
@end
@implementation MWMButtonCell
- (void)configureWithDelegate:(id<MWMButtonCellDelegate>)delegate title:(NSString *)title enabled:(BOOL)enabled {
[self.button setTitle:title forState:UIControlStateNormal];
self.button.enabled = enabled;
self.delegate = delegate;
}
- (IBAction)buttonTap {
[self.delegate cellDidPressButton:self];
}
@end

View file

@ -0,0 +1,48 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="19529" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES">
<device id="retina4_7" orientation="portrait" appearance="light"/>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="19519"/>
<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" id="KGk-i7-Jjw" customClass="MWMButtonCell" propertyAccessControl="none">
<rect key="frame" x="0.0" y="0.0" width="320" height="44"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="KGk-i7-Jjw" id="H2p-sc-9uM">
<rect key="frame" x="0.0" y="0.0" width="320" height="44"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="c7Y-Nr-P4C">
<rect key="frame" x="0.0" y="0.0" width="320" height="44"/>
<constraints>
<constraint firstAttribute="height" relation="greaterThanOrEqual" constant="44" id="Z6u-ES-sTJ"/>
</constraints>
<state key="normal" title="Button">
<color key="titleColor" red="0.95686274510000002" green="0.26274509800000001" blue="0.21176470589999999" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</state>
<userDefinedRuntimeAttributes>
<userDefinedRuntimeAttribute type="string" keyPath="styleName" value="BookmarksCategoryDeleteButton"/>
</userDefinedRuntimeAttributes>
<connections>
<action selector="buttonTap" destination="KGk-i7-Jjw" eventType="touchUpInside" id="kS2-aj-wfq"/>
</connections>
</button>
</subviews>
<constraints>
<constraint firstAttribute="trailing" secondItem="c7Y-Nr-P4C" secondAttribute="trailing" id="AVP-GR-W7u"/>
<constraint firstAttribute="bottom" secondItem="c7Y-Nr-P4C" secondAttribute="bottom" id="F3N-Zb-tnQ"/>
<constraint firstItem="c7Y-Nr-P4C" firstAttribute="leading" secondItem="H2p-sc-9uM" secondAttribute="leading" id="JQx-63-Ane"/>
<constraint firstItem="c7Y-Nr-P4C" firstAttribute="top" secondItem="H2p-sc-9uM" secondAttribute="top" id="fTj-1o-vWJ"/>
</constraints>
</tableViewCellContentView>
<connections>
<outlet property="button" destination="c7Y-Nr-P4C" id="UDx-n5-6fr"/>
</connections>
<point key="canvasLocation" x="139" y="155"/>
</tableViewCell>
</objects>
</document>

View file

@ -0,0 +1,8 @@
#import "MWMEditorCommon.h"
#import "MWMTableViewCell.h"
@interface MWMEditorAddAdditionalNameTableViewCell : MWMTableViewCell
- (void)configWithDelegate:(id<MWMEditorAdditionalName>)delegate;
@end

View file

@ -0,0 +1,13 @@
#import "MWMEditorAddAdditionalNameTableViewCell.h"
@interface MWMEditorAddAdditionalNameTableViewCell ()
@property(weak, nonatomic) id<MWMEditorAdditionalName> delegate;
@end
@implementation MWMEditorAddAdditionalNameTableViewCell
- (void)configWithDelegate:(id<MWMEditorAdditionalName>)delegate { self.delegate = delegate; }
- (IBAction)addLanguageTap { [self.delegate editAdditionalNameLanguage:NSNotFound]; }
@end

View file

@ -0,0 +1,55 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="23727" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES">
<device id="retina6_12" orientation="portrait" appearance="light"/>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="23721"/>
<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" id="81H-Jz-Sl2" customClass="MWMEditorAddAdditionalNameTableViewCell" propertyAccessControl="none">
<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="81H-Jz-Sl2" id="EHS-hP-aIE">
<rect key="frame" x="0.0" y="0.0" width="320" height="44"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="Ua5-4V-1PH" customClass="MWMButton">
<rect key="frame" x="0.0" y="0.0" width="320" height="44"/>
<constraints>
<constraint firstAttribute="height" priority="750" constant="44" id="oVm-ep-LLL"/>
</constraints>
<inset key="contentEdgeInsets" minX="12" minY="0.0" maxX="0.0" maxY="0.0"/>
<inset key="titleEdgeInsets" minX="14" minY="0.0" maxX="0.0" maxY="0.0"/>
<state key="normal" title="add_language" image="plus.circle.fill" catalog="system"/>
<userDefinedRuntimeAttributes>
<userDefinedRuntimeAttribute type="string" keyPath="styleName" value="FlatNormalTransButtonBig"/>
<userDefinedRuntimeAttribute type="string" keyPath="localizedText" value="add_language"/>
</userDefinedRuntimeAttributes>
<connections>
<action selector="addLanguageTap" destination="81H-Jz-Sl2" eventType="touchUpInside" id="Lw7-kU-hIK"/>
</connections>
</button>
</subviews>
<constraints>
<constraint firstAttribute="bottom" secondItem="Ua5-4V-1PH" secondAttribute="bottom" id="Nmp-Cj-ffg"/>
<constraint firstItem="Ua5-4V-1PH" firstAttribute="leading" secondItem="EHS-hP-aIE" secondAttribute="leading" id="XP5-8s-Vka"/>
<constraint firstItem="Ua5-4V-1PH" firstAttribute="top" secondItem="EHS-hP-aIE" secondAttribute="top" id="YAU-Xb-h9Y"/>
<constraint firstAttribute="trailing" secondItem="Ua5-4V-1PH" secondAttribute="trailing" id="f6J-6o-AjX"/>
</constraints>
<userDefinedRuntimeAttributes>
<userDefinedRuntimeAttribute type="string" keyPath="styleName" value="Background"/>
</userDefinedRuntimeAttributes>
</tableViewCellContentView>
<userDefinedRuntimeAttributes>
<userDefinedRuntimeAttribute type="string" keyPath="styleName" value="Background"/>
</userDefinedRuntimeAttributes>
<point key="canvasLocation" x="342" y="257"/>
</tableViewCell>
</objects>
<resources>
<image name="plus.circle.fill" catalog="system" width="128" height="123"/>
</resources>
</document>

View file

@ -0,0 +1,16 @@
#import "MWMEditorCommon.h"
#import "MWMTableViewCell.h"
@interface MWMEditorAdditionalNameTableViewCell : MWMTableViewCell
@property(nonatomic, readonly) NSInteger code;
- (void)configWithDelegate:(id<MWMEditorAdditionalName>)delegate
langCode:(NSInteger)langCode
langName:(NSString *)langName
name:(NSString *)name
errorMessage:(NSString *)errorMessage
isValid:(BOOL)isValid
keyboardType:(UIKeyboardType)keyboardType;
@end

View file

@ -0,0 +1,103 @@
#import "MWMEditorAdditionalNameTableViewCell.h"
#import "SwiftBridge.h"
static CGFloat const kErrorLabelHeight = 16;
@interface MWMEditorAdditionalNameTableViewCell ()
@property(weak, nonatomic) IBOutlet UIStackView * stackView;
@property(weak, nonatomic) IBOutlet UILabel * languageLabel;
@property(weak, nonatomic) IBOutlet UITextField * textField;
@property(weak, nonatomic) IBOutlet UILabel * errorLabel;
@property(weak, nonatomic) IBOutlet NSLayoutConstraint * errorLabelHeight;
@property(nonatomic, readwrite) NSInteger code;
@property(weak, nonatomic) id<MWMEditorAdditionalName> delegate;
@property(nonatomic) BOOL isValid;
@end
@implementation MWMEditorAdditionalNameTableViewCell
- (void)configWithDelegate:(id<MWMEditorAdditionalName>)delegate
langCode:(NSInteger)langCode
langName:(NSString *)langName
name:(NSString *)name
errorMessage:(NSString *)errorMessage
isValid:(BOOL)isValid
keyboardType:(UIKeyboardType)keyboardType
{
self.delegate = delegate;
self.code = langCode;
self.languageLabel.text = langName;
self.errorLabel.text = errorMessage;
self.isValid = isValid;
self.textField.text = name;
self.textField.keyboardType = keyboardType;
self.textField.backgroundColor = [UIColor clearColor];
[self processValidation];
}
- (void)processValidation
{
if (self.isValid)
{
self.errorLabelHeight.constant = 0;
[self.contentView setStyleNameAndApply: @"Background"];
}
else
{
self.errorLabelHeight.constant = kErrorLabelHeight;
[self.contentView setStyleNameAndApply: @"ErrorBackground"];
}
[self layoutIfNeeded];
}
- (void)changeInvalidCellState
{
if (self.isValid)
return;
self.isValid = YES;
[self processValidation];
[self.delegate tryToChangeInvalidStateForCell:self];
}
#pragma mark - UITextFieldDelegate
- (BOOL)textField:(UITextField *)textField
shouldChangeCharactersInRange:(NSRange)range
replacementString:(NSString *)string
{
[self changeInvalidCellState];
return YES;
}
- (BOOL)textFieldShouldClear:(UITextField *)textField
{
[self changeInvalidCellState];
return YES;
}
- (void)textFieldDidEndEditing:(UITextField *)textField
{
[self.delegate cell:self changedText:textField.text];
}
- (BOOL)textFieldShouldReturn:(UITextField *)textField
{
[textField resignFirstResponder];
return YES;
}
- (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event
{
// Allow to tap on the whole cell to start editing.
UIView * view = [super hitTest:point withEvent:event];
if (view == self.stackView)
return self.textField;
return view;
}
@end

View file

@ -0,0 +1,90 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="22505" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES">
<device id="retina6_1" orientation="portrait" appearance="light"/>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="22504"/>
<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" id="hfo-cP-AGX" customClass="MWMEditorAdditionalNameTableViewCell">
<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="hfo-cP-AGX" id="JQH-ks-NoC">
<rect key="frame" x="0.0" y="0.0" width="320" height="44"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<stackView opaque="NO" contentMode="scaleToFill" axis="vertical" distribution="fillProportionally" alignment="top" spacing="3" translatesAutoresizingMaskIntoConstraints="NO" id="eca-XW-QZR">
<rect key="frame" x="16" y="16" width="288" height="12"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="zh-classical" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="efb-nS-cjm">
<rect key="frame" x="0.0" y="0.0" width="77" height="5"/>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<fontDescription key="fontDescription" type="system" pointSize="14"/>
<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="styleName" value="regular14:blackSecondaryText"/>
</userDefinedRuntimeAttributes>
</label>
<textField opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" horizontalCompressionResistancePriority="499" contentHorizontalAlignment="left" contentVerticalAlignment="center" minimumFontSize="17" clearButtonMode="whileEditing" translatesAutoresizingMaskIntoConstraints="NO" id="9BY-PA-dlA">
<rect key="frame" x="0.0" y="8" width="5" height="4"/>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<textInputTraits key="textInputTraits"/>
<userDefinedRuntimeAttributes>
<userDefinedRuntimeAttribute type="string" keyPath="styleName" value="regular17:blackPrimaryText"/>
<userDefinedRuntimeAttribute type="string" keyPath="localizedPlaceholder" value="editor_edit_place_name_hint"/>
</userDefinedRuntimeAttributes>
<connections>
<outlet property="delegate" destination="hfo-cP-AGX" id="jkD-0x-Ods"/>
</connections>
</textField>
</subviews>
<constraints>
<constraint firstItem="9BY-PA-dlA" firstAttribute="width" secondItem="eca-XW-QZR" secondAttribute="width" id="OSr-03-hPe"/>
</constraints>
</stackView>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="natural" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" preferredMaxLayoutWidth="252" translatesAutoresizingMaskIntoConstraints="NO" id="SZa-Bj-se1">
<rect key="frame" x="60" y="32" width="252" height="0.0"/>
<color key="backgroundColor" red="0.0" green="0.0" blue="0.0" alpha="0.0" colorSpace="custom" customColorSpace="sRGB"/>
<constraints>
<constraint firstAttribute="height" priority="999" id="CPF-uE-pzx"/>
</constraints>
<fontDescription key="fontDescription" type="system" pointSize="12"/>
<color key="textColor" red="0.95686274510000002" green="0.26274509800000001" blue="0.21176470589999999" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<nil key="highlightedColor"/>
<userDefinedRuntimeAttributes>
<userDefinedRuntimeAttribute type="string" keyPath="styleName" value="regular12:redText"/>
</userDefinedRuntimeAttributes>
</label>
</subviews>
<constraints>
<constraint firstItem="SZa-Bj-se1" firstAttribute="leading" secondItem="JQH-ks-NoC" secondAttribute="leading" constant="60" id="BcS-gb-9vl"/>
<constraint firstAttribute="trailing" secondItem="SZa-Bj-se1" secondAttribute="trailing" constant="8" id="EBU-G3-tgp"/>
<constraint firstItem="eca-XW-QZR" firstAttribute="top" secondItem="JQH-ks-NoC" secondAttribute="top" constant="16" id="FJ5-Zj-wLR"/>
<constraint firstAttribute="trailing" secondItem="eca-XW-QZR" secondAttribute="trailing" constant="16" id="NZO-C9-ZCS"/>
<constraint firstItem="SZa-Bj-se1" firstAttribute="top" secondItem="eca-XW-QZR" secondAttribute="bottom" constant="4" id="T9Z-G5-LVc"/>
<constraint firstAttribute="bottom" secondItem="SZa-Bj-se1" secondAttribute="bottom" constant="12" id="TdX-jx-CpD"/>
<constraint firstItem="eca-XW-QZR" firstAttribute="leading" secondItem="JQH-ks-NoC" secondAttribute="leading" constant="16" id="dbb-bG-8uT"/>
</constraints>
<userDefinedRuntimeAttributes>
<userDefinedRuntimeAttribute type="string" keyPath="styleName" value="Background"/>
</userDefinedRuntimeAttributes>
</tableViewCellContentView>
<userDefinedRuntimeAttributes>
<userDefinedRuntimeAttribute type="string" keyPath="styleName" value="Background"/>
</userDefinedRuntimeAttributes>
<connections>
<outlet property="errorLabel" destination="SZa-Bj-se1" id="hqN-vX-0Hw"/>
<outlet property="errorLabelHeight" destination="CPF-uE-pzx" id="X4g-6X-W0e"/>
<outlet property="languageLabel" destination="efb-nS-cjm" id="13M-9D-Qbf"/>
<outlet property="stackView" destination="eca-XW-QZR" id="RPt-fc-aoR"/>
<outlet property="textField" destination="9BY-PA-dlA" id="SCv-JL-5TL"/>
</connections>
<point key="canvasLocation" x="340.57971014492756" y="256.47321428571428"/>
</tableViewCell>
</objects>
</document>

View file

@ -0,0 +1,11 @@
#import "MWMTableViewCell.h"
@protocol MWMEditorCellProtocol;
@interface MWMEditorCategoryCell : MWMTableViewCell
- (void)configureWithDelegate:(id<MWMEditorCellProtocol>)delegate
detailTitle:(NSString *)detail
isCreating:(BOOL)isCreating;
@end

View file

@ -0,0 +1,44 @@
#import "MWMEditorCategoryCell.h"
#import "MWMEditorCommon.h"
#import "SwiftBridge.h"
CGFloat const kDetailShortRightSpace = 16;
@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;
@end
@implementation MWMEditorCategoryCell
- (void)configureWithDelegate:(id<MWMEditorCellProtocol>)delegate
detailTitle:(NSString *)detail
isCreating:(BOOL)isCreating
{
self.delegate = delegate;
self.detail.text = detail;
self.accessoryIcon.hidden = !isCreating;
if (isCreating)
{
self.selectedBackgroundView = [[UIView alloc] init];
self.selectedBackgroundView.styleName = @"PressBackground";
}
else
{
self.selectionStyle = UITableViewCellSelectionStyleNone;
self.detailRightSpace.constant = kDetailShortRightSpace;
}
}
- (IBAction)cellTap
{
if (self.accessoryIcon.hidden)
return;
[self.delegate cellDidPressButton:self];
}
@end

View file

@ -0,0 +1,92 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="15702" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" colorMatched="YES">
<device id="retina4_7" orientation="portrait" appearance="light"/>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="15704"/>
<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="default" indentationWidth="10" id="rsc-tP-qGq" customClass="MWMEditorCategoryCell" propertyAccessControl="none">
<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="rsc-tP-qGq" id="mWc-I7-4kZ">
<rect key="frame" x="0.0" y="0.0" width="320" height="44"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="ic_arrow_gray_right" translatesAutoresizingMaskIntoConstraints="NO" id="uA3-ru-Ja1">
<rect key="frame" x="286" y="8" width="28" height="28"/>
<constraints>
<constraint firstAttribute="width" constant="28" id="CW0-pF-saL"/>
<constraint firstAttribute="height" constant="28" id="P6z-Sg-ZyD"/>
</constraints>
<userDefinedRuntimeAttributes>
<userDefinedRuntimeAttribute type="string" keyPath="styleName" value="MWMGray"/>
</userDefinedRuntimeAttributes>
</imageView>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Jfx-Kc-WOc">
<rect key="frame" x="16" y="12" width="226" height="20"/>
<constraints>
<constraint firstAttribute="width" relation="greaterThanOrEqual" constant="50" id="BaE-rI-CN2"/>
<constraint firstAttribute="height" constant="20" id="oLW-um-5dA"/>
</constraints>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<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="styleName" value="regular17:blackPrimaryText"/>
<userDefinedRuntimeAttribute type="string" keyPath="localizedText" value="editor_edit_place_category_title"/>
</userDefinedRuntimeAttributes>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="501" verticalHuggingPriority="251" text="Label" textAlignment="right" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="qrd-hP-nIJ">
<rect key="frame" x="250" y="11.5" width="42" height="21"/>
<constraints>
<constraint firstAttribute="height" constant="21" id="hsO-dV-WsY"/>
</constraints>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<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="styleName" value="regular17:blackSecondaryText"/>
</userDefinedRuntimeAttributes>
</label>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="icU-WX-U52">
<rect key="frame" x="0.0" y="0.0" width="320" height="44"/>
<connections>
<action selector="cellTap" destination="rsc-tP-qGq" eventType="touchUpInside" id="dru-SF-L7z"/>
</connections>
</button>
</subviews>
<constraints>
<constraint firstItem="Jfx-Kc-WOc" firstAttribute="leading" secondItem="mWc-I7-4kZ" secondAttribute="leading" constant="16" id="5lg-6C-NQt"/>
<constraint firstItem="qrd-hP-nIJ" firstAttribute="leading" secondItem="Jfx-Kc-WOc" secondAttribute="trailing" constant="8" id="ETn-mX-ysj"/>
<constraint firstItem="Jfx-Kc-WOc" firstAttribute="centerY" secondItem="mWc-I7-4kZ" secondAttribute="centerY" id="P6u-UL-5f7"/>
<constraint firstAttribute="trailing" secondItem="qrd-hP-nIJ" secondAttribute="trailing" constant="28" id="Rwj-G9-EoG"/>
<constraint firstAttribute="trailing" secondItem="uA3-ru-Ja1" secondAttribute="trailing" constant="6" id="byM-mn-aQu"/>
<constraint firstItem="uA3-ru-Ja1" firstAttribute="centerY" secondItem="mWc-I7-4kZ" secondAttribute="centerY" id="sVc-Kt-8ZX"/>
<constraint firstItem="qrd-hP-nIJ" firstAttribute="centerY" secondItem="mWc-I7-4kZ" secondAttribute="centerY" id="wSH-Lz-TEL"/>
</constraints>
</tableViewCellContentView>
<constraints>
<constraint firstItem="icU-WX-U52" firstAttribute="centerX" secondItem="rsc-tP-qGq" secondAttribute="centerX" id="F9k-Ej-LFc"/>
<constraint firstItem="icU-WX-U52" firstAttribute="width" secondItem="rsc-tP-qGq" secondAttribute="width" id="ZUi-Rh-jlL"/>
<constraint firstItem="icU-WX-U52" firstAttribute="height" secondItem="rsc-tP-qGq" secondAttribute="height" id="dy8-tF-aiq"/>
<constraint firstItem="icU-WX-U52" firstAttribute="centerY" secondItem="rsc-tP-qGq" secondAttribute="centerY" id="uky-CX-2ye"/>
</constraints>
<userDefinedRuntimeAttributes>
<userDefinedRuntimeAttribute type="string" keyPath="styleName" value="Background"/>
</userDefinedRuntimeAttributes>
<connections>
<outlet property="accessoryIcon" destination="uA3-ru-Ja1" id="esf-Xi-gLG"/>
<outlet property="detail" destination="qrd-hP-nIJ" id="IOE-vz-HaI"/>
<outlet property="detailRightSpace" destination="Rwj-G9-EoG" id="H8f-mf-vOJ"/>
</connections>
<point key="canvasLocation" x="501.44927536231887" y="199.55357142857142"/>
</tableViewCell>
</objects>
<resources>
<image name="ic_arrow_gray_right" width="28" height="28"/>
</resources>
</document>

View file

@ -0,0 +1,12 @@
#import "MWMEditorCommon.h"
#import "MWMTableViewCell.h"
#include "indexer/yes_no_unknown.hpp"
@interface MWMEditorSegmentedTableViewCell : MWMTableViewCell
- (void)configWithDelegate:(id<MWMEditorCellProtocol>)delegate
icon:(UIImage *)icon
text:(NSString *)text
value:(YesNoUnknown)value;
@end

View file

@ -0,0 +1,82 @@
#import "MWMEditorSegmentedTableViewCell.hpp"
#import "SwiftBridge.h"
@interface MWMEditorSegmentedTableViewCell ()
@property(weak, nonatomic) IBOutlet UIImageView * icon;
@property(weak, nonatomic) IBOutlet UILabel * label;
@property(weak, nonatomic) IBOutlet UISegmentedControl * segmentedControl;
@property(weak, nonatomic) id<MWMEditorCellProtocol> delegate;
@end
@implementation MWMEditorSegmentedTableViewCell
- (void)configWithDelegate:(id<MWMEditorCellProtocol>)delegate
icon:(UIImage *)icon
text:(NSString *)text
value:(YesNoUnknown)value
{
self.delegate = delegate;
self.icon.image = icon;
self.icon.styleName = @"MWMBlack";
self.label.text = text;
[self.segmentedControl setTitle:NSLocalizedString(@"no", nil) forSegmentAtIndex:0];
[self.segmentedControl setTitle:NSLocalizedString(@"yes", nil) forSegmentAtIndex:2];
switch(value)
{
case Yes:
self.segmentedControl.selectedSegmentIndex = 2;
break;
case No:
self.segmentedControl.selectedSegmentIndex = 0;
break;
case Unknown:
self.segmentedControl.selectedSegmentIndex = 1;
break;
}
[self setTextColorWithSegmentedValue:value];
}
- (void)setTextColorWithSegmentedValue:(YesNoUnknown)value
{
switch (value)
{
case Yes:
case No:
self.label.textColor = [UIColor blackPrimaryText];
break;
case Unknown:
self.label.textColor = [UIColor blackHintText];
break;
}
}
- (IBAction)valueChanged
{
YesNoUnknown value;
switch (self.segmentedControl.selectedSegmentIndex)
{
case 0:
value = No;
break;
case 1:
value = Unknown;
break;
case 2:
value = Yes;
break;
default:
value = Unknown;
NSAssert(false, @"Unexpected YesNoUnknown value %ld", static_cast<long>(self.segmentedControl.selectedSegmentIndex));
}
[self.delegate cell:self changeSegmented:value];
[self setTextColorWithSegmentedValue:value];
}
@end

View file

@ -0,0 +1,79 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="32700.99.1234" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES">
<device id="retina4_7" orientation="portrait" appearance="light"/>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="22684"/>
<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" id="qme-9J-aMf" customClass="MWMEditorSegmentedTableViewCell" propertyAccessControl="none">
<rect key="frame" x="0.0" y="0.0" width="320" height="44"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="qme-9J-aMf" id="fpo-VO-awT">
<rect key="frame" x="0.0" y="0.0" width="320" height="44"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="j3u-fF-pG6">
<rect key="frame" x="16" y="8" width="28" height="28"/>
<constraints>
<constraint firstAttribute="height" constant="28" id="Ce3-kg-QsX"/>
<constraint firstAttribute="width" constant="28" id="MT3-eQ-SOL"/>
</constraints>
<userDefinedRuntimeAttributes>
<userDefinedRuntimeAttribute type="string" keyPath="styleName" value="MWMBlack"/>
</userDefinedRuntimeAttributes>
</imageView>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" text="Label" textAlignment="natural" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" preferredMaxLayoutWidth="187" translatesAutoresizingMaskIntoConstraints="NO" id="QFf-wR-pPw">
<rect key="frame" x="60" y="0.0" width="133" height="44"/>
<constraints>
<constraint firstAttribute="height" relation="greaterThanOrEqual" priority="750" constant="44" id="XYk-fv-D9R"/>
</constraints>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<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="styleName" value="regular17:blackPrimaryText"/>
</userDefinedRuntimeAttributes>
</label>
<segmentedControl opaque="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" contentHorizontalAlignment="left" contentVerticalAlignment="top" apportionsSegmentWidthsByContent="YES" segmentControlStyle="plain" selectedSegmentIndex="0" translatesAutoresizingMaskIntoConstraints="NO" id="Rp8-YJ-AzV">
<rect key="frame" x="201" y="6.5" width="103" height="32"/>
<segments>
<segment title="No"/>
<segment title="-"/>
<segment title="Yes"/>
</segments>
<connections>
<action selector="valueChanged" destination="qme-9J-aMf" eventType="valueChanged" id="jR4-p8-Ldo"/>
</connections>
</segmentedControl>
</subviews>
<constraints>
<constraint firstItem="QFf-wR-pPw" firstAttribute="top" secondItem="fpo-VO-awT" secondAttribute="top" id="3mH-Ua-EUl"/>
<constraint firstItem="j3u-fF-pG6" firstAttribute="centerY" secondItem="fpo-VO-awT" secondAttribute="centerY" id="4xr-PJ-Dl2"/>
<constraint firstItem="j3u-fF-pG6" firstAttribute="leading" secondItem="fpo-VO-awT" secondAttribute="leading" constant="16" id="TFM-QG-P2e"/>
<constraint firstAttribute="bottom" secondItem="QFf-wR-pPw" secondAttribute="bottom" id="YAg-Wx-DLo"/>
<constraint firstItem="Rp8-YJ-AzV" firstAttribute="centerY" secondItem="fpo-VO-awT" secondAttribute="centerY" id="aTy-ab-vvF"/>
<constraint firstItem="Rp8-YJ-AzV" firstAttribute="leading" secondItem="QFf-wR-pPw" secondAttribute="trailing" constant="8" id="ge8-tr-S4S"/>
<constraint firstItem="QFf-wR-pPw" firstAttribute="leading" secondItem="fpo-VO-awT" secondAttribute="leading" constant="60" id="mNR-IV-cek"/>
<constraint firstAttribute="trailing" secondItem="Rp8-YJ-AzV" secondAttribute="trailing" constant="16" id="z6B-PV-rXg"/>
</constraints>
<userDefinedRuntimeAttributes>
<userDefinedRuntimeAttribute type="string" keyPath="styleName" value="Background"/>
</userDefinedRuntimeAttributes>
</tableViewCellContentView>
<inset key="separatorInset" minX="60" minY="0.0" maxX="0.0" maxY="0.0"/>
<userDefinedRuntimeAttributes>
<userDefinedRuntimeAttribute type="string" keyPath="styleName" value="Background"/>
</userDefinedRuntimeAttributes>
<connections>
<outlet property="icon" destination="j3u-fF-pG6" id="nIz-cY-MCW"/>
<outlet property="label" destination="QFf-wR-pPw" id="1MO-Vf-bt6"/>
<outlet property="segmentedControl" destination="Rp8-YJ-AzV" id="C9T-O3-dMM"/>
</connections>
<point key="canvasLocation" x="137.59999999999999" y="154.72263868065968"/>
</tableViewCell>
</objects>
</document>

View file

@ -0,0 +1,11 @@
#import "MWMEditorCommon.h"
#import "MWMTableViewCell.h"
@interface MWMEditorSelectTableViewCell : MWMTableViewCell
- (void)configWithDelegate:(id<MWMEditorCellProtocol>)delegate
icon:(UIImage *)icon
text:(NSString *)text
placeholder:(NSString *)placeholder;
@end

View file

@ -0,0 +1,46 @@
#import "MWMEditorSelectTableViewCell.h"
#import <CoreApi/MWMCommon.h>
#import "SwiftBridge.h"
@interface MWMEditorSelectTableViewCell ()
@property(weak, nonatomic) IBOutlet UIImageView * icon;
@property(weak, nonatomic) IBOutlet UILabel * label;
@property(weak, nonatomic) IBOutlet NSLayoutConstraint * labelLeadingOffset;
@property(weak, nonatomic) IBOutlet NSLayoutConstraint * labelTrailingOffset;
@property(weak, nonatomic) IBOutlet UIImageView * grayArrow;
@property(weak, nonatomic) id<MWMEditorCellProtocol> delegate;
@end
@implementation MWMEditorSelectTableViewCell
- (void)configWithDelegate:(id<MWMEditorCellProtocol>)delegate
icon:(UIImage *)icon
text:(NSString *)text
placeholder:(NSString *)placeholder
{
self.delegate = delegate;
self.icon.hidden = NO;
self.icon.image = icon;
self.icon.styleName = @"MWMBlack";
if (text && text.length != 0)
{
self.label.text = text;
[self.label setStyleNameAndApply: @"blackPrimaryText"];
}
else
{
self.label.text = placeholder;
[self.label setStyleNameAndApply: @"blackHintText"];
}
self.label.preferredMaxLayoutWidth =
self.width - self.labelLeadingOffset.constant - self.labelTrailingOffset.constant;
if (isInterfaceRightToLeft())
self.grayArrow.transform = CGAffineTransformMakeScale(-1, 1);
}
- (IBAction)selectAction { [self.delegate cellDidPressButton:self]; }
@end

View file

@ -0,0 +1,93 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="15702" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES">
<device id="retina4_7" orientation="portrait" appearance="light"/>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="15704"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<objects>
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner"/>
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
<tableViewCell contentMode="scaleToFill" selectionStyle="default" indentationWidth="10" id="xiI-ev-aU2" customClass="MWMEditorSelectTableViewCell" propertyAccessControl="none">
<rect key="frame" x="0.0" y="0.0" width="320" height="44"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="xiI-ev-aU2" id="V1p-K9-KlE">
<rect key="frame" x="0.0" y="0.0" width="320" height="44"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="xur-tJ-HA9">
<rect key="frame" x="16" y="8" width="28" height="28"/>
<constraints>
<constraint firstAttribute="width" constant="28" id="Oak-eT-K2q"/>
<constraint firstAttribute="height" constant="28" id="s7g-CH-05Z"/>
</constraints>
<userDefinedRuntimeAttributes>
<userDefinedRuntimeAttribute type="string" keyPath="styleName" value="MWMBlack"/>
</userDefinedRuntimeAttributes>
</imageView>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="natural" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" preferredMaxLayoutWidth="220" translatesAutoresizingMaskIntoConstraints="NO" id="MBe-6r-IsA">
<rect key="frame" x="60" y="8" width="220" height="28"/>
<constraints>
<constraint firstAttribute="height" relation="greaterThanOrEqual" priority="750" constant="28" id="7cv-Wq-vWC"/>
</constraints>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<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="styleName" value="regular17:blackPrimaryText"/>
</userDefinedRuntimeAttributes>
</label>
<imageView userInteractionEnabled="NO" contentMode="center" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="ic_arrow_gray_right" translatesAutoresizingMaskIntoConstraints="NO" id="jLw-GA-z3y">
<rect key="frame" x="286" y="8" width="28" height="28"/>
<constraints>
<constraint firstAttribute="width" constant="28" id="Ki5-4h-NRK"/>
<constraint firstAttribute="height" constant="28" id="PG8-LW-72y"/>
</constraints>
<userDefinedRuntimeAttributes>
<userDefinedRuntimeAttribute type="string" keyPath="styleName" value="MWMGray"/>
</userDefinedRuntimeAttributes>
</imageView>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="nq9-KC-Ujh">
<rect key="frame" x="0.0" y="0.0" width="320" height="44"/>
<connections>
<action selector="selectAction" destination="xiI-ev-aU2" eventType="touchUpInside" id="xXk-7q-LQQ"/>
</connections>
</button>
</subviews>
<constraints>
<constraint firstAttribute="trailing" secondItem="jLw-GA-z3y" secondAttribute="trailing" constant="6" id="3Bg-20-t7E"/>
<constraint firstAttribute="trailing" secondItem="nq9-KC-Ujh" secondAttribute="trailing" id="5gd-06-ZOC"/>
<constraint firstItem="MBe-6r-IsA" firstAttribute="top" secondItem="V1p-K9-KlE" secondAttribute="top" constant="8" id="6FB-in-VCz"/>
<constraint firstAttribute="bottom" secondItem="MBe-6r-IsA" secondAttribute="bottom" constant="8" id="CG0-ar-vx9"/>
<constraint firstItem="xur-tJ-HA9" firstAttribute="leading" secondItem="V1p-K9-KlE" secondAttribute="leading" constant="16" id="DlR-yh-2JK"/>
<constraint firstItem="MBe-6r-IsA" firstAttribute="leading" secondItem="V1p-K9-KlE" secondAttribute="leading" constant="60" id="RGA-XL-gLq"/>
<constraint firstItem="xur-tJ-HA9" firstAttribute="centerY" secondItem="V1p-K9-KlE" secondAttribute="centerY" id="agx-Kf-DpK"/>
<constraint firstAttribute="bottom" secondItem="nq9-KC-Ujh" secondAttribute="bottom" id="fK8-AO-JKa"/>
<constraint firstItem="nq9-KC-Ujh" firstAttribute="top" secondItem="V1p-K9-KlE" secondAttribute="top" id="ibI-hy-19F"/>
<constraint firstItem="jLw-GA-z3y" firstAttribute="centerY" secondItem="V1p-K9-KlE" secondAttribute="centerY" id="nY0-7m-bcZ"/>
<constraint firstItem="nq9-KC-Ujh" firstAttribute="leading" secondItem="V1p-K9-KlE" secondAttribute="leading" id="tyN-aq-pC1"/>
<constraint firstAttribute="trailing" secondItem="MBe-6r-IsA" secondAttribute="trailing" constant="40" id="yG7-RB-5Pa"/>
</constraints>
<userDefinedRuntimeAttributes>
<userDefinedRuntimeAttribute type="string" keyPath="styleName" value="Background"/>
</userDefinedRuntimeAttributes>
</tableViewCellContentView>
<inset key="separatorInset" minX="60" minY="0.0" maxX="0.0" maxY="0.0"/>
<userDefinedRuntimeAttributes>
<userDefinedRuntimeAttribute type="string" keyPath="styleName" value="Background"/>
</userDefinedRuntimeAttributes>
<connections>
<outlet property="grayArrow" destination="jLw-GA-z3y" id="5NK-K5-4IO"/>
<outlet property="icon" destination="xur-tJ-HA9" id="ObZ-fc-tbA"/>
<outlet property="label" destination="MBe-6r-IsA" id="mvf-Q3-vMz"/>
<outlet property="labelLeadingOffset" destination="RGA-XL-gLq" id="Tb4-Ew-iDe"/>
<outlet property="labelTrailingOffset" destination="yG7-RB-5Pa" id="NqK-3D-zMQ"/>
</connections>
<point key="canvasLocation" x="139" y="155"/>
</tableViewCell>
</objects>
<resources>
<image name="ic_arrow_gray_right" width="28" height="28"/>
</resources>
</document>

View file

@ -0,0 +1,11 @@
#import "MWMEditorCommon.h"
#import "MWMTableViewCell.h"
@interface MWMEditorSwitchTableViewCell : MWMTableViewCell
- (void)configWithDelegate:(id<MWMEditorCellProtocol>)delegate
icon:(UIImage *)icon
text:(NSString *)text
on:(BOOL)on;
@end

View file

@ -0,0 +1,41 @@
#import "MWMEditorSwitchTableViewCell.h"
#import "SwiftBridge.h"
@interface MWMEditorSwitchTableViewCell ()
@property(weak, nonatomic) IBOutlet UIImageView * icon;
@property(weak, nonatomic) IBOutlet UILabel * label;
@property(weak, nonatomic) IBOutlet UISwitch * switchControl;
@property(weak, nonatomic) id<MWMEditorCellProtocol> delegate;
@end
@implementation MWMEditorSwitchTableViewCell
- (void)configWithDelegate:(id<MWMEditorCellProtocol>)delegate
icon:(UIImage *)icon
text:(NSString *)text
on:(BOOL)on
{
self.delegate = delegate;
self.icon.image = icon;
self.icon.styleName = @"MWMBlack";
self.label.text = text;
self.switchControl.on = on;
[self setTextColorWithSwitchValue:on];
}
- (void)setTextColorWithSwitchValue:(BOOL)value
{
self.label.textColor = value ? [UIColor blackPrimaryText] : [UIColor blackHintText];
}
- (IBAction)valueChanged
{
BOOL const value = self.switchControl.on;
[self.delegate cell:self changeSwitch:value];
[self setTextColorWithSwitchValue:value];
}
@end

View file

@ -0,0 +1,74 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="15705" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES">
<device id="retina4_7" orientation="portrait" appearance="light"/>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="15706"/>
<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" id="qme-9J-aMf" customClass="MWMEditorSwitchTableViewCell" propertyAccessControl="none">
<rect key="frame" x="0.0" y="0.0" width="320" height="44"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="qme-9J-aMf" id="fpo-VO-awT">
<rect key="frame" x="0.0" y="0.0" width="320" height="44"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="j3u-fF-pG6">
<rect key="frame" x="16" y="8" width="28" height="28"/>
<constraints>
<constraint firstAttribute="height" constant="28" id="Ce3-kg-QsX"/>
<constraint firstAttribute="width" constant="28" id="MT3-eQ-SOL"/>
</constraints>
<userDefinedRuntimeAttributes>
<userDefinedRuntimeAttribute type="string" keyPath="styleName" value="MWMBlack"/>
</userDefinedRuntimeAttributes>
</imageView>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="natural" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" preferredMaxLayoutWidth="187" translatesAutoresizingMaskIntoConstraints="NO" id="QFf-wR-pPw">
<rect key="frame" x="60" y="0.0" width="187" height="44"/>
<constraints>
<constraint firstAttribute="height" relation="greaterThanOrEqual" priority="750" constant="44" id="XYk-fv-D9R"/>
</constraints>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<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="styleName" value="regular17:blackPrimaryText"/>
</userDefinedRuntimeAttributes>
</label>
<switch opaque="NO" contentMode="scaleToFill" horizontalHuggingPriority="750" verticalHuggingPriority="750" contentHorizontalAlignment="center" contentVerticalAlignment="center" on="YES" translatesAutoresizingMaskIntoConstraints="NO" id="qvr-u3-nNo">
<rect key="frame" x="255" y="6.5" width="51" height="31"/>
<connections>
<action selector="valueChanged" destination="qme-9J-aMf" eventType="valueChanged" id="sak-SB-Nvi"/>
</connections>
</switch>
</subviews>
<constraints>
<constraint firstItem="QFf-wR-pPw" firstAttribute="top" secondItem="fpo-VO-awT" secondAttribute="top" id="3mH-Ua-EUl"/>
<constraint firstItem="j3u-fF-pG6" firstAttribute="centerY" secondItem="fpo-VO-awT" secondAttribute="centerY" id="4xr-PJ-Dl2"/>
<constraint firstAttribute="trailing" secondItem="qvr-u3-nNo" secondAttribute="trailing" constant="16" id="T2E-Dp-9aj"/>
<constraint firstItem="j3u-fF-pG6" firstAttribute="leading" secondItem="fpo-VO-awT" secondAttribute="leading" constant="16" id="TFM-QG-P2e"/>
<constraint firstAttribute="bottom" secondItem="QFf-wR-pPw" secondAttribute="bottom" id="YAg-Wx-DLo"/>
<constraint firstItem="qvr-u3-nNo" firstAttribute="leading" secondItem="QFf-wR-pPw" secondAttribute="trailing" constant="8" id="m7G-DT-9Wm"/>
<constraint firstItem="QFf-wR-pPw" firstAttribute="leading" secondItem="fpo-VO-awT" secondAttribute="leading" constant="60" id="mNR-IV-cek"/>
<constraint firstItem="qvr-u3-nNo" firstAttribute="centerY" secondItem="fpo-VO-awT" secondAttribute="centerYWithinMargins" id="opz-Nt-Q5b"/>
</constraints>
<userDefinedRuntimeAttributes>
<userDefinedRuntimeAttribute type="string" keyPath="styleName" value="Background"/>
</userDefinedRuntimeAttributes>
</tableViewCellContentView>
<inset key="separatorInset" minX="60" minY="0.0" maxX="0.0" maxY="0.0"/>
<userDefinedRuntimeAttributes>
<userDefinedRuntimeAttribute type="string" keyPath="styleName" value="Background"/>
</userDefinedRuntimeAttributes>
<connections>
<outlet property="icon" destination="j3u-fF-pG6" id="nIz-cY-MCW"/>
<outlet property="label" destination="QFf-wR-pPw" id="1MO-Vf-bt6"/>
<outlet property="switchControl" destination="qvr-u3-nNo" id="hfe-x6-0cw"/>
</connections>
<point key="canvasLocation" x="139" y="155"/>
</tableViewCell>
</objects>
</document>

View file

@ -0,0 +1,25 @@
#import "MWMTableViewCell.h"
@protocol MWMEditorCellProtocol;
@interface MWMEditorTextTableViewCell : MWMTableViewCell
- (void)configWithDelegate:(id<MWMEditorCellProtocol>)delegate
icon:(UIImage *)icon
text:(NSString *)text
placeholder:(NSString *)placeholder
keyboardType:(UIKeyboardType)keyboardType
capitalization:(UITextAutocapitalizationType)capitalization;
- (void)configWithDelegate:(id<MWMEditorCellProtocol>)delegate
icon:(UIImage *)icon
text:(NSString *)text
placeholder:(NSString *)placeholder
errorMessage:(NSString *)errorMessage
isValid:(BOOL)isValid
keyboardType:(UIKeyboardType)keyboardType
capitalization:(UITextAutocapitalizationType)capitalization;
@property(weak, nonatomic, readonly) IBOutlet UITextField * textField;
@end

View file

@ -0,0 +1,120 @@
#import "MWMEditorTextTableViewCell.h"
#import "MWMEditorCommon.h"
#import "UIImageView+Coloring.h"
#import "SwiftBridge.h"
static CGFloat const kErrorLabelDefaultTopSpace = 4.;
@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 NSLayoutConstraint * errorLabelTopSpace;
@property(weak, nonatomic) IBOutlet NSLayoutConstraint * labelHeight;
@property(weak, nonatomic) id<MWMEditorCellProtocol> delegate;
@property(nonatomic) BOOL isValid;
@end
@implementation MWMEditorTextTableViewCell
- (void)configWithDelegate:(id<MWMEditorCellProtocol>)delegate
icon:(UIImage *)icon
text:(NSString *)text
placeholder:(NSString *)placeholder
keyboardType:(UIKeyboardType)keyboardType
capitalization:(UITextAutocapitalizationType)capitalization
{
[self configWithDelegate:delegate
icon:icon
text:text
placeholder:placeholder
errorMessage:nil
isValid:YES
keyboardType:keyboardType
capitalization:capitalization];
}
- (void)configWithDelegate:(id<MWMEditorCellProtocol>)delegate
icon:(UIImage *)icon
text:(NSString *)text
placeholder:(NSString *)placeholder
errorMessage:(NSString *)errorMessage
isValid:(BOOL)isValid
keyboardType:(UIKeyboardType)keyboardType
capitalization:(UITextAutocapitalizationType)capitalization
{
self.delegate = delegate;
self.icon.image = icon;
[self.icon setStyleNameAndApply: @"MWMBlack"];
self.icon.hidden = (icon == nil);
self.textField.text = text;
self.textField.attributedPlaceholder = [[NSAttributedString alloc]
initWithString:placeholder
attributes:@{NSForegroundColorAttributeName : [UIColor blackHintText]}];
self.errorLabel.text = errorMessage;
self.textField.keyboardType = keyboardType;
self.textField.backgroundColor = UIColor.clearColor;
self.isValid = isValid;
self.textField.autocapitalizationType = capitalization;
[self processValidation];
}
- (void)processValidation
{
if (self.isValid)
{
self.labelHeight.priority = UILayoutPriorityDefaultHigh;
self.errorLabelTopSpace.constant = 0.;
[self.contentView setStyleNameAndApply: @"Background"];
}
else
{
self.labelHeight.priority = UILayoutPriorityDefaultLow;
self.errorLabelTopSpace.constant = kErrorLabelDefaultTopSpace;
[self.contentView setStyleNameAndApply: @"ErrorBackground"];
}
[self layoutIfNeeded];
}
- (void)changeInvalidCellState
{
if (self.isValid)
return;
self.isValid = YES;
[self processValidation];
[self.delegate tryToChangeInvalidStateForCell:self];
}
#pragma mark - UITextFieldDelegate
- (BOOL)textField:(UITextField *)textField
shouldChangeCharactersInRange:(NSRange)range
replacementString:(NSString *)string
{
[self changeInvalidCellState];
return YES;
}
- (BOOL)textFieldShouldClear:(UITextField *)textField
{
[self changeInvalidCellState];
return YES;
}
- (void)textFieldDidEndEditing:(UITextField *)textField
{
[self.delegate cell:self changedText:textField.text];
}
- (BOOL)textFieldShouldReturn:(UITextField *)textField
{
[textField resignFirstResponder];
return YES;
}
@end

View file

@ -0,0 +1,87 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="20037" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES">
<device id="retina6_1" orientation="portrait" appearance="light"/>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="20020"/>
<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" rowHeight="56" id="KGk-i7-Jjw" customClass="MWMEditorTextTableViewCell">
<rect key="frame" x="0.0" y="0.0" width="320" height="59"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="KGk-i7-Jjw" id="H2p-sc-9uM">
<rect key="frame" x="0.0" y="0.0" width="320" height="59"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="5uK-5Q-cg0">
<rect key="frame" x="16" y="15.5" width="28" height="28"/>
<constraints>
<constraint firstAttribute="height" constant="28" id="6Kb-wI-H3V"/>
<constraint firstAttribute="width" constant="28" id="nbm-T8-Yob"/>
</constraints>
<userDefinedRuntimeAttributes>
<userDefinedRuntimeAttribute type="string" keyPath="styleName" value="MWMBlack"/>
</userDefinedRuntimeAttributes>
</imageView>
<textField opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="bottom" textAlignment="natural" minimumFontSize="17" clearButtonMode="whileEditing" translatesAutoresizingMaskIntoConstraints="NO" id="krN-k2-9qO">
<rect key="frame" x="60" y="0.0" width="252" height="28"/>
<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="28" id="P3n-mD-g5V"/>
</constraints>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<textInputTraits key="textInputTraits" autocapitalizationType="sentences"/>
<userDefinedRuntimeAttributes>
<userDefinedRuntimeAttribute type="string" keyPath="styleName" value="regular17:blackPrimaryText"/>
</userDefinedRuntimeAttributes>
<connections>
<outlet property="delegate" destination="KGk-i7-Jjw" id="GO4-EB-MG9"/>
</connections>
</textField>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="natural" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" preferredMaxLayoutWidth="252" translatesAutoresizingMaskIntoConstraints="NO" id="Lht-i1-s0H">
<rect key="frame" x="60" y="32" width="252" 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="250" id="2X4-TJ-v2V"/>
</constraints>
<fontDescription key="fontDescription" type="system" pointSize="12"/>
<color key="textColor" red="0.95686274510000002" green="0.26274509800000001" blue="0.21176470589999999" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<nil key="highlightedColor"/>
<userDefinedRuntimeAttributes>
<userDefinedRuntimeAttribute type="string" keyPath="styleName" value="regular12:redText"/>
</userDefinedRuntimeAttributes>
</label>
</subviews>
<constraints>
<constraint firstAttribute="bottom" secondItem="Lht-i1-s0H" secondAttribute="bottom" constant="12" id="DhN-vK-bTb"/>
<constraint firstItem="Lht-i1-s0H" firstAttribute="leading" secondItem="H2p-sc-9uM" secondAttribute="leading" constant="60" id="EIo-KA-vQX"/>
<constraint firstItem="krN-k2-9qO" firstAttribute="top" secondItem="H2p-sc-9uM" secondAttribute="top" id="M6R-qw-860"/>
<constraint firstAttribute="trailing" secondItem="krN-k2-9qO" secondAttribute="trailing" constant="8" id="O2l-xa-4ZO"/>
<constraint firstItem="Lht-i1-s0H" firstAttribute="top" secondItem="krN-k2-9qO" secondAttribute="bottom" constant="4" id="WLe-gG-Nur"/>
<constraint firstAttribute="trailing" secondItem="Lht-i1-s0H" secondAttribute="trailing" constant="8" id="bkK-l2-xGd"/>
<constraint firstItem="5uK-5Q-cg0" firstAttribute="centerY" secondItem="H2p-sc-9uM" secondAttribute="centerYWithinMargins" id="mZL-51-0kV"/>
<constraint firstItem="5uK-5Q-cg0" firstAttribute="leading" secondItem="H2p-sc-9uM" secondAttribute="leading" constant="16" id="ufn-3T-MOd"/>
<constraint firstItem="krN-k2-9qO" firstAttribute="leading" secondItem="H2p-sc-9uM" secondAttribute="leading" constant="60" id="w8z-Hi-yGr"/>
</constraints>
<userDefinedRuntimeAttributes>
<userDefinedRuntimeAttribute type="string" keyPath="styleName" value="Background"/>
</userDefinedRuntimeAttributes>
</tableViewCellContentView>
<inset key="separatorInset" minX="60" minY="0.0" maxX="0.0" maxY="0.0"/>
<userDefinedRuntimeAttributes>
<userDefinedRuntimeAttribute type="string" keyPath="styleName" value="Background"/>
</userDefinedRuntimeAttributes>
<connections>
<outlet property="errorLabel" destination="Lht-i1-s0H" id="N2I-je-OSW"/>
<outlet property="errorLabelTopSpace" destination="WLe-gG-Nur" id="shl-Rd-fU4"/>
<outlet property="icon" destination="5uK-5Q-cg0" id="5du-LU-RmA"/>
<outlet property="labelHeight" destination="2X4-TJ-v2V" id="5jn-qt-Ma7"/>
<outlet property="textField" destination="krN-k2-9qO" id="Fqg-H9-JpU"/>
</connections>
<point key="canvasLocation" x="327" y="351"/>
</tableViewCell>
</objects>
</document>

View file

@ -0,0 +1,27 @@
#import "MWMTableViewCell.h"
@class MWMNoteCell;
NS_ASSUME_NONNULL_BEGIN
@protocol MWMNoteCellDelegate <NSObject>
- (void)cell:(MWMNoteCell *)cell didChangeSizeAndText:(NSString *)text;
- (void)cell:(MWMNoteCell *)cell didFinishEditingWithText:(NSString *)text;
@end
@interface MWMNoteCell : MWMTableViewCell
@property(nonatomic, readonly, class) CGFloat minimalHeight;
@property(nonatomic, readonly) CGFloat cellHeight;
@property(nonatomic, readonly) CGFloat textViewContentHeight;
- (void)configWithDelegate:(id<MWMNoteCellDelegate>)delegate
noteText:(NSString *)text
placeholder:(NSString *)placeholder;
- (void)updateTextViewForHeight:(CGFloat)height;
@end
NS_ASSUME_NONNULL_END

View file

@ -0,0 +1,87 @@
#import "MWMNoteCell.h"
#import "MWMTextView.h"
static CGFloat const kTopTextViewOffset = 12.;
static NSString *const kTextViewContentSizeKeyPath = @"contentSize";
static CGFloat const kMinimalTextViewHeight = 44.;
static void *kContext = &kContext;
@interface MWMNoteCell () <UITextViewDelegate>
@property(nonatomic) IBOutlet MWMTextView *textView;
@property(nonatomic) IBOutlet NSLayoutConstraint *textViewHeight;
@property(weak, nonatomic) id<MWMNoteCellDelegate> delegate;
@end
@implementation MWMNoteCell
- (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.placeholder = placeholder;
}
- (void)updateTextViewForHeight:(CGFloat)height {
id<MWMNoteCellDelegate> delegate = self.delegate;
if (height > kMinimalTextViewHeight) {
[delegate cell:self didChangeSizeAndText:self.textView.text];
}
[self setNeedsLayout];
}
- (void)observeValueForKeyPath:(NSString *)keyPath
ofObject:(id)object
change:(NSDictionary *)change
context:(void *)context {
if (context == kContext) {
NSValue *s = change[NSKeyValueChangeNewKey];
CGFloat height = s.CGSizeValue.height;
[self updateTextViewForHeight:height];
return;
}
[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;
}
- (void)textViewDidEndEditing:(UITextView *)textView {
[self.delegate cell:self didFinishEditingWithText:textView.text];
[self unregisterObserver];
}
- (void)textViewDidBeginEditing:(UITextView *)textView {
[self registerObserver];
}
- (void)textViewDidChange:(UITextView *)textView {
[textView sizeToFit];
}
- (void)unregisterObserver {
[self.textView removeObserver:self forKeyPath:kTextViewContentSizeKeyPath context:kContext];
}
- (void)registerObserver {
[self.textView addObserver:self
forKeyPath:kTextViewContentSizeKeyPath
options:NSKeyValueObservingOptionNew
context:kContext];
}
@end

View file

@ -0,0 +1,49 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="19529" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES">
<device id="retina4_7" orientation="portrait" appearance="light"/>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="19519"/>
<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" rowHeight="129" id="KGk-i7-Jjw" customClass="MWMNoteCell" propertyAccessControl="none">
<rect key="frame" x="0.0" y="0.0" width="320" height="129"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="KGk-i7-Jjw" id="H2p-sc-9uM">
<rect key="frame" x="0.0" y="0.0" width="320" height="129"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<textView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" scrollEnabled="NO" showsHorizontalScrollIndicator="NO" showsVerticalScrollIndicator="NO" textAlignment="natural" translatesAutoresizingMaskIntoConstraints="NO" id="d32-xF-MvW" customClass="MWMTextView">
<rect key="frame" x="16" y="12" width="288" height="105"/>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<constraints>
<constraint firstAttribute="height" relation="greaterThanOrEqual" constant="44" id="J3M-HG-f2p"/>
</constraints>
<fontDescription key="fontDescription" type="system" pointSize="14"/>
<textInputTraits key="textInputTraits" autocapitalizationType="sentences"/>
<userDefinedRuntimeAttributes>
<userDefinedRuntimeAttribute type="string" keyPath="styleName" value="Background:regular17:blackPrimaryText"/>
</userDefinedRuntimeAttributes>
<connections>
<outlet property="delegate" destination="KGk-i7-Jjw" id="b3Z-HX-D7g"/>
</connections>
</textView>
</subviews>
<constraints>
<constraint firstAttribute="trailing" secondItem="d32-xF-MvW" secondAttribute="trailing" constant="16" id="Ost-1C-1e0"/>
<constraint firstItem="d32-xF-MvW" firstAttribute="leading" secondItem="H2p-sc-9uM" secondAttribute="leading" constant="16" id="VYR-fH-Xju"/>
<constraint firstAttribute="bottom" secondItem="d32-xF-MvW" secondAttribute="bottom" constant="12" id="X92-RT-6WG"/>
<constraint firstItem="d32-xF-MvW" firstAttribute="top" secondItem="H2p-sc-9uM" secondAttribute="top" constant="12" id="YRt-nX-DIa"/>
</constraints>
</tableViewCellContentView>
<connections>
<outlet property="textView" destination="d32-xF-MvW" id="dwC-Cl-3Pl"/>
<outlet property="textViewHeight" destination="J3M-HG-f2p" id="rK2-Hv-d1g"/>
</connections>
<point key="canvasLocation" x="334" y="383"/>
</tableViewCell>
</objects>
</document>

View file

@ -0,0 +1,17 @@
#import "MWMViewController.h"
#include <string>
#include <vector>
@protocol MWMCuisineEditorProtocol <NSObject>
- (std::vector<std::string>)selectedCuisines;
- (void)setSelectedCuisines:(std::vector<std::string> const &)cuisines;
@end
@interface MWMCuisineEditorViewController : MWMViewController
@property (weak, nonatomic) id<MWMCuisineEditorProtocol> delegate;
@end

View file

@ -0,0 +1,239 @@
#import "MWMCuisineEditorViewController.h"
#import "MWMKeyboard.h"
#import "MWMTableViewCell.h"
#import "SwiftBridge.h"
#include "indexer/cuisines.hpp"
#include "indexer/search_string_utils.hpp"
namespace
{
NSString * const kCuisineEditorCell = @"MWMCuisineEditorTableViewCell";
/// @returns pair.first in a separate vector.
std::vector<std::string> SliceKeys(std::vector<std::pair<std::string, std::string>> const & v)
{
std::vector<std::string> res;
for (auto const & kv : v)
res.push_back(kv.first);
return res;
}
} // namespace
@interface MWMCuisineEditorViewController ()<UISearchBarDelegate, MWMKeyboardObserver>
{
osm::AllCuisines m_allCuisines;
std::vector<std::string> m_selectedCuisines;
std::vector<std::string> m_displayedKeys;
std::vector<std::string> m_untranslatedKeys;
}
@property(weak, nonatomic) IBOutlet UITableView * tableView;
@property(weak, nonatomic) IBOutlet UISearchBar * searchBar;
@property(nonatomic) BOOL isSearch;
@end
@implementation MWMCuisineEditorViewController
- (void)viewDidLoad
{
[super viewDidLoad];
[self configNavBar];
[self configSearchBar];
[self configData];
[self configTable];
[MWMKeyboard addObserver:self];
}
- (UIStatusBarStyle)preferredStatusBarStyle
{
return UIStatusBarStyleLightContent;
}
#pragma mark - MWMKeyboard
- (void)onKeyboardAnimation
{
UIEdgeInsets const contentInsets = {.bottom = [MWMKeyboard keyboardHeight]};
self.tableView.contentInset = contentInsets;
self.tableView.scrollIndicatorInsets = contentInsets;
}
#pragma mark - UISearchBarDelegate
- (void)searchBar:(UISearchBar *)searchBar textDidChange:(NSString *)searchText
{
m_displayedKeys.clear();
if (searchText.length)
{
self.isSearch = YES;
std::string const st = searchText.UTF8String;
for (auto const & kv : m_allCuisines)
if (search::ContainsNormalized(kv.second, st))
m_displayedKeys.push_back(kv.first);
}
else
{
self.isSearch = NO;
m_displayedKeys = SliceKeys(m_allCuisines);
}
[self.tableView reloadData];
}
- (BOOL)searchBarShouldBeginEditing:(UISearchBar *)searchBar
{
self.isSearch = NO;
[self searchBar:searchBar setActiveState:YES];
return YES;
}
- (BOOL)searchBarShouldEndEditing:(UISearchBar *)searchBar
{
if (!searchBar.text.length)
{
self.isSearch = NO;
[self searchBar:searchBar setActiveState:NO];
}
return YES;
}
- (void)searchBarCancelButtonClicked:(UISearchBar *)searchBar
{
self.isSearch = NO;
[searchBar resignFirstResponder];
searchBar.text = @"";
[self searchBar:searchBar setActiveState:NO];
m_displayedKeys = SliceKeys(m_allCuisines);
[self.tableView reloadData];
}
- (void)searchBarSearchButtonClicked:(UISearchBar *)searchBar { [searchBar resignFirstResponder]; }
- (UIBarPosition)positionForBar:(id<UIBarPositioning>)bar { return UIBarPositionTopAttached; }
- (void)searchBar:(UISearchBar *)searchBar setActiveState:(BOOL)isActiveState
{
[searchBar setShowsCancelButton:isActiveState animated:YES];
[self.navigationController setNavigationBarHidden:isActiveState animated:YES];
}
#pragma mark - Configuration
- (void)configNavBar
{
self.title = L(@"cuisine");
self.navigationItem.leftBarButtonItem =
[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCancel
target:self
action:@selector(onCancel)];
self.navigationItem.rightBarButtonItem =
[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemDone
target:self
action:@selector(onDone)];
self.navigationController.navigationBar.barStyle = UIBarStyleBlack;
}
- (void)configSearchBar
{
self.isSearch = NO;
self.searchBar.placeholder = L(@"search");
}
- (void)configData
{
using namespace osm;
m_allCuisines = Cuisines::Instance().AllSupportedCuisines();
m_displayedKeys = SliceKeys(m_allCuisines);
m_selectedCuisines = [self.delegate selectedCuisines];
for (auto const & s : m_selectedCuisines)
{
std::string const translated = Cuisines::Instance().Translate(s);
if (translated.empty())
m_untranslatedKeys.push_back(s);
}
}
- (void)configTable
{
[self.tableView registerClass:[MWMTableViewCell class]
forCellReuseIdentifier:[UITableViewCell className]];
}
#pragma mark - Actions
- (void)onCancel { [self.navigationController popViewControllerAnimated:YES]; }
- (void)onDone
{
[self.delegate setSelectedCuisines:m_selectedCuisines];
[self onCancel];
}
#pragma mark - MWMCuisineEditorTableViewCellProtocol
- (void)change:(std::string const &)key selected:(BOOL)selected
{
if (selected)
m_selectedCuisines.push_back(key);
else
m_selectedCuisines.erase(std::find(m_selectedCuisines.begin(), m_selectedCuisines.end(), key));
}
#pragma mark - UITableViewDataSource
- (UITableViewCell * _Nonnull)tableView:(UITableView * _Nonnull)tableView
cellForRowAtIndexPath:(NSIndexPath * _Nonnull)indexPath
{
auto cell =
[tableView dequeueReusableCellWithCellClass:[UITableViewCell class] indexPath:indexPath];
NSInteger const index = indexPath.row;
auto const & dataSource = [self dataSourceForSection:indexPath.section];
std::string const & key = dataSource[index];
if (dataSource == m_displayedKeys)
{
std::string const translated = osm::Cuisines::Instance().Translate(m_displayedKeys[index]);
NSAssert(!translated.empty(), @"There are only localizable keys in m_displayedKeys!");
cell.textLabel.text = @(translated.c_str());
}
else
{
cell.textLabel.text = @(key.c_str());
}
BOOL const selected =
std::find(m_selectedCuisines.begin(), m_selectedCuisines.end(), key) != m_selectedCuisines.end();
cell.accessoryType = selected ? UITableViewCellAccessoryCheckmark : UITableViewCellAccessoryNone;
return cell;
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return self.isSearch ? 1 : !m_untranslatedKeys.empty() + !m_displayedKeys.empty();
}
- (NSInteger)tableView:(UITableView * _Nonnull)tableView numberOfRowsInSection:(NSInteger)section
{
return [self dataSourceForSection:section].size();
}
- (std::vector<std::string> const &)dataSourceForSection:(NSInteger)section
{
if (m_untranslatedKeys.empty())
return m_displayedKeys;
else
return self.isSearch ? m_displayedKeys : (section == 0 ? m_untranslatedKeys : m_displayedKeys);
}
#pragma mark - UITableViewDelegate
- (void)tableView:(UITableView * _Nonnull)tableView
didSelectRowAtIndexPath:(NSIndexPath * _Nonnull)indexPath
{
UITableViewCell * cell = [tableView cellForRowAtIndexPath:indexPath];
[cell setSelected:NO animated:YES];
BOOL const isAlreadySelected = cell.accessoryType == UITableViewCellAccessoryCheckmark;
cell.accessoryType =
isAlreadySelected ? UITableViewCellAccessoryNone : UITableViewCellAccessoryCheckmark;
[self change:[self dataSourceForSection:indexPath.section][indexPath.row]
selected:!isAlreadySelected];
}
@end

View file

@ -0,0 +1,8 @@
@interface MWMEditorAdditionalNamesHeader : UIView
+ (instancetype)header:(MWMVoidBlock)toggleBlock;
- (void)setShowAdditionalNames:(BOOL)showAdditionalNames;
- (void)setAdditionalNamesVisible:(BOOL)visible;
@end

View file

@ -0,0 +1,38 @@
#import "MWMButton.h"
#import "MWMEditorAdditionalNamesHeader.h"
@interface MWMEditorAdditionalNamesHeader ()
@property (weak, nonatomic) IBOutlet UILabel * label;
@property(copy, nonatomic) MWMVoidBlock toggleBlock;
@property (weak, nonatomic) IBOutlet MWMButton * toggleButton;
@end
@implementation MWMEditorAdditionalNamesHeader
+ (instancetype)header:(MWMVoidBlock)toggleBlock
{
MWMEditorAdditionalNamesHeader * h =
[NSBundle.mainBundle loadNibNamed:[self className] owner:nil options:nil].firstObject;
h.label.text = L(@"place_name").uppercaseString;
h.toggleBlock = toggleBlock;
return h;
}
- (IBAction)toggleAction
{
self.toggleBlock();
}
- (void)setShowAdditionalNames:(BOOL)showAdditionalNames
{
[self.toggleButton setTitle:showAdditionalNames ? L(@"hide") : L(@"show") forState:UIControlStateNormal];
}
- (void)setAdditionalNamesVisible:(BOOL)visible
{
self.toggleButton.hidden = !visible;
}
@end

View file

@ -0,0 +1,61 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="15702" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES">
<device id="retina6_1" orientation="portrait" appearance="light"/>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="15704"/>
<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"/>
<view contentMode="scaleToFill" preservesSuperviewLayoutMargins="YES" id="fMr-en-6Lb" customClass="MWMEditorAdditionalNamesHeader" propertyAccessControl="none">
<rect key="frame" x="0.0" y="0.0" width="320" height="40"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="ZVV-q9-714">
<rect key="frame" x="16" y="16" width="194" height="16"/>
<fontDescription key="fontDescription" type="system" pointSize="13"/>
<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="styleName" value="regular13:blackSecondaryText"/>
</userDefinedRuntimeAttributes>
</label>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="right" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="fgf-k2-uT4" customClass="MWMButton">
<rect key="frame" x="214" y="0.0" width="90" height="40"/>
<constraints>
<constraint firstAttribute="width" priority="750" constant="90" id="WzJ-y1-Q2m"/>
</constraints>
<fontDescription key="fontDescription" type="system" pointSize="14"/>
<inset key="contentEdgeInsets" minX="0.0" minY="0.0" maxX="16" maxY="4"/>
<state key="normal" title="Скрыть">
<color key="titleColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</state>
<userDefinedRuntimeAttributes>
<userDefinedRuntimeAttribute type="string" keyPath="styleName" value="MoreButton:regular13"/>
<userDefinedRuntimeAttribute type="string" keyPath="localizedText" value="show"/>
</userDefinedRuntimeAttributes>
<connections>
<action selector="toggleAction" destination="fMr-en-6Lb" eventType="touchUpInside" id="tKp-wB-cKI"/>
</connections>
</button>
</subviews>
<color key="backgroundColor" red="0.0" green="0.0" blue="0.0" alpha="0.0" colorSpace="custom" customColorSpace="sRGB"/>
<constraints>
<constraint firstItem="fgf-k2-uT4" firstAttribute="top" secondItem="fMr-en-6Lb" secondAttribute="top" id="aa6-A6-gYY"/>
<constraint firstAttribute="bottom" secondItem="ZVV-q9-714" secondAttribute="bottom" constant="8" id="acW-Jb-4Rd"/>
<constraint firstItem="ZVV-q9-714" firstAttribute="leading" secondItem="fMr-en-6Lb" secondAttribute="leadingMargin" id="bfa-to-CBn"/>
<constraint firstAttribute="bottom" secondItem="fgf-k2-uT4" secondAttribute="bottom" id="i6A-IT-Uyi"/>
<constraint firstAttribute="trailingMargin" secondItem="fgf-k2-uT4" secondAttribute="trailing" priority="750" id="oMs-yA-J0S"/>
<constraint firstItem="fgf-k2-uT4" firstAttribute="leading" secondItem="ZVV-q9-714" secondAttribute="trailing" priority="700" constant="4" id="yNz-90-zJf"/>
</constraints>
<freeformSimulatedSizeMetrics key="simulatedDestinationMetrics"/>
<connections>
<outlet property="label" destination="ZVV-q9-714" id="wba-YT-Rav"/>
<outlet property="toggleButton" destination="fgf-k2-uT4" id="sr5-LJ-kfu"/>
</connections>
<point key="canvasLocation" x="244" y="341"/>
</view>
</objects>
</document>

View file

@ -0,0 +1,26 @@
#pragma once
#include "indexer/feature_meta.hpp"
using MetadataID = feature::Metadata::EType;
enum MWMEditorCellType
{
MWMEditorCellTypeCoordinate = MetadataID::FMD_COUNT + 1,
MWMEditorCellTypeBookmark,
MWMEditorCellTypeEditButton,
MWMEditorCellTypeAddBusinessButton,
MWMEditorCellTypeAddPlaceButton,
MWMEditorCellTypeReportButton,
MWMEditorCellTypeCategory,
MWMEditorCellTypeName,
MWMEditorCellTypeAdditionalName,
MWMEditorCellTypeAddAdditionalName,
MWMEditorCellTypeAddAdditionalNamePlaceholder,
MWMEditorCellTypeStreet,
MWMEditorCellTypeBuilding,
MWMEditorCellTypeNote,
MWMEditorCellTypeBookingMore,
};
// Combines MetadataID and MWMEditorCellType.
using MWMEditorCellID = std::underlying_type<MetadataID>::type;

View file

@ -0,0 +1,20 @@
#include "indexer/yes_no_unknown.hpp"
@class MWMEditorTextTableViewCell;
@class MWMTableViewCell;
@protocol MWMEditorCellProtocol <NSObject>
- (void)cell:(MWMTableViewCell *)cell changedText:(NSString *)changeText;
- (void)cell:(UITableViewCell *)cell changeSwitch:(BOOL)changeSwitch;
- (void)cell:(UITableViewCell *)cell changeSegmented:(YesNoUnknown)changeSegmented;
- (void)cellDidPressButton:(UITableViewCell *)cell;
- (void)tryToChangeInvalidStateForCell:(MWMTableViewCell *)cell;
@end
@protocol MWMEditorAdditionalName <MWMEditorCellProtocol>
- (void)editAdditionalNameLanguage:(NSInteger)selectedLangCode;
@end

View file

@ -0,0 +1,5 @@
@interface MWMEditorNotesFooter : UIView
+ (instancetype)footerForController:(UIViewController *)controller;
@end

View file

@ -0,0 +1,28 @@
#import "MWMEditorNotesFooter.h"
@interface MWMEditorNotesFooter ()
@property (weak, nonatomic) UIViewController * controller;
@end
@implementation MWMEditorNotesFooter
+ (instancetype)footerForController:(UIViewController *)controller
{
MWMEditorNotesFooter * f =
[NSBundle.mainBundle loadNibNamed:[self className] owner:nil options:nil].firstObject;
f.controller = controller;
[f setNeedsLayout];
[f layoutIfNeeded];
NSAssert(f.subviews.firstObject, @"Subviews can't be empty!");
f.height = f.subviews.firstObject.height;
return f;
}
- (IBAction)osmTap
{
[self.controller openUrl:L(@"osm_more_about_url")];
}
@end

View file

@ -0,0 +1,71 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="23727" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" colorMatched="YES">
<device id="retina4_7" orientation="portrait" appearance="light"/>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="23721"/>
<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"/>
<view contentMode="scaleToFill" id="IBb-39-rly" customClass="MWMEditorNotesFooter" propertyAccessControl="none">
<rect key="frame" x="0.0" y="0.0" width="320" height="144"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<subviews>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="xcv-fG-OmU">
<rect key="frame" x="0.0" y="-14.5" width="320" height="173"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" textAlignment="natural" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" preferredMaxLayoutWidth="288" translatesAutoresizingMaskIntoConstraints="NO" id="vxr-iR-qGP">
<rect key="frame" x="16" y="0.0" width="288" height="143"/>
<constraints>
<constraint firstAttribute="height" relation="greaterThanOrEqual" constant="21" id="q02-z4-K9S"/>
</constraints>
<string key="text">Предложенные вами изменения на карте будут отправлены в OpenStreetMap. Если у вас есть дополнительные сведения об объекте, которые CoMaps не может позволить отредактировать, напишите о них.</string>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<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="styleName" value="regular14:blackSecondaryText"/>
<userDefinedRuntimeAttribute type="string" keyPath="localizedText" value="editor_detailed_description"/>
</userDefinedRuntimeAttributes>
</label>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="60F-c7-enR">
<rect key="frame" x="16" y="151" width="288" height="16"/>
<constraints>
<constraint firstAttribute="height" constant="16" id="lB5-ya-sBr"/>
</constraints>
<state key="normal" title="Button"/>
<userDefinedRuntimeAttributes>
<userDefinedRuntimeAttribute type="string" keyPath="localizedText" value="osm_more_about"/>
<userDefinedRuntimeAttribute type="string" keyPath="styleName" value="MoreButton:regular14"/>
</userDefinedRuntimeAttributes>
<connections>
<action selector="osmTap" destination="IBb-39-rly" eventType="touchUpInside" id="EjN-0s-Ycy"/>
</connections>
</button>
</subviews>
<color key="backgroundColor" red="0.0" green="0.0" blue="0.0" alpha="0.0" colorSpace="custom" customColorSpace="sRGB"/>
<constraints>
<constraint firstAttribute="trailingMargin" secondItem="60F-c7-enR" secondAttribute="trailing" constant="8" id="dTB-mL-e3M"/>
<constraint firstItem="vxr-iR-qGP" firstAttribute="leading" secondItem="xcv-fG-OmU" secondAttribute="leadingMargin" constant="8" id="g35-I7-Ct4"/>
<constraint firstItem="60F-c7-enR" firstAttribute="leading" secondItem="xcv-fG-OmU" secondAttribute="leadingMargin" constant="8" id="iiZ-Je-sn7"/>
<constraint firstItem="60F-c7-enR" firstAttribute="top" secondItem="vxr-iR-qGP" secondAttribute="bottom" constant="8" id="r8W-qV-Dd0"/>
<constraint firstItem="vxr-iR-qGP" firstAttribute="top" secondItem="xcv-fG-OmU" secondAttribute="top" id="tP9-HJ-DDm"/>
<constraint firstAttribute="trailingMargin" secondItem="vxr-iR-qGP" secondAttribute="trailing" constant="8" id="wPA-fe-5a9"/>
<constraint firstAttribute="bottom" secondItem="60F-c7-enR" secondAttribute="bottom" constant="6" id="ylg-M3-Ejt"/>
</constraints>
</view>
</subviews>
<color key="backgroundColor" red="0.0" green="0.0" blue="0.0" alpha="0.0" colorSpace="custom" customColorSpace="sRGB"/>
<constraints>
<constraint firstItem="xcv-fG-OmU" firstAttribute="centerY" secondItem="IBb-39-rly" secondAttribute="centerY" id="FeQ-eT-FSb"/>
<constraint firstItem="xcv-fG-OmU" firstAttribute="centerX" secondItem="IBb-39-rly" secondAttribute="centerX" id="HR2-4M-jr2"/>
<constraint firstItem="xcv-fG-OmU" firstAttribute="width" secondItem="IBb-39-rly" secondAttribute="width" id="das-TJ-zih"/>
</constraints>
<nil key="simulatedTopBarMetrics"/>
<freeformSimulatedSizeMetrics key="simulatedDestinationMetrics"/>
<point key="canvasLocation" x="655.07246376811599" y="311.38392857142856"/>
</view>
</objects>
</document>

View file

@ -0,0 +1,16 @@
#import "MWMTableViewController.h"
struct FeatureID;
namespace osm
{
class EditableMapObject;
} // namespace osm
@interface MWMEditorViewController : MWMTableViewController
@property (nonatomic) BOOL isCreating;
- (void)setFeatureToEdit:(FeatureID const &)fid;
- (void)setEditableMapObject:(osm::EditableMapObject const &)emo;
@end

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,22 @@
#import "MWMViewController.h"
#include <string>
namespace osm
{
class EditableMapObject;
} // namespace osm
@protocol MWMObjectsCategorySelectorDelegate <NSObject>
- (void)reloadObject:(osm::EditableMapObject const &)object;
@end
@interface MWMObjectsCategorySelectorController : MWMViewController
@property (weak, nonatomic) id<MWMObjectsCategorySelectorDelegate> delegate;
- (void)setSelectedCategory:(std::string const &)type;
@end

View file

@ -0,0 +1,282 @@
#import "MWMObjectsCategorySelectorController.h"
#import "MWMObjectsCategorySelectorDataSource.h"
#import "MWMEditorViewController.h"
#import "MWMKeyboard.h"
#import "MWMTableViewCell.h"
#import "SwiftBridge.h"
#include <CoreApi/Framework.h>
using namespace osm;
namespace
{
NSString * const kToEditorSegue = @"CategorySelectorToEditorSegue";
} // namespace
@interface MWMObjectsCategorySelectorController ()<UISearchBarDelegate, UITableViewDelegate,
UITableViewDataSource, MWMKeyboardObserver>
{
}
@property(weak, nonatomic) IBOutlet UITableView * tableView;
@property(weak, nonatomic) IBOutlet UISearchBar * searchBar;
@property(nonatomic) NSString * selectedType;
@property(nonatomic) BOOL isSearch;
@property(nonatomic) MWMObjectsCategorySelectorDataSource * dataSource;
@property(nonatomic, strong) UIStackView * searchResultsIsEmptyDisclaimer;
@end
@implementation MWMObjectsCategorySelectorController
- (instancetype)initWithCoder:(NSCoder *)aDecoder
{
self = [super initWithCoder:aDecoder];
return self;
}
- (void)viewDidLoad
{
[super viewDidLoad];
self.isSearch = NO;
[self configTable];
[self configNavBar];
[self configSearchBar];
[self configEmptySearchResultsDisclaimer];
[MWMKeyboard addObserver:self];
self.dataSource = [[MWMObjectsCategorySelectorDataSource alloc] init];
}
- (void)configTable
{
[self.tableView registerClass:[MWMTableViewCell class]
forCellReuseIdentifier:[UITableViewCell className]];
}
- (void)setSelectedCategory:(std::string const &)type
{
self.selectedType = @(type.c_str());
}
- (UIStatusBarStyle)preferredStatusBarStyle
{
return UIStatusBarStyleLightContent;
}
- (void)configNavBar { self.title = L(@"editor_add_select_category"); }
- (void)configSearchBar
{
self.searchBar.placeholder = L(@"search");
}
- (void)configEmptySearchResultsDisclaimer
{
UIStackView * stackView = [[UIStackView alloc] init];
stackView.axis = UILayoutConstraintAxisVertical;
stackView.alignment = UIStackViewAlignmentFill;
stackView.translatesAutoresizingMaskIntoConstraints = NO;
stackView.spacing = 12;
self.searchResultsIsEmptyDisclaimer = stackView;
UILabel *titleLabel = [[UILabel alloc] init];
titleLabel.text = L(@"editor_category_unsuitable_title");
titleLabel.font = [UIFont boldSystemFontOfSize:20];
titleLabel.textAlignment = NSTextAlignmentCenter;
titleLabel.translatesAutoresizingMaskIntoConstraints = NO;
titleLabel.font = [UIFont bold17];
titleLabel.numberOfLines = 0;
UITextView * subtitleTextView = [[UITextView alloc] init];
subtitleTextView.translatesAutoresizingMaskIntoConstraints = NO;
subtitleTextView.editable = NO;
subtitleTextView.scrollEnabled = NO;
subtitleTextView.backgroundColor = [UIColor clearColor];
subtitleTextView.textContainerInset = UIEdgeInsetsZero;
NSString *subtitleHTML = L(@"editor_category_unsuitable_text");
NSData *htmlData = [subtitleHTML dataUsingEncoding:NSUnicodeStringEncoding];
NSDictionary *options = @{NSDocumentTypeDocumentAttribute: NSHTMLTextDocumentType};
NSError *error = nil;
NSAttributedString *attributedText =
[[NSAttributedString alloc] initWithData:htmlData
options:options
documentAttributes:nil
error:&error];
if (error) {
LOG(LERROR, ("Error parsing HTML:", error.localizedDescription));
} else {
UIColor * textColor;
if (@available(iOS 13.0, *)) {
textColor = [[UIColor alloc] initWithDynamicProvider:^UIColor * (UITraitCollection * traitCollection) {
return traitCollection.userInterfaceStyle == UIUserInterfaceStyleDark ? UIColor.whitePrimaryText : UIColor.blackPrimaryText;
}];
} else {
textColor = UIColor.blackPrimaryText;
}
NSMutableAttributedString *mutableAttributedText = [[NSMutableAttributedString alloc] initWithAttributedString:attributedText];
[mutableAttributedText addAttributes:@{ NSForegroundColorAttributeName: textColor,
NSFontAttributeName: UIFont.regular14}
range:NSMakeRange(0, mutableAttributedText.length)];
subtitleTextView.attributedText = mutableAttributedText;
subtitleTextView.textAlignment = NSTextAlignmentCenter;
}
[self.view addSubview:stackView];
[stackView addArrangedSubview:titleLabel];
[stackView addArrangedSubview:subtitleTextView];
[NSLayoutConstraint activateConstraints:@[
[stackView.centerXAnchor constraintEqualToAnchor:self.view.centerXAnchor],
[stackView.centerYAnchor constraintEqualToAnchor:self.view.centerYAnchor],
[stackView.leadingAnchor constraintEqualToAnchor:self.view.leadingAnchor constant:20],
[stackView.trailingAnchor constraintEqualToAnchor:self.view.trailingAnchor constant:-20]
]];
}
- (void)onDone
{
if (!self.selectedType)
return;
[self performSegueWithIdentifier:kToEditorSegue sender:nil];
}
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
if (![segue.identifier isEqualToString:kToEditorSegue])
{
NSAssert(false, @"incorrect segue");
return;
}
MWMEditorViewController * dest =
static_cast<MWMEditorViewController *>(segue.destinationViewController);
dest.isCreating = YES;
auto const object = self.createdObject;
[dest setEditableMapObject:object];
}
#pragma mark - MWMKeyboard
- (void)onKeyboardAnimation
{
UIEdgeInsets const contentInsets = {.bottom = [MWMKeyboard keyboardHeight]};
self.tableView.contentInset = contentInsets;
self.tableView.scrollIndicatorInsets = contentInsets;
}
#pragma mark - Create object
- (EditableMapObject)createdObject
{
EditableMapObject emo;
auto & f = GetFramework();
auto const type = classif().GetTypeByReadableObjectName(self.selectedType.UTF8String);
if (!f.CreateMapObject(f.GetViewportCenter(), type, emo))
NSAssert(false, @"This call should never fail, because IsPointCoveredByDownloadedMaps is "
@"always called before!");
return emo;
}
#pragma mark - UITableView
- (UITableViewCell *)tableView:(UITableView *)tableView
cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
auto cell =
[tableView dequeueReusableCellWithCellClass:[UITableViewCell class] indexPath:indexPath];
cell.textLabel.text = [self.dataSource getTranslation:indexPath.row];
auto const type = [self.dataSource getType:indexPath.row];
if ([type isEqualToString:self.selectedType])
cell.accessoryType = UITableViewCellAccessoryCheckmark;
else
cell.accessoryType = UITableViewCellAccessoryNone;
return cell;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
self.selectedType = [self.dataSource getType:indexPath.row];
id<MWMObjectsCategorySelectorDelegate> delegate = self.delegate;
if (delegate)
{
auto const object = self.createdObject;
[delegate reloadObject:object];
[self goBack];
}
else
[self performSegueWithIdentifier:kToEditorSegue sender:nil];
}
// TODO(Vlad): Uncoment this line when we will be ready to show recent categories
//- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
//{
// return self.isSearch ? 1 : !m_categories.m_allSorted.empty() + !m_categories.m_lastUsed.empty();
//}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
NSInteger size = [self.dataSource size];
[self.searchResultsIsEmptyDisclaimer setHidden:size != 0];
return size;
}
- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section
{
if (self.isSearch)
return nil;
return L(@"editor_add_select_category_all_subtitle");
// TODO(Vlad): Uncoment this line when we will be ready to show recent categories
// if (m_categories.m_lastUsed.empty())
// return L(@"editor_add_select_category_all_subtitle");
// return section == 0 ? L(@"editor_add_select_category_popular_subtitle") :
// L(@"editor_add_select_category_all_subtitle");
}
#pragma mark - UISearchBarDelegate
- (void)searchBar:(UISearchBar *)searchBar textDidChange:(NSString *)searchText
{
self.isSearch = searchText.length == 0 ? NO : YES;
[self.dataSource search:[searchText lowercaseStringWithLocale:NSLocale.currentLocale]];
[self.tableView reloadData];
}
- (BOOL)searchBarShouldBeginEditing:(UISearchBar *)searchBar
{
[self searchBar:searchBar setActiveState:YES];
self.isSearch = NO;
return YES;
}
- (BOOL)searchBarShouldEndEditing:(UISearchBar *)searchBar
{
if (!searchBar.text.length)
{
[self searchBar:searchBar setActiveState:NO];
self.isSearch = NO;
}
return YES;
}
- (void)searchBarCancelButtonClicked:(UISearchBar *)searchBar
{
[searchBar resignFirstResponder];
searchBar.text = @"";
[self searchBar:searchBar setActiveState:NO];
self.isSearch = NO;
[self.tableView reloadData];
}
- (void)searchBarSearchButtonClicked:(UISearchBar *)searchBar { [searchBar resignFirstResponder]; }
- (UIBarPosition)positionForBar:(id<UIBarPositioning>)bar { return UIBarPositionTopAttached; }
- (void)searchBar:(UISearchBar *)searchBar setActiveState:(BOOL)isActiveState
{
[searchBar setShowsCancelButton:isActiveState animated:YES];
[self.navigationController setNavigationBarHidden:isActiveState animated:YES];
if (!isActiveState)
[self.dataSource search:@""];
}
@end

View file

@ -0,0 +1,8 @@
@interface MWMObjectsCategorySelectorDataSource : NSObject
- (void)search:(NSString *)query;
- (NSString *)getTranslation:(NSInteger)row;
- (NSString *)getType:(NSInteger)row;
- (NSInteger)size;
@end

View file

@ -0,0 +1,84 @@
#import "MWMObjectsCategorySelectorDataSource.h"
#include "LocaleTranslator.h"
#include <CoreApi/Framework.h>
#include "platform/localization.hpp"
namespace
{
using Category = std::pair<std::string, osm::NewFeatureCategories::TypeName>;
using Categories = std::vector<Category>;
std::string locale()
{
return locale_translator::bcp47ToTwineLanguage(NSLocale.currentLocale.localeIdentifier);
}
} // namespace
@interface MWMObjectsCategorySelectorDataSource()
{
osm::NewFeatureCategories m_categories;
Categories m_categoriesList;
}
@end
@implementation MWMObjectsCategorySelectorDataSource
- (instancetype)init
{
self = [super init];
if (self)
[self load];
return self;
}
- (void)initializeList:(osm::NewFeatureCategories::TypeNames const &)types
{
m_categoriesList.clear();
for (auto const & type : types)
m_categoriesList.emplace_back(platform::GetLocalizedTypeName(type), type);
std::sort(m_categoriesList.begin(), m_categoriesList.end());
}
- (void)load
{
m_categories = GetFramework().GetEditorCategories();
m_categories.AddLanguage(locale());
m_categories.AddLanguage("en");
auto const & types = m_categories.GetAllCreatableTypeNames();
m_categoriesList.reserve(types.size());
[self initializeList: types];
}
- (void)search:(NSString *)query
{
if (query.length == 0)
[self initializeList: m_categories.GetAllCreatableTypeNames()];
else
[self initializeList: m_categories.Search([query UTF8String])];
}
- (NSString *)getTranslation:(NSInteger)row
{
return @(m_categoriesList[row].first.c_str());
}
- (NSString *)getType:(NSInteger)row
{
return @(m_categoriesList[row].second.c_str());
}
- (NSInteger)size
{
return m_categoriesList.size();
}
@end

View file

@ -0,0 +1,5 @@
#import "MWMOpeningHoursTableViewCell.h"
@interface MWMOpeningHoursAddClosedTableViewCell : MWMOpeningHoursTableViewCell
@end

View file

@ -0,0 +1,30 @@
#import "MWMOpeningHoursAddClosedTableViewCell.h"
@interface MWMOpeningHoursAddClosedTableViewCell ()
@property (weak, nonatomic) IBOutlet UIButton * addClosedButton;
@end
@implementation MWMOpeningHoursAddClosedTableViewCell
+ (CGFloat)heightForWidth:(CGFloat)width
{
return 44.0;
}
- (void)refresh
{
[super refresh];
self.addClosedButton.enabled = self.section.canAddClosedTime;
}
#pragma mark - Actions
- (IBAction)addClosedTap
{
if (self.isVisible)
[self.section addClosedTime];
}
@end

View file

@ -0,0 +1,66 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="15705" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="15706"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<objects>
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner"/>
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
<tableViewCell contentMode="scaleToFill" selectionStyle="default" indentationWidth="10" id="KGk-i7-Jjw" customClass="MWMOpeningHoursAddClosedTableViewCell" propertyAccessControl="none">
<rect key="frame" x="0.0" y="0.0" width="320" height="44"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="KGk-i7-Jjw" id="H2p-sc-9uM">
<rect key="frame" x="0.0" y="0.0" width="320" height="44"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<button opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="DPW-UE-5UN">
<rect key="frame" x="0.0" y="0.0" width="320" height="42.5"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<state key="normal" title="Add Hours Closed"/>
<userDefinedRuntimeAttributes>
<userDefinedRuntimeAttribute type="string" keyPath="styleName" value="FlatNormalTransButtonBig"/>
<userDefinedRuntimeAttribute type="string" keyPath="localizedText" value="editor_time_add_closed"/>
</userDefinedRuntimeAttributes>
<connections>
<action selector="addClosedTap" destination="KGk-i7-Jjw" eventType="touchUpInside" id="HxR-3Y-SiG"/>
</connections>
</button>
<imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="separator_image" translatesAutoresizingMaskIntoConstraints="NO" id="6P1-ZO-JMA">
<rect key="frame" x="0.0" y="43.5" width="320" height="1"/>
<constraints>
<constraint firstAttribute="height" constant="1" id="ckb-Sc-MTJ"/>
</constraints>
<userDefinedRuntimeAttributes>
<userDefinedRuntimeAttribute type="string" keyPath="styleName" value="MWMSeparator"/>
</userDefinedRuntimeAttributes>
</imageView>
</subviews>
<constraints>
<constraint firstItem="DPW-UE-5UN" firstAttribute="top" secondItem="H2p-sc-9uM" secondAttribute="top" id="4Li-Xr-b3S"/>
<constraint firstItem="DPW-UE-5UN" firstAttribute="leading" secondItem="H2p-sc-9uM" secondAttribute="leading" id="Ng6-qX-haA"/>
<constraint firstItem="6P1-ZO-JMA" firstAttribute="top" secondItem="DPW-UE-5UN" secondAttribute="bottom" constant="1" id="b8H-yj-uLc"/>
<constraint firstAttribute="trailing" secondItem="DPW-UE-5UN" secondAttribute="trailing" id="bAd-QF-f1s"/>
<constraint firstAttribute="bottom" secondItem="6P1-ZO-JMA" secondAttribute="bottom" constant="-0.5" id="edX-pE-hpk"/>
<constraint firstAttribute="trailing" secondItem="6P1-ZO-JMA" secondAttribute="trailing" id="uJU-yO-Xeh"/>
<constraint firstItem="6P1-ZO-JMA" firstAttribute="leading" secondItem="H2p-sc-9uM" secondAttribute="leading" id="yxQ-et-0D2"/>
</constraints>
<userDefinedRuntimeAttributes>
<userDefinedRuntimeAttribute type="string" keyPath="styleName" value="Background"/>
</userDefinedRuntimeAttributes>
</tableViewCellContentView>
<viewLayoutGuide key="safeArea" id="nLi-ui-Rk2"/>
<userDefinedRuntimeAttributes>
<userDefinedRuntimeAttribute type="string" keyPath="styleName" value="Background"/>
</userDefinedRuntimeAttributes>
<connections>
<outlet property="addClosedButton" destination="DPW-UE-5UN" id="Z5D-1Z-Hxa"/>
</connections>
<point key="canvasLocation" x="139" y="155"/>
</tableViewCell>
</objects>
<resources>
<image name="separator_image" width="1" height="1"/>
</resources>
</document>

View file

@ -0,0 +1,9 @@
#import "MWMOpeningHoursModel.h"
@interface MWMOpeningHoursAddScheduleTableViewCell : UITableViewCell
+ (CGFloat)height;
@property (weak, nonatomic) MWMOpeningHoursModel * model;
@end

View file

@ -0,0 +1,45 @@
#import "MWMOpeningHoursAddScheduleTableViewCell.h"
#import <CoreApi/MWMOpeningHoursCommon.h>
@interface MWMOpeningHoursAddScheduleTableViewCell ()
@property (weak, nonatomic) IBOutlet UIButton * addScheduleButton;
@end
@implementation MWMOpeningHoursAddScheduleTableViewCell
- (void)awakeFromNib
{
[super awakeFromNib];
self.backgroundColor = UIColor.clearColor;
}
+ (CGFloat)height
{
return 84.0;
}
- (void)refresh
{
NSString * title = [NSString stringWithFormat:@"%@ %@", L(@"editor_time_add"),
stringFromOpeningDays([self.model unhandledDays])];
[self.addScheduleButton setTitle:title forState:UIControlStateNormal];
}
#pragma mark - Actions
- (IBAction)addScheduleTap
{
[self.model addSchedule];
}
#pragma mark - Properties
- (void)setModel:(MWMOpeningHoursModel *)model
{
_model = model;
[self refresh];
}
@end

View file

@ -0,0 +1,53 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="15702" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES">
<device id="retina4_7" orientation="portrait" appearance="light"/>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="15704"/>
<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" rowHeight="84" id="KGk-i7-Jjw" customClass="MWMOpeningHoursAddScheduleTableViewCell" propertyAccessControl="none">
<rect key="frame" x="0.0" y="0.0" width="320" height="84"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="KGk-i7-Jjw" id="H2p-sc-9uM">
<rect key="frame" x="0.0" y="0.0" width="320" height="84"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<button opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="Rja-9J-5hA">
<rect key="frame" x="40" y="6" width="240" height="32"/>
<constraints>
<constraint firstAttribute="height" constant="32" id="hCp-vK-2rD"/>
<constraint firstAttribute="width" constant="240" id="xAy-7R-cxW"/>
</constraints>
<fontDescription key="fontDescription" type="system" pointSize="14"/>
<state key="normal" title="Another Schedule">
<color key="titleColor" red="0.1176470588" green="0.58823529409999997" blue="0.94117647059999998" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<color key="titleShadowColor" red="0.5" green="0.5" blue="0.5" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</state>
<userDefinedRuntimeAttributes>
<userDefinedRuntimeAttribute type="string" keyPath="styleName" value="EditButton"/>
</userDefinedRuntimeAttributes>
<connections>
<action selector="addScheduleTap" destination="KGk-i7-Jjw" eventType="touchUpInside" id="u6e-fL-daC"/>
</connections>
</button>
</subviews>
<color key="backgroundColor" red="0.0" green="0.0" blue="0.0" alpha="0.0" colorSpace="custom" customColorSpace="sRGB"/>
<color key="tintColor" red="0.0" green="0.0" blue="0.0" alpha="0.0" colorSpace="custom" customColorSpace="sRGB"/>
<constraints>
<constraint firstItem="Rja-9J-5hA" firstAttribute="centerX" secondItem="H2p-sc-9uM" secondAttribute="centerX" id="fcS-KP-VSI"/>
<constraint firstItem="Rja-9J-5hA" firstAttribute="top" secondItem="H2p-sc-9uM" secondAttribute="top" constant="6" id="i23-52-8oh"/>
</constraints>
</tableViewCellContentView>
<color key="backgroundColor" red="0.0" green="0.0" blue="0.0" alpha="0.0" colorSpace="custom" customColorSpace="sRGB"/>
<color key="tintColor" red="0.0" green="0.0" blue="0.0" alpha="0.0" colorSpace="custom" customColorSpace="sRGB"/>
<connections>
<outlet property="addScheduleButton" destination="Rja-9J-5hA" id="Ubq-Fn-Zg0"/>
</connections>
<point key="canvasLocation" x="139" y="155"/>
</tableViewCell>
</objects>
</document>

View file

@ -0,0 +1,5 @@
#import "MWMOpeningHoursTableViewCell.h"
@interface MWMOpeningHoursAllDayTableViewCell : MWMOpeningHoursTableViewCell
@end

View file

@ -0,0 +1,42 @@
#import "MWMOpeningHoursAllDayTableViewCell.h"
@interface MWMOpeningHoursAllDayTableViewCell ()
@property (weak, nonatomic) IBOutlet UISwitch * switcher;
@property (weak, nonatomic) IBOutlet UILabel * label;
@end
@implementation MWMOpeningHoursAllDayTableViewCell
- (void)awakeFromNib
{
[super awakeFromNib];
[self setupLabelColor];
}
- (void)setupLabelColor
{
self.label.textColor = self.switcher.on ? [UIColor blackPrimaryText] : [UIColor blackHintText];
}
+ (CGFloat)heightForWidth:(CGFloat)width
{
return 44.0;
}
- (void)refresh
{
[super refresh];
self.switcher.on = self.section.allDay;
}
#pragma mark - Actions
- (IBAction)onSwitch
{
self.section.allDay = self.switcher.on;
[self setupLabelColor];
}
@end

View file

@ -0,0 +1,72 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="15705" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES">
<device id="retina4_7" orientation="portrait" appearance="light"/>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="15706"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<objects>
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner"/>
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
<tableViewCell contentMode="scaleToFill" selectionStyle="default" indentationWidth="10" id="KGk-i7-Jjw" customClass="MWMOpeningHoursAllDayTableViewCell" propertyAccessControl="none">
<rect key="frame" x="0.0" y="0.0" width="320" height="44"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="KGk-i7-Jjw" id="H2p-sc-9uM">
<rect key="frame" x="0.0" y="0.0" width="320" height="44"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="All Day (24 hours)" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" preferredMaxLayoutWidth="223" translatesAutoresizingMaskIntoConstraints="NO" id="0Ni-TD-6Ia">
<rect key="frame" x="16" y="12" width="223" height="20"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<nil key="highlightedColor"/>
<userDefinedRuntimeAttributes>
<userDefinedRuntimeAttribute type="string" keyPath="styleName" value="regular17:blackPrimaryText"/>
<userDefinedRuntimeAttribute type="string" keyPath="localizedText" value="editor_time_allday"/>
</userDefinedRuntimeAttributes>
</label>
<switch opaque="NO" contentMode="scaleToFill" horizontalHuggingPriority="750" verticalHuggingPriority="750" contentHorizontalAlignment="center" contentVerticalAlignment="center" on="YES" translatesAutoresizingMaskIntoConstraints="NO" id="0BP-HJ-Tdq">
<rect key="frame" x="255" y="7.5" width="51" height="29"/>
<connections>
<action selector="onSwitch" destination="KGk-i7-Jjw" eventType="valueChanged" id="qZA-HV-PB6"/>
</connections>
</switch>
<imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="separator_image" translatesAutoresizingMaskIntoConstraints="NO" id="lbK-kB-c4p">
<rect key="frame" x="0.0" y="43.5" width="320" height="1"/>
<constraints>
<constraint firstAttribute="height" constant="1" id="JvF-ZU-maq"/>
</constraints>
<userDefinedRuntimeAttributes>
<userDefinedRuntimeAttribute type="string" keyPath="styleName" value="MWMSeparator"/>
</userDefinedRuntimeAttributes>
</imageView>
</subviews>
<constraints>
<constraint firstItem="0BP-HJ-Tdq" firstAttribute="centerY" secondItem="H2p-sc-9uM" secondAttribute="centerYWithinMargins" id="1kG-H0-QmS"/>
<constraint firstItem="0Ni-TD-6Ia" firstAttribute="centerY" secondItem="H2p-sc-9uM" secondAttribute="centerY" id="4y2-py-cgM"/>
<constraint firstAttribute="trailing" secondItem="lbK-kB-c4p" secondAttribute="trailing" id="797-Uf-0Jb"/>
<constraint firstItem="lbK-kB-c4p" firstAttribute="leading" secondItem="H2p-sc-9uM" secondAttribute="leading" id="Dv4-Kj-kii"/>
<constraint firstAttribute="trailing" secondItem="0BP-HJ-Tdq" secondAttribute="trailing" constant="16" id="Ejw-wu-5pE"/>
<constraint firstItem="lbK-kB-c4p" firstAttribute="top" secondItem="0BP-HJ-Tdq" secondAttribute="bottom" constant="7" id="KIL-OP-roj"/>
<constraint firstItem="0BP-HJ-Tdq" firstAttribute="leading" secondItem="0Ni-TD-6Ia" secondAttribute="trailing" constant="16" id="cgf-7m-Kki"/>
<constraint firstItem="0Ni-TD-6Ia" firstAttribute="leading" secondItem="H2p-sc-9uM" secondAttribute="leading" constant="16" id="gZM-Zt-RId"/>
<constraint firstAttribute="bottom" secondItem="lbK-kB-c4p" secondAttribute="bottom" constant="-0.5" id="jbG-hH-bln"/>
</constraints>
<userDefinedRuntimeAttributes>
<userDefinedRuntimeAttribute type="string" keyPath="styleName" value="Background"/>
</userDefinedRuntimeAttributes>
</tableViewCellContentView>
<userDefinedRuntimeAttributes>
<userDefinedRuntimeAttribute type="string" keyPath="styleName" value="Background"/>
</userDefinedRuntimeAttributes>
<connections>
<outlet property="label" destination="0Ni-TD-6Ia" id="zLO-3p-8E4"/>
<outlet property="switcher" destination="0BP-HJ-Tdq" id="mHZ-4O-ve2"/>
</connections>
<point key="canvasLocation" x="139" y="155"/>
</tableViewCell>
</objects>
<resources>
<image name="separator_image" width="1" height="1"/>
</resources>
</document>

View file

@ -0,0 +1,5 @@
#import "MWMOpeningHoursTableViewCell.h"
@interface MWMOpeningHoursClosedSpanTableViewCell : MWMOpeningHoursTableViewCell
@end

View file

@ -0,0 +1,106 @@
#import "MWMOpeningHoursClosedSpanTableViewCell.h"
#import "CoreApi/CoreApi-Swift.h"
static NSString * const kLabelText = L(@"editor_hours_closed");
CGFloat labelWidth()
{
UILabel * label = [[UILabel alloc] initWithFrame:CGRectZero];
label.font = [UIFont regular17];
label.text = kLabelText;
[label sizeToFit];
return label.width;
}
BOOL isCompactForCellWidth(CGFloat width)
{
static CGFloat const kLabelWidth = labelWidth();
CGFloat constexpr widthOfAllElementsWithoutLabel = 234.0;
CGFloat const maxLabelWidthForCompactCell = width - widthOfAllElementsWithoutLabel;
return kLabelWidth < maxLabelWidthForCompactCell;
}
@interface MWMOpeningHoursClosedSpanTableViewCell ()
@property(weak, nonatomic) IBOutlet UILabel * hoursClosedLabel;
@property(weak, nonatomic) IBOutlet UILabel * timeSpanLabel;
@property(weak, nonatomic) IBOutlet NSLayoutConstraint * timeSpanHorizontalAlignment;
@property(weak, nonatomic) IBOutlet NSLayoutConstraint * timeSpanVerticalAlignment;
@property(weak, nonatomic) IBOutlet NSLayoutConstraint * hoursClosedTrailing;
@property(nonatomic) BOOL isCompact;
@end
@implementation MWMOpeningHoursClosedSpanTableViewCell
+ (CGFloat)heightForWidth:(CGFloat)width { return isCompactForCellWidth(width) ? 44.0 : 64.0; }
- (void)awakeFromNib
{
[super awakeFromNib];
self.hoursClosedLabel.text = kLabelText;
self.isCompact = YES;
}
- (void)layoutSubviews
{
if (self.isCompact != isCompactForCellWidth(self.width))
{
self.isCompact = !self.isCompact;
if (self.isCompact)
{
self.hoursClosedLabel.font = [UIFont regular17];
self.timeSpanLabel.textAlignment = NSTextAlignmentRight;
self.timeSpanHorizontalAlignment.priority = UILayoutPriorityDefaultLow;
self.timeSpanVerticalAlignment.priority = UILayoutPriorityDefaultLow;
self.hoursClosedTrailing.priority = UILayoutPriorityDefaultLow;
}
else
{
self.hoursClosedLabel.font = [UIFont regular14];
self.timeSpanLabel.textAlignment = NSTextAlignmentLeft;
self.timeSpanHorizontalAlignment.priority = UILayoutPriorityDefaultHigh;
self.timeSpanVerticalAlignment.priority = UILayoutPriorityDefaultHigh;
self.hoursClosedTrailing.priority = UILayoutPriorityDefaultHigh;
}
}
[super layoutSubviews];
}
- (void)refresh
{
[super refresh];
NSCalendar * calendar = NSCalendar.currentCalendar;
MWMOpeningHoursSection * section = self.section;
NSUInteger const row = self.row;
NSDate * openDate = [calendar dateFromComponents:[section timeForRow:row isStart:YES]];
NSDate * closeDate = [calendar dateFromComponents:[section timeForRow:row isStart:NO]];
NSDateFormatterStyle timeStyle = NSDateFormatterShortStyle;
NSDateFormatterStyle dateStyle = NSDateFormatterNoStyle;
NSString * openString = [DateTimeFormatter dateStringFrom:openDate dateStyle:dateStyle timeStyle:timeStyle];
NSString * closeString = [DateTimeFormatter dateStringFrom:closeDate dateStyle:dateStyle timeStyle:timeStyle];
self.timeSpanLabel.text = [NSString stringWithFormat:@"%@-%@", openString, closeString];
BOOL const isRowSelected = [section isRowSelected:row];
self.timeSpanLabel.textColor = isRowSelected ? [UIColor linkBlue] : [UIColor blackSecondaryText];
}
#pragma mark - Actions
- (IBAction)cancelTap { [self.section removeClosedTime:self.row]; }
- (IBAction)expandTap
{
if (!self.isVisible)
return;
NSUInteger const row = self.row;
MWMOpeningHoursSection * section = self.section;
section.selectedRow = [section isRowSelected:row] ? nil : @(row);
[section refresh:NO];
}
@end

View file

@ -0,0 +1,112 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="15702" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES">
<device id="retina4_7" orientation="portrait" appearance="light"/>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="15704"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<objects>
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner"/>
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
<tableViewCell contentMode="scaleToFill" selectionStyle="default" indentationWidth="10" id="KGk-i7-Jjw" customClass="MWMOpeningHoursClosedSpanTableViewCell" propertyAccessControl="none">
<rect key="frame" x="0.0" y="0.0" width="320" height="44"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="KGk-i7-Jjw" id="H2p-sc-9uM">
<rect key="frame" x="0.0" y="0.0" width="320" height="44"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="eHW-h6-k3U" userLabel="Cancel Button" customClass="MWMButton">
<rect key="frame" x="0.0" y="0.0" width="44" height="44"/>
<constraints>
<constraint firstAttribute="width" constant="44" id="6T7-Ur-RWl"/>
</constraints>
<state key="normal" image="ic_clear_sys"/>
<userDefinedRuntimeAttributes>
<userDefinedRuntimeAttribute type="string" keyPath="styleName" value="MWMBlack"/>
</userDefinedRuntimeAttributes>
<connections>
<action selector="cancelTap" destination="KGk-i7-Jjw" eventType="touchUpInside" id="UKS-mG-ZJG"/>
</connections>
</button>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Closed" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" preferredMaxLayoutWidth="86" translatesAutoresizingMaskIntoConstraints="NO" id="lia-DA-sOa">
<rect key="frame" x="44" y="12" width="86" height="20"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<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="styleName" value="regular17:blackPrimaryText"/>
</userDefinedRuntimeAttributes>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="14:00-15:00" textAlignment="right" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" preferredMaxLayoutWidth="170" translatesAutoresizingMaskIntoConstraints="NO" id="hOg-Ps-YH4">
<rect key="frame" x="134" y="11.5" width="170" height="20"/>
<constraints>
<constraint firstAttribute="width" constant="170" id="lQt-Xw-FNV"/>
</constraints>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<color key="textColor" red="0.49803921569999998" green="0.49803921569999998" blue="0.49803921569999998" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<nil key="highlightedColor"/>
<userDefinedRuntimeAttributes>
<userDefinedRuntimeAttribute type="string" keyPath="styleName" value="regular17:blackHintText"/>
</userDefinedRuntimeAttributes>
</label>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="3cC-7h-Nyb" userLabel="Expand Button">
<rect key="frame" x="44" y="0.0" width="276" height="44"/>
<color key="backgroundColor" red="0.0" green="0.0" blue="0.0" alpha="0.0" colorSpace="custom" customColorSpace="sRGB"/>
<connections>
<action selector="expandTap" destination="KGk-i7-Jjw" eventType="touchUpInside" id="Fva-H8-Hgd"/>
</connections>
</button>
<imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="separator_image" translatesAutoresizingMaskIntoConstraints="NO" id="fZN-J3-A1c">
<rect key="frame" x="0.0" y="43.5" width="320" height="1"/>
<constraints>
<constraint firstAttribute="height" constant="1" id="Vyg-vJ-QBa"/>
</constraints>
<userDefinedRuntimeAttributes>
<userDefinedRuntimeAttribute type="string" keyPath="styleName" value="MWMSeparator"/>
</userDefinedRuntimeAttributes>
</imageView>
</subviews>
<constraints>
<constraint firstAttribute="trailing" secondItem="fZN-J3-A1c" secondAttribute="trailing" id="4ix-Pa-jem"/>
<constraint firstAttribute="bottom" secondItem="3cC-7h-Nyb" secondAttribute="bottom" id="8WG-92-rMW"/>
<constraint firstItem="3cC-7h-Nyb" firstAttribute="leading" secondItem="eHW-h6-k3U" secondAttribute="trailing" id="9Bn-Ln-6Kp"/>
<constraint firstItem="lia-DA-sOa" firstAttribute="top" secondItem="H2p-sc-9uM" secondAttribute="top" constant="12" id="9iu-Vt-ehV"/>
<constraint firstAttribute="bottom" secondItem="eHW-h6-k3U" secondAttribute="bottom" id="EBf-Wx-e3F"/>
<constraint firstItem="eHW-h6-k3U" firstAttribute="leading" secondItem="H2p-sc-9uM" secondAttribute="leading" id="F0P-mc-NEh"/>
<constraint firstItem="eHW-h6-k3U" firstAttribute="top" secondItem="H2p-sc-9uM" secondAttribute="top" id="Plg-3V-wwv"/>
<constraint firstItem="fZN-J3-A1c" firstAttribute="top" secondItem="hOg-Ps-YH4" secondAttribute="bottom" constant="12" id="Pyv-5m-MMc"/>
<constraint firstAttribute="bottom" secondItem="fZN-J3-A1c" secondAttribute="bottom" constant="-0.5" id="Yi4-tf-i9O"/>
<constraint firstItem="3cC-7h-Nyb" firstAttribute="top" secondItem="H2p-sc-9uM" secondAttribute="top" id="ZM1-oj-Ttu"/>
<constraint firstItem="hOg-Ps-YH4" firstAttribute="leading" secondItem="lia-DA-sOa" secondAttribute="trailing" priority="500" constant="4" id="bUD-vp-CsK"/>
<constraint firstAttribute="trailing" secondItem="3cC-7h-Nyb" secondAttribute="trailing" id="dwl-rT-xgr"/>
<constraint firstAttribute="trailing" secondItem="hOg-Ps-YH4" secondAttribute="trailing" priority="500" constant="16" id="jzD-AQ-ZIp"/>
<constraint firstItem="hOg-Ps-YH4" firstAttribute="centerY" secondItem="H2p-sc-9uM" secondAttribute="centerY" priority="500" id="kba-LF-TBE"/>
<constraint firstItem="hOg-Ps-YH4" firstAttribute="leading" secondItem="lia-DA-sOa" secondAttribute="leading" priority="250" id="mU9-yf-vga"/>
<constraint firstItem="fZN-J3-A1c" firstAttribute="leading" secondItem="H2p-sc-9uM" secondAttribute="leading" id="nVn-y5-wFx"/>
<constraint firstItem="hOg-Ps-YH4" firstAttribute="top" secondItem="lia-DA-sOa" secondAttribute="bottom" priority="250" constant="4" id="ne6-qS-gOV"/>
<constraint firstItem="lia-DA-sOa" firstAttribute="leading" secondItem="eHW-h6-k3U" secondAttribute="trailing" id="sEk-K9-5ox"/>
<constraint firstAttribute="trailing" secondItem="lia-DA-sOa" secondAttribute="trailing" priority="250" constant="8" id="zjM-Hg-INM"/>
</constraints>
<userDefinedRuntimeAttributes>
<userDefinedRuntimeAttribute type="string" keyPath="styleName" value="Background"/>
</userDefinedRuntimeAttributes>
</tableViewCellContentView>
<userDefinedRuntimeAttributes>
<userDefinedRuntimeAttribute type="string" keyPath="styleName" value="Background"/>
</userDefinedRuntimeAttributes>
<connections>
<outlet property="hoursClosedLabel" destination="lia-DA-sOa" id="tUx-Cy-R9r"/>
<outlet property="hoursClosedTrailing" destination="zjM-Hg-INM" id="QKd-Py-tbi"/>
<outlet property="timeSpanHorizontalAlignment" destination="mU9-yf-vga" id="k7T-pi-YAP"/>
<outlet property="timeSpanLabel" destination="hOg-Ps-YH4" id="dyB-M5-ePt"/>
<outlet property="timeSpanVerticalAlignment" destination="ne6-qS-gOV" id="i2Q-La-wrT"/>
</connections>
<point key="canvasLocation" x="139" y="155"/>
</tableViewCell>
</objects>
<resources>
<image name="ic_clear_sys" width="28" height="28"/>
<image name="separator_image" width="1" height="1"/>
</resources>
</document>

View file

@ -0,0 +1,5 @@
#import "MWMOpeningHoursTableViewCell.h"
@interface MWMOpeningHoursDaysSelectorTableViewCell : MWMOpeningHoursTableViewCell
@end

View file

@ -0,0 +1,99 @@
#import "MWMOpeningHoursDaysSelectorTableViewCell.h"
#import "SwiftBridge.h"
@interface MWMOpeningHoursDaysSelectorTableViewCell ()
@property (nonatomic) IBOutletCollection(UIButton) NSArray * buttons;
@property (nonatomic) IBOutletCollection(UILabel) NSArray * labels;
@property (nonatomic) IBOutletCollection(UIImageView) NSArray * images;
@property (nonatomic) NSUInteger firstWeekday;
@end
using namespace osmoh;
@implementation MWMOpeningHoursDaysSelectorTableViewCell
+ (CGFloat)heightForWidth:(CGFloat)width
{
return 76.0;
}
- (void)awakeFromNib
{
[super awakeFromNib];
NSCalendar * cal = NSCalendar.currentCalendar;
cal.locale = NSLocale.currentLocale;
self.firstWeekday = cal.firstWeekday;
NSArray<NSString *> * weekdaySymbols = cal.shortStandaloneWeekdaySymbols;
for (UILabel * label in self.labels)
{
label.text = weekdaySymbols[[self tag2SymbolIndex:label.tag]];
}
}
- (NSUInteger)tag2SymbolIndex:(NSUInteger)tag
{
NSUInteger idx = tag + self.firstWeekday - 1;
NSUInteger const weekDaysCount = 7;
if (idx >= weekDaysCount)
idx -= weekDaysCount;
return idx;
}
- (Weekday)tag2Weekday:(NSUInteger)tag
{
return static_cast<Weekday>([self tag2SymbolIndex:tag] + 1);
}
- (void)makeDay:(NSUInteger)tag selected:(BOOL)selected refresh:(BOOL)refresh
{
if (refresh)
{
Weekday const wd = [self tag2Weekday:tag];
MWMOpeningHoursSection * section = self.section;
if (selected)
[section addSelectedDay:wd];
else
[section removeSelectedDay:wd];
}
for (UIButton * btn in self.buttons)
{
if (btn.tag == tag)
btn.selected = selected;
}
for (UILabel * label in self.labels)
{
if (label.tag == tag)
label.textColor = (selected ? [UIColor blackPrimaryText] : [UIColor blackHintText]);
}
for (UIImageView * image in self.images)
{
if (image.tag == tag)
{
image.image = [UIImage imageNamed:selected ? @"radioBtnOn" : @"radioBtnOff"];
[image setStyleNameAndApply: selected ? @"MWMBlue" : @"MWMGray"];
}
}
}
- (void)refresh
{
[super refresh];
for (UILabel * label in self.labels)
{
NSUInteger const tag = label.tag;
BOOL const selected = [self.section containsSelectedDay:[self tag2Weekday:tag]];
[self makeDay:tag selected:selected refresh:NO];
}
}
#pragma mark - Actions
- (IBAction)selectDay:(UIButton *)sender
{
[self makeDay:sender.tag selected:!sender.isSelected refresh:YES];
}
@end

View file

@ -0,0 +1,427 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="15702" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES">
<device id="retina4_7" orientation="portrait" appearance="light"/>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="15704"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<objects>
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner"/>
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
<tableViewCell contentMode="scaleToFill" selectionStyle="default" indentationWidth="10" rowHeight="76" id="KGk-i7-Jjw" customClass="MWMOpeningHoursDaysSelectorTableViewCell" propertyAccessControl="none">
<rect key="frame" x="0.0" y="0.0" width="320" height="76"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="KGk-i7-Jjw" id="H2p-sc-9uM">
<rect key="frame" x="0.0" y="0.0" width="320" height="76"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="CCr-vZ-lZV" userLabel="Day#1">
<rect key="frame" x="16" y="0.0" width="41" height="76"/>
<subviews>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="tQj-bk-oM9">
<rect key="frame" x="0.0" y="0.0" width="41" height="76"/>
<connections>
<action selector="selectDay:" destination="KGk-i7-Jjw" eventType="touchUpInside" id="9i4-jY-OM3"/>
</connections>
</button>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Su" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" preferredMaxLayoutWidth="40" translatesAutoresizingMaskIntoConstraints="NO" id="brZ-af-NfP">
<rect key="frame" x="0.0" y="12" width="41" height="20"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<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="styleName" value="regular17"/>
</userDefinedRuntimeAttributes>
</label>
<imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="radioBtnOff" highlightedImage="radioBtnOn" translatesAutoresizingMaskIntoConstraints="NO" id="eN6-Is-HP5">
<rect key="frame" x="9.5" y="40" width="22" height="22"/>
<constraints>
<constraint firstAttribute="height" constant="22" id="6PM-WV-5ha"/>
<constraint firstAttribute="width" constant="22" id="Wid-uC-2rb"/>
</constraints>
<userDefinedRuntimeAttributes>
<userDefinedRuntimeAttribute type="string" keyPath="styleName" value="MWMBlue"/>
</userDefinedRuntimeAttributes>
</imageView>
</subviews>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<constraints>
<constraint firstItem="brZ-af-NfP" firstAttribute="top" secondItem="CCr-vZ-lZV" secondAttribute="top" constant="12" id="4Tb-B7-xF1"/>
<constraint firstItem="tQj-bk-oM9" firstAttribute="leading" secondItem="CCr-vZ-lZV" secondAttribute="leading" id="5sp-pU-VqX"/>
<constraint firstAttribute="bottom" secondItem="tQj-bk-oM9" secondAttribute="bottom" id="Flv-li-zyy"/>
<constraint firstItem="brZ-af-NfP" firstAttribute="leading" secondItem="CCr-vZ-lZV" secondAttribute="leading" id="b0u-K1-vTb"/>
<constraint firstAttribute="trailing" secondItem="tQj-bk-oM9" secondAttribute="trailing" id="hDV-MS-mRl"/>
<constraint firstAttribute="trailing" secondItem="brZ-af-NfP" secondAttribute="trailing" id="i2d-9N-WXl"/>
<constraint firstItem="eN6-Is-HP5" firstAttribute="centerX" secondItem="CCr-vZ-lZV" secondAttribute="centerX" id="iez-0J-YL1"/>
<constraint firstItem="eN6-Is-HP5" firstAttribute="top" secondItem="brZ-af-NfP" secondAttribute="bottom" constant="8" id="rZo-zS-ly1"/>
<constraint firstItem="tQj-bk-oM9" firstAttribute="top" secondItem="CCr-vZ-lZV" secondAttribute="top" id="z4X-lt-MRQ"/>
</constraints>
<userDefinedRuntimeAttributes>
<userDefinedRuntimeAttribute type="string" keyPath="styleName" value="Background"/>
</userDefinedRuntimeAttributes>
</view>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="d7U-Vz-ZXn" userLabel="Day#2">
<rect key="frame" x="57" y="0.0" width="41.5" height="76"/>
<subviews>
<button opaque="NO" tag="1" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="7fE-x8-2Vl">
<rect key="frame" x="0.0" y="0.0" width="41.5" height="76"/>
<connections>
<action selector="selectDay:" destination="KGk-i7-Jjw" eventType="touchUpInside" id="zPb-wt-0Cz"/>
</connections>
</button>
<label opaque="NO" userInteractionEnabled="NO" tag="1" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Su" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" preferredMaxLayoutWidth="40" translatesAutoresizingMaskIntoConstraints="NO" id="TX4-wv-r7d">
<rect key="frame" x="0.0" y="12" width="41.5" height="20"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<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="styleName" value="regular17"/>
</userDefinedRuntimeAttributes>
</label>
<imageView userInteractionEnabled="NO" tag="1" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="radioBtnOff" highlightedImage="radioBtnOn" translatesAutoresizingMaskIntoConstraints="NO" id="PA6-gY-SsH">
<rect key="frame" x="9.5" y="40" width="22" height="22"/>
<constraints>
<constraint firstAttribute="height" constant="22" id="ACp-b4-BbL"/>
<constraint firstAttribute="width" constant="22" id="PHS-nj-MJ1"/>
</constraints>
<userDefinedRuntimeAttributes>
<userDefinedRuntimeAttribute type="string" keyPath="styleName" value="MWMBlue"/>
</userDefinedRuntimeAttributes>
</imageView>
</subviews>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<constraints>
<constraint firstItem="TX4-wv-r7d" firstAttribute="top" secondItem="d7U-Vz-ZXn" secondAttribute="top" constant="12" id="3Os-r4-IV4"/>
<constraint firstAttribute="trailing" secondItem="7fE-x8-2Vl" secondAttribute="trailing" id="9kd-YQ-iqd"/>
<constraint firstItem="7fE-x8-2Vl" firstAttribute="leading" secondItem="d7U-Vz-ZXn" secondAttribute="leading" id="EE7-5x-SsE"/>
<constraint firstAttribute="trailing" secondItem="TX4-wv-r7d" secondAttribute="trailing" id="FzE-0n-OB0"/>
<constraint firstItem="PA6-gY-SsH" firstAttribute="top" secondItem="TX4-wv-r7d" secondAttribute="bottom" constant="8" id="LZb-fg-8V8"/>
<constraint firstAttribute="bottom" secondItem="7fE-x8-2Vl" secondAttribute="bottom" id="Rwg-cY-7Rp"/>
<constraint firstItem="7fE-x8-2Vl" firstAttribute="top" secondItem="d7U-Vz-ZXn" secondAttribute="top" id="dmg-IY-kyu"/>
<constraint firstItem="PA6-gY-SsH" firstAttribute="centerX" secondItem="d7U-Vz-ZXn" secondAttribute="centerX" id="nuB-5g-8P7"/>
<constraint firstItem="TX4-wv-r7d" firstAttribute="leading" secondItem="d7U-Vz-ZXn" secondAttribute="leading" id="uIH-NW-Yob"/>
</constraints>
<userDefinedRuntimeAttributes>
<userDefinedRuntimeAttribute type="string" keyPath="styleName" value="Background"/>
</userDefinedRuntimeAttributes>
</view>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="J8L-sr-yWu" userLabel="Day#3">
<rect key="frame" x="98.5" y="0.0" width="41" height="76"/>
<subviews>
<button opaque="NO" tag="2" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="Ocy-4H-ZwH">
<rect key="frame" x="0.0" y="0.0" width="41" height="76"/>
<connections>
<action selector="selectDay:" destination="KGk-i7-Jjw" eventType="touchUpInside" id="Nab-Ud-zim"/>
</connections>
</button>
<label opaque="NO" userInteractionEnabled="NO" tag="2" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Su" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" preferredMaxLayoutWidth="40" translatesAutoresizingMaskIntoConstraints="NO" id="6IK-aQ-W8x">
<rect key="frame" x="0.0" y="12" width="41" height="20"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<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="styleName" value="regular17"/>
</userDefinedRuntimeAttributes>
</label>
<imageView userInteractionEnabled="NO" tag="2" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="radioBtnOff" highlightedImage="radioBtnOn" translatesAutoresizingMaskIntoConstraints="NO" id="eLh-R1-Lvc">
<rect key="frame" x="9.5" y="40" width="22" height="22"/>
<constraints>
<constraint firstAttribute="height" constant="22" id="0ck-A4-4EU"/>
<constraint firstAttribute="width" constant="22" id="OuD-FL-tq0"/>
</constraints>
<userDefinedRuntimeAttributes>
<userDefinedRuntimeAttribute type="string" keyPath="styleName" value="MWMBlue"/>
</userDefinedRuntimeAttributes>
</imageView>
</subviews>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<constraints>
<constraint firstItem="Ocy-4H-ZwH" firstAttribute="top" secondItem="J8L-sr-yWu" secondAttribute="top" id="0sk-ua-zdd"/>
<constraint firstItem="eLh-R1-Lvc" firstAttribute="top" secondItem="6IK-aQ-W8x" secondAttribute="bottom" constant="8" id="2fp-13-n6h"/>
<constraint firstAttribute="trailing" secondItem="6IK-aQ-W8x" secondAttribute="trailing" id="BHD-Pp-LW4"/>
<constraint firstItem="6IK-aQ-W8x" firstAttribute="top" secondItem="J8L-sr-yWu" secondAttribute="top" constant="12" id="JQl-98-UDe"/>
<constraint firstItem="6IK-aQ-W8x" firstAttribute="leading" secondItem="J8L-sr-yWu" secondAttribute="leading" id="RvV-4c-Mev"/>
<constraint firstAttribute="bottom" secondItem="Ocy-4H-ZwH" secondAttribute="bottom" id="gPh-zG-ajh"/>
<constraint firstAttribute="trailing" secondItem="Ocy-4H-ZwH" secondAttribute="trailing" id="mZP-f1-Frz"/>
<constraint firstItem="Ocy-4H-ZwH" firstAttribute="leading" secondItem="J8L-sr-yWu" secondAttribute="leading" id="qxq-5J-8be"/>
<constraint firstItem="eLh-R1-Lvc" firstAttribute="centerX" secondItem="J8L-sr-yWu" secondAttribute="centerX" id="vJl-bp-Rdn"/>
</constraints>
<userDefinedRuntimeAttributes>
<userDefinedRuntimeAttribute type="string" keyPath="styleName" value="Background"/>
</userDefinedRuntimeAttributes>
</view>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="8q8-c5-QBM" userLabel="Day#4">
<rect key="frame" x="139.5" y="0.0" width="41" height="76"/>
<subviews>
<button opaque="NO" tag="3" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="Pmq-0T-6ND">
<rect key="frame" x="0.0" y="0.0" width="41" height="76"/>
<connections>
<action selector="selectDay:" destination="KGk-i7-Jjw" eventType="touchUpInside" id="PZT-nD-iid"/>
</connections>
</button>
<label opaque="NO" userInteractionEnabled="NO" tag="3" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Su" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" preferredMaxLayoutWidth="40" translatesAutoresizingMaskIntoConstraints="NO" id="gSE-qV-osv">
<rect key="frame" x="0.0" y="12" width="41" height="20"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<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="styleName" value="regular17"/>
</userDefinedRuntimeAttributes>
</label>
<imageView userInteractionEnabled="NO" tag="3" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="radioBtnOff" highlightedImage="radioBtnOn" translatesAutoresizingMaskIntoConstraints="NO" id="IVB-FW-ULI">
<rect key="frame" x="9.5" y="40" width="22" height="22"/>
<constraints>
<constraint firstAttribute="height" constant="22" id="rkz-jd-7Vx"/>
<constraint firstAttribute="width" constant="22" id="zeP-ls-q95"/>
</constraints>
<userDefinedRuntimeAttributes>
<userDefinedRuntimeAttribute type="string" keyPath="styleName" value="MWMBlue"/>
</userDefinedRuntimeAttributes>
</imageView>
</subviews>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<constraints>
<constraint firstAttribute="trailing" secondItem="Pmq-0T-6ND" secondAttribute="trailing" id="FKK-TY-xSz"/>
<constraint firstItem="IVB-FW-ULI" firstAttribute="centerX" secondItem="8q8-c5-QBM" secondAttribute="centerX" id="Jgi-xs-3J6"/>
<constraint firstItem="IVB-FW-ULI" firstAttribute="top" secondItem="gSE-qV-osv" secondAttribute="bottom" constant="8" id="OQT-Tr-My1"/>
<constraint firstAttribute="trailing" secondItem="gSE-qV-osv" secondAttribute="trailing" id="RH3-SD-kbf"/>
<constraint firstItem="Pmq-0T-6ND" firstAttribute="top" secondItem="8q8-c5-QBM" secondAttribute="top" id="aYK-b7-hF0"/>
<constraint firstItem="Pmq-0T-6ND" firstAttribute="leading" secondItem="8q8-c5-QBM" secondAttribute="leading" id="diE-wI-FSD"/>
<constraint firstAttribute="bottom" secondItem="Pmq-0T-6ND" secondAttribute="bottom" id="hpD-TJ-qGT"/>
<constraint firstItem="gSE-qV-osv" firstAttribute="leading" secondItem="8q8-c5-QBM" secondAttribute="leading" id="hxl-Gc-Ey0"/>
<constraint firstItem="gSE-qV-osv" firstAttribute="top" secondItem="8q8-c5-QBM" secondAttribute="top" constant="12" id="lfH-66-upM"/>
</constraints>
<userDefinedRuntimeAttributes>
<userDefinedRuntimeAttribute type="string" keyPath="styleName" value="Background"/>
</userDefinedRuntimeAttributes>
</view>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="15A-tH-C45" userLabel="Day#5">
<rect key="frame" x="180.5" y="0.0" width="41" height="76"/>
<subviews>
<button opaque="NO" tag="4" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="Otc-DJ-XJQ">
<rect key="frame" x="0.0" y="0.0" width="41" height="76"/>
<connections>
<action selector="selectDay:" destination="KGk-i7-Jjw" eventType="touchUpInside" id="Fgx-45-oKW"/>
</connections>
</button>
<label opaque="NO" userInteractionEnabled="NO" tag="4" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Su" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" preferredMaxLayoutWidth="40" translatesAutoresizingMaskIntoConstraints="NO" id="JHH-2W-e7Q">
<rect key="frame" x="0.0" y="12" width="41" height="20"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<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="styleName" value="regular17"/>
</userDefinedRuntimeAttributes>
</label>
<imageView userInteractionEnabled="NO" tag="4" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="radioBtnOff" highlightedImage="radioBtnOn" translatesAutoresizingMaskIntoConstraints="NO" id="WaR-h2-4mE">
<rect key="frame" x="9.5" y="40" width="22" height="22"/>
<constraints>
<constraint firstAttribute="width" constant="22" id="2WN-hW-NfA"/>
<constraint firstAttribute="height" constant="22" id="paI-VA-gTy"/>
</constraints>
<userDefinedRuntimeAttributes>
<userDefinedRuntimeAttribute type="string" keyPath="styleName" value="MWMBlue"/>
</userDefinedRuntimeAttributes>
</imageView>
</subviews>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<constraints>
<constraint firstAttribute="bottom" secondItem="Otc-DJ-XJQ" secondAttribute="bottom" id="8rG-g5-oib"/>
<constraint firstItem="WaR-h2-4mE" firstAttribute="top" secondItem="JHH-2W-e7Q" secondAttribute="bottom" constant="8" id="EUf-Hh-CZk"/>
<constraint firstItem="JHH-2W-e7Q" firstAttribute="leading" secondItem="15A-tH-C45" secondAttribute="leading" id="HJ5-tT-Z3E"/>
<constraint firstItem="JHH-2W-e7Q" firstAttribute="top" secondItem="15A-tH-C45" secondAttribute="top" constant="12" id="Qmm-tS-5nK"/>
<constraint firstItem="Otc-DJ-XJQ" firstAttribute="leading" secondItem="15A-tH-C45" secondAttribute="leading" id="TMg-gA-iyJ"/>
<constraint firstItem="WaR-h2-4mE" firstAttribute="centerX" secondItem="15A-tH-C45" secondAttribute="centerX" id="Ub0-7c-gNn"/>
<constraint firstAttribute="trailing" secondItem="Otc-DJ-XJQ" secondAttribute="trailing" id="X8Z-eo-2rO"/>
<constraint firstItem="Otc-DJ-XJQ" firstAttribute="top" secondItem="15A-tH-C45" secondAttribute="top" id="jmD-7s-O2V"/>
<constraint firstAttribute="trailing" secondItem="JHH-2W-e7Q" secondAttribute="trailing" id="ns8-PY-dck"/>
</constraints>
<userDefinedRuntimeAttributes>
<userDefinedRuntimeAttribute type="string" keyPath="styleName" value="Background"/>
</userDefinedRuntimeAttributes>
</view>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="Tqf-QU-RCZ" userLabel="Day#6">
<rect key="frame" x="221.5" y="0.0" width="41.5" height="76"/>
<subviews>
<button opaque="NO" tag="5" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="Kid-OJ-nOc">
<rect key="frame" x="0.0" y="0.0" width="41.5" height="76"/>
<connections>
<action selector="selectDay:" destination="KGk-i7-Jjw" eventType="touchUpInside" id="Viw-8h-SMl"/>
</connections>
</button>
<label opaque="NO" userInteractionEnabled="NO" tag="5" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Su" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" preferredMaxLayoutWidth="40" translatesAutoresizingMaskIntoConstraints="NO" id="F0Z-Fk-0s9">
<rect key="frame" x="0.0" y="12" width="41.5" height="20"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<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="styleName" value="regular17"/>
</userDefinedRuntimeAttributes>
</label>
<imageView userInteractionEnabled="NO" tag="5" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="radioBtnOff" highlightedImage="radioBtnOn" translatesAutoresizingMaskIntoConstraints="NO" id="Qo3-ii-YnF">
<rect key="frame" x="10" y="40" width="22" height="22"/>
<constraints>
<constraint firstAttribute="width" constant="22" id="9Ya-Qr-OeU"/>
<constraint firstAttribute="height" constant="22" id="jS5-JM-9BC"/>
</constraints>
<userDefinedRuntimeAttributes>
<userDefinedRuntimeAttribute type="string" keyPath="styleName" value="MWMBlue"/>
</userDefinedRuntimeAttributes>
</imageView>
</subviews>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<constraints>
<constraint firstItem="Kid-OJ-nOc" firstAttribute="leading" secondItem="Tqf-QU-RCZ" secondAttribute="leading" id="4op-ZK-yva"/>
<constraint firstItem="F0Z-Fk-0s9" firstAttribute="leading" secondItem="Tqf-QU-RCZ" secondAttribute="leading" id="H7T-aM-96w"/>
<constraint firstItem="F0Z-Fk-0s9" firstAttribute="top" secondItem="Tqf-QU-RCZ" secondAttribute="top" constant="12" id="R78-3k-Sfz"/>
<constraint firstItem="Qo3-ii-YnF" firstAttribute="centerX" secondItem="Tqf-QU-RCZ" secondAttribute="centerX" id="YGK-VR-Te1"/>
<constraint firstItem="Qo3-ii-YnF" firstAttribute="top" secondItem="F0Z-Fk-0s9" secondAttribute="bottom" constant="8" id="ZHq-Ok-ieq"/>
<constraint firstAttribute="trailing" secondItem="F0Z-Fk-0s9" secondAttribute="trailing" id="cCr-SP-3Ab"/>
<constraint firstItem="Kid-OJ-nOc" firstAttribute="top" secondItem="Tqf-QU-RCZ" secondAttribute="top" id="d6T-9c-FKV"/>
<constraint firstAttribute="bottom" secondItem="Kid-OJ-nOc" secondAttribute="bottom" id="ff1-SR-Ci6"/>
<constraint firstAttribute="trailing" secondItem="Kid-OJ-nOc" secondAttribute="trailing" id="tHe-1w-a4t"/>
</constraints>
<userDefinedRuntimeAttributes>
<userDefinedRuntimeAttribute type="string" keyPath="styleName" value="Background"/>
</userDefinedRuntimeAttributes>
</view>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="lBL-06-25g" userLabel="Day#7">
<rect key="frame" x="263" y="0.0" width="41" height="76"/>
<subviews>
<button opaque="NO" tag="6" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="l5X-og-86Q">
<rect key="frame" x="0.0" y="0.0" width="41" height="76"/>
<connections>
<action selector="selectDay:" destination="KGk-i7-Jjw" eventType="touchUpInside" id="xnf-pU-Pv9"/>
</connections>
</button>
<label opaque="NO" userInteractionEnabled="NO" tag="6" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Su" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" preferredMaxLayoutWidth="40" translatesAutoresizingMaskIntoConstraints="NO" id="Nzo-2k-zUZ">
<rect key="frame" x="0.0" y="12" width="41" height="20"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<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="styleName" value="regular17"/>
</userDefinedRuntimeAttributes>
</label>
<imageView userInteractionEnabled="NO" tag="6" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="radioBtnOff" highlightedImage="radioBtnOn" translatesAutoresizingMaskIntoConstraints="NO" id="vIl-li-8uM">
<rect key="frame" x="9.5" y="40" width="22" height="22"/>
<constraints>
<constraint firstAttribute="height" constant="22" id="D4F-jl-d8J"/>
<constraint firstAttribute="width" constant="22" id="nOA-Kh-nx9"/>
</constraints>
<userDefinedRuntimeAttributes>
<userDefinedRuntimeAttribute type="string" keyPath="styleName" value="MWMBlue"/>
</userDefinedRuntimeAttributes>
</imageView>
</subviews>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<constraints>
<constraint firstItem="vIl-li-8uM" firstAttribute="top" secondItem="Nzo-2k-zUZ" secondAttribute="bottom" constant="8" id="5Md-vp-o0X"/>
<constraint firstAttribute="bottom" secondItem="l5X-og-86Q" secondAttribute="bottom" id="CGB-N7-ce6"/>
<constraint firstItem="vIl-li-8uM" firstAttribute="centerX" secondItem="lBL-06-25g" secondAttribute="centerX" id="Jjk-zY-3C6"/>
<constraint firstItem="Nzo-2k-zUZ" firstAttribute="leading" secondItem="lBL-06-25g" secondAttribute="leading" id="LHL-ac-W2r"/>
<constraint firstItem="Nzo-2k-zUZ" firstAttribute="top" secondItem="lBL-06-25g" secondAttribute="top" constant="12" id="cAw-kT-cSs"/>
<constraint firstAttribute="trailing" secondItem="Nzo-2k-zUZ" secondAttribute="trailing" id="cau-Ip-qka"/>
<constraint firstAttribute="trailing" secondItem="l5X-og-86Q" secondAttribute="trailing" id="ftk-0P-Eda"/>
<constraint firstItem="l5X-og-86Q" firstAttribute="leading" secondItem="lBL-06-25g" secondAttribute="leading" id="xfC-RT-CxJ"/>
<constraint firstItem="l5X-og-86Q" firstAttribute="top" secondItem="lBL-06-25g" secondAttribute="top" id="yir-ep-anV"/>
</constraints>
<userDefinedRuntimeAttributes>
<userDefinedRuntimeAttribute type="string" keyPath="styleName" value="Background"/>
</userDefinedRuntimeAttributes>
</view>
<imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="separator_image" translatesAutoresizingMaskIntoConstraints="NO" id="i4V-yS-NEg">
<rect key="frame" x="0.0" y="75.5" width="320" height="1"/>
<constraints>
<constraint firstAttribute="height" constant="1" id="ebA-bw-LdR"/>
</constraints>
<userDefinedRuntimeAttributes>
<userDefinedRuntimeAttribute type="string" keyPath="styleName" value="MWMSeparator"/>
</userDefinedRuntimeAttributes>
</imageView>
<imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="separator_image" translatesAutoresizingMaskIntoConstraints="NO" id="131-Pr-FGS">
<rect key="frame" x="0.0" y="0.0" width="320" height="1"/>
<constraints>
<constraint firstAttribute="height" constant="1" id="qnM-sM-4SM"/>
</constraints>
<userDefinedRuntimeAttributes>
<userDefinedRuntimeAttribute type="string" keyPath="styleName" value="MWMSeparator"/>
</userDefinedRuntimeAttributes>
</imageView>
</subviews>
<constraints>
<constraint firstItem="Tqf-QU-RCZ" firstAttribute="leading" secondItem="15A-tH-C45" secondAttribute="trailing" id="1zj-Fh-hEJ"/>
<constraint firstItem="Tqf-QU-RCZ" firstAttribute="top" secondItem="H2p-sc-9uM" secondAttribute="top" id="2wt-Fw-elF"/>
<constraint firstItem="CCr-vZ-lZV" firstAttribute="top" secondItem="H2p-sc-9uM" secondAttribute="top" id="4yI-Y2-fGK"/>
<constraint firstAttribute="trailing" secondItem="lBL-06-25g" secondAttribute="trailing" constant="16" id="684-Mj-MPT"/>
<constraint firstItem="d7U-Vz-ZXn" firstAttribute="top" secondItem="H2p-sc-9uM" secondAttribute="top" id="7Kd-9C-rrI"/>
<constraint firstItem="d7U-Vz-ZXn" firstAttribute="leading" secondItem="CCr-vZ-lZV" secondAttribute="trailing" id="9BW-il-aHi"/>
<constraint firstAttribute="bottom" secondItem="i4V-yS-NEg" secondAttribute="bottom" constant="-0.5" id="Ai5-Rm-yCG"/>
<constraint firstItem="8q8-c5-QBM" firstAttribute="top" secondItem="H2p-sc-9uM" secondAttribute="top" id="Bc6-d7-0np"/>
<constraint firstItem="lBL-06-25g" firstAttribute="leading" secondItem="Tqf-QU-RCZ" secondAttribute="trailing" id="Cjw-Ap-AU1"/>
<constraint firstItem="Tqf-QU-RCZ" firstAttribute="width" secondItem="lBL-06-25g" secondAttribute="width" id="EOh-Xy-asn"/>
<constraint firstAttribute="bottom" secondItem="8q8-c5-QBM" secondAttribute="bottom" id="FeI-Xq-7qp"/>
<constraint firstItem="CCr-vZ-lZV" firstAttribute="leading" secondItem="H2p-sc-9uM" secondAttribute="leading" constant="16" id="LMf-O6-0za"/>
<constraint firstItem="131-Pr-FGS" firstAttribute="leading" secondItem="H2p-sc-9uM" secondAttribute="leading" id="MWV-1b-VBO"/>
<constraint firstAttribute="bottom" secondItem="lBL-06-25g" secondAttribute="bottom" id="Mif-uK-Glu"/>
<constraint firstItem="8q8-c5-QBM" firstAttribute="leading" secondItem="J8L-sr-yWu" secondAttribute="trailing" id="OhY-sz-5EG"/>
<constraint firstAttribute="bottom" secondItem="Tqf-QU-RCZ" secondAttribute="bottom" id="PLc-Et-DgL"/>
<constraint firstAttribute="trailing" secondItem="i4V-yS-NEg" secondAttribute="trailing" id="QQ4-vc-HVH"/>
<constraint firstItem="lBL-06-25g" firstAttribute="top" secondItem="H2p-sc-9uM" secondAttribute="top" id="Qst-JA-vhN"/>
<constraint firstAttribute="bottom" secondItem="15A-tH-C45" secondAttribute="bottom" id="Rt0-jf-VSs"/>
<constraint firstItem="15A-tH-C45" firstAttribute="width" secondItem="Tqf-QU-RCZ" secondAttribute="width" id="StI-Qm-Vr2"/>
<constraint firstItem="J8L-sr-yWu" firstAttribute="width" secondItem="8q8-c5-QBM" secondAttribute="width" id="Y8q-0K-tpN"/>
<constraint firstItem="i4V-yS-NEg" firstAttribute="leading" secondItem="H2p-sc-9uM" secondAttribute="leading" id="dCf-tV-y5Z"/>
<constraint firstAttribute="bottom" secondItem="J8L-sr-yWu" secondAttribute="bottom" id="eO5-aC-qFU"/>
<constraint firstItem="15A-tH-C45" firstAttribute="top" secondItem="H2p-sc-9uM" secondAttribute="top" id="gOd-8i-R7q"/>
<constraint firstAttribute="trailing" secondItem="131-Pr-FGS" secondAttribute="trailing" id="gne-P8-mu2"/>
<constraint firstItem="15A-tH-C45" firstAttribute="leading" secondItem="8q8-c5-QBM" secondAttribute="trailing" id="hBC-FV-co6"/>
<constraint firstItem="CCr-vZ-lZV" firstAttribute="width" secondItem="d7U-Vz-ZXn" secondAttribute="width" id="hnc-hx-D5T"/>
<constraint firstItem="J8L-sr-yWu" firstAttribute="leading" secondItem="d7U-Vz-ZXn" secondAttribute="trailing" id="jbs-xW-KED"/>
<constraint firstItem="d7U-Vz-ZXn" firstAttribute="width" secondItem="J8L-sr-yWu" secondAttribute="width" id="n3E-ch-hIY"/>
<constraint firstAttribute="bottom" secondItem="d7U-Vz-ZXn" secondAttribute="bottom" id="r4p-8g-HHw"/>
<constraint firstItem="8q8-c5-QBM" firstAttribute="width" secondItem="15A-tH-C45" secondAttribute="width" id="tLl-N7-MHZ"/>
<constraint firstItem="131-Pr-FGS" firstAttribute="top" secondItem="H2p-sc-9uM" secondAttribute="top" id="wM0-sy-1Sy"/>
<constraint firstItem="J8L-sr-yWu" firstAttribute="top" secondItem="H2p-sc-9uM" secondAttribute="top" id="y7s-Ip-YCm"/>
<constraint firstAttribute="bottom" secondItem="CCr-vZ-lZV" secondAttribute="bottom" id="zPu-9q-ZMS"/>
</constraints>
<userDefinedRuntimeAttributes>
<userDefinedRuntimeAttribute type="string" keyPath="styleName" value="Background"/>
</userDefinedRuntimeAttributes>
</tableViewCellContentView>
<userDefinedRuntimeAttributes>
<userDefinedRuntimeAttribute type="string" keyPath="styleName" value="Background"/>
</userDefinedRuntimeAttributes>
<connections>
<outletCollection property="buttons" destination="tQj-bk-oM9" id="pbb-m3-HUd"/>
<outletCollection property="buttons" destination="7fE-x8-2Vl" id="TmQ-vt-r6l"/>
<outletCollection property="buttons" destination="Ocy-4H-ZwH" id="2bS-QH-S0k"/>
<outletCollection property="buttons" destination="Pmq-0T-6ND" id="nnb-lP-2YI"/>
<outletCollection property="buttons" destination="Otc-DJ-XJQ" id="LRt-yc-uL5"/>
<outletCollection property="buttons" destination="Kid-OJ-nOc" id="35j-cH-m6c"/>
<outletCollection property="buttons" destination="l5X-og-86Q" id="WuX-FB-cM4"/>
<outletCollection property="labels" destination="brZ-af-NfP" id="fcY-bQ-CtM"/>
<outletCollection property="labels" destination="TX4-wv-r7d" id="13b-5d-3SZ"/>
<outletCollection property="labels" destination="6IK-aQ-W8x" id="SBl-jh-pr8"/>
<outletCollection property="labels" destination="gSE-qV-osv" id="Arl-Nm-RJF"/>
<outletCollection property="labels" destination="JHH-2W-e7Q" id="MjO-dj-2Sh"/>
<outletCollection property="labels" destination="F0Z-Fk-0s9" id="Bdy-1N-ZAu"/>
<outletCollection property="labels" destination="Nzo-2k-zUZ" id="4Le-5S-4MH"/>
<outletCollection property="images" destination="eN6-Is-HP5" id="7X9-ac-EXy"/>
<outletCollection property="images" destination="PA6-gY-SsH" id="zQC-LG-juN"/>
<outletCollection property="images" destination="eLh-R1-Lvc" id="7JR-kO-NXC"/>
<outletCollection property="images" destination="IVB-FW-ULI" id="2hg-XH-3ij"/>
<outletCollection property="images" destination="WaR-h2-4mE" id="ipy-v0-dHA"/>
<outletCollection property="images" destination="Qo3-ii-YnF" id="gtk-HH-8Z7"/>
<outletCollection property="images" destination="vIl-li-8uM" id="tE0-YJ-8Rh"/>
</connections>
<point key="canvasLocation" x="139" y="155"/>
</tableViewCell>
</objects>
<resources>
<image name="radioBtnOff" width="22" height="22"/>
<image name="radioBtnOn" width="22" height="22"/>
<image name="separator_image" width="1" height="1"/>
</resources>
</document>

View file

@ -0,0 +1,5 @@
#import "MWMOpeningHoursTableViewCell.h"
@interface MWMOpeningHoursDeleteScheduleTableViewCell : MWMOpeningHoursTableViewCell
@end

View file

@ -0,0 +1,15 @@
#import "MWMOpeningHoursDeleteScheduleTableViewCell.h"
@implementation MWMOpeningHoursDeleteScheduleTableViewCell
+ (CGFloat)heightForWidth:(CGFloat)width
{
return 44.0;
}
- (IBAction)deleteScheduleTap
{
[self.section deleteSchedule];
}
@end

View file

@ -0,0 +1,66 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="15702" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES">
<device id="retina4_7" orientation="portrait" appearance="light"/>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="15704"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<objects>
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner"/>
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
<tableViewCell contentMode="scaleToFill" selectionStyle="default" indentationWidth="10" id="KGk-i7-Jjw" customClass="MWMOpeningHoursDeleteScheduleTableViewCell" propertyAccessControl="none">
<rect key="frame" x="0.0" y="0.0" width="320" height="44"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="KGk-i7-Jjw" id="H2p-sc-9uM">
<rect key="frame" x="0.0" y="0.0" width="320" height="44"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<button opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="6sA-sN-4Dk">
<rect key="frame" x="0.0" y="0.0" width="320" height="44"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<state key="normal" title="Delete Schedule">
<color key="titleColor" red="1" green="0.0" blue="0.0" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<color key="titleShadowColor" red="0.5" green="0.5" blue="0.5" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</state>
<userDefinedRuntimeAttributes>
<userDefinedRuntimeAttribute type="string" keyPath="styleName" value="FlatRedTransButtonBig"/>
<userDefinedRuntimeAttribute type="string" keyPath="localizedText" value="editor_time_delete"/>
</userDefinedRuntimeAttributes>
<connections>
<action selector="deleteScheduleTap" destination="KGk-i7-Jjw" eventType="touchUpInside" id="Wrd-G9-gDM"/>
</connections>
</button>
<imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="separator_image" translatesAutoresizingMaskIntoConstraints="NO" id="pwt-wM-TFm">
<rect key="frame" x="0.0" y="43.5" width="320" height="1"/>
<constraints>
<constraint firstAttribute="height" constant="1" id="uj7-UU-MSZ"/>
</constraints>
<userDefinedRuntimeAttributes>
<userDefinedRuntimeAttribute type="string" keyPath="styleName" value="MWMSeparator"/>
</userDefinedRuntimeAttributes>
</imageView>
</subviews>
<constraints>
<constraint firstAttribute="bottom" secondItem="6sA-sN-4Dk" secondAttribute="bottom" id="HqD-nd-D5C"/>
<constraint firstAttribute="trailing" secondItem="6sA-sN-4Dk" secondAttribute="trailing" id="ajb-sy-7f6"/>
<constraint firstItem="6sA-sN-4Dk" firstAttribute="top" secondItem="H2p-sc-9uM" secondAttribute="top" id="fyt-5F-eSU"/>
<constraint firstItem="pwt-wM-TFm" firstAttribute="leading" secondItem="H2p-sc-9uM" secondAttribute="leading" id="jD1-ee-pdn"/>
<constraint firstAttribute="bottom" secondItem="pwt-wM-TFm" secondAttribute="bottom" constant="-0.5" id="jr1-UN-iiO"/>
<constraint firstAttribute="trailing" secondItem="pwt-wM-TFm" secondAttribute="trailing" id="uAP-Dw-Gir"/>
<constraint firstItem="6sA-sN-4Dk" firstAttribute="leading" secondItem="H2p-sc-9uM" secondAttribute="leading" id="ywG-MR-eI2"/>
</constraints>
<userDefinedRuntimeAttributes>
<userDefinedRuntimeAttribute type="string" keyPath="styleName" value="Background"/>
</userDefinedRuntimeAttributes>
</tableViewCellContentView>
<userDefinedRuntimeAttributes>
<userDefinedRuntimeAttribute type="string" keyPath="styleName" value="Background"/>
</userDefinedRuntimeAttributes>
<point key="canvasLocation" x="139" y="155"/>
</tableViewCell>
</objects>
<resources>
<image name="separator_image" width="1" height="1"/>
</resources>
</document>

View file

@ -0,0 +1,17 @@
#import "MWMOpeningHoursSection.h"
#import "MWMTableViewCell.h"
@interface MWMOpeningHoursTableViewCell : MWMTableViewCell
+ (CGFloat)heightForWidth:(CGFloat)width;
@property (nonatomic, readonly) NSUInteger row;
@property (weak, nonatomic) MWMOpeningHoursSection * section;
@property (nonatomic) NSIndexPath * indexPathAtInit;
@property (nonatomic, readonly) BOOL isVisible;
- (void)hide;
- (void)refresh;
@end

View file

@ -0,0 +1,51 @@
#import "MWMOpeningHoursTableViewCell.h"
@implementation MWMOpeningHoursTableViewCell
+ (CGFloat)heightForWidth:(CGFloat)width
{
return 0.0;
}
- (void)setHighlighted:(BOOL)highlighted animated:(BOOL)animated
{
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated
{
}
- (void)hide
{
self.alpha = 0.0;
}
- (void)refresh
{
self.alpha = 1.0;
}
#pragma mark - Properties
- (void)setSection:(MWMOpeningHoursSection *)section
{
_section = section;
[self refresh];
}
- (NSUInteger)row
{
UITableView * tableView = self.section.delegate.tableView;
NSIndexPath * indexPath = [tableView indexPathForCell:self];
if (!indexPath)
indexPath = self.indexPathAtInit;
return indexPath.row;
}
- (BOOL)isVisible
{
UITableView * tableView = self.section.delegate.tableView;
return [tableView indexPathForCell:self] != nil;
}
@end

View file

@ -0,0 +1,5 @@
#import "MWMOpeningHoursTableViewCell.h"
@interface MWMOpeningHoursTimeSelectorTableViewCell : MWMOpeningHoursTableViewCell
@end

View file

@ -0,0 +1,54 @@
#import "MWMOpeningHoursTimeSelectorTableViewCell.h"
@interface MWMOpeningHoursTimeSelectorTableViewCell ()
@property (weak, nonatomic) IBOutlet UIDatePicker * openTimePicker;
@property (weak, nonatomic) IBOutlet UIDatePicker * closeTimePicker;
@property (nonatomic) NSCalendar * calendar;
@end
@implementation MWMOpeningHoursTimeSelectorTableViewCell
+ (CGFloat)heightForWidth:(CGFloat)width
{
return 180.0;
}
- (void)awakeFromNib
{
[super awakeFromNib];
self.calendar = NSCalendar.currentCalendar;
self.calendar.locale = NSLocale.currentLocale;
}
- (void)refresh
{
[super refresh];
MWMOpeningHoursSection * section = self.section;
NSUInteger const row = section.selectedRow.unsignedIntegerValue;
NSDate * openDate = [self.calendar dateFromComponents:[section timeForRow:row isStart:YES]];
NSDate * closeDate = [self.calendar dateFromComponents:[section timeForRow:row isStart:NO]];
[self.openTimePicker setDate:openDate animated:NO];
[self.closeTimePicker setDate:closeDate animated:NO];
}
#pragma mark - Actions
- (IBAction)openValueChanged
{
NSDate * date = self.openTimePicker.date;
NSCalendarUnit const components = NSCalendarUnitHour | NSCalendarUnitMinute;
self.section.cachedStartTime = [self.calendar components:components fromDate:date];
}
- (IBAction)closeValueChanged
{
NSDate * date = self.closeTimePicker.date;
NSCalendarUnit const components = NSCalendarUnitHour | NSCalendarUnitMinute;
self.section.cachedEndTime = [self.calendar components:components fromDate:date];
}
@end

View file

@ -0,0 +1,104 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="15702" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES">
<device id="retina4_7" orientation="portrait" appearance="light"/>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="15704"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<objects>
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner"/>
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
<tableViewCell contentMode="scaleToFill" selectionStyle="default" indentationWidth="10" rowHeight="180" id="KGk-i7-Jjw" customClass="MWMOpeningHoursTimeSelectorTableViewCell" propertyAccessControl="none">
<rect key="frame" x="0.0" y="0.0" width="320" height="180"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="KGk-i7-Jjw" id="H2p-sc-9uM">
<rect key="frame" x="0.0" y="0.0" width="320" height="180"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<datePicker contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" datePickerMode="time" minuteInterval="5" style="wheels" translatesAutoresizingMaskIntoConstraints="NO" id="GQP-ns-cE1">
<rect key="frame" x="16" y="0.0" width="128" height="180"/>
<locale key="locale" localeIdentifier="ru"/>
<connections>
<action selector="openValueChanged" destination="KGk-i7-Jjw" eventType="valueChanged" id="abn-DQ-iYH"/>
</connections>
</datePicker>
<datePicker contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" datePickerMode="time" minuteInterval="5" style="wheels" translatesAutoresizingMaskIntoConstraints="NO" id="w7f-Rh-vzg">
<rect key="frame" x="176" y="0.0" width="128" height="180"/>
<locale key="locale" localeIdentifier="ru"/>
<connections>
<action selector="closeValueChanged" destination="KGk-i7-Jjw" eventType="valueChanged" id="dwu-wx-oRQ"/>
</connections>
</datePicker>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text=":" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" preferredMaxLayoutWidth="8" translatesAutoresizingMaskIntoConstraints="NO" id="6b2-fN-HrU">
<rect key="frame" x="72" y="79.5" width="8" height="21"/>
<constraints>
<constraint firstAttribute="height" constant="21" id="CFL-td-w0X"/>
<constraint firstAttribute="width" constant="8" id="YVE-JC-Z8n"/>
</constraints>
<fontDescription key="fontDescription" type="boldSystem" pointSize="21"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="—" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" preferredMaxLayoutWidth="24" translatesAutoresizingMaskIntoConstraints="NO" id="ArA-iX-w8F">
<rect key="frame" x="148" y="79.5" width="24" height="21"/>
<constraints>
<constraint firstAttribute="width" constant="24" id="CeN-3u-tRz"/>
<constraint firstAttribute="height" constant="21" id="oBr-Rr-mKP"/>
</constraints>
<fontDescription key="fontDescription" type="system" pointSize="21"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text=":" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" preferredMaxLayoutWidth="8" translatesAutoresizingMaskIntoConstraints="NO" id="MQr-gL-ImO">
<rect key="frame" x="232" y="79.5" width="8" height="21"/>
<constraints>
<constraint firstAttribute="width" constant="8" id="KIB-6H-1UD"/>
<constraint firstAttribute="height" constant="21" id="Xad-ok-Mz7"/>
</constraints>
<fontDescription key="fontDescription" type="boldSystem" pointSize="21"/>
<nil key="highlightedColor"/>
</label>
<imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="separator_image" translatesAutoresizingMaskIntoConstraints="NO" id="rOS-aO-0gb">
<rect key="frame" x="0.0" y="179.5" width="320" height="1"/>
<constraints>
<constraint firstAttribute="height" constant="1" id="etc-9t-7gU"/>
</constraints>
<userDefinedRuntimeAttributes>
<userDefinedRuntimeAttribute type="string" keyPath="styleName" value="MWMSeparator"/>
</userDefinedRuntimeAttributes>
</imageView>
</subviews>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<constraints>
<constraint firstItem="MQr-gL-ImO" firstAttribute="centerX" secondItem="w7f-Rh-vzg" secondAttribute="centerX" constant="-4" id="1aM-UN-taw"/>
<constraint firstAttribute="bottom" secondItem="rOS-aO-0gb" secondAttribute="bottom" constant="-0.5" id="48x-fh-WrH"/>
<constraint firstItem="6b2-fN-HrU" firstAttribute="centerY" secondItem="GQP-ns-cE1" secondAttribute="centerY" id="CFO-NC-K5i"/>
<constraint firstItem="MQr-gL-ImO" firstAttribute="centerY" secondItem="w7f-Rh-vzg" secondAttribute="centerY" id="IAa-cP-AKa"/>
<constraint firstItem="ArA-iX-w8F" firstAttribute="centerX" secondItem="H2p-sc-9uM" secondAttribute="centerX" id="Jwt-Hj-rB5"/>
<constraint firstAttribute="bottom" secondItem="GQP-ns-cE1" secondAttribute="bottom" id="MD6-2s-qbb"/>
<constraint firstItem="GQP-ns-cE1" firstAttribute="centerX" secondItem="H2p-sc-9uM" secondAttribute="centerX" multiplier="1:2" id="TAR-AD-a1X"/>
<constraint firstItem="GQP-ns-cE1" firstAttribute="width" secondItem="H2p-sc-9uM" secondAttribute="width" multiplier="0.4" id="TeT-Yf-UeO"/>
<constraint firstAttribute="trailing" secondItem="rOS-aO-0gb" secondAttribute="trailing" id="W3v-cq-ONy"/>
<constraint firstItem="w7f-Rh-vzg" firstAttribute="width" secondItem="H2p-sc-9uM" secondAttribute="width" multiplier="0.4" id="fYI-wR-woS"/>
<constraint firstAttribute="bottom" secondItem="w7f-Rh-vzg" secondAttribute="bottom" id="hf6-7a-fuy"/>
<constraint firstItem="GQP-ns-cE1" firstAttribute="top" secondItem="H2p-sc-9uM" secondAttribute="top" id="jAC-6F-GVz"/>
<constraint firstItem="w7f-Rh-vzg" firstAttribute="centerX" secondItem="H2p-sc-9uM" secondAttribute="centerX" multiplier="3:2" id="kaE-sT-Ycx"/>
<constraint firstItem="w7f-Rh-vzg" firstAttribute="top" secondItem="H2p-sc-9uM" secondAttribute="top" id="ke4-wU-x0k"/>
<constraint firstItem="6b2-fN-HrU" firstAttribute="centerX" secondItem="GQP-ns-cE1" secondAttribute="centerX" constant="-4" id="nzt-Rr-b0u"/>
<constraint firstItem="rOS-aO-0gb" firstAttribute="leading" secondItem="H2p-sc-9uM" secondAttribute="leading" id="t8r-sp-fRg"/>
<constraint firstItem="ArA-iX-w8F" firstAttribute="centerY" secondItem="H2p-sc-9uM" secondAttribute="centerY" id="zKO-lN-XyI"/>
</constraints>
</tableViewCellContentView>
<userDefinedRuntimeAttributes>
<userDefinedRuntimeAttribute type="string" keyPath="styleName" value="Background"/>
</userDefinedRuntimeAttributes>
<connections>
<outlet property="closeTimePicker" destination="w7f-Rh-vzg" id="jdP-dK-pwF"/>
<outlet property="openTimePicker" destination="GQP-ns-cE1" id="qnP-We-WvA"/>
</connections>
<point key="canvasLocation" x="139" y="155"/>
</tableViewCell>
</objects>
<resources>
<image name="separator_image" width="1" height="1"/>
</resources>
</document>

View file

@ -0,0 +1,5 @@
#import "MWMOpeningHoursTableViewCell.h"
@interface MWMOpeningHoursTimeSpanTableViewCell : MWMOpeningHoursTableViewCell
@end

View file

@ -0,0 +1,50 @@
#import "MWMOpeningHoursTimeSpanTableViewCell.h"
@interface MWMOpeningHoursTimeSpanTableViewCell ()
@property (weak, nonatomic) IBOutlet UILabel * openTimeLabel;
@property (weak, nonatomic) IBOutlet UILabel * closeTimeLabel;
@end
@implementation MWMOpeningHoursTimeSpanTableViewCell
+ (CGFloat)heightForWidth:(CGFloat)width
{
return 64.0;
}
- (void)refresh
{
[super refresh];
NSCalendar * calendar = NSCalendar.currentCalendar;
MWMOpeningHoursSection * section = self.section;
NSUInteger const row = self.row;
NSDate * openDate = [calendar dateFromComponents:[section timeForRow:row isStart:YES]];
NSDate * closeDate = [calendar dateFromComponents:[section timeForRow:row isStart:NO]];
NSDateFormatterStyle timeStyle = NSDateFormatterShortStyle;
NSDateFormatterStyle dateStyle = NSDateFormatterNoStyle;
self.openTimeLabel.text = [DateTimeFormatter dateStringFrom:openDate dateStyle:dateStyle timeStyle:timeStyle];
self.closeTimeLabel.text = [DateTimeFormatter dateStringFrom:closeDate dateStyle:dateStyle timeStyle:timeStyle];
UIColor * clr = [section isRowSelected:row] ? [UIColor linkBlue] : [UIColor blackSecondaryText];
self.openTimeLabel.textColor = clr;
self.closeTimeLabel.textColor = clr;
}
#pragma mark - Actions
- (IBAction)expandTap
{
if (self.isVisible)
{
MWMOpeningHoursSection * section = self.section;
NSUInteger const row = self.row;
section.selectedRow = [section isRowSelected:row] ? nil : @(row);
[section refresh:NO];
}
}
@end

View file

@ -0,0 +1,125 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="15702" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES">
<device id="retina4_7" orientation="portrait" appearance="light"/>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="15704"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<objects>
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner"/>
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
<tableViewCell contentMode="scaleToFill" selectionStyle="default" indentationWidth="10" rowHeight="64" id="KGk-i7-Jjw" customClass="MWMOpeningHoursTimeSpanTableViewCell" propertyAccessControl="none">
<rect key="frame" x="0.0" y="0.0" width="320" height="64"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="KGk-i7-Jjw" id="H2p-sc-9uM">
<rect key="frame" x="0.0" y="0.0" width="320" height="64"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Open time" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" preferredMaxLayoutWidth="128" translatesAutoresizingMaskIntoConstraints="NO" id="CgC-lU-buo">
<rect key="frame" x="16" y="12" width="131.5" height="16"/>
<fontDescription key="fontDescription" type="system" pointSize="14"/>
<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="styleName" value="regular14:blackPrimaryText"/>
<userDefinedRuntimeAttribute type="string" keyPath="localizedText" value="editor_time_open"/>
</userDefinedRuntimeAttributes>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="8:00" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" preferredMaxLayoutWidth="128" translatesAutoresizingMaskIntoConstraints="NO" id="CuG-0G-4pB">
<rect key="frame" x="16" y="32" width="131.5" height="17"/>
<fontDescription key="fontDescription" type="system" pointSize="14"/>
<color key="textColor" red="0.1176470588" green="0.58823529409999997" blue="0.94117647059999998" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<nil key="highlightedColor"/>
<userDefinedRuntimeAttributes>
<userDefinedRuntimeAttribute type="string" keyPath="styleName" value="regular17:linkBlueText"/>
</userDefinedRuntimeAttributes>
</label>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="oux-nC-xpk" userLabel="VerticalSeparator">
<rect key="frame" x="159.5" y="0.0" width="1" height="64"/>
<color key="backgroundColor" red="0.0" green="0.0" blue="0.0" alpha="0.12" colorSpace="custom" customColorSpace="sRGB"/>
<constraints>
<constraint firstAttribute="width" constant="1" id="1m4-5Q-ym8"/>
</constraints>
<userDefinedRuntimeAttributes>
<userDefinedRuntimeAttribute type="string" keyPath="styleName" value="Divider"/>
</userDefinedRuntimeAttributes>
</view>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Close time" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" preferredMaxLayoutWidth="127" translatesAutoresizingMaskIntoConstraints="NO" id="cGX-Q7-Ddh">
<rect key="frame" x="176.5" y="12" width="127.5" height="16"/>
<fontDescription key="fontDescription" type="system" pointSize="14"/>
<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="styleName" value="regular14:blackPrimaryText"/>
<userDefinedRuntimeAttribute type="string" keyPath="localizedText" value="editor_time_close"/>
</userDefinedRuntimeAttributes>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="20:30" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" preferredMaxLayoutWidth="127" translatesAutoresizingMaskIntoConstraints="NO" id="o59-Hp-LIf">
<rect key="frame" x="176.5" y="32" width="127.5" height="17"/>
<fontDescription key="fontDescription" type="system" pointSize="14"/>
<color key="textColor" red="0.0" green="0.47843137250000001" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<nil key="highlightedColor"/>
<userDefinedRuntimeAttributes>
<userDefinedRuntimeAttribute type="string" keyPath="styleName" value="regular17:linkBlueText"/>
</userDefinedRuntimeAttributes>
</label>
<imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="separator_image" translatesAutoresizingMaskIntoConstraints="NO" id="qsf-WG-QJW">
<rect key="frame" x="0.0" y="63.5" width="320" height="1"/>
<constraints>
<constraint firstAttribute="height" constant="1" id="Pfd-8E-gxy"/>
</constraints>
<userDefinedRuntimeAttributes>
<userDefinedRuntimeAttribute type="string" keyPath="styleName" value="MWMSeparator"/>
</userDefinedRuntimeAttributes>
</imageView>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="jNP-mE-elz" userLabel="Expand Button">
<rect key="frame" x="0.0" y="0.0" width="320" height="64"/>
<color key="backgroundColor" red="0.0" green="0.0" blue="0.0" alpha="0.0" colorSpace="custom" customColorSpace="sRGB"/>
<connections>
<action selector="expandTap" destination="KGk-i7-Jjw" eventType="touchUpInside" id="La8-XF-Fnv"/>
</connections>
</button>
</subviews>
<constraints>
<constraint firstAttribute="bottom" secondItem="oux-nC-xpk" secondAttribute="bottom" id="5IL-Ia-kot"/>
<constraint firstItem="oux-nC-xpk" firstAttribute="leading" secondItem="CgC-lU-buo" secondAttribute="trailing" constant="12" id="6mt-ZU-wDQ"/>
<constraint firstItem="o59-Hp-LIf" firstAttribute="top" secondItem="cGX-Q7-Ddh" secondAttribute="bottom" constant="4" id="9lg-5H-iWb"/>
<constraint firstItem="qsf-WG-QJW" firstAttribute="leading" secondItem="H2p-sc-9uM" secondAttribute="leading" id="AD8-yB-pdV"/>
<constraint firstAttribute="bottom" secondItem="jNP-mE-elz" secondAttribute="bottom" id="FLC-q7-gpV"/>
<constraint firstAttribute="trailing" secondItem="jNP-mE-elz" secondAttribute="trailing" id="HAn-uc-gIX"/>
<constraint firstItem="jNP-mE-elz" firstAttribute="leading" secondItem="H2p-sc-9uM" secondAttribute="leading" id="Jaw-Pm-p8E"/>
<constraint firstItem="CgC-lU-buo" firstAttribute="top" secondItem="H2p-sc-9uM" secondAttribute="top" constant="12" id="Ji6-6i-Iuz"/>
<constraint firstItem="CuG-0G-4pB" firstAttribute="top" secondItem="CgC-lU-buo" secondAttribute="bottom" constant="4" id="NbX-uq-7HO"/>
<constraint firstItem="oux-nC-xpk" firstAttribute="top" secondItem="H2p-sc-9uM" secondAttribute="top" id="OIR-lX-7FF"/>
<constraint firstItem="oux-nC-xpk" firstAttribute="leading" secondItem="CuG-0G-4pB" secondAttribute="trailing" constant="12" id="T0l-Xe-jBq"/>
<constraint firstAttribute="trailing" secondItem="cGX-Q7-Ddh" secondAttribute="trailing" constant="16" id="UPX-QC-I2L"/>
<constraint firstItem="CuG-0G-4pB" firstAttribute="leading" secondItem="H2p-sc-9uM" secondAttribute="leading" constant="16" id="VZc-gy-4dr"/>
<constraint firstItem="jNP-mE-elz" firstAttribute="top" secondItem="H2p-sc-9uM" secondAttribute="top" id="Y32-SZ-Ap1"/>
<constraint firstItem="o59-Hp-LIf" firstAttribute="leading" secondItem="oux-nC-xpk" secondAttribute="trailing" constant="16" id="cvy-Bd-TWo"/>
<constraint firstAttribute="bottom" secondItem="qsf-WG-QJW" secondAttribute="bottom" constant="-0.5" id="fwf-rw-9k6"/>
<constraint firstItem="cGX-Q7-Ddh" firstAttribute="top" secondItem="H2p-sc-9uM" secondAttribute="top" constant="12" id="jXv-Nx-MES"/>
<constraint firstAttribute="trailing" secondItem="qsf-WG-QJW" secondAttribute="trailing" id="mle-r1-uUX"/>
<constraint firstAttribute="trailing" secondItem="o59-Hp-LIf" secondAttribute="trailing" constant="16" id="oYK-KJ-Asi"/>
<constraint firstItem="oux-nC-xpk" firstAttribute="centerX" secondItem="H2p-sc-9uM" secondAttribute="centerX" id="qpb-DW-pu0"/>
<constraint firstItem="CgC-lU-buo" firstAttribute="leading" secondItem="H2p-sc-9uM" secondAttribute="leading" constant="16" id="rji-cJ-629"/>
<constraint firstItem="cGX-Q7-Ddh" firstAttribute="leading" secondItem="oux-nC-xpk" secondAttribute="trailing" constant="16" id="xCE-ly-lub"/>
</constraints>
<userDefinedRuntimeAttributes>
<userDefinedRuntimeAttribute type="string" keyPath="styleName" value="Background"/>
</userDefinedRuntimeAttributes>
</tableViewCellContentView>
<userDefinedRuntimeAttributes>
<userDefinedRuntimeAttribute type="string" keyPath="styleName" value="Background"/>
</userDefinedRuntimeAttributes>
<connections>
<outlet property="closeTimeLabel" destination="o59-Hp-LIf" id="U3D-MI-UR4"/>
<outlet property="openTimeLabel" destination="CuG-0G-4pB" id="aDq-t8-Eag"/>
</connections>
<point key="canvasLocation" x="139" y="155"/>
</tableViewCell>
</objects>
<resources>
<image name="separator_image" width="1" height="1"/>
</resources>
</document>

View file

@ -0,0 +1,12 @@
typedef NS_ENUM (NSUInteger, MWMOpeningHoursEditorCells)
{
MWMOpeningHoursEditorDaysSelectorCell,
MWMOpeningHoursEditorAllDayCell,
MWMOpeningHoursEditorTimeSpanCell,
MWMOpeningHoursEditorTimeSelectorCell,
MWMOpeningHoursEditorClosedSpanCell,
MWMOpeningHoursEditorAddClosedCell,
MWMOpeningHoursEditorDeleteScheduleCell,
MWMOpeningHoursEditorAddScheduleCell
};

View file

@ -0,0 +1,14 @@
#import "MWMViewController.h"
@protocol MWMOpeningHoursEditorProtocol <NSObject>
- (void)setOpeningHours:(NSString *)openingHours;
@end
@interface MWMOpeningHoursEditorViewController : MWMViewController
@property (copy, nonatomic) NSString * openingHours;
@property (weak, nonatomic) id<MWMOpeningHoursEditorProtocol> delegate;
@end

View file

@ -0,0 +1,218 @@
#import "MWMOpeningHoursEditorViewController.h"
#import "MWMOpeningHoursAddClosedTableViewCell.h"
#import "MWMOpeningHoursAddScheduleTableViewCell.h"
#import "MWMOpeningHoursAllDayTableViewCell.h"
#import "MWMOpeningHoursClosedSpanTableViewCell.h"
#import "MWMOpeningHoursDaysSelectorTableViewCell.h"
#import "MWMOpeningHoursDeleteScheduleTableViewCell.h"
#import "MWMOpeningHoursTimeSelectorTableViewCell.h"
#import "MWMOpeningHoursTimeSpanTableViewCell.h"
#import "SwiftBridge.h"
extern NSDictionary * const kMWMOpeningHoursEditorTableCells = @{
@(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,
UITextViewDelegate, MWMOpeningHoursModelProtocol>
@property(weak, nonatomic, readwrite) IBOutlet UITableView * tableView;
@property(weak, nonatomic, readwrite) IBOutlet UIView * advancedEditor;
@property(weak, nonatomic, readwrite) IBOutlet MWMTextView * editorView;
@property(weak, nonatomic) IBOutlet UIView * helpView;
@property(weak, nonatomic) IBOutlet WKWebView * help;
@property(weak, nonatomic, readwrite) IBOutlet NSLayoutConstraint * ohTextViewHeight;
@property(weak, nonatomic) IBOutlet UIView * exampleValuesSeparator;
@property(weak, nonatomic) IBOutlet UIImageView * exampleValuesExpandView;
@property(weak, nonatomic) IBOutlet NSLayoutConstraint * examplesButtonBottomOffset;
@property(weak, nonatomic, readwrite) IBOutlet UIButton * toggleModeButton;
@property(nonatomic) BOOL exampleExpanded;
@property(nonatomic) BOOL isSimpleMode;
@property(nonatomic) MWMOpeningHoursModel * model;
@end
@implementation MWMOpeningHoursEditorViewController
- (void)viewDidLoad
{
[super viewDidLoad];
[self configNavBar];
[self configTable];
[self configAdvancedEditor];
[self configData];
}
#pragma mark - Configuration
- (void)configNavBar
{
self.title = L(@"editor_time_title");
self.navigationItem.rightBarButtonItem =
[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemDone
target:self
action:@selector(onDone)];
}
- (void)configTable
{
[kMWMOpeningHoursEditorTableCells
enumerateKeysAndObjectsUsingBlock:^(id _Nonnull key, Class cls, BOOL * _Nonnull stop) {
[self.tableView registerNibWithCellClass:cls];
}];
}
- (void)configAdvancedEditor
{
[self.editorView setTextContainerInset:{.top = 12, .left = 10, .bottom = 12, .right = 10}];
self.editorView.keyboardAppearance =
[UIColor isNightMode] ? UIKeyboardAppearanceDark : UIKeyboardAppearanceDefault;
NSString * path =
[NSBundle.mainBundle pathForResource:@"opening_hours_how_to_edit" ofType:@"html"];
NSString * html =
[[NSString alloc] initWithContentsOfFile:path encoding:NSUTF8StringEncoding error:nil];
NSURL * baseURL = [NSURL fileURLWithPath:path];
[self.help loadHTMLString:html baseURL:baseURL];
}
- (void)configData
{
self.model = [[MWMOpeningHoursModel alloc] initWithDelegate:self];
self.isSimpleMode = self.model.isSimpleModeCapable;
}
#pragma mark - Actions
- (void)onCancel { [self.navigationController popViewControllerAnimated:YES]; }
- (void)onDone
{
[self.model storeCachedData];
[self.model updateOpeningHours];
[self.delegate setOpeningHours:self.openingHours];
[self onCancel];
}
#pragma mark - Table
- (MWMOpeningHoursEditorCells)cellKeyForIndexPath:(NSIndexPath *)indexPath
{
if (indexPath.section < self.model.count)
return [self.model cellKeyForIndexPath:indexPath];
else
return MWMOpeningHoursEditorAddScheduleCell;
}
- (CGFloat)heightForRowAtIndexPath:(NSIndexPath * _Nonnull)indexPath
{
CGFloat const width = self.view.width;
if (indexPath.section < self.model.count)
return [self.model heightForIndexPath:indexPath withWidth:width];
else
return [MWMOpeningHoursAddScheduleTableViewCell height];
}
#pragma mark - Fill cells with data
- (void)fillCell:(MWMOpeningHoursTableViewCell * _Nonnull)cell
atIndexPath:(NSIndexPath * _Nonnull)indexPath
{
if (!self.parentViewController)
return;
if (indexPath.section < self.model.count)
[self.model fillCell:cell atIndexPath:indexPath];
else if ([cell isKindOfClass:[MWMOpeningHoursAddScheduleTableViewCell class]])
((MWMOpeningHoursAddScheduleTableViewCell *)cell).model = self.model;
}
#pragma mark - UITableViewDataSource
- (UITableViewCell * _Nonnull)tableView:(UITableView * _Nonnull)tableView
cellForRowAtIndexPath:(NSIndexPath * _Nonnull)indexPath
{
Class cls = kMWMOpeningHoursEditorTableCells[@([self cellKeyForIndexPath:indexPath])];
auto cell = [tableView dequeueReusableCellWithCellClass:cls indexPath:indexPath];
return cell;
}
- (NSInteger)numberOfSectionsInTableView:(UITableView * _Nonnull)tableView
{
if (!self.model.isSimpleMode)
return 0;
return self.model.count + (self.model.canAddSection ? 1 : 0);
}
- (NSInteger)tableView:(UITableView * _Nonnull)tableView numberOfRowsInSection:(NSInteger)section
{
return (section < self.model.count ? [self.model numberOfRowsInSection:section] : 1);
}
#pragma mark - UITableViewDelegate
- (CGFloat)tableView:(UITableView * _Nonnull)tableView
heightForRowAtIndexPath:(NSIndexPath * _Nonnull)indexPath
{
return [self heightForRowAtIndexPath:indexPath];
}
- (CGFloat)tableView:(UITableView * _Nonnull)tableView
estimatedHeightForRowAtIndexPath:(NSIndexPath * _Nonnull)indexPath
{
return [self heightForRowAtIndexPath:indexPath];
}
- (void)tableView:(UITableView * _Nonnull)tableView
willDisplayCell:(MWMOpeningHoursTableViewCell * _Nonnull)cell
forRowAtIndexPath:(NSIndexPath * _Nonnull)indexPath
{
[self fillCell:cell atIndexPath:indexPath];
}
#pragma mark - Advanced mode
- (void)setExampleExpanded:(BOOL)exampleExpanded
{
_exampleExpanded = exampleExpanded;
self.help.hidden = !exampleExpanded;
self.examplesButtonBottomOffset.priority =
exampleExpanded ? UILayoutPriorityDefaultLow : UILayoutPriorityDefaultHigh;
self.exampleValuesSeparator.hidden = !exampleExpanded;
self.exampleValuesExpandView.image =
[UIImage imageNamed:exampleExpanded ? @"ic_arrow_gray_up" : @"ic_arrow_gray_down"];
if (exampleExpanded)
[self.editorView resignFirstResponder];
else
[self.editorView becomeFirstResponder];
}
- (IBAction)toggleExample { self.exampleExpanded = !self.exampleExpanded; }
- (IBAction)toggleMode { self.isSimpleMode = !self.isSimpleMode; }
#pragma mark - UITextViewDelegate
- (void)textViewDidChange:(UITextView *)textView
{
self.openingHours = textView.text;
self.navigationItem.rightBarButtonItem.enabled = self.model.isValid;
self.toggleModeButton.enabled = self.model.isSimpleModeCapable;
}
#pragma mark - Properties
- (void)setIsSimpleMode:(BOOL)isSimpleMode
{
self.model.isSimpleMode = isSimpleMode;
if (!isSimpleMode)
self.exampleExpanded = NO;
self.toggleModeButton.enabled = self.model.isSimpleModeCapable;
}
- (BOOL)isSimpleMode { return self.model.isSimpleMode; }
@end

View file

@ -0,0 +1,39 @@
#import "MWMOpeningHoursEditorCells.h"
#import "MWMOpeningHoursTableViewCell.h"
#import "MWMTextView.h"
@protocol MWMOpeningHoursModelProtocol <NSObject>
@property(nonnull, copy, nonatomic) NSString * openingHours;
@property(nullable, weak, nonatomic, readonly) UITableView * tableView;
@property(nullable, weak, nonatomic, readonly) UIView * advancedEditor;
@property(nullable, weak, nonatomic, readonly) MWMTextView * editorView;
@property(nullable, weak, nonatomic, readonly) UIButton * toggleModeButton;
@end
@interface MWMOpeningHoursModel : NSObject
@property(nonatomic, readonly) NSUInteger count;
@property(nonatomic, readonly) BOOL canAddSection;
@property(nonatomic, readonly) BOOL isValid;
@property(nonatomic) BOOL isSimpleMode;
@property(nonatomic, readonly) BOOL isSimpleModeCapable;
- (instancetype _Nullable)initWithDelegate:(id<MWMOpeningHoursModelProtocol> _Nonnull)delegate;
- (void)addSchedule;
- (void)deleteSchedule:(NSUInteger)index;
- (MWMOpeningHoursEditorCells)cellKeyForIndexPath:(NSIndexPath * _Nonnull)indexPath;
- (CGFloat)heightForIndexPath:(NSIndexPath * _Nonnull)indexPath withWidth:(CGFloat)width;
- (void)fillCell:(MWMOpeningHoursTableViewCell * _Nonnull)cell atIndexPath:(NSIndexPath * _Nonnull)indexPath;
- (NSUInteger)numberOfRowsInSection:(NSUInteger)section;
- (editor::ui::OpeningDays)unhandledDays;
- (void)storeCachedData;
- (void)updateOpeningHours;
@end

View file

@ -0,0 +1,214 @@
#import <CoreApi/MWMOpeningHoursCommon.h>
#import "MWMOpeningHoursModel.h"
#include "editor/ui2oh.hpp"
extern UITableViewRowAnimation const kMWMOpeningHoursEditorRowAnimation = UITableViewRowAnimationFade;
@interface MWMOpeningHoursModel () <MWMOpeningHoursSectionProtocol>
@property (weak, nonatomic) id<MWMOpeningHoursModelProtocol> delegate;
@property (nonatomic) NSMutableArray<MWMOpeningHoursSection *> * sections;
@end
using namespace editor;
using namespace osmoh;
@implementation MWMOpeningHoursModel
{
ui::TimeTableSet timeTableSet;
}
- (instancetype _Nullable)initWithDelegate:(id<MWMOpeningHoursModelProtocol> _Nonnull)delegate
{
self = [super init];
if (self)
_delegate = delegate;
return self;
}
- (void)addSection
{
[self.sections addObject:[[MWMOpeningHoursSection alloc] initWithDelegate:self]];
[self refreshSectionsIndexes];
}
- (void)refreshSectionsIndexes
{
[self.sections enumerateObjectsUsingBlock:^(MWMOpeningHoursSection * _Nonnull section,
NSUInteger idx, BOOL * _Nonnull stop)
{
[section refreshIndex:idx];
}];
}
- (void)addSchedule
{
NSAssert(self.canAddSection, @"Can not add schedule");
timeTableSet.Append(timeTableSet.GetComplementTimeTable());
[self addSection];
[self.tableView reloadSections:[[NSIndexSet alloc] initWithIndex:self.sections.count - 1]
withRowAnimation:kMWMOpeningHoursEditorRowAnimation];
NSAssert(timeTableSet.Size() == self.sections.count, @"Inconsistent state");
[self.sections[self.sections.count - 1] scrollIntoView];
}
- (void)deleteSchedule:(NSUInteger)index
{
NSAssert(index < self.count, @"Invalid section index");
BOOL const needRealDelete = self.canAddSection;
timeTableSet.Remove(index);
[self.sections removeObjectAtIndex:index];
[self refreshSectionsIndexes];
UITableView * tableView = self.tableView;
if (needRealDelete)
{
[tableView deleteSections:[[NSIndexSet alloc] initWithIndex:index]
withRowAnimation:kMWMOpeningHoursEditorRowAnimation];
[tableView reloadSections:[[NSIndexSet alloc] initWithIndex:self.count]
withRowAnimation:kMWMOpeningHoursEditorRowAnimation];
}
else
{
NSRange reloadRange = {index, self.count - index + 1};
[tableView reloadSections:[[NSIndexSet alloc] initWithIndexesInRange:reloadRange]
withRowAnimation:kMWMOpeningHoursEditorRowAnimation];
}
}
- (void)updateActiveSection:(NSUInteger)index
{
for (MWMOpeningHoursSection * section in self.sections)
{
if (section.index != index)
section.selectedRow = nil;
}
}
- (ui::TimeTableSet::Proxy)timeTableProxy:(NSUInteger)index
{
NSAssert(index < self.count, @"Invalid section index");
return timeTableSet.Get(index);
}
- (MWMOpeningHoursEditorCells)cellKeyForIndexPath:(NSIndexPath * _Nonnull)indexPath
{
NSUInteger const section = indexPath.section;
NSAssert(section < self.count, @"Invalid section index");
return [self.sections[section] cellKeyForRow:indexPath.row];
}
- (CGFloat)heightForIndexPath:(NSIndexPath * _Nonnull)indexPath withWidth:(CGFloat)width
{
NSUInteger const section = indexPath.section;
NSAssert(section < self.count, @"Invalid section index");
return [self.sections[section] heightForRow:indexPath.row withWidth:width];
}
- (void)fillCell:(MWMOpeningHoursTableViewCell * _Nonnull)cell atIndexPath:(NSIndexPath * _Nonnull)indexPath
{
NSUInteger const section = indexPath.section;
NSAssert(section < self.count, @"Invalid section index");
cell.indexPathAtInit = indexPath;
cell.section = self.sections[section];
}
- (NSUInteger)numberOfRowsInSection:(NSUInteger)section
{
NSAssert(section < self.count, @"Invalid section index");
return self.sections[section].numberOfRows;
}
- (ui::OpeningDays)unhandledDays
{
return timeTableSet.GetUnhandledDays();
}
- (void)storeCachedData
{
for (MWMOpeningHoursModel * m in self.sections)
[m storeCachedData];
}
- (void)updateOpeningHours
{
if (!self.isSimpleMode)
return;
std::stringstream sstr;
sstr << MakeOpeningHours(timeTableSet).GetRule();
self.delegate.openingHours = @(sstr.str().c_str());
}
#pragma mark - Properties
- (NSUInteger)count
{
NSAssert(timeTableSet.Size() == self.sections.count, @"Inconsistent state");
return self.sections.count;
}
- (BOOL)canAddSection
{
return !timeTableSet.GetUnhandledDays().empty();
}
- (UITableView *)tableView
{
return self.delegate.tableView;
}
- (BOOL)isValid
{
return osmoh::OpeningHours(self.delegate.openingHours.UTF8String).IsValid();
}
- (void)setIsSimpleMode:(BOOL)isSimpleMode
{
id<MWMOpeningHoursModelProtocol> delegate = self.delegate;
NSString * oh = delegate.openingHours;
auto isSimple = isSimpleMode;
if (isSimple && oh && oh.length)
isSimple = MakeTimeTableSet(osmoh::OpeningHours(oh.UTF8String), timeTableSet);
delegate.advancedEditor.hidden = isSimple;
UITableView * tv = delegate.tableView;
UIButton * toggleModeButton = delegate.toggleModeButton;
if (isSimple)
{
_isSimpleMode = YES;
tv.hidden = NO;
[toggleModeButton setTitle:L(@"editor_time_advanced") forState:UIControlStateNormal];
_sections = [NSMutableArray arrayWithCapacity:timeTableSet.Size()];
while (self.sections.count < timeTableSet.Size())
[self addSection];
[tv reloadData];
}
else
{
if (_isSimpleMode)
{
[self updateOpeningHours];
_isSimpleMode = NO;
}
tv.hidden = YES;
[toggleModeButton setTitle:L(@"editor_time_simple") forState:UIControlStateNormal];
MWMTextView * ev = delegate.editorView;
ev.text = delegate.openingHours;
[ev becomeFirstResponder];
}
}
- (BOOL)isSimpleModeCapable
{
NSString * oh = self.delegate.openingHours;
if (!oh || !oh.length)
return YES;
ui::TimeTableSet tts;
return MakeTimeTableSet(osmoh::OpeningHours(oh.UTF8String), tts);
}
@end

View file

@ -0,0 +1,59 @@
#import "MWMOpeningHoursEditorCells.h"
#include "editor/opening_hours_ui.hpp"
@class MWMOpeningHoursTableViewCell;
@protocol MWMOpeningHoursSectionProtocol <NSObject>
@property(nullable, weak, nonatomic, readonly) UITableView * tableView;
- (void)updateActiveSection:(NSUInteger)index;
- (editor::ui::TimeTableSet::Proxy)timeTableProxy:(NSUInteger)index;
- (void)deleteSchedule:(NSUInteger)index;
@end
@interface MWMOpeningHoursSection : NSObject
@property(nonatomic) BOOL allDay;
@property(nonatomic, readonly) NSUInteger index;
@property(nullable, nonatomic) NSNumber * selectedRow;
@property(nonatomic, readonly) NSUInteger numberOfRows;
@property(nullable, nonatomic) NSDateComponents * cachedStartTime;
@property(nullable, nonatomic) NSDateComponents * cachedEndTime;
@property(nonatomic, readonly) BOOL canAddClosedTime;
@property(nullable, weak, nonatomic, readonly) id<MWMOpeningHoursSectionProtocol> delegate;
- (instancetype _Nonnull)initWithDelegate:(id<MWMOpeningHoursSectionProtocol> _Nonnull)delegate;
- (void)refreshIndex:(NSUInteger)index;
- (MWMOpeningHoursEditorCells)cellKeyForRow:(NSUInteger)row;
- (CGFloat)heightForRow:(NSUInteger)row withWidth:(CGFloat)width;
- (NSDateComponents * _Nonnull)timeForRow:(NSUInteger)row isStart:(BOOL)isStart;
- (void)addSelectedDay:(osmoh::Weekday)day;
- (void)removeSelectedDay:(osmoh::Weekday)day;
- (BOOL)containsSelectedDay:(osmoh::Weekday)day;
- (void)addClosedTime;
- (void)removeClosedTime:(NSUInteger)row;
- (void)deleteSchedule;
- (void)refresh:(BOOL)force;
- (void)scrollIntoView;
- (void)storeCachedData;
- (BOOL)isRowSelected:(NSUInteger)row;
@end

View file

@ -0,0 +1,481 @@
#import "MWMOpeningHoursSection.h"
#import <CoreApi/MWMOpeningHoursCommon.h>
#import "MWMOpeningHoursTableViewCell.h"
#import "SwiftBridge.h"
extern NSDictionary * const kMWMOpeningHoursEditorTableCells;
extern UITableViewRowAnimation const kMWMOpeningHoursEditorRowAnimation;
@interface MWMOpeningHoursSection ()
@property (nonatomic, readonly) NSUInteger excludeTimeCount;
@property (nonatomic) BOOL skipStoreCachedData;
@property (nonatomic) BOOL removeBrokenExcludeTime;
@end
using namespace editor::ui;
using namespace osmoh;
@implementation MWMOpeningHoursSection
- (instancetype _Nonnull)initWithDelegate:(id<MWMOpeningHoursSectionProtocol> _Nonnull)delegate
{
self = [super init];
if (self)
{
_delegate = delegate;
_selectedRow = nil;
}
return self;
}
- (void)refreshIndex:(NSUInteger)index
{
_index = index;
}
#pragma mark - Rows
- (NSUInteger)firstRowForKey:(MWMOpeningHoursEditorCells)key
{
NSUInteger const numberOfRows = self.numberOfRows;
for (NSUInteger row = 0; row != numberOfRows; ++row)
{
if ([self cellKeyForRow:row] == key)
return row;
}
return numberOfRows;
}
- (MWMOpeningHoursEditorCells)cellKeyForRow:(NSUInteger)row
{
if (row == 0)
return MWMOpeningHoursEditorDaysSelectorCell;
if (row == 1)
return MWMOpeningHoursEditorAllDayCell;
NSUInteger const numberOfRows = self.numberOfRows;
BOOL const firstSection = (self.index == 0);
if (firstSection && row == numberOfRows - 1)
return MWMOpeningHoursEditorAddClosedCell;
else if (!firstSection && row == numberOfRows - 1)
return MWMOpeningHoursEditorDeleteScheduleCell;
else if (!firstSection && row == numberOfRows - 2)
return MWMOpeningHoursEditorAddClosedCell;
else if (row == 2)
return MWMOpeningHoursEditorTimeSpanCell;
if ([self.selectedRow isEqualToNumber:@(row - 1)])
return MWMOpeningHoursEditorTimeSelectorCell;
return MWMOpeningHoursEditorClosedSpanCell;
}
- (NSUInteger)numberOfRowsForAllDay:(BOOL)allDay
{
NSUInteger rowsCount = 2; // MWMOpeningHoursDaysSelectorTableViewCell, MWMOpeningHoursAllDayTableViewCell
if (!allDay)
{
rowsCount += 2; // MWMOpeningHoursTimeSpanTableViewCell, MWMOpeningHoursAddClosedTableViewCell
rowsCount += [self closedTimesCount]; // MWMOpeningHoursClosedSpanTableViewCell
if (self.selectedRow)
rowsCount++; // MWMOpeningHoursTimeSelectorTableViewCell
}
if (self.index != 0)
rowsCount++; // MWMOpeningHoursDeleteScheduleTableViewCell
return rowsCount;
}
- (CGFloat)heightForRow:(NSUInteger)row withWidth:(CGFloat)width
{
Class cls = kMWMOpeningHoursEditorTableCells[@([self cellKeyForRow:row])];
return [cls heightForWidth:width];
}
- (void)fillCell:(MWMOpeningHoursTableViewCell * _Nonnull)cell
{
cell.section = self;
}
#pragma mark - Row time
- (NSDateComponents * _Nonnull)timeForRow:(NSUInteger)row isStart:(BOOL)isStart
{
NSDateComponents * cachedTime = isStart ? self.cachedStartTime : self.cachedEndTime;
if (cachedTime && [self isRowSelected:row])
return cachedTime;
BOOL const isClosed = [self cellKeyForRow:row] != MWMOpeningHoursEditorTimeSpanCell;
auto tt = [self timeTableProxy];
NSUInteger const index = isClosed ? [self closedTimeIndex:row] : 0;
Timespan span = isClosed ? tt.GetExcludeTime()[index] : tt.GetOpeningTime();
return dateComponentsFromTime(isStart ? span.GetStart() : span.GetEnd());
}
- (void)setStartTime:(NSDateComponents *)startTime endTime:(NSDateComponents *)endTime isClosed:(BOOL)isClosed
{
if (!startTime && !endTime)
return;
auto tt = [self timeTableProxy];
NSUInteger const row = self.selectedRow.unsignedIntegerValue;
NSUInteger const index = isClosed ? [self closedTimeIndex:row] : 0;
Timespan span = isClosed ? tt.GetExcludeTime()[index] : tt.GetOpeningTime();
if (startTime)
{
HourMinutes startHM;
startHM.SetHours(HourMinutes::THours(startTime.hour));
startHM.SetMinutes(HourMinutes::TMinutes(startTime.minute));
span.SetStart(startHM);
}
if (endTime)
{
HourMinutes endHM;
endHM.SetHours(HourMinutes::THours(endTime.hour));
endHM.SetMinutes(HourMinutes::TMinutes(endTime.minute));
span.SetEnd(endHM);
}
NSUInteger const closedTimesCountBeforeUpdate = [self closedTimesCount];
if (isClosed)
{
if (!tt.ReplaceExcludeTime(span, index) && self.removeBrokenExcludeTime)
tt.RemoveExcludeTime(index);
}
else
{
tt.SetOpeningTime(span);
}
tt.Commit();
[self refresh:closedTimesCountBeforeUpdate != [self closedTimesCount]];
}
#pragma mark - Closed Time
- (NSUInteger)closedTimesCount
{
return [self timeTableProxy].GetExcludeTime().size();
}
- (NSUInteger)closedTimeIndex:(NSUInteger)row
{
NSUInteger indexShift = [self firstRowForKey:MWMOpeningHoursEditorTimeSpanCell] + 1;
if (self.selectedRow && self.selectedRow.unsignedIntegerValue + 1 < row)
indexShift++;
NSAssert(row >= indexShift, @"Invalid row index");
NSAssert(row - indexShift < [self closedTimesCount], @"Invalid row index");
return row - indexShift;
}
- (void)addClosedTime
{
self.removeBrokenExcludeTime = YES;
self.selectedRow = nil;
NSUInteger const row = [self firstRowForKey:MWMOpeningHoursEditorAddClosedCell];
auto timeTable = [self timeTableProxy];
NSUInteger const closedTimesCountBeforeUpdate = [self closedTimesCount];
Timespan timeSpan = timeTable.GetPredefinedExcludeTime();
timeTable.AddExcludeTime(timeSpan);
timeTable.Commit();
NSUInteger const closedTimesCountAfterUpdate = [self closedTimesCount];
if (closedTimesCountAfterUpdate < closedTimesCountBeforeUpdate)
{
[self refresh:YES];
return;
}
if (closedTimesCountAfterUpdate > closedTimesCountBeforeUpdate)
{
[self.delegate.tableView update:^{
[self insertRow:row];
self.selectedRow = @(row);
}];
}
[self refresh:NO];
}
- (void)removeClosedTime:(NSUInteger)row
{
NSUInteger const closedTimesCountBeforeUpdate = [self closedTimesCount];
self.skipStoreCachedData = [self isRowSelected:row];
if (closedTimesCountBeforeUpdate == [self closedTimesCount])
{
[self.delegate.tableView update:^{
auto timeTable = [self timeTableProxy];
timeTable.RemoveExcludeTime([self closedTimeIndex:row]);
timeTable.Commit();
self.selectedRow = nil;
[self deleteRow:row];
}];
}
[self refresh:NO];
}
#pragma mark - Selected days
- (void)addSelectedDay:(Weekday)day
{
auto timeTable = [self timeTableProxy];
auto openingDays(timeTable.GetOpeningDays());
openingDays.insert(day);
timeTable.SetOpeningDays(openingDays);
timeTable.Commit();
[self refresh:YES];
}
- (void)removeSelectedDay:(Weekday)day
{
auto timeTable = [self timeTableProxy];
auto openingDays(timeTable.GetOpeningDays());
openingDays.erase(day);
timeTable.SetOpeningDays(openingDays);
timeTable.Commit();
[self refresh:YES];
}
- (BOOL)containsSelectedDay:(Weekday)day
{
auto timeTable = [self timeTableProxy];
auto const & openingDays = timeTable.GetOpeningDays();
return openingDays.find(day) != openingDays.end();
}
#pragma mark - Table
- (void)refresh:(BOOL)force
{
UITableView * tableView = self.delegate.tableView;
if (force)
{
[tableView reloadData];
return;
}
for (MWMOpeningHoursTableViewCell * cell in tableView.visibleCells)
{
[cell refresh];
}
}
- (void)refreshForNewRowCount:(NSUInteger)newRowCount oldRowCount:(NSUInteger)oldRowCount
{
NSAssert(newRowCount != oldRowCount, @"Invalid rows change");
BOOL const addRows = newRowCount > oldRowCount;
NSUInteger const minRows = MIN(newRowCount, oldRowCount);
NSUInteger const maxRows = MAX(newRowCount, oldRowCount);
NSMutableArray<NSIndexPath *> * indexes = [NSMutableArray arrayWithCapacity:maxRows - minRows];
UITableView * tableView = self.delegate.tableView;
[tableView update:^{
for (NSUInteger row = minRows; row < maxRows; ++row)
[indexes addObject:[NSIndexPath indexPathForRow:row inSection:self.index]];
if (addRows)
[tableView insertRowsAtIndexPaths:indexes
withRowAnimation:kMWMOpeningHoursEditorRowAnimation];
else
[tableView deleteRowsAtIndexPaths:indexes
withRowAnimation:kMWMOpeningHoursEditorRowAnimation];
}];
[self refresh:NO];
}
- (void)insertRow:(NSUInteger)row
{
NSIndexPath * path = [NSIndexPath indexPathForRow:row inSection:self.index];
UITableView * tableView = self.delegate.tableView;
[tableView insertRowsAtIndexPaths:@[ path ] withRowAnimation:kMWMOpeningHoursEditorRowAnimation];
}
- (void)deleteRow:(NSUInteger)row
{
NSIndexPath * path = [NSIndexPath indexPathForRow:row inSection:self.index];
UITableView * tableView = self.delegate.tableView;
[tableView deleteRowsAtIndexPaths:@[ path ] withRowAnimation:kMWMOpeningHoursEditorRowAnimation];
}
#pragma mark - Model
- (TimeTableSet::Proxy)timeTableProxy
{
return [self.delegate timeTableProxy:self.index];
}
- (void)deleteSchedule
{
[self.delegate deleteSchedule:self.index];
}
#pragma mark - Selected row
- (void)setSelectedRow:(NSNumber *)selectedRow
{
if ((!_selectedRow && !selectedRow) || _selectedRow.unsignedIntegerValue == selectedRow.unsignedIntegerValue)
return;
NSUInteger const closedTimesCountBeforeUpdate = [self closedTimesCount];
[self storeCachedData];
if (closedTimesCountBeforeUpdate != [self closedTimesCount])
{
_selectedRow = nil;
[self refresh:YES];
return;
}
NSNumber * oldSelectedRow = _selectedRow;
NSUInteger const newInd = selectedRow.unsignedIntegerValue;
NSUInteger const oldInd = oldSelectedRow.unsignedIntegerValue;
id<MWMOpeningHoursSectionProtocol> delegate = self.delegate;
UITableView * tableView = delegate.tableView;
[tableView update:^{
if (!oldSelectedRow)
{
self->_selectedRow = selectedRow;
[self insertRow:newInd + 1];
[delegate updateActiveSection:self.index];
}
else if (selectedRow)
{
if (newInd < oldInd)
{
self->_selectedRow = selectedRow;
[self insertRow:newInd + 1];
}
else
{
self->_selectedRow = @(newInd - 1);
[self insertRow:newInd];
}
[self deleteRow:oldInd + 1];
}
else
{
self->_selectedRow = selectedRow;
[self deleteRow:oldInd + 1];
}
}];
[self scrollToSelection];
}
- (BOOL)isRowSelected:(NSUInteger)row
{
return self.selectedRow && self.selectedRow.unsignedIntegerValue == row;
}
- (void)storeCachedData
{
if (!self.selectedRow)
return;
if (!self.skipStoreCachedData)
{
switch ([self cellKeyForRow:self.selectedRow.unsignedIntegerValue])
{
case MWMOpeningHoursEditorTimeSpanCell:
[self setStartTime:self.cachedStartTime endTime:self.cachedEndTime isClosed:NO];
break;
case MWMOpeningHoursEditorClosedSpanCell:
[self setStartTime:self.cachedStartTime endTime:self.cachedEndTime isClosed:YES];
break;
default:
NSAssert(false, @"Invalid case");
break;
}
}
self.cachedStartTime = nil;
self.cachedEndTime = nil;
self.skipStoreCachedData = NO;
self.removeBrokenExcludeTime = NO;
}
#pragma mark - Scrolling
- (void)scrollIntoView
{
dispatch_async(dispatch_get_main_queue(), ^
{
UITableView * tableView = self.delegate.tableView;
NSUInteger const lastRow = self.numberOfRows - 1;
NSIndexPath * path = [NSIndexPath indexPathForRow:lastRow inSection:self.index];
[tableView scrollToRowAtIndexPath:path
atScrollPosition:UITableViewScrollPositionNone
animated:YES];
});
}
- (void)scrollToSelection
{
dispatch_async(dispatch_get_main_queue(), ^
{
if (!self.selectedRow)
return;
UITableView * tableView = self.delegate.tableView;
NSUInteger const timeSelectorRow = self.selectedRow.unsignedIntegerValue + 1;
NSIndexPath * path = [NSIndexPath indexPathForRow:timeSelectorRow inSection:self.index];
[tableView scrollToRowAtIndexPath:path
atScrollPosition:UITableViewScrollPositionNone
animated:YES];
});
}
#pragma mark - Properties
- (BOOL)allDay
{
return [self timeTableProxy].IsTwentyFourHours();
}
- (void)setAllDay:(BOOL)allDay
{
BOOL const currentAllDay = self.allDay;
if (currentAllDay == allDay)
return;
self.selectedRow = nil;
NSUInteger const deleteScheduleCellShift = self.index != 0 ? 1 : 0;
NSUInteger const oldRowCount = [self numberOfRowsForAllDay:currentAllDay] - deleteScheduleCellShift;
NSUInteger const newRowCount = [self numberOfRowsForAllDay:allDay] - deleteScheduleCellShift;
auto timeTable = [self timeTableProxy];
timeTable.SetTwentyFourHours(allDay);
timeTable.Commit();
[self refreshForNewRowCount:newRowCount oldRowCount:oldRowCount];
[self scrollIntoView];
}
- (NSUInteger)numberOfRows
{
return [self numberOfRowsForAllDay:self.allDay];
}
- (void)setCachedStartTime:(NSDateComponents *)cachedStartTime
{
_cachedStartTime = cachedStartTime;
if (cachedStartTime)
[self refresh:NO];
}
- (void)setCachedEndTime:(NSDateComponents *)cachedEndTime
{
_cachedEndTime = cachedEndTime;
if (cachedEndTime)
[self refresh:NO];
}
- (BOOL)canAddClosedTime
{
return [self timeTableProxy].CanAddExcludeTime();
}
@end

View file

@ -0,0 +1,13 @@
#import "MWMTableViewCell.h"
@protocol MWMStreetEditorEditCellProtocol <NSObject>
- (void)editCellTextChanged:(NSString *)text;
@end
@interface MWMStreetEditorEditTableViewCell : MWMTableViewCell
- (void)configWithDelegate:(id<MWMStreetEditorEditCellProtocol>)delegate street:(NSString *)street;
@end

View file

@ -0,0 +1,33 @@
#import "MWMStreetEditorEditTableViewCell.h"
@interface MWMStreetEditorEditTableViewCell ()
@property (weak, nonatomic) IBOutlet UITextField * textField;
@property (weak, nonatomic) id<MWMStreetEditorEditCellProtocol> delegate;
@end
@implementation MWMStreetEditorEditTableViewCell
- (void)configWithDelegate:(id<MWMStreetEditorEditCellProtocol>)delegate street:(NSString *)street
{
self.delegate = delegate;
self.textField.text = street;
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(textDidChange:)
name:UITextFieldTextDidChangeNotification
object:self.textField];
}
- (void)dealloc
{
[[NSNotificationCenter defaultCenter] removeObserver:self];
}
- (void)textDidChange:(NSNotification*)notification
{
UITextField * textField = (UITextField *)[notification object];
[self.delegate editCellTextChanged:textField.text];
}
@end

View file

@ -0,0 +1,54 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="19529" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES">
<device id="retina6_1" orientation="portrait" appearance="light"/>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="19519"/>
<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" id="KGk-i7-Jjw" customClass="MWMStreetEditorEditTableViewCell">
<rect key="frame" x="0.0" y="0.0" width="320" height="44"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="KGk-i7-Jjw" id="H2p-sc-9uM">
<rect key="frame" x="0.0" y="0.0" width="320" height="44"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<textField opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" textAlignment="natural" minimumFontSize="17" clearButtonMode="whileEditing" translatesAutoresizingMaskIntoConstraints="NO" id="8Pj-WT-J59">
<rect key="frame" x="16" y="12" width="288" height="20"/>
<constraints>
<constraint firstAttribute="height" relation="greaterThanOrEqual" priority="750" constant="44" id="bRV-YH-9xE"/>
</constraints>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<textInputTraits key="textInputTraits"/>
<userDefinedRuntimeAttributes>
<userDefinedRuntimeAttribute type="string" keyPath="styleName" value="regular17:blackPrimaryText"/>
<userDefinedRuntimeAttribute type="string" keyPath="localizedPlaceholder" value="add_street"/>
</userDefinedRuntimeAttributes>
<connections>
<outlet property="delegate" destination="KGk-i7-Jjw" id="r4r-Wy-T2m"/>
</connections>
</textField>
</subviews>
<constraints>
<constraint firstAttribute="trailing" secondItem="8Pj-WT-J59" secondAttribute="trailing" constant="16" id="R0z-r6-X9f"/>
<constraint firstAttribute="bottom" secondItem="8Pj-WT-J59" secondAttribute="bottom" constant="12" id="XDU-Xd-7Pl"/>
<constraint firstItem="8Pj-WT-J59" firstAttribute="leading" secondItem="H2p-sc-9uM" secondAttribute="leading" constant="16" id="fWv-z1-q0b"/>
<constraint firstItem="8Pj-WT-J59" firstAttribute="top" secondItem="H2p-sc-9uM" secondAttribute="top" constant="12" id="wRV-57-6CZ"/>
</constraints>
<userDefinedRuntimeAttributes>
<userDefinedRuntimeAttribute type="string" keyPath="styleName" value="Background"/>
</userDefinedRuntimeAttributes>
</tableViewCellContentView>
<userDefinedRuntimeAttributes>
<userDefinedRuntimeAttribute type="string" keyPath="styleName" value="Background"/>
</userDefinedRuntimeAttributes>
<connections>
<outlet property="textField" destination="8Pj-WT-J59" id="lqN-IV-C5E"/>
</connections>
<point key="canvasLocation" x="139" y="154"/>
</tableViewCell>
</objects>
</document>

View file

@ -0,0 +1,19 @@
#import "MWMTableViewController.h"
#include "indexer/editable_map_object.hpp"
#include <vector>
@protocol MWMStreetEditorProtocol <NSObject>
- (osm::LocalizedStreet const &)currentStreet;
- (void)setNearbyStreet:(osm::LocalizedStreet const &)street;
- (std::vector<osm::LocalizedStreet> const &)nearbyStreets;
@end
@interface MWMStreetEditorViewController : MWMTableViewController
@property (weak, nonatomic) id<MWMStreetEditorProtocol> delegate;
@end

View file

@ -0,0 +1,198 @@
#import "MWMStreetEditorViewController.h"
#import "MWMStreetEditorEditTableViewCell.h"
#import "SwiftBridge.h"
@interface MWMStreetEditorViewController () <MWMStreetEditorEditCellProtocol>
{
std::vector<osm::LocalizedStreet> m_streets;
std::string m_editedStreetName;
}
@property (nonatomic) NSUInteger selectedStreet;
@property (nonatomic) NSUInteger lastSelectedStreet;
@end
@implementation MWMStreetEditorViewController
- (void)viewDidLoad
{
[super viewDidLoad];
[self configNavBar];
[self configData];
[self configTable];
}
#pragma mark - Configuration
- (void)configNavBar
{
self.title = L(@"choose_street");
self.navigationItem.leftBarButtonItem =
[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCancel
target:self
action:@selector(onCancel)];
self.navigationItem.rightBarButtonItem =
[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemDone
target:self
action:@selector(onDone)];
self.navigationController.navigationBar.barStyle = UIBarStyleBlack;
}
- (void)configData
{
id<MWMStreetEditorProtocol> delegate = self.delegate;
m_streets = delegate.nearbyStreets;
auto const & currentStreet = delegate.currentStreet;
BOOL const haveCurrentStreet = !currentStreet.m_defaultName.empty();
if (haveCurrentStreet)
{
auto const it = find(m_streets.begin(), m_streets.end(), currentStreet);
if (it == m_streets.end())
{
m_streets.insert(m_streets.begin(), currentStreet);
self.selectedStreet = 0;
}
else
{
self.selectedStreet = distance(m_streets.begin(), it);
}
}
else
{
self.selectedStreet = NSNotFound;
}
self.navigationItem.rightBarButtonItem.enabled = haveCurrentStreet;
self.lastSelectedStreet = NSNotFound;
m_editedStreetName = "";
}
- (void)configTable
{
UITableView * tv = self.tableView;
[tv registerNibWithCellClass:[MWMStreetEditorEditTableViewCell class]];
}
#pragma mark - Actions
- (void)onCancel
{
[self.navigationController popViewControllerAnimated:YES];
}
- (void)onDone
{
id<MWMStreetEditorProtocol> delegate = self.delegate;
if (self.selectedStreet == NSNotFound)
[delegate setNearbyStreet:{m_editedStreetName, ""}];
else
[delegate setNearbyStreet:m_streets[self.selectedStreet]];
[self onCancel];
}
- (void)fillCell:(UITableViewCell *)cell indexPath:(NSIndexPath *)indexPath
{
if ([cell isKindOfClass:[MWMStreetEditorEditTableViewCell class]])
{
MWMStreetEditorEditTableViewCell * tCell = (MWMStreetEditorEditTableViewCell *)cell;
[tCell configWithDelegate:self street:@(m_editedStreetName.c_str())];
}
else
{
NSUInteger const index = indexPath.row;
auto const & localizedStreet = m_streets[index];
NSString * street = @(localizedStreet.m_defaultName.c_str());
BOOL const selected = (self.selectedStreet == index);
cell.textLabel.text = street;
cell.detailTextLabel.text = @(localizedStreet.m_localizedName.c_str());
cell.accessoryType = selected ? UITableViewCellAccessoryCheckmark : UITableViewCellAccessoryNone;
}
}
#pragma mark - MWMStreetEditorEditCellProtocol
- (void)editCellTextChanged:(NSString *)text
{
if (text && text.length != 0)
{
self.navigationItem.rightBarButtonItem.enabled = YES;
m_editedStreetName = text.UTF8String;
if (self.selectedStreet != NSNotFound)
{
self.lastSelectedStreet = self.selectedStreet;
self.selectedStreet = NSNotFound;
}
}
else
{
self.selectedStreet = self.lastSelectedStreet;
self.navigationItem.rightBarButtonItem.enabled = (self.selectedStreet != NSNotFound);
}
for (UITableViewCell * cell in self.tableView.visibleCells)
{
if ([cell isKindOfClass:[MWMStreetEditorEditTableViewCell class]])
continue;
NSIndexPath * indexPath = [self.tableView indexPathForCell:cell];
[self fillCell:cell indexPath:indexPath];
}
}
#pragma mark - UITableViewDataSource
- (UITableViewCell * _Nonnull)tableView:(UITableView * _Nonnull)tableView cellForRowAtIndexPath:(NSIndexPath * _Nonnull)indexPath
{
UITableViewCell * cell = nil;
if (m_streets.empty())
{
cell = [tableView dequeueReusableCellWithCellClass:[MWMStreetEditorEditTableViewCell class]
indexPath:indexPath];
}
else
{
if (indexPath.section == 0)
{
Class cls = m_streets[indexPath.row].m_localizedName.empty()
? [UITableViewCell class]
: [MWMTableViewSubtitleCell class];
cell = [tableView dequeueReusableCellWithCellClass:cls indexPath:indexPath];
}
else
{
cell = [tableView dequeueReusableCellWithCellClass:[MWMStreetEditorEditTableViewCell class]
indexPath:indexPath];
}
}
[self fillCell:cell indexPath:indexPath];
return cell;
}
- (NSInteger)tableView:(UITableView * _Nonnull)tableView numberOfRowsInSection:(NSInteger)section
{
auto const count = m_streets.size();
if ((section == 0 && count == 0) || section != 0)
return 1;
return count;
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return m_streets.empty()? 1 : 2;
}
#pragma mark - UITableViewDelegate
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell * cell = [tableView cellForRowAtIndexPath:indexPath];
if ([cell isKindOfClass:[MWMStreetEditorEditTableViewCell class]])
return;
self.selectedStreet = indexPath.row;
[self onDone];
}
@end