[ios] Removed custom opening hours edit button.

This commit is contained in:
Ilya Grechuhin 2016-01-05 10:39:11 +03:00 committed by Sergey Yershov
parent aa720a5c8b
commit 5f065bf53f
11 changed files with 87 additions and 165 deletions

View file

@ -9,7 +9,7 @@
@interface MWMPlacePageOpeningHoursCell : UITableViewCell
- (void)configWithInfo:(NSString *)info editable:(BOOL)editable delegate:(id<MWMPlacePageOpeningHoursCellProtocol>)delegate;
- (void)configWithInfo:(NSString *)info delegate:(id<MWMPlacePageOpeningHoursCellProtocol>)delegate;
- (CGFloat)cellHeight;

View file

@ -17,7 +17,6 @@ using WeekDayView = MWMPlacePageOpeningHoursDayView *;
@property (weak, nonatomic) IBOutlet WeekDayView currentDay;
@property (weak, nonatomic) IBOutlet UIView * middleSeparator;
@property (weak, nonatomic) IBOutlet UIView * weekDaysView;
@property (weak, nonatomic) IBOutlet UIButton * editButton;
@property (weak, nonatomic) IBOutlet UIImageView * expandImage;
@property (weak, nonatomic) IBOutlet UIButton * toggleButton;
@ -57,42 +56,30 @@ WeekDayView getWeekDayView()
ui::TimeTableSet timeTableSet;
}
- (void)configWithInfo:(NSString *)info editable:(BOOL)editable delegate:(id<MWMPlacePageOpeningHoursCellProtocol>)delegate
- (void)configWithInfo:(NSString *)info delegate:(id<MWMPlacePageOpeningHoursCellProtocol>)delegate
{
self.toggleButton.hidden = !editable;
self.delegate = delegate;
WeekDayView cd = self.currentDay;
cd.currentDay = YES;
if (info)
self.toggleButton.hidden = YES;
self.expandImage.hidden = YES;
NSAssert(info, @"Schedule can not be empty");
osmoh::OpeningHours oh(info.UTF8String);
if (MakeTimeTableSet(oh, timeTableSet))
{
osmoh::OpeningHours oh(info.UTF8String);
if (MakeTimeTableSet(oh, timeTableSet))
{
cd.mode = MWMPlacePageOpeningHoursDayViewModeRegular;
self.isClosed = oh.IsClosed(time(nullptr));
[self processSchedule];
}
else
{
cd.mode = MWMPlacePageOpeningHoursDayViewModeCompatibility;
[cd setCompatibilityText:info];
}
BOOL const isExpanded = delegate.openingHoursCellExpanded;
self.middleSeparator.hidden = !isExpanded;
self.weekDaysView.hidden = !isExpanded;
self.editButton.hidden = !editable || !isExpanded;
self.expandImage.hidden = !editable;
self.expandImage.image = [UIImage imageNamed:isExpanded ? @"ic_arrow_gray_up" : @"ic_arrow_gray_down"];
cd.isCompatibility = NO;
self.isClosed = oh.IsClosed(time(nullptr));
[self processSchedule];
}
else
{
cd.mode = MWMPlacePageOpeningHoursDayViewModeEmpty;
self.middleSeparator.hidden = YES;
self.weekDaysView.hidden = YES;
self.editButton.hidden = YES;
self.expandImage.hidden = YES;
cd.isCompatibility = YES;
[cd setCompatibilityText:info];
}
BOOL const isExpanded = delegate.openingHoursCellExpanded;
self.middleSeparator.hidden = !isExpanded;
self.weekDaysView.hidden = !isExpanded;
[cd invalidate];
}
@ -107,7 +94,6 @@ WeekDayView getWeekDayView()
BOOL const isExpanded = self.delegate.openingHoursCellExpanded;
self.weekDaysViewEstimatedHeight = 0.0;
[self.weekDaysView.subviews makeObjectsPerformSelector:@selector(removeFromSuperview)];
[self.currentDay setCanExpand:YES];
for (size_t idx = 0; idx < timeTablesCount; ++idx)
{
ui::TTimeTableProxy tt = timeTableSet.Get(idx);
@ -122,8 +108,14 @@ WeekDayView getWeekDayView()
}
if (!haveCurrentDay)
[self addEmptyCurrentDay];
if (haveExpandSchedule && isExpanded)
[self addClosedDays];
if (haveExpandSchedule)
{
self.toggleButton.hidden = NO;
self.expandImage.hidden = NO;
self.expandImage.image = [UIImage imageNamed:isExpanded ? @"ic_arrow_gray_up" : @"ic_arrow_gray_down"];
if (isExpanded)
[self addClosedDays];
}
self.weekDaysViewHeight.constant = ceil(self.weekDaysViewEstimatedHeight);
}
@ -197,10 +189,9 @@ WeekDayView getWeekDayView()
CGFloat height = self.currentDay.viewHeight;
if (self.delegate.openingHoursCellExpanded)
{
MWMPlacePageOpeningHoursDayViewMode const mode = self.currentDay.mode;
if (mode != MWMPlacePageOpeningHoursDayViewModeEmpty && !self.toggleButton.hidden)
height += self.editButton.height;
if (mode == MWMPlacePageOpeningHoursDayViewModeRegular)
CGFloat const bottomOffset = 12.0;
height += bottomOffset;
if (!self.currentDay.isCompatibility)
height += self.weekDaysViewHeight.constant;
}
return ceil(height);
@ -210,22 +201,7 @@ WeekDayView getWeekDayView()
- (IBAction)toggleButtonTap
{
switch (self.currentDay.mode)
{
case MWMPlacePageOpeningHoursDayViewModeRegular:
case MWMPlacePageOpeningHoursDayViewModeCompatibility:
[self.delegate setOpeningHoursCellExpanded:!self.delegate.openingHoursCellExpanded forCell:self];
break;
case MWMPlacePageOpeningHoursDayViewModeEmpty:
[self editButtonTap];
break;
}
}
- (IBAction)editButtonTap
{
[[Statistics instance] logEvent:kStatEventName(kStatPlacePage, kStatEditTime)];
[self.delegate editPlaceTime];
[self.delegate setOpeningHoursCellExpanded:!self.delegate.openingHoursCellExpanded forCell:self];
}
@end

View file

@ -8,10 +8,10 @@
<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="MWMPlacePageOpeningHoursCell">
<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="249"/>
<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="291.5"/>
<rect key="frame" x="0.0" y="0.0" width="320" height="248.5"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="swk-um-XzG" customClass="MWMPlacePageOpeningHoursDayView">
@ -143,7 +143,6 @@
<outlet property="breaksHolderHeight" destination="RWf-JS-tim" id="Pgt-3Q-cEG"/>
<outlet property="closedLabel" destination="EcD-Q8-7zu" id="hhh-Q4-9vo"/>
<outlet property="compatibilityLabel" destination="ZdV-4y-cz4" id="Jwu-Ux-lqO"/>
<outlet property="expandImage" destination="mGc-k4-uvQ" id="6VJ-Xv-Knr"/>
<outlet property="height" destination="hsa-4B-Df0" id="he7-ZL-kOE"/>
<outlet property="label" destination="Ot5-QJ-jhp" id="zOc-Fe-grg"/>
<outlet property="labelWidth" destination="5G1-mL-J4T" id="esU-tO-DPm"/>
@ -167,23 +166,8 @@
<constraint firstAttribute="height" constant="122" id="Ifb-EB-LIb"/>
</constraints>
</view>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="acu-oR-Ylj">
<rect key="frame" x="60" y="248" width="260" height="44"/>
<constraints>
<constraint firstAttribute="height" priority="750" constant="44" id="GZv-lM-zKz"/>
</constraints>
<state key="normal" title="Edit time"/>
<userDefinedRuntimeAttributes>
<userDefinedRuntimeAttribute type="string" keyPath="fontName" value="regular17"/>
<userDefinedRuntimeAttribute type="string" keyPath="textColorName" value="linkBlue"/>
<userDefinedRuntimeAttribute type="string" keyPath="localizedText" value="edit_opening_time"/>
</userDefinedRuntimeAttributes>
<connections>
<action selector="editButtonTap" destination="KGk-i7-Jjw" eventType="touchUpInside" id="dpE-up-9Wu"/>
</connections>
</button>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="9WP-gb-0Hl" userLabel="Bottom Separator">
<rect key="frame" x="60" y="291" width="260" height="1"/>
<rect key="frame" x="60" y="248" width="260" height="1"/>
<color key="backgroundColor" white="0.66666666666666663" alpha="1" colorSpace="calibratedWhite"/>
<constraints>
<constraint firstAttribute="height" constant="1" id="ISb-za-hzz"/>
@ -196,7 +180,6 @@
<constraints>
<constraint firstItem="fNU-1q-AiR" firstAttribute="leading" secondItem="H2p-sc-9uM" secondAttribute="leading" id="08I-np-9jr"/>
<constraint firstAttribute="trailing" secondItem="fNU-1q-AiR" secondAttribute="trailing" id="2Hz-cA-KuN"/>
<constraint firstItem="acu-oR-Ylj" firstAttribute="leading" secondItem="H2p-sc-9uM" secondAttribute="leading" constant="60" id="5s8-nY-ULm"/>
<constraint firstAttribute="trailing" secondItem="q9R-jU-fIk" secondAttribute="trailing" constant="32" id="GqM-0e-qyu"/>
<constraint firstItem="q9R-jU-fIk" firstAttribute="top" secondItem="swk-um-XzG" secondAttribute="bottom" id="HNR-8z-cc0"/>
<constraint firstItem="fNU-1q-AiR" firstAttribute="top" secondItem="q9R-jU-fIk" secondAttribute="bottom" id="JFR-YU-rAy"/>
@ -205,15 +188,12 @@
<constraint firstItem="q9R-jU-fIk" firstAttribute="leading" secondItem="H2p-sc-9uM" secondAttribute="leading" constant="60" id="eUW-RI-gaa"/>
<constraint firstItem="9WP-gb-0Hl" firstAttribute="leading" secondItem="H2p-sc-9uM" secondAttribute="leading" constant="60" id="fCK-Qq-Hci"/>
<constraint firstItem="swk-um-XzG" firstAttribute="leading" secondItem="H2p-sc-9uM" secondAttribute="leading" id="p14-Mi-kcR"/>
<constraint firstAttribute="trailing" secondItem="acu-oR-Ylj" secondAttribute="trailing" id="sCm-Vb-stb"/>
<constraint firstAttribute="bottom" secondItem="acu-oR-Ylj" secondAttribute="bottom" id="sey-To-H3h"/>
<constraint firstAttribute="trailing" secondItem="9WP-gb-0Hl" secondAttribute="trailing" id="vof-Qq-rXP"/>
<constraint firstAttribute="trailing" secondItem="swk-um-XzG" secondAttribute="trailing" id="zir-No-59Q"/>
</constraints>
</tableViewCellContentView>
<connections>
<outlet property="currentDay" destination="swk-um-XzG" id="CJG-LQ-Pu8"/>
<outlet property="editButton" destination="acu-oR-Ylj" id="e0k-BO-Ske"/>
<outlet property="expandImage" destination="mGc-k4-uvQ" id="ohq-Yq-hLX"/>
<outlet property="middleSeparator" destination="q9R-jU-fIk" id="vcZ-Lb-HgY"/>
<outlet property="toggleButton" destination="3Fa-V6-tC5" id="8FI-Je-uFy"/>

View file

@ -1,21 +1,13 @@
typedef NS_ENUM(NSUInteger, MWMPlacePageOpeningHoursDayViewMode)
{
MWMPlacePageOpeningHoursDayViewModeRegular,
MWMPlacePageOpeningHoursDayViewModeCompatibility,
MWMPlacePageOpeningHoursDayViewModeEmpty
};
@interface MWMPlacePageOpeningHoursDayView : UIView
@property (nonatomic) BOOL currentDay;
@property (nonatomic) CGFloat viewHeight;
@property (nonatomic) MWMPlacePageOpeningHoursDayViewMode mode;
@property (nonatomic) BOOL isCompatibility;
- (void)setLabelText:(NSString *)text isRed:(BOOL)isRed;
- (void)setOpenTimeText:(NSString *)text;
- (void)setBreaks:(NSArray<NSString *> *)breaks;
- (void)setClosed:(BOOL)closed;
- (void)setCanExpand:(BOOL)canExpand;
- (void)setCompatibilityText:(NSString *)text;
- (void)invalidate;

View file

@ -13,8 +13,6 @@
@property (weak, nonatomic) IBOutlet UILabel * closedLabel;
@property (weak, nonatomic) IBOutlet UIImageView * expandImage;
@property (weak, nonatomic) IBOutlet NSLayoutConstraint * height;
@property (weak, nonatomic) IBOutlet NSLayoutConstraint * labelWidth;
@property (weak, nonatomic) IBOutlet NSLayoutConstraint * breakLabelWidth;
@ -77,11 +75,6 @@
self.closedLabel.hidden = !closed;
}
- (void)setCanExpand:(BOOL)canExpand
{
self.expandImage.hidden = !canExpand;
}
- (void)setCompatibilityText:(NSString *)text
{
self.compatibilityLabel.text = text;
@ -90,8 +83,13 @@
- (void)invalidate
{
CGFloat viewHeight;
BOOL const isRegular = (self.mode == MWMPlacePageOpeningHoursDayViewModeRegular);
if (isRegular)
if (self.isCompatibility)
{
[self.compatibilityLabel sizeToIntegralFit];
CGFloat const compatibilityLabelVerticalOffsets = 24.0;
viewHeight = self.compatibilityLabel.height + compatibilityLabelVerticalOffsets;
}
else
{
[self.label sizeToIntegralFit];
self.labelWidth.constant = self.label.width;
@ -107,12 +105,6 @@
if (!self.closedLabel.hidden)
viewHeight += heightForClosedLabel;
}
else
{
[self.compatibilityLabel sizeToIntegralFit];
CGFloat const compatibilityLabelVerticalOffsets = 24.0;
viewHeight = self.compatibilityLabel.height + compatibilityLabelVerticalOffsets;
}
self.viewHeight = ceil(viewHeight);
@ -137,20 +129,15 @@
}
}
- (void)setMode:(MWMPlacePageOpeningHoursDayViewMode)mode
- (void)setIsCompatibility:(BOOL)isCompatibility
{
_mode = mode;
BOOL const isRegular = (mode == MWMPlacePageOpeningHoursDayViewModeRegular);
BOOL const isEmpty = (mode == MWMPlacePageOpeningHoursDayViewModeEmpty);
self.compatibilityLabel.hidden = isRegular;
self.label.hidden = !isRegular;
self.openTime.hidden = !isRegular;
self.breakLabel.hidden = !isRegular;
self.breaksHolder.hidden = !isRegular;
self.closedLabel.hidden = !isRegular;
if (isEmpty)
self.compatibilityLabel.text = L(@"add_opening_hours");
_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;
}
@end

View file

@ -185,7 +185,7 @@ extern CGFloat const kBasePlacePageViewTitleBottomOffset = 2.;
[self.typeDescriptionView removeFromSuperview];
self.typeDescriptionView = nil;
[self.typeLabel sizeToFit];
[self.entity insertBookmarkInTypes];
[self.entity addBookmarkField];
[self configure];
}
@ -194,7 +194,7 @@ extern CGFloat const kBasePlacePageViewTitleBottomOffset = 2.;
[[Statistics instance] logEvent:kStatEventName(kStatPlacePage, kStatToggleBookmark)
withParameters:@{kStatValue : kStatRemove}];
self.entity.type = MWMPlacePageEntityTypeRegular;
[self.entity removeBookmarkFromTypes];
[self.entity removeBookmarkField];
[self configure];
}
@ -257,47 +257,36 @@ extern CGFloat const kBasePlacePageViewTitleBottomOffset = 2.;
@implementation MWMBasePlacePageView (UITableView)
- (CGFloat)tableView:(UITableView *)tableView estimatedHeightForRowAtIndexPath:(NSIndexPath *)indexPath
{
return 44.0;
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
MWMPlacePageEntity * entity = self.entity;
MWMPlacePageMetadataField const field = [entity getFieldType:indexPath.row];
UITableViewCell * cell = [self offscreenCellForIdentifier:[self cellIdentifierForField:field]];
if (field == MWMPlacePageMetadataFieldBookmark)
if ([cell isKindOfClass:[MWMPlacePageBookmarkCell class]])
{
MWMPlacePageBookmarkCell * tCell = (MWMPlacePageBookmarkCell *)cell;
[tCell config:self.ownerPlacePage forHeight:YES];
return tCell.cellHeight;
}
else if (field == MWMPlacePageMetadataFieldOpenHours)
else if ([cell isKindOfClass:[MWMPlacePageOpeningHoursCell class]])
{
MWMPlacePageOpeningHoursCell * tCell = (MWMPlacePageOpeningHoursCell *)cell;
[tCell configWithInfo:[entity getFieldValue:field]
editable:[entity isFieldEditable:field]
delegate:self];
[tCell configWithInfo:[entity getFieldValue:field] delegate:self];
return tCell.cellHeight;
}
else if (field == MWMPlacePageMetadataFieldEditButton)
{
return [MWMPlacePageButtonCell height];
}
else
else if ([cell isKindOfClass:[MWMPlacePageInfoCell class]])
{
MWMPlacePageInfoCell * tCell = (MWMPlacePageInfoCell *)cell;
tCell.currentEntity = self.entity;
[tCell configureWithType:field info:[entity getFieldValue:field]];
[tCell setNeedsUpdateConstraints];
[tCell updateConstraintsIfNeeded];
tCell.bounds = {{}, {CGRectGetWidth(tableView.bounds), CGRectGetHeight(tCell.bounds)}};
[tCell setNeedsLayout];
[tCell layoutIfNeeded];
CGSize const size = [tCell.contentView systemLayoutSizeFittingSize:UILayoutFittingCompressedSize];
return size.height;
}
[cell setNeedsUpdateConstraints];
[cell updateConstraintsIfNeeded];
cell.bounds = {{}, {CGRectGetWidth(tableView.bounds), CGRectGetHeight(cell.bounds)}};
[cell setNeedsLayout];
[cell layoutIfNeeded];
CGSize const size = [cell.contentView systemLayoutSizeFittingSize:UILayoutFittingCompressedSize];
return size.height;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
@ -316,9 +305,7 @@ extern CGFloat const kBasePlacePageViewTitleBottomOffset = 2.;
}
else if (field == MWMPlacePageMetadataFieldOpenHours)
{
[(MWMPlacePageOpeningHoursCell *)cell configWithInfo:[entity getFieldValue:field]
editable:[entity isFieldEditable:field]
delegate:self];
[(MWMPlacePageOpeningHoursCell *)cell configWithInfo:[entity getFieldValue:field] delegate:self];
}
else if (field == MWMPlacePageMetadataFieldEditButton)
{

View file

@ -2,8 +2,6 @@
@interface MWMPlacePageButtonCell : UITableViewCell
+ (CGFloat)height;
- (void)config:(MWMPlacePage *)placePage;
@end

View file

@ -10,11 +10,6 @@
@implementation MWMPlacePageButtonCell
+ (CGFloat)height
{
return 44.0;
}
- (void)config:(MWMPlacePage *)placePage
{
self.placePage = placePage;

View file

@ -16,16 +16,19 @@
<subviews>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="jmU-dJ-aRH">
<rect key="frame" x="0.0" y="0.0" width="320" height="44"/>
<constraints>
<constraint firstAttribute="height" constant="44" id="gfO-mi-8yS"/>
</constraints>
<fontDescription key="fontDescription" name="HelveticaNeue" family="Helvetica Neue" pointSize="17"/>
<inset key="contentEdgeInsets" minX="16" minY="0.0" maxX="9" maxY="0.0"/>
<state key="normal" title="Login">
<state key="normal" title="Edit">
<color key="titleColor" red="0.1176470588" green="0.58823529409999997" blue="0.94117647059999998" alpha="1" colorSpace="calibratedRGB"/>
<color key="titleShadowColor" red="0.49803921568627452" green="0.49803921568627452" blue="0.49803921568627452" alpha="1" colorSpace="calibratedRGB"/>
</state>
<userDefinedRuntimeAttributes>
<userDefinedRuntimeAttribute type="string" keyPath="fontName" value="regular17"/>
<userDefinedRuntimeAttribute type="string" keyPath="textColorName" value="linkBlue"/>
<userDefinedRuntimeAttribute type="string" keyPath="localizedText" value="login"/>
<userDefinedRuntimeAttribute type="string" keyPath="localizedText" value="edit"/>
</userDefinedRuntimeAttributes>
<connections>
<action selector="editPlaceButtonTouchUpIndide" destination="KGk-i7-Jjw" eventType="touchUpInside" id="ZyS-5r-oKK"/>

View file

@ -10,8 +10,8 @@ typedef NS_ENUM(NSUInteger, MWMPlacePageMetadataField)
MWMPlacePageMetadataFieldURL,
MWMPlacePageMetadataFieldEmail,
MWMPlacePageMetadataFieldOpenHours,
MWMPlacePageMetadataFieldCoordinate,
MWMPlacePageMetadataFieldWiFi,
MWMPlacePageMetadataFieldCoordinate,
MWMPlacePageMetadataFieldBookmark,
MWMPlacePageMetadataFieldEditButton
};
@ -47,9 +47,8 @@ typedef NS_ENUM(NSUInteger, MWMPlacePageEntityType)
@property (nonatomic, readonly) ms::LatLon latlon;
- (void)enableEditing;
- (void)insertBookmarkInTypes;
- (void)removeBookmarkFromTypes;
- (void)addBookmarkField;
- (void)removeBookmarkField;
- (instancetype)initWithUserMark:(UserMark const *)mark;
- (void)synchronize;

View file

@ -9,11 +9,17 @@ using feature::Metadata;
extern NSString * const kUserDefaultsLatLonAsDMSKey = @"UserDefaultsLatLonAsDMS";
static array<MWMPlacePageMetadataField, 8> const kPatternFieldsArray{
{MWMPlacePageMetadataFieldPostcode, MWMPlacePageMetadataFieldPhoneNumber,
MWMPlacePageMetadataFieldWebsite, MWMPlacePageMetadataFieldURL, MWMPlacePageMetadataFieldEmail,
MWMPlacePageMetadataFieldOpenHours, MWMPlacePageMetadataFieldWiFi,
MWMPlacePageMetadataFieldCoordinate}};
static array<MWMPlacePageMetadataField, 10> const kPatternFieldsArray{
{MWMPlacePageMetadataFieldPostcode,
MWMPlacePageMetadataFieldPhoneNumber,
MWMPlacePageMetadataFieldWebsite,
MWMPlacePageMetadataFieldURL,
MWMPlacePageMetadataFieldEmail,
MWMPlacePageMetadataFieldOpenHours,
MWMPlacePageMetadataFieldWiFi,
MWMPlacePageMetadataFieldCoordinate,
MWMPlacePageMetadataFieldBookmark,
MWMPlacePageMetadataFieldEditButton}};
static map<Metadata::EType, MWMPlacePageMetadataField> const kMetaFieldsMap{
{Metadata::FMD_URL, MWMPlacePageMetadataFieldURL},
@ -111,7 +117,7 @@ static map<Metadata::EType, MWMPlacePageMetadataField> const kMetaFieldsMap{
self.bookmarkColor = @(data.GetType().c_str());
[self configureEntityWithFeature:bookmark->GetFeature()];
[self insertBookmarkInTypes];
[self addBookmarkField];
}
- (void)configureForMyPosition:(MyPositionMarkPoint const *)myPositionMark
@ -208,17 +214,18 @@ static map<Metadata::EType, MWMPlacePageMetadataField> const kMetaFieldsMap{
[self addMetaField:MWMPlacePageMetadataFieldCoordinate];
}
- (void)enableEditing
- (void)addEditField
{
[self addMetaField:MWMPlacePageMetadataFieldEditButton];
}
- (void)insertBookmarkInTypes
- (void)addBookmarkField
{
[self addMetaField:MWMPlacePageMetadataFieldBookmark];
[self sortMetaFields];
}
- (void)removeBookmarkFromTypes
- (void)removeBookmarkField
{
[self removeMetaField:MWMPlacePageMetadataFieldBookmark];
}
@ -237,12 +244,10 @@ static map<Metadata::EType, MWMPlacePageMetadataField> const kMetaFieldsMap{
// TODO: Replace with real array
vector<Metadata::EType> const editableTypes {Metadata::FMD_OPEN_HOURS};
//osm::Editor::Instance().EditableMetadataForType(<#const FeatureType &feature#>);
if (!editableTypes.empty())
[self addEditField];
for (auto const & type : editableTypes)
{
MWMPlacePageMetadataField uiType = kMetaFieldsMap.at(type);
[self addMetaField:uiType];
m_editableFields.insert(uiType);
}
m_editableFields.insert(kMetaFieldsMap.at(type));
}
- (BOOL)isFieldEditable:(MWMPlacePageMetadataField)field