[ios] Added editable fields support.

This commit is contained in:
Илья Гречухин 2015-12-30 13:34:58 +03:00 committed by Sergey Yershov
parent 70c61b34ec
commit 41480a567a
16 changed files with 157 additions and 112 deletions

View file

@ -62,27 +62,35 @@ WeekDayView getWeekDayView()
WeekDayView cd = self.currentDay;
cd.currentDay = YES;
osmoh::OpeningHours oh(info.UTF8String);
if (MakeTimeTableSet(oh, timeTableSet))
if (info)
{
cd.isCompatibility = NO;
self.isClosed = oh.IsClosed(time(nullptr));
[self processSchedule];
osmoh::OpeningHours oh(info.UTF8String);
if (MakeTimeTableSet(oh, timeTableSet))
{
cd.mode = MWMPlacePageOpeningHoursDayViewModeRegular;
self.isClosed = oh.IsClosed(time(nullptr));
[self processSchedule];
BOOL const isExpanded = delegate.openingHoursCellExpanded;
self.middleSeparator.hidden = !isExpanded;
self.weekDaysView.hidden = !isExpanded;
self.editButton.hidden = !isExpanded;
self.expandImage.image = [UIImage imageNamed:isExpanded ? @"ic_arrow_gray_up" : @"ic_arrow_gray_down"];
BOOL const isExpanded = delegate.openingHoursCellExpanded;
self.middleSeparator.hidden = !isExpanded;
self.weekDaysView.hidden = !isExpanded;
self.editButton.hidden = !isExpanded;
self.expandImage.image = [UIImage imageNamed:isExpanded ? @"ic_arrow_gray_up" : @"ic_arrow_gray_down"];
[cd invalidate];
return;
}
cd.mode = MWMPlacePageOpeningHoursDayViewModeCompatibility;
[cd setCompatibilityText:info];
}
else
{
cd.isCompatibility = YES;
[cd setCompatibilityText:info];
self.middleSeparator.hidden = YES;
self.weekDaysView.hidden = YES;
self.editButton.hidden = YES;
cd.mode = MWMPlacePageOpeningHoursDayViewModeEmpty;
}
self.middleSeparator.hidden = YES;
self.weekDaysView.hidden = YES;
self.editButton.hidden = YES;
self.expandImage.hidden = YES;
[cd invalidate];
}
@ -185,7 +193,8 @@ WeekDayView getWeekDayView()
- (CGFloat)cellHeight
{
CGFloat height = self.currentDay.viewHeight;
if (!self.currentDay.isCompatibility && self.delegate.openingHoursCellExpanded)
BOOL const isRegular = (self.currentDay.mode == MWMPlacePageOpeningHoursDayViewModeRegular);
if (isRegular && self.delegate.openingHoursCellExpanded)
height += self.weekDaysViewHeight.constant + self.editButton.height;
return ceil(height);
}
@ -194,10 +203,18 @@ WeekDayView getWeekDayView()
- (IBAction)toggleButtonTap
{
if (self.currentDay.isCompatibility)
return;
[self.delegate setOpeningHoursCellExpanded:!self.delegate.openingHoursCellExpanded forCell:self];
switch (self.currentDay.mode) {
case MWMPlacePageOpeningHoursDayViewModeRegular:
[self.delegate setOpeningHoursCellExpanded:!self.delegate.openingHoursCellExpanded forCell:self];
break;
case MWMPlacePageOpeningHoursDayViewModeCompatibility:
break;
case MWMPlacePageOpeningHoursDayViewModeEmpty:
[self editButtonTap];
break;
}
}
- (IBAction)editButtonTap
{
[[Statistics instance] logEvent:kStatEventName(kStatPlacePage, kStatEditTime)];

View file

@ -11,19 +11,19 @@
<rect key="frame" x="0.0" y="0.0" width="320" height="292"/>
<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="292"/>
<rect key="frame" x="0.0" y="0.0" width="320" height="291.5"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="swk-um-XzG" customClass="MWMPlacePageOpeningHoursDayView">
<rect key="frame" x="0.0" y="0.0" width="320" height="126"/>
<subviews>
<label hidden="YES" opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Mo-Su 11:00-24:00" textAlignment="natural" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" preferredMaxLayoutWidth="228" translatesAutoresizingMaskIntoConstraints="NO" id="ZdV-4y-cz4">
<label hidden="YES" opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" misplaced="YES" text="Mo-Su 11:00-24:00" textAlignment="natural" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" preferredMaxLayoutWidth="228" translatesAutoresizingMaskIntoConstraints="NO" id="ZdV-4y-cz4">
<rect key="frame" x="60" y="53" width="228" height="21"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<fontDescription key="fontDescription" name="HelveticaNeue" family="Helvetica Neue" pointSize="16"/>
<color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="calibratedRGB"/>
<nil key="highlightedColor"/>
<userDefinedRuntimeAttributes>
<userDefinedRuntimeAttribute type="string" keyPath="fontName" value="regular17"/>
<userDefinedRuntimeAttribute type="string" keyPath="fontName" value="regular16"/>
<userDefinedRuntimeAttribute type="string" keyPath="colorName" value="blackPrimaryText"/>
</userDefinedRuntimeAttributes>
</label>
@ -33,24 +33,24 @@
<constraint firstAttribute="width" constant="68" id="5G1-mL-J4T"/>
<constraint firstAttribute="height" constant="20" id="Uo2-AE-U2v"/>
</constraints>
<fontDescription key="fontDescription" name="HelveticaNeue" family="Helvetica Neue" pointSize="17"/>
<fontDescription key="fontDescription" name="HelveticaNeue" family="Helvetica Neue" pointSize="16"/>
<color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="calibratedRGB"/>
<nil key="highlightedColor"/>
<userDefinedRuntimeAttributes>
<userDefinedRuntimeAttribute type="string" keyPath="fontName" value="regular17"/>
<userDefinedRuntimeAttribute type="string" keyPath="fontName" value="regular16"/>
</userDefinedRuntimeAttributes>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="10:00—20:00" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" preferredMaxLayoutWidth="180" translatesAutoresizingMaskIntoConstraints="NO" id="oTF-IZ-Un1">
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" misplaced="YES" text="10:00—20:00" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" preferredMaxLayoutWidth="140" translatesAutoresizingMaskIntoConstraints="NO" id="oTF-IZ-Un1">
<rect key="frame" x="166" y="12" width="140" height="20"/>
<constraints>
<constraint firstAttribute="width" relation="greaterThanOrEqual" constant="140" id="up3-Kv-Z1P"/>
</constraints>
<fontDescription key="fontDescription" name="HelveticaNeue" family="Helvetica Neue" pointSize="17"/>
<fontDescription key="fontDescription" name="HelveticaNeue" family="Helvetica Neue" pointSize="16"/>
<color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="calibratedRGB"/>
<nil key="highlightedColor"/>
<userDefinedRuntimeAttributes>
<userDefinedRuntimeAttribute type="string" keyPath="colorName" value="blackPrimaryText"/>
<userDefinedRuntimeAttribute type="string" keyPath="fontName" value="regular17"/>
<userDefinedRuntimeAttribute type="string" keyPath="fontName" value="regular16"/>
</userDefinedRuntimeAttributes>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Перерыв" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" preferredMaxLayoutWidth="94" translatesAutoresizingMaskIntoConstraints="NO" id="hpw-oR-ZSb">
@ -66,7 +66,7 @@
<userDefinedRuntimeAttribute type="string" keyPath="fontName" value="regular14"/>
</userDefinedRuntimeAttributes>
</label>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="7Oa-hg-icC">
<view contentMode="scaleToFill" misplaced="YES" translatesAutoresizingMaskIntoConstraints="NO" id="7Oa-hg-icC">
<rect key="frame" x="166" y="36" width="140" height="58"/>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
<constraints>
@ -115,13 +115,13 @@
<constraint firstAttribute="trailing" secondItem="3Fa-V6-tC5" secondAttribute="trailing" id="7pT-0E-9ir"/>
<constraint firstItem="oTF-IZ-Un1" firstAttribute="top" secondItem="swk-um-XzG" secondAttribute="top" constant="12" id="93j-yG-wF2"/>
<constraint firstItem="hpw-oR-ZSb" firstAttribute="top" secondItem="Ot5-QJ-jhp" secondAttribute="bottom" constant="4" id="9GL-pC-tse"/>
<constraint firstItem="oTF-IZ-Un1" firstAttribute="leading" relation="greaterThanOrEqual" secondItem="Ot5-QJ-jhp" secondAttribute="trailing" constant="12" id="9QL-6i-a0L"/>
<constraint firstItem="oTF-IZ-Un1" firstAttribute="leading" relation="greaterThanOrEqual" secondItem="Ot5-QJ-jhp" secondAttribute="trailing" constant="8" id="9QL-6i-a0L"/>
<constraint firstItem="EcD-Q8-7zu" firstAttribute="leading" secondItem="swk-um-XzG" secondAttribute="leading" constant="60" id="Bhv-rl-AUe"/>
<constraint firstAttribute="trailing" secondItem="mGc-k4-uvQ" secondAttribute="trailing" constant="8" id="CS2-Y7-odx"/>
<constraint firstItem="pa0-fe-w8W" firstAttribute="centerY" secondItem="swk-um-XzG" secondAttribute="centerY" id="CXB-0i-wxj"/>
<constraint firstItem="mGc-k4-uvQ" firstAttribute="centerY" secondItem="swk-um-XzG" secondAttribute="centerY" id="DQP-gP-Lv1"/>
<constraint firstItem="pa0-fe-w8W" firstAttribute="leading" secondItem="swk-um-XzG" secondAttribute="leading" constant="16" id="Dgv-BZ-60x"/>
<constraint firstItem="oTF-IZ-Un1" firstAttribute="leading" secondItem="swk-um-XzG" secondAttribute="leading" priority="750" constant="60" id="KGY-T0-s0P"/>
<constraint firstItem="oTF-IZ-Un1" firstAttribute="leading" secondItem="swk-um-XzG" secondAttribute="leading" priority="750" constant="48" id="KGY-T0-s0P"/>
<constraint firstItem="3Fa-V6-tC5" firstAttribute="leading" secondItem="swk-um-XzG" secondAttribute="leading" id="LUO-vn-JQ8"/>
<constraint firstItem="7Oa-hg-icC" firstAttribute="leading" secondItem="oTF-IZ-Un1" secondAttribute="leading" id="RBf-8S-CYY"/>
<constraint firstItem="7Oa-hg-icC" firstAttribute="top" secondItem="oTF-IZ-Un1" secondAttribute="bottom" constant="4" id="Urv-Lw-rBo"/>

View file

@ -1,8 +1,15 @@
typedef NS_ENUM(NSUInteger, MWMPlacePageOpeningHoursDayViewMode)
{
MWMPlacePageOpeningHoursDayViewModeRegular,
MWMPlacePageOpeningHoursDayViewModeCompatibility,
MWMPlacePageOpeningHoursDayViewModeEmpty
};
@interface MWMPlacePageOpeningHoursDayView : UIView
@property (nonatomic) BOOL currentDay;
@property (nonatomic) CGFloat viewHeight;
@property (nonatomic) BOOL isCompatibility;
@property (nonatomic) MWMPlacePageOpeningHoursDayViewMode mode;
- (void)setLabelText:(NSString *)text isRed:(BOOL)isRed;
- (void)setOpenTimeText:(NSString *)text;

View file

@ -90,13 +90,8 @@
- (void)invalidate
{
CGFloat viewHeight;
if (self.isCompatibility)
{
[self.compatibilityLabel sizeToIntegralFit];
CGFloat const compatibilityLabelVerticalOffsets = 24.0;
viewHeight = self.compatibilityLabel.height + compatibilityLabelVerticalOffsets;
}
else
BOOL const isRegular = (self.mode == MWMPlacePageOpeningHoursDayViewModeRegular);
if (isRegular)
{
[self.label sizeToIntegralFit];
self.labelWidth.constant = self.label.width;
@ -112,6 +107,12 @@
if (!self.closedLabel.hidden)
viewHeight += heightForClosedLabel;
}
else
{
[self.compatibilityLabel sizeToIntegralFit];
CGFloat const compatibilityLabelVerticalOffsets = 24.0;
viewHeight = self.compatibilityLabel.height + compatibilityLabelVerticalOffsets;
}
self.viewHeight = ceil(viewHeight);
@ -136,16 +137,20 @@
}
}
- (void)setIsCompatibility:(BOOL)isCompatibility
- (void)setMode:(MWMPlacePageOpeningHoursDayViewMode)mode
{
_isCompatibility = isCompatibility;
self.compatibilityLabel.hidden = !isCompatibility;
self.label.hidden = isCompatibility;
self.openTime.hidden = isCompatibility;
self.breakLabel.hidden = isCompatibility;
self.breaksHolder.hidden = isCompatibility;
self.closedLabel.hidden = isCompatibility;
self.expandImage.hidden = isCompatibility;
_mode = mode;
BOOL const isRegular = (mode == MWMPlacePageOpeningHoursDayViewModeRegular);
self.compatibilityLabel.hidden = isRegular;
self.label.hidden = !isRegular;
self.openTime.hidden = !isRegular;
self.breakLabel.hidden = !isRegular;
self.breaksHolder.hidden = !isRegular;
self.closedLabel.hidden = !isRegular;
self.expandImage.hidden = !isRegular;
if (mode == MWMPlacePageOpeningHoursDayViewModeEmpty)
self.compatibilityLabel.text = L(@"add_opening_hours");
}
@end

View file

@ -18,7 +18,7 @@
<constraint firstAttribute="height" constant="16" id="nkp-xj-OH6"/>
</constraints>
<fontDescription key="fontDescription" name="HelveticaNeue" family="Helvetica Neue" pointSize="14"/>
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
<color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="calibratedRGB"/>
<nil key="highlightedColor"/>
<userDefinedRuntimeAttributes>
<userDefinedRuntimeAttribute type="string" keyPath="colorName" value="blackSecondaryText"/>
@ -31,7 +31,7 @@
<constraint firstAttribute="width" relation="greaterThanOrEqual" constant="180" id="HSs-ZO-QYt"/>
</constraints>
<fontDescription key="fontDescription" name="HelveticaNeue" family="Helvetica Neue" pointSize="13"/>
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
<color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="calibratedRGB"/>
<nil key="highlightedColor"/>
<userDefinedRuntimeAttributes>
<userDefinedRuntimeAttribute type="string" keyPath="colorName" value="blackSecondaryText"/>
@ -44,7 +44,7 @@
<constraint firstAttribute="width" constant="68" id="zcl-0l-OMI"/>
</constraints>
<fontDescription key="fontDescription" name="HelveticaNeue" family="Helvetica Neue" pointSize="12"/>
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
<color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="calibratedRGB"/>
<nil key="highlightedColor"/>
<userDefinedRuntimeAttributes>
<userDefinedRuntimeAttribute type="string" keyPath="colorName" value="blackSecondaryText"/>

View file

@ -1,8 +1,10 @@
#import "MWMAuthorizationCommon.h"
#import "MWMOpeningHoursAddScheduleTableViewCell.h"
#import "MWMOpeningHoursEditorViewController.h"
#import "MWMOpeningHoursModel.h"
#import "MWMOpeningHoursSection.h"
#import "MWMTextView.h"
#import "Statistics.h"
extern NSDictionary * const kMWMOpeningHoursEditorTableCells = @{
@(MWMOpeningHoursEditorDaysSelectorCell) : @"MWMOpeningHoursDaysSelectorTableViewCell",
@ -42,12 +44,26 @@ extern NSDictionary * const kMWMOpeningHoursEditorTableCells = @{
- (void)viewDidLoad
{
[super viewDidLoad];
[self checkAuthorization];
[self configNavBar];
[self configTable];
[self configAdvancedEditor];
[self configData];
}
- (void)checkAuthorization
{
NSUserDefaults * ud = [NSUserDefaults standardUserDefaults];
NSString * username = [ud stringForKey:kOSMUsernameKey];
NSString * password = [ud stringForKey:kOSMPasswordKey];
if (!username || !password)
{
[[Statistics instance] logEvent:kStatEventName(kStatPlacePage, kStatEditTime)
withParameters:@{kStatValue : kStatAuthorization}];
[self performSegueWithIdentifier:@"OpeningHoursEditor2Authorization" sender:nil];
}
}
#pragma mark - Configuration
- (void)configNavBar

View file

@ -163,7 +163,10 @@ using namespace osmoh;
return;
_isSimpleMode = isSimpleMode;
id<MWMOpeningHoursModelProtocol> delegate = self.delegate;
if (isSimpleMode && MakeTimeTableSet(osmoh::OpeningHours(delegate.openingHours.UTF8String), timeTableSet))
NSString * oh = delegate.openingHours;
BOOL const isSimpleCapable =
oh ? MakeTimeTableSet(osmoh::OpeningHours(oh.UTF8String), timeTableSet) : YES;
if (isSimpleMode && isSimpleCapable)
{
delegate.tableView.hidden = NO;
delegate.advancedEditor.hidden = YES;
@ -187,6 +190,9 @@ using namespace osmoh;
- (BOOL)isSimpleModeCapable
{
NSString * oh = self.delegate.openingHours;
if (!oh)
return YES;
ui::TimeTableSet tts;
return MakeTimeTableSet(osmoh::OpeningHours(self.delegate.openingHours.UTF8String), tts);
}

View file

@ -270,7 +270,7 @@ extern CGFloat const kBasePlacePageViewTitleBottomOffset = 2.;
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
MWMPlacePageEntity * entity = self.entity;
MWMPlacePageMetadataType const currentType = [entity getType:indexPath.row];
MWMPlacePageMetadataType const currentType = [entity getFeatureType:indexPath.row];
if (currentType == MWMPlacePageMetadataTypeBookmark)
{
[self.bookmarkSizingCell config:self.ownerPlacePage forHeight:YES];
@ -278,7 +278,7 @@ extern CGFloat const kBasePlacePageViewTitleBottomOffset = 2.;
}
else if (currentType == MWMPlacePageMetadataTypeOpenHours)
{
[self.openingHoursSizingCell configWithInfo:[entity getValue:currentType] delegate:self];
[self.openingHoursSizingCell configWithInfo:[entity getFeatureValue:currentType] delegate:self];
return self.openingHoursSizingCell.cellHeight;
}
else if (currentType == MWMPlacePageMetadataTypeEditButton)
@ -292,7 +292,7 @@ extern CGFloat const kBasePlacePageViewTitleBottomOffset = 2.;
CGFloat const rightOffset = 22.;
UILabel * label = [[UILabel alloc] initWithFrame:CGRectMake(0., 0., defaultWidth - leftOffset - rightOffset, 10.)];
label.numberOfLines = 0;
label.text = [entity getValue:currentType];
label.text = [entity getFeatureValue:currentType];
[label sizeToFit];
CGFloat const defaultCellOffset = 24.;
return MAX(label.height + defaultCellOffset, defaultCellHeight);
@ -300,13 +300,13 @@ extern CGFloat const kBasePlacePageViewTitleBottomOffset = 2.;
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return [self.entity getTypesCount];
return [self.entity getFeatureTypesCount];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
MWMPlacePageEntity * entity = self.entity;
MWMPlacePageMetadataType const currentType = [entity getType:indexPath.row];
MWMPlacePageMetadataType const currentType = [entity getFeatureType:indexPath.row];
if (currentType == MWMPlacePageMetadataTypeBookmark)
{
MWMPlacePageBookmarkCell * cell = (MWMPlacePageBookmarkCell *)[tableView dequeueReusableCellWithIdentifier:kPlacePageBookmarkCellIdentifier];
@ -318,7 +318,7 @@ extern CGFloat const kBasePlacePageViewTitleBottomOffset = 2.;
{
MWMPlacePageOpeningHoursCell * cell = (MWMPlacePageOpeningHoursCell *)
[tableView dequeueReusableCellWithIdentifier:kPlacePageOpeningHoursCellIdentifier];
[cell configWithInfo:[entity getValue:currentType] delegate:self];
[cell configWithInfo:[entity getFeatureValue:currentType] delegate:self];
return cell;
}
else if (currentType == MWMPlacePageMetadataTypeEditButton)
@ -334,7 +334,7 @@ extern CGFloat const kBasePlacePageViewTitleBottomOffset = 2.;
MWMPlacePageInfoCell * cell = (MWMPlacePageInfoCell *)[tableView dequeueReusableCellWithIdentifier:cellIdentifier];
cell.currentEntity = self.entity;
[cell configureWithType:currentType info:[entity getValue:currentType]];
[cell configureWithType:currentType info:[entity getFeatureValue:currentType]];
return cell;
}

View file

@ -58,8 +58,8 @@ typedef NS_ENUM (NSUInteger, MWMPlacePageEntityType)
- (void)toggleCoordinateSystem;
- (NSUInteger)getTypesCount;
- (MWMPlacePageMetadataType)getType:(NSUInteger)index;
- (NSString *)getValue:(MWMPlacePageMetadataType)type;
- (NSUInteger)getFeatureTypesCount;
- (MWMPlacePageMetadataType)getFeatureType:(NSUInteger)index;
- (NSString *)getFeatureValue:(MWMPlacePageMetadataType)type;
@end

View file

@ -1,7 +1,9 @@
#import "MWMPlacePageEntity.h"
#import "MWMPlacePageViewManager.h"
#import "MapViewController.h"
#include "platform/measurement_utils.hpp"
#include "indexer/osm_editor.hpp"
using feature::Metadata;
@ -61,6 +63,18 @@ static map<Metadata::EType, MWMPlacePageMetadataType> const kMetaTypesMap{
[self configureForBookmark:mark];
break;
}
[self addEditableTypes];
[self sortMeta];
}
- (void)sortMeta
{
auto begin = kPatternTypesArray.begin();
auto end = kPatternTypesArray.end();
sort(m_types.begin(), m_types.end(), [&](MWMPlacePageMetadataType a, MWMPlacePageMetadataType b)
{
return find(begin, end, a) < find(begin, end, b);
});
}
- (void)addMetaType:(MWMPlacePageMetadataType)type
@ -196,31 +210,16 @@ static map<Metadata::EType, MWMPlacePageMetadataType> const kMetaTypesMap{
case Metadata::FMD_OPEN_HOURS:
case Metadata::FMD_EMAIL:
case Metadata::FMD_POSTCODE:
[self addMetaType:kMetaTypesMap.at(type) value:metadata.Get(type)];
break;
case Metadata::FMD_INTERNET:
{
auto metaType = kMetaTypesMap.find(type);
if (metaType != kMetaTypesMap.end())
{
BOOL const internet = (type == Metadata::FMD_INTERNET);
[self addMetaType:metaType->second value:internet ? L(@"WiFi_available").UTF8String : metadata.Get(type)];
}
else
{
NSAssert(false, @"Unhandled meta type, see kMetaTypesMap.");
}
}
[self addMetaType:kMetaTypesMap.at(type) value:L(@"WiFi_available").UTF8String];
break;
default:
break;
}
}
auto begin = kPatternTypesArray.begin();
auto end = kPatternTypesArray.end();
sort(m_types.begin(), m_types.end(), [&](MWMPlacePageMetadataType a, MWMPlacePageMetadataType b)
{
return find(begin, end, a) < find(begin, end, b);
});
[self addMetaType:MWMPlacePageMetadataTypeCoordinate];
}
@ -246,25 +245,32 @@ static map<Metadata::EType, MWMPlacePageMetadataType> const kMetaTypesMap{
[ud synchronize];
}
#pragma mark - Editing
- (void)addEditableTypes
{
// TODO: Add real logic
}
#pragma mark - Getters
- (NSUInteger)getTypesCount
- (NSUInteger)getFeatureTypesCount
{
return m_types.size();
}
- (MWMPlacePageMetadataType)getType:(NSUInteger)index
- (MWMPlacePageMetadataType)getFeatureType:(NSUInteger)index
{
NSAssert(index < [self getTypesCount], @"Invalid meta index");
NSAssert(index < [self getFeatureTypesCount], @"Invalid meta index");
return m_types[index];
}
- (NSString *)getValue:(MWMPlacePageMetadataType)type
- (NSString *)getFeatureValue:(MWMPlacePageMetadataType)type
{
if (type == MWMPlacePageMetadataTypeCoordinate)
return [self coordinate];
auto it = m_values.find(type);
return it != m_values.end() ? @(it->second.c_str()) : @"";
return it != m_values.end() ? @(it->second.c_str()) : nil;
}
- (NSString *)coordinate

View file

@ -113,7 +113,7 @@
case MWMPlacePageMetadataTypeCoordinate:
[[Statistics instance] logEvent:kStatEventName(kStatPlacePage, kStatToggleCoordinates)];
[self.currentEntity toggleCoordinateSystem];
[self.textContainer setText:[self.currentEntity getValue:MWMPlacePageMetadataTypeCoordinate]];
[self.textContainer setText:[self.currentEntity getFeatureValue:MWMPlacePageMetadataTypeCoordinate]];
break;
default:
break;

View file

@ -3,7 +3,6 @@
#import "MapsAppDelegate.h"
#import "MWMActivityViewController.h"
#import "MWMAPIBar.h"
#import "MWMAuthorizationCommon.h"
#import "MWMBasePlacePageView.h"
#import "MWMDirectionView.h"
#import "MWMiPadPlacePage.h"
@ -284,21 +283,9 @@ typedef NS_ENUM(NSUInteger, MWMPlacePageManagerState)
- (void)editPlaceTime
{
NSUserDefaults * ud = [NSUserDefaults standardUserDefaults];
NSString * username = [ud stringForKey:kOSMUsernameKey];
NSString * password = [ud stringForKey:kOSMPasswordKey];
if (!username || !password)
{
[[Statistics instance] logEvent:kStatEventName(kStatPlacePage, kStatEditTime)
withParameters:@{kStatValue : kStatAuthorization}];
[self.ownerViewController performSegueWithIdentifier:@"Map2Login" sender:nil];
}
else
{
[[Statistics instance] logEvent:kStatEventName(kStatPlacePage, kStatEditTime)
withParameters:@{kStatValue : kStatEdit}];
[self.ownerViewController performSegueWithIdentifier:@"Map2OpeningHoursEditor" sender:self.entity];
}
[[Statistics instance] logEvent:kStatEventName(kStatPlacePage, kStatEditTime)
withParameters:@{kStatValue : kStatEdit}];
[self.ownerViewController performSegueWithIdentifier:@"Map2OpeningHoursEditor" sender:self.entity];
}
- (void)addBookmark

View file

@ -802,7 +802,7 @@ typedef NS_ENUM(NSUInteger, UserTouchesAction)
self.skipDismissOnViewDisappear = YES;
MWMPlacePageEntity * entity = sender;
MWMOpeningHoursEditorViewController * dvc = segue.destinationViewController;
dvc.openingHours = [entity getValue:MWMPlacePageMetadataTypeOpenHours];
dvc.openingHours = [entity getFeatureValue:MWMPlacePageMetadataTypeOpenHours];
}
}

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="9531" systemVersion="15A284" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="9531" systemVersion="15C50" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES">
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="9529"/>
@ -35,6 +35,7 @@
<userDefinedRuntimeAttributes>
<userDefinedRuntimeAttribute type="string" keyPath="localizedPlaceholder" value="name"/>
<userDefinedRuntimeAttribute type="string" keyPath="colorName" value="blackPrimaryText"/>
<userDefinedRuntimeAttribute type="string" keyPath="fontName" value="regular16"/>
</userDefinedRuntimeAttributes>
<connections>
<outlet property="delegate" destination="jfp-wb-Z7G" id="00o-sa-QS2"/>
@ -96,7 +97,7 @@
</userDefinedRuntimeAttributes>
</view>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Note" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="XF8-Ny-HSu" userLabel="Title">
<rect key="frame" x="16" y="13" width="31" height="17"/>
<rect key="frame" x="16" y="13" width="30" height="16"/>
<fontDescription key="fontDescription" name="HelveticaNeue" family="Helvetica Neue" pointSize="14"/>
<color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="0.54000000000000004" colorSpace="calibratedRGB"/>
<nil key="highlightedColor"/>
@ -157,14 +158,14 @@
<constraints>
<constraint firstAttribute="height" constant="44" id="5rE-hZ-GLl"/>
</constraints>
<fontDescription key="fontDescription" name="HelveticaNeue" family="Helvetica Neue" pointSize="17"/>
<fontDescription key="fontDescription" name="HelveticaNeue" family="Helvetica Neue" pointSize="16"/>
<inset key="contentEdgeInsets" minX="16" minY="0.0" maxX="9" maxY="0.0"/>
<state key="normal" title="Edit Bookmark">
<color key="titleColor" red="0.1176470588" green="0.58823529409999997" blue="0.94117647059999998" alpha="1" colorSpace="calibratedRGB"/>
<color key="titleShadowColor" white="0.5" alpha="1" colorSpace="calibratedWhite"/>
</state>
<userDefinedRuntimeAttributes>
<userDefinedRuntimeAttribute type="string" keyPath="fontName" value="regular17"/>
<userDefinedRuntimeAttribute type="string" keyPath="fontName" value="regular16"/>
<userDefinedRuntimeAttribute type="string" keyPath="textColorName" value="linkBlue"/>
</userDefinedRuntimeAttributes>
<connections>
@ -194,7 +195,6 @@
</subviews>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
<constraints>
<constraint firstItem="VLh-WI-T7X" firstAttribute="leading" secondItem="NJ3-lK-ziZ" secondAttribute="trailing" constant="16" id="6qf-Bl-HGm"/>
<constraint firstItem="8KR-m1-j51" firstAttribute="width" secondItem="f8i-PA-TJb" secondAttribute="width" id="7FM-xU-xDL"/>
<constraint firstItem="Wax-9r-T5y" firstAttribute="leading" secondItem="VLh-WI-T7X" secondAttribute="trailing" constant="12" id="7mj-gk-N51"/>
<constraint firstItem="Sx9-cz-Scg" firstAttribute="top" secondItem="8KR-m1-j51" secondAttribute="bottom" id="9Kr-d5-TnV"/>
@ -208,6 +208,7 @@
<constraint firstItem="Sx9-cz-Scg" firstAttribute="centerX" secondItem="8KR-m1-j51" secondAttribute="centerX" id="R2v-D5-fHw"/>
<constraint firstAttribute="bottom" secondItem="Sx9-cz-Scg" secondAttribute="bottom" id="SuF-wy-cAu"/>
<constraint firstItem="6e1-wr-Alw" firstAttribute="centerX" secondItem="VLh-WI-T7X" secondAttribute="centerX" id="UjZ-c7-pSl"/>
<constraint firstItem="VLh-WI-T7X" firstAttribute="leading" secondItem="kUu-ao-FYN" secondAttribute="leading" constant="60" id="XuD-Lr-D6H"/>
<constraint firstItem="NJ3-lK-ziZ" firstAttribute="leading" secondItem="kUu-ao-FYN" secondAttribute="leading" constant="16" id="Z9y-hZ-0pk"/>
<constraint firstItem="meU-rN-T7y" firstAttribute="trailing" secondItem="8KR-m1-j51" secondAttribute="trailing" constant="-8" id="f7Q-08-8Ix"/>
<constraint firstItem="f8i-PA-TJb" firstAttribute="top" secondItem="jxG-Qv-eKF" secondAttribute="bottom" id="jP6-dp-yga"/>

View file

@ -11,7 +11,7 @@
<rect key="frame" x="0.0" y="0.0" width="320" height="44"/>
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMaxX="YES" flexibleMinY="YES" flexibleMaxY="YES"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="VAd-kw-ZEC" id="KHz-zH-ymS">
<rect key="frame" x="0.0" y="0.0" width="320" height="43.5"/>
<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="xwC-DR-6Il">
@ -29,7 +29,7 @@
<color key="textColor" red="0.12941176469999999" green="0.12941176469999999" blue="0.12941176469999999" alpha="1" colorSpace="calibratedRGB"/>
<nil key="highlightedColor"/>
<userDefinedRuntimeAttributes>
<userDefinedRuntimeAttribute type="string" keyPath="fontName" value="regular17"/>
<userDefinedRuntimeAttribute type="string" keyPath="fontName" value="regular16"/>
</userDefinedRuntimeAttributes>
</label>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="CNm-TR-GPW" userLabel="Separator">

View file

@ -30,7 +30,6 @@
<nil key="simulatedTopBarMetrics"/>
<connections>
<segue destination="Ld6-gM-2hk" kind="custom" identifier="Map2OpeningHoursEditor" customClass="MWMSegue" id="VzH-mq-fOy"/>
<segue destination="2fX-ws-Tuc" kind="custom" identifier="Map2Login" customClass="MWMSegue" id="ezg-7i-mi5"/>
</connections>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="cKg-Q7-bFd" userLabel="First Responder" sceneMemberID="firstResponder"/>
@ -979,6 +978,7 @@
<outlet property="ohTextViewHeight" destination="oBv-SK-cOU" id="8yB-hb-hml"/>
<outlet property="tableView" destination="X1H-IB-Nv1" id="9jh-Ds-VNe"/>
<outlet property="toggleModeButton" destination="fB1-w2-lJI" id="hSt-55-5S2"/>
<segue destination="2fX-ws-Tuc" kind="custom" identifier="OpeningHoursEditor2Authorization" customClass="MWMSegue" id="zSu-Mv-oPV"/>
</connections>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="zeH-cr-FVE" userLabel="First Responder" sceneMemberID="firstResponder"/>