forked from organicmaps/organicmaps
[ios] Changed place page edit button display logic.
This commit is contained in:
parent
ddcad2a979
commit
ed6ee4c3e6
12 changed files with 202 additions and 160 deletions
|
@ -9,7 +9,7 @@
|
|||
|
||||
@interface MWMPlacePageOpeningHoursCell : UITableViewCell
|
||||
|
||||
- (void)configWithInfo:(NSString *)info delegate:(id<MWMPlacePageOpeningHoursCellProtocol>)delegate;
|
||||
- (void)configWithInfo:(NSString *)info editable:(BOOL)editable delegate:(id<MWMPlacePageOpeningHoursCellProtocol>)delegate;
|
||||
|
||||
- (CGFloat)cellHeight;
|
||||
|
||||
|
|
|
@ -19,6 +19,7 @@ using WeekDayView = MWMPlacePageOpeningHoursDayView *;
|
|||
@property (weak, nonatomic) IBOutlet UIView * weekDaysView;
|
||||
@property (weak, nonatomic) IBOutlet UIButton * editButton;
|
||||
@property (weak, nonatomic) IBOutlet UIImageView * expandImage;
|
||||
@property (weak, nonatomic) IBOutlet UIButton * toggleButton;
|
||||
|
||||
@property (weak, nonatomic) IBOutlet NSLayoutConstraint * weekDaysViewHeight;
|
||||
@property (nonatomic) CGFloat weekDaysViewEstimatedHeight;
|
||||
|
@ -56,8 +57,9 @@ WeekDayView getWeekDayView()
|
|||
ui::TimeTableSet timeTableSet;
|
||||
}
|
||||
|
||||
- (void)configWithInfo:(NSString *)info delegate:(id<MWMPlacePageOpeningHoursCellProtocol>)delegate
|
||||
- (void)configWithInfo:(NSString *)info editable:(BOOL)editable delegate:(id<MWMPlacePageOpeningHoursCellProtocol>)delegate
|
||||
{
|
||||
self.toggleButton.hidden = !editable;
|
||||
self.delegate = delegate;
|
||||
WeekDayView cd = self.currentDay;
|
||||
cd.currentDay = YES;
|
||||
|
@ -79,7 +81,8 @@ WeekDayView getWeekDayView()
|
|||
BOOL const isExpanded = delegate.openingHoursCellExpanded;
|
||||
self.middleSeparator.hidden = !isExpanded;
|
||||
self.weekDaysView.hidden = !isExpanded;
|
||||
self.editButton.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"];
|
||||
}
|
||||
else
|
||||
|
@ -88,6 +91,7 @@ WeekDayView getWeekDayView()
|
|||
self.middleSeparator.hidden = YES;
|
||||
self.weekDaysView.hidden = YES;
|
||||
self.editButton.hidden = YES;
|
||||
self.expandImage.hidden = YES;
|
||||
}
|
||||
[cd invalidate];
|
||||
}
|
||||
|
@ -194,7 +198,7 @@ WeekDayView getWeekDayView()
|
|||
if (self.delegate.openingHoursCellExpanded)
|
||||
{
|
||||
MWMPlacePageOpeningHoursDayViewMode const mode = self.currentDay.mode;
|
||||
if (mode != MWMPlacePageOpeningHoursDayViewModeEmpty)
|
||||
if (mode != MWMPlacePageOpeningHoursDayViewModeEmpty && !self.toggleButton.hidden)
|
||||
height += self.editButton.height;
|
||||
if (mode == MWMPlacePageOpeningHoursDayViewModeRegular)
|
||||
height += self.weekDaysViewHeight.constant;
|
||||
|
@ -206,7 +210,8 @@ WeekDayView getWeekDayView()
|
|||
|
||||
- (IBAction)toggleButtonTap
|
||||
{
|
||||
switch (self.currentDay.mode) {
|
||||
switch (self.currentDay.mode)
|
||||
{
|
||||
case MWMPlacePageOpeningHoursDayViewModeRegular:
|
||||
case MWMPlacePageOpeningHoursDayViewModeCompatibility:
|
||||
[self.delegate setOpeningHoursCellExpanded:!self.delegate.openingHoursCellExpanded forCell:self];
|
||||
|
|
|
@ -216,6 +216,7 @@
|
|||
<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"/>
|
||||
<outlet property="weekDaysView" destination="fNU-1q-AiR" id="zM3-OD-vBA"/>
|
||||
<outlet property="weekDaysViewHeight" destination="Ifb-EB-LIb" id="sEe-Y1-ubY"/>
|
||||
</connections>
|
||||
|
|
|
@ -148,7 +148,6 @@
|
|||
self.breakLabel.hidden = !isRegular;
|
||||
self.breaksHolder.hidden = !isRegular;
|
||||
self.closedLabel.hidden = !isRegular;
|
||||
self.expandImage.hidden = isEmpty;
|
||||
|
||||
if (isEmpty)
|
||||
self.compatibilityLabel.text = L(@"add_opening_hours");
|
||||
|
|
|
@ -27,8 +27,8 @@ extern CGFloat const kBasePlacePageViewTitleBottomOffset = 2.;
|
|||
|
||||
@property (weak, nonatomic) MWMPlacePageEntity * entity;
|
||||
@property (weak, nonatomic) IBOutlet MWMPlacePage * ownerPlacePage;
|
||||
@property (nonatomic) MWMPlacePageBookmarkCell * bookmarkSizingCell;
|
||||
@property (nonatomic) MWMPlacePageOpeningHoursCell * openingHoursSizingCell;
|
||||
|
||||
@property (nonatomic) NSMutableDictionary<NSString *, UITableViewCell *> * offscreenCells;
|
||||
|
||||
@property (nonatomic, readwrite) BOOL openingHoursCellExpanded;
|
||||
|
||||
|
@ -242,100 +242,117 @@ extern CGFloat const kBasePlacePageViewTitleBottomOffset = 2.;
|
|||
[self.ownerPlacePage editPlaceTime];
|
||||
}
|
||||
|
||||
#pragma mark - Properties
|
||||
|
||||
- (MWMPlacePageBookmarkCell *)bookmarkSizingCell
|
||||
- (UITableViewCell *)offscreenCellForIdentifier:(NSString *)reuseIdentifier
|
||||
{
|
||||
if (!_bookmarkSizingCell)
|
||||
_bookmarkSizingCell = [[[NSBundle mainBundle] loadNibNamed:kPlacePageBookmarkCellIdentifier
|
||||
owner:nil
|
||||
options:nil] firstObject];
|
||||
return _bookmarkSizingCell;
|
||||
}
|
||||
|
||||
- (MWMPlacePageOpeningHoursCell *)openingHoursSizingCell
|
||||
{
|
||||
if (!_openingHoursSizingCell)
|
||||
_openingHoursSizingCell =
|
||||
[[[NSBundle mainBundle] loadNibNamed:kPlacePageOpeningHoursCellIdentifier
|
||||
owner:nil
|
||||
options:nil] firstObject];
|
||||
return _openingHoursSizingCell;
|
||||
UITableViewCell * cell = self.offscreenCells[reuseIdentifier];
|
||||
if (!cell)
|
||||
{
|
||||
cell = [[[NSBundle mainBundle] loadNibNamed:reuseIdentifier owner:nil options:nil] firstObject];
|
||||
self.offscreenCells[reuseIdentifier] = cell;
|
||||
}
|
||||
return cell;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@implementation MWMBasePlacePageView (UITableView)
|
||||
|
||||
- (CGFloat)tableView:(UITableView *)tableView estimatedHeightForRowAtIndexPath:(NSIndexPath *)indexPath
|
||||
{
|
||||
return 44.0;
|
||||
}
|
||||
|
||||
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
|
||||
{
|
||||
MWMPlacePageEntity * entity = self.entity;
|
||||
MWMPlacePageMetadataType const currentType = [entity getFeatureType:indexPath.row];
|
||||
if (currentType == MWMPlacePageMetadataTypeBookmark)
|
||||
MWMPlacePageMetadataField const field = [entity getFieldType:indexPath.row];
|
||||
UITableViewCell * cell = [self offscreenCellForIdentifier:[self cellIdentifierForField:field]];
|
||||
if (field == MWMPlacePageMetadataFieldBookmark)
|
||||
{
|
||||
[self.bookmarkSizingCell config:self.ownerPlacePage forHeight:YES];
|
||||
return self.bookmarkSizingCell.cellHeight;
|
||||
MWMPlacePageBookmarkCell * tCell = (MWMPlacePageBookmarkCell *)cell;
|
||||
[tCell config:self.ownerPlacePage forHeight:YES];
|
||||
return tCell.cellHeight;
|
||||
}
|
||||
else if (currentType == MWMPlacePageMetadataTypeOpenHours)
|
||||
else if (field == MWMPlacePageMetadataFieldOpenHours)
|
||||
{
|
||||
[self.openingHoursSizingCell configWithInfo:[entity getFeatureValue:currentType] delegate:self];
|
||||
return self.openingHoursSizingCell.cellHeight;
|
||||
MWMPlacePageOpeningHoursCell * tCell = (MWMPlacePageOpeningHoursCell *)cell;
|
||||
[tCell configWithInfo:[entity getFieldValue:field]
|
||||
editable:[entity isFieldEditable:field]
|
||||
delegate:self];
|
||||
return tCell.cellHeight;
|
||||
}
|
||||
else if (currentType == MWMPlacePageMetadataTypeEditButton)
|
||||
else if (field == MWMPlacePageMetadataFieldEditButton)
|
||||
{
|
||||
return [MWMPlacePageButtonCell height];
|
||||
}
|
||||
|
||||
CGFloat const defaultCellHeight = 44.;
|
||||
CGFloat const defaultWidth = tableView.width;
|
||||
CGFloat const leftOffset = 40.;
|
||||
CGFloat const rightOffset = 22.;
|
||||
UILabel * label = [[UILabel alloc] initWithFrame:CGRectMake(0., 0., defaultWidth - leftOffset - rightOffset, 10.)];
|
||||
label.numberOfLines = 0;
|
||||
label.text = [entity getFeatureValue:currentType];
|
||||
[label sizeToFit];
|
||||
CGFloat const defaultCellOffset = 24.;
|
||||
return MAX(label.height + defaultCellOffset, defaultCellHeight);
|
||||
else
|
||||
{
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
|
||||
{
|
||||
return [self.entity getFeatureTypesCount];
|
||||
return [self.entity getFieldsCount];
|
||||
}
|
||||
|
||||
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
|
||||
{
|
||||
MWMPlacePageEntity * entity = self.entity;
|
||||
MWMPlacePageMetadataType const currentType = [entity getFeatureType:indexPath.row];
|
||||
if (currentType == MWMPlacePageMetadataTypeBookmark)
|
||||
MWMPlacePageMetadataField const field = [entity getFieldType:indexPath.row];
|
||||
UITableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:[self cellIdentifierForField:field]];
|
||||
if (field == MWMPlacePageMetadataFieldBookmark)
|
||||
{
|
||||
MWMPlacePageBookmarkCell * cell = (MWMPlacePageBookmarkCell *)[tableView dequeueReusableCellWithIdentifier:kPlacePageBookmarkCellIdentifier];
|
||||
|
||||
[cell config:self.ownerPlacePage forHeight:NO];
|
||||
return cell;
|
||||
[(MWMPlacePageBookmarkCell *)cell config:self.ownerPlacePage forHeight:NO];
|
||||
}
|
||||
else if (currentType == MWMPlacePageMetadataTypeOpenHours)
|
||||
else if (field == MWMPlacePageMetadataFieldOpenHours)
|
||||
{
|
||||
MWMPlacePageOpeningHoursCell * cell = (MWMPlacePageOpeningHoursCell *)
|
||||
[tableView dequeueReusableCellWithIdentifier:kPlacePageOpeningHoursCellIdentifier];
|
||||
[cell configWithInfo:[entity getFeatureValue:currentType] delegate:self];
|
||||
return cell;
|
||||
[(MWMPlacePageOpeningHoursCell *)cell configWithInfo:[entity getFieldValue:field]
|
||||
editable:[entity isFieldEditable:field]
|
||||
delegate:self];
|
||||
}
|
||||
else if (currentType == MWMPlacePageMetadataTypeEditButton)
|
||||
else if (field == MWMPlacePageMetadataFieldEditButton)
|
||||
{
|
||||
MWMPlacePageButtonCell * cell = (MWMPlacePageButtonCell *)[tableView dequeueReusableCellWithIdentifier:kPlacePageButtonCellIdentifier];
|
||||
[cell config:self.ownerPlacePage];
|
||||
return cell;
|
||||
[(MWMPlacePageButtonCell *)cell config:self.ownerPlacePage];
|
||||
}
|
||||
else
|
||||
{
|
||||
MWMPlacePageInfoCell * tCell = (MWMPlacePageInfoCell *)cell;
|
||||
tCell.currentEntity = self.entity;
|
||||
[tCell configureWithType:field info:[entity getFieldValue:field]];
|
||||
}
|
||||
|
||||
BOOL const isLinkTypeCell = (currentType == MWMPlacePageMetadataTypePhoneNumber || currentType == MWMPlacePageMetadataTypeEmail || currentType == MWMPlacePageMetadataTypeWebsite || currentType == MWMPlacePageMetadataTypeURL);
|
||||
NSString * const cellIdentifier = isLinkTypeCell ? kPlacePageLinkCellIdentifier : kPlacePageInfoCellIdentifier;
|
||||
|
||||
MWMPlacePageInfoCell * cell = (MWMPlacePageInfoCell *)[tableView dequeueReusableCellWithIdentifier:cellIdentifier];
|
||||
|
||||
cell.currentEntity = self.entity;
|
||||
[cell configureWithType:currentType info:[entity getFeatureValue:currentType]];
|
||||
return cell;
|
||||
}
|
||||
|
||||
- (NSString *)cellIdentifierForField:(MWMPlacePageMetadataField)field
|
||||
{
|
||||
switch (field)
|
||||
{
|
||||
case MWMPlacePageMetadataFieldWiFi:
|
||||
case MWMPlacePageMetadataFieldCoordinate:
|
||||
case MWMPlacePageMetadataFieldPostcode:
|
||||
return kPlacePageInfoCellIdentifier;
|
||||
case MWMPlacePageMetadataFieldURL:
|
||||
case MWMPlacePageMetadataFieldWebsite:
|
||||
case MWMPlacePageMetadataFieldEmail:
|
||||
case MWMPlacePageMetadataFieldPhoneNumber:
|
||||
return kPlacePageLinkCellIdentifier;
|
||||
case MWMPlacePageMetadataFieldOpenHours:
|
||||
return kPlacePageOpeningHoursCellIdentifier;
|
||||
case MWMPlacePageMetadataFieldBookmark:
|
||||
return kPlacePageBookmarkCellIdentifier;
|
||||
case MWMPlacePageMetadataFieldEditButton:
|
||||
return kPlacePageButtonCellIdentifier;
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
|
@ -1,24 +1,22 @@
|
|||
#import <Foundation/Foundation.h>
|
||||
|
||||
#include "Framework.h"
|
||||
|
||||
#include "map/user_mark.hpp"
|
||||
|
||||
typedef NS_ENUM (NSUInteger, MWMPlacePageMetadataType)
|
||||
typedef NS_ENUM(NSUInteger, MWMPlacePageMetadataField)
|
||||
{
|
||||
MWMPlacePageMetadataTypePostcode,
|
||||
MWMPlacePageMetadataTypePhoneNumber,
|
||||
MWMPlacePageMetadataTypeWebsite,
|
||||
MWMPlacePageMetadataTypeURL,
|
||||
MWMPlacePageMetadataTypeEmail,
|
||||
MWMPlacePageMetadataTypeOpenHours,
|
||||
MWMPlacePageMetadataTypeCoordinate,
|
||||
MWMPlacePageMetadataTypeWiFi,
|
||||
MWMPlacePageMetadataTypeBookmark,
|
||||
MWMPlacePageMetadataTypeEditButton
|
||||
MWMPlacePageMetadataFieldPostcode,
|
||||
MWMPlacePageMetadataFieldPhoneNumber,
|
||||
MWMPlacePageMetadataFieldWebsite,
|
||||
MWMPlacePageMetadataFieldURL,
|
||||
MWMPlacePageMetadataFieldEmail,
|
||||
MWMPlacePageMetadataFieldOpenHours,
|
||||
MWMPlacePageMetadataFieldCoordinate,
|
||||
MWMPlacePageMetadataFieldWiFi,
|
||||
MWMPlacePageMetadataFieldBookmark,
|
||||
MWMPlacePageMetadataFieldEditButton
|
||||
};
|
||||
|
||||
typedef NS_ENUM (NSUInteger, MWMPlacePageEntityType)
|
||||
typedef NS_ENUM(NSUInteger, MWMPlacePageEntityType)
|
||||
{
|
||||
MWMPlacePageEntityTypeRegular,
|
||||
MWMPlacePageEntityTypeBookmark,
|
||||
|
@ -58,8 +56,9 @@ typedef NS_ENUM (NSUInteger, MWMPlacePageEntityType)
|
|||
|
||||
- (void)toggleCoordinateSystem;
|
||||
|
||||
- (NSUInteger)getFeatureTypesCount;
|
||||
- (MWMPlacePageMetadataType)getFeatureType:(NSUInteger)index;
|
||||
- (NSString *)getFeatureValue:(MWMPlacePageMetadataType)type;
|
||||
- (NSUInteger)getFieldsCount;
|
||||
- (MWMPlacePageMetadataField)getFieldType:(NSUInteger)index;
|
||||
- (NSString *)getFieldValue:(MWMPlacePageMetadataField)field;
|
||||
- (BOOL)isFieldEditable:(MWMPlacePageMetadataField)field;
|
||||
|
||||
@end
|
||||
|
|
|
@ -9,25 +9,26 @@ using feature::Metadata;
|
|||
|
||||
extern NSString * const kUserDefaultsLatLonAsDMSKey = @"UserDefaultsLatLonAsDMS";
|
||||
|
||||
static array<MWMPlacePageMetadataType, 8> const kPatternTypesArray{
|
||||
{MWMPlacePageMetadataTypePostcode, MWMPlacePageMetadataTypePhoneNumber,
|
||||
MWMPlacePageMetadataTypeWebsite, MWMPlacePageMetadataTypeURL, MWMPlacePageMetadataTypeEmail,
|
||||
MWMPlacePageMetadataTypeOpenHours, MWMPlacePageMetadataTypeWiFi,
|
||||
MWMPlacePageMetadataTypeCoordinate}};
|
||||
static array<MWMPlacePageMetadataField, 8> const kPatternFieldsArray{
|
||||
{MWMPlacePageMetadataFieldPostcode, MWMPlacePageMetadataFieldPhoneNumber,
|
||||
MWMPlacePageMetadataFieldWebsite, MWMPlacePageMetadataFieldURL, MWMPlacePageMetadataFieldEmail,
|
||||
MWMPlacePageMetadataFieldOpenHours, MWMPlacePageMetadataFieldWiFi,
|
||||
MWMPlacePageMetadataFieldCoordinate}};
|
||||
|
||||
static map<Metadata::EType, MWMPlacePageMetadataType> const kMetaTypesMap{
|
||||
{Metadata::FMD_URL, MWMPlacePageMetadataTypeURL},
|
||||
{Metadata::FMD_WEBSITE, MWMPlacePageMetadataTypeWebsite},
|
||||
{Metadata::FMD_PHONE_NUMBER, MWMPlacePageMetadataTypePhoneNumber},
|
||||
{Metadata::FMD_OPEN_HOURS, MWMPlacePageMetadataTypeOpenHours},
|
||||
{Metadata::FMD_EMAIL, MWMPlacePageMetadataTypeEmail},
|
||||
{Metadata::FMD_POSTCODE, MWMPlacePageMetadataTypePostcode},
|
||||
{Metadata::FMD_INTERNET, MWMPlacePageMetadataTypeWiFi}};
|
||||
static map<Metadata::EType, MWMPlacePageMetadataField> const kMetaFieldsMap{
|
||||
{Metadata::FMD_URL, MWMPlacePageMetadataFieldURL},
|
||||
{Metadata::FMD_WEBSITE, MWMPlacePageMetadataFieldWebsite},
|
||||
{Metadata::FMD_PHONE_NUMBER, MWMPlacePageMetadataFieldPhoneNumber},
|
||||
{Metadata::FMD_OPEN_HOURS, MWMPlacePageMetadataFieldOpenHours},
|
||||
{Metadata::FMD_EMAIL, MWMPlacePageMetadataFieldEmail},
|
||||
{Metadata::FMD_POSTCODE, MWMPlacePageMetadataFieldPostcode},
|
||||
{Metadata::FMD_INTERNET, MWMPlacePageMetadataFieldWiFi}};
|
||||
|
||||
@implementation MWMPlacePageEntity
|
||||
{
|
||||
vector<MWMPlacePageMetadataType> m_types;
|
||||
map<MWMPlacePageMetadataType, string> m_values;
|
||||
vector<MWMPlacePageMetadataField> m_fields;
|
||||
set<MWMPlacePageMetadataField> m_editableFields;
|
||||
map<MWMPlacePageMetadataField, string> m_values;
|
||||
}
|
||||
|
||||
- (instancetype)initWithUserMark:(UserMark const *)userMark
|
||||
|
@ -63,37 +64,37 @@ static map<Metadata::EType, MWMPlacePageMetadataType> const kMetaTypesMap{
|
|||
[self configureForBookmark:mark];
|
||||
break;
|
||||
}
|
||||
[self addEditableTypes];
|
||||
[self sortMeta];
|
||||
[self setEditableFields];
|
||||
[self sortMetaFields];
|
||||
}
|
||||
|
||||
- (void)sortMeta
|
||||
- (void)sortMetaFields
|
||||
{
|
||||
auto begin = kPatternTypesArray.begin();
|
||||
auto end = kPatternTypesArray.end();
|
||||
sort(m_types.begin(), m_types.end(), [&](MWMPlacePageMetadataType a, MWMPlacePageMetadataType b)
|
||||
auto begin = kPatternFieldsArray.begin();
|
||||
auto end = kPatternFieldsArray.end();
|
||||
sort(m_fields.begin(), m_fields.end(), [&](MWMPlacePageMetadataField a, MWMPlacePageMetadataField b)
|
||||
{
|
||||
return find(begin, end, a) < find(begin, end, b);
|
||||
});
|
||||
}
|
||||
|
||||
- (void)addMetaType:(MWMPlacePageMetadataType)type
|
||||
- (void)addMetaField:(MWMPlacePageMetadataField)field
|
||||
{
|
||||
if (find(m_types.begin(), m_types.end(), type) == m_types.end())
|
||||
m_types.emplace_back(type);
|
||||
if (find(m_fields.begin(), m_fields.end(), field) == m_fields.end())
|
||||
m_fields.emplace_back(field);
|
||||
}
|
||||
|
||||
- (void)removeMetaType:(MWMPlacePageMetadataType)type
|
||||
- (void)removeMetaField:(MWMPlacePageMetadataField)field
|
||||
{
|
||||
auto it = find(m_types.begin(), m_types.end(), type);
|
||||
if (it != m_types.end())
|
||||
m_types.erase(it);
|
||||
auto it = find(m_fields.begin(), m_fields.end(), field);
|
||||
if (it != m_fields.end())
|
||||
m_fields.erase(it);
|
||||
}
|
||||
|
||||
- (void)addMetaType:(MWMPlacePageMetadataType)type value:(string const &)value
|
||||
- (void)addMetaField:(MWMPlacePageMetadataField)field value:(string const &)value
|
||||
{
|
||||
[self addMetaType:type];
|
||||
m_values.emplace(type, value);
|
||||
[self addMetaField:field];
|
||||
m_values.emplace(field, value);
|
||||
}
|
||||
|
||||
- (void)configureForBookmark:(UserMark const *)bookmark
|
||||
|
@ -138,7 +139,7 @@ static map<Metadata::EType, MWMPlacePageMetadataType> const kMetaTypesMap{
|
|||
{
|
||||
self.title = L(@"my_position");
|
||||
self.type = MWMPlacePageEntityTypeMyPosition;
|
||||
[self addMetaType:MWMPlacePageMetadataTypeCoordinate];
|
||||
[self addMetaField:MWMPlacePageMetadataFieldCoordinate];
|
||||
}
|
||||
|
||||
- (void)configureForApi:(ApiMarkPoint const *)apiMark
|
||||
|
@ -146,7 +147,7 @@ static map<Metadata::EType, MWMPlacePageMetadataType> const kMetaTypesMap{
|
|||
self.type = MWMPlacePageEntityTypeAPI;
|
||||
self.title = @(apiMark->GetName().c_str());
|
||||
self.category = @(GetFramework().GetApiDataHolder().GetAppTitle().c_str());
|
||||
[self addMetaType:MWMPlacePageMetadataTypeCoordinate];
|
||||
[self addMetaField:MWMPlacePageMetadataFieldCoordinate];
|
||||
}
|
||||
|
||||
- (void)configureEntityWithMetadata:(Metadata const &)metadata addressInfo:(search::AddressInfo const &)info
|
||||
|
@ -210,32 +211,32 @@ 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)];
|
||||
[self addMetaField:kMetaFieldsMap.at(type) value:metadata.Get(type)];
|
||||
break;
|
||||
case Metadata::FMD_INTERNET:
|
||||
[self addMetaType:kMetaTypesMap.at(type) value:L(@"WiFi_available").UTF8String];
|
||||
[self addMetaField:kMetaFieldsMap.at(type) value:L(@"WiFi_available").UTF8String];
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
[self addMetaType:MWMPlacePageMetadataTypeCoordinate];
|
||||
[self addMetaField:MWMPlacePageMetadataFieldCoordinate];
|
||||
}
|
||||
|
||||
- (void)enableEditing
|
||||
{
|
||||
[self addMetaType:MWMPlacePageMetadataTypeEditButton];
|
||||
[self addMetaField:MWMPlacePageMetadataFieldEditButton];
|
||||
}
|
||||
|
||||
- (void)insertBookmarkInTypes
|
||||
{
|
||||
[self addMetaType:MWMPlacePageMetadataTypeBookmark];
|
||||
[self addMetaField:MWMPlacePageMetadataFieldBookmark];
|
||||
}
|
||||
|
||||
- (void)removeBookmarkFromTypes
|
||||
{
|
||||
[self removeMetaType:MWMPlacePageMetadataTypeBookmark];
|
||||
[self removeMetaField:MWMPlacePageMetadataFieldBookmark];
|
||||
}
|
||||
|
||||
- (void)toggleCoordinateSystem
|
||||
|
@ -247,29 +248,42 @@ static map<Metadata::EType, MWMPlacePageMetadataType> const kMetaTypesMap{
|
|||
|
||||
#pragma mark - Editing
|
||||
|
||||
- (void)addEditableTypes
|
||||
- (void)setEditableFields
|
||||
{
|
||||
// TODO: Add real logic
|
||||
// TODO: Replace with real array
|
||||
vector<Metadata::EType> const editableTypes {Metadata::FMD_OPEN_HOURS};
|
||||
//osm::Editor::Instance().EditableMetadataForType(<#const FeatureType &feature#>);
|
||||
for (auto const & type : editableTypes)
|
||||
{
|
||||
MWMPlacePageMetadataField uiType = kMetaFieldsMap.at(type);
|
||||
[self addMetaField:uiType];
|
||||
m_editableFields.insert(uiType);
|
||||
}
|
||||
}
|
||||
|
||||
- (BOOL)isFieldEditable:(MWMPlacePageMetadataField)field
|
||||
{
|
||||
return m_editableFields.count(field) == 1;
|
||||
}
|
||||
|
||||
#pragma mark - Getters
|
||||
|
||||
- (NSUInteger)getFeatureTypesCount
|
||||
- (NSUInteger)getFieldsCount
|
||||
{
|
||||
return m_types.size();
|
||||
return m_fields.size();
|
||||
}
|
||||
|
||||
- (MWMPlacePageMetadataType)getFeatureType:(NSUInteger)index
|
||||
- (MWMPlacePageMetadataField)getFieldType:(NSUInteger)index
|
||||
{
|
||||
NSAssert(index < [self getFeatureTypesCount], @"Invalid meta index");
|
||||
return m_types[index];
|
||||
NSAssert(index < [self getFieldsCount], @"Invalid meta index");
|
||||
return m_fields[index];
|
||||
}
|
||||
|
||||
- (NSString *)getFeatureValue:(MWMPlacePageMetadataType)type
|
||||
- (NSString *)getFieldValue:(MWMPlacePageMetadataField)field
|
||||
{
|
||||
if (type == MWMPlacePageMetadataTypeCoordinate)
|
||||
if (field == MWMPlacePageMetadataFieldCoordinate)
|
||||
return [self coordinate];
|
||||
auto it = m_values.find(type);
|
||||
auto it = m_values.find(field);
|
||||
return it != m_values.end() ? @(it->second.c_str()) : nil;
|
||||
}
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
@interface MWMPlacePageInfoCell : MWMTableViewCell
|
||||
|
||||
- (void)configureWithType:(MWMPlacePageMetadataType)type info:(NSString *)info;
|
||||
- (void)configureWithType:(MWMPlacePageMetadataField)type info:(NSString *)info;
|
||||
|
||||
@property (weak, nonatomic, readonly) IBOutlet UIImageView * icon;
|
||||
@property (weak, nonatomic, readonly) IBOutlet id textContainer;
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
@property (weak, nonatomic) IBOutlet UIButton * upperButton;
|
||||
@property (weak, nonatomic) IBOutlet UIImageView * toggleImage;
|
||||
|
||||
@property (nonatomic) MWMPlacePageMetadataType type;
|
||||
@property (nonatomic) MWMPlacePageMetadataField type;
|
||||
|
||||
@end
|
||||
|
||||
|
@ -29,39 +29,39 @@
|
|||
[(UITextView *)self.textContainer setTextContainerInset:{.top = 12, 0, 0, 0}];
|
||||
}
|
||||
|
||||
- (void)configureWithType:(MWMPlacePageMetadataType)type info:(NSString *)info;
|
||||
- (void)configureWithType:(MWMPlacePageMetadataField)type info:(NSString *)info;
|
||||
{
|
||||
NSString * typeName;
|
||||
switch (type)
|
||||
{
|
||||
case MWMPlacePageMetadataTypeURL:
|
||||
case MWMPlacePageMetadataTypeWebsite:
|
||||
case MWMPlacePageMetadataFieldURL:
|
||||
case MWMPlacePageMetadataFieldWebsite:
|
||||
self.toggleImage.hidden = YES;
|
||||
typeName = @"website";
|
||||
break;
|
||||
case MWMPlacePageMetadataTypeEmail:
|
||||
case MWMPlacePageMetadataFieldEmail:
|
||||
self.toggleImage.hidden = YES;
|
||||
typeName = @"email";
|
||||
break;
|
||||
case MWMPlacePageMetadataTypePhoneNumber:
|
||||
case MWMPlacePageMetadataFieldPhoneNumber:
|
||||
self.toggleImage.hidden = YES;
|
||||
typeName = @"phone_number";
|
||||
break;
|
||||
case MWMPlacePageMetadataTypeCoordinate:
|
||||
case MWMPlacePageMetadataFieldCoordinate:
|
||||
self.toggleImage.hidden = NO;
|
||||
typeName = @"coordinate";
|
||||
break;
|
||||
case MWMPlacePageMetadataTypePostcode:
|
||||
case MWMPlacePageMetadataFieldPostcode:
|
||||
self.toggleImage.hidden = YES;
|
||||
typeName = @"postcode";
|
||||
break;
|
||||
case MWMPlacePageMetadataTypeWiFi:
|
||||
case MWMPlacePageMetadataFieldWiFi:
|
||||
self.toggleImage.hidden = YES;
|
||||
typeName = @"wifi";
|
||||
break;
|
||||
case MWMPlacePageMetadataTypeBookmark:
|
||||
case MWMPlacePageMetadataTypeEditButton:
|
||||
case MWMPlacePageMetadataTypeOpenHours:
|
||||
case MWMPlacePageMetadataFieldBookmark:
|
||||
case MWMPlacePageMetadataFieldEditButton:
|
||||
case MWMPlacePageMetadataFieldOpenHours:
|
||||
NSAssert(false, @"Incorrect type!");
|
||||
break;
|
||||
}
|
||||
|
@ -106,20 +106,20 @@
|
|||
{
|
||||
switch (self.type)
|
||||
{
|
||||
case MWMPlacePageMetadataTypeURL:
|
||||
case MWMPlacePageMetadataTypeWebsite:
|
||||
case MWMPlacePageMetadataFieldURL:
|
||||
case MWMPlacePageMetadataFieldWebsite:
|
||||
[[Statistics instance] logEvent:kStatEventName(kStatPlacePage, kStatOpenSite)];
|
||||
break;
|
||||
case MWMPlacePageMetadataTypeEmail:
|
||||
case MWMPlacePageMetadataFieldEmail:
|
||||
[[Statistics instance] logEvent:kStatEventName(kStatPlacePage, kStatSendEmail)];
|
||||
break;
|
||||
case MWMPlacePageMetadataTypePhoneNumber:
|
||||
case MWMPlacePageMetadataFieldPhoneNumber:
|
||||
[[Statistics instance] logEvent:kStatEventName(kStatPlacePage, kStatCallPhoneNumber)];
|
||||
break;
|
||||
case MWMPlacePageMetadataTypeCoordinate:
|
||||
case MWMPlacePageMetadataFieldCoordinate:
|
||||
[[Statistics instance] logEvent:kStatEventName(kStatPlacePage, kStatToggleCoordinates)];
|
||||
[self.currentEntity toggleCoordinateSystem];
|
||||
[self changeText:[self.currentEntity getFeatureValue:MWMPlacePageMetadataTypeCoordinate]];
|
||||
[self changeText:[self.currentEntity getFieldValue:MWMPlacePageMetadataFieldCoordinate]];
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
|
|
@ -802,7 +802,7 @@ typedef NS_ENUM(NSUInteger, UserTouchesAction)
|
|||
self.skipDismissOnViewDisappear = YES;
|
||||
MWMPlacePageEntity * entity = sender;
|
||||
MWMOpeningHoursEditorViewController * dvc = segue.destinationViewController;
|
||||
dvc.openingHours = [entity getFeatureValue:MWMPlacePageMetadataTypeOpenHours];
|
||||
dvc.openingHours = [entity getFieldValue:MWMPlacePageMetadataFieldOpenHours];
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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="44"/>
|
||||
<rect key="frame" x="0.0" y="0.0" width="320" height="43.5"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<subviews>
|
||||
<imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="xwC-DR-6Il">
|
||||
|
@ -22,9 +22,12 @@
|
|||
</constraints>
|
||||
</imageView>
|
||||
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" preferredMaxLayoutWidth="228" translatesAutoresizingMaskIntoConstraints="NO" id="viE-zJ-wsl" customClass="CopyLabel">
|
||||
<rect key="frame" x="60" y="12" width="228" height="20"/>
|
||||
<rect key="frame" x="60" y="0.0" width="228" height="42"/>
|
||||
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
|
||||
<gestureRecognizers/>
|
||||
<constraints>
|
||||
<constraint firstAttribute="height" relation="greaterThanOrEqual" constant="42" id="26Z-I0-jym"/>
|
||||
</constraints>
|
||||
<fontDescription key="fontDescription" name="HelveticaNeue" family="Helvetica Neue" pointSize="17"/>
|
||||
<color key="textColor" red="0.12941176469999999" green="0.12941176469999999" blue="0.12941176469999999" alpha="1" colorSpace="calibratedRGB"/>
|
||||
<nil key="highlightedColor"/>
|
||||
|
@ -67,10 +70,11 @@
|
|||
<constraint firstItem="xwC-DR-6Il" firstAttribute="centerY" secondItem="KHz-zH-ymS" secondAttribute="centerY" id="CYL-hn-gD1"/>
|
||||
<constraint firstAttribute="bottom" secondItem="vu9-VL-9jn" secondAttribute="bottom" id="GwU-YF-i08"/>
|
||||
<constraint firstItem="viE-zJ-wsl" firstAttribute="leading" secondItem="KHz-zH-ymS" secondAttribute="leading" constant="60" id="OiU-eg-c9z"/>
|
||||
<constraint firstItem="viE-zJ-wsl" firstAttribute="centerY" secondItem="KHz-zH-ymS" secondAttribute="centerY" id="Xmo-J0-JuP"/>
|
||||
<constraint firstItem="viE-zJ-wsl" firstAttribute="top" secondItem="KHz-zH-ymS" secondAttribute="top" id="Us6-HP-TU4"/>
|
||||
<constraint firstItem="CNm-TR-GPW" firstAttribute="leading" secondItem="KHz-zH-ymS" secondAttribute="leading" constant="60" id="YBm-HI-8QY"/>
|
||||
<constraint firstItem="RZw-oW-agi" firstAttribute="leading" secondItem="viE-zJ-wsl" secondAttribute="trailing" id="b4Y-Av-Oa4"/>
|
||||
<constraint firstItem="vu9-VL-9jn" firstAttribute="leading" secondItem="KHz-zH-ymS" secondAttribute="leading" id="bwh-x8-HDj"/>
|
||||
<constraint firstItem="CNm-TR-GPW" firstAttribute="top" secondItem="viE-zJ-wsl" secondAttribute="bottom" id="ckP-Yd-RUt"/>
|
||||
<constraint firstItem="RZw-oW-agi" firstAttribute="centerY" secondItem="KHz-zH-ymS" secondAttribute="centerY" id="ftp-Ze-2yH"/>
|
||||
<constraint firstItem="vu9-VL-9jn" firstAttribute="top" secondItem="KHz-zH-ymS" secondAttribute="top" id="hAZ-rE-oQa"/>
|
||||
<constraint firstAttribute="trailing" secondItem="CNm-TR-GPW" secondAttribute="trailing" id="j04-QC-yoJ"/>
|
||||
|
|
|
@ -22,8 +22,11 @@
|
|||
</constraints>
|
||||
</imageView>
|
||||
<textView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" scrollEnabled="NO" showsHorizontalScrollIndicator="NO" showsVerticalScrollIndicator="NO" editable="NO" translatesAutoresizingMaskIntoConstraints="NO" id="T5l-Sb-Hfo">
|
||||
<rect key="frame" x="60" y="0.0" width="228" height="42"/>
|
||||
<rect key="frame" x="60" y="0.0" width="228" height="43"/>
|
||||
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
|
||||
<constraints>
|
||||
<constraint firstAttribute="height" relation="greaterThanOrEqual" constant="42" id="2uD-kp-7lD"/>
|
||||
</constraints>
|
||||
<string key="text">Lorem ipsum dolor sit er elit lamet, consectetaur cillium adipisicing pecu, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Nam liber te conscient to factor tum poen legum odioque civiuda.</string>
|
||||
<fontDescription key="fontDescription" type="system" weight="light" pointSize="16"/>
|
||||
<textInputTraits key="textInputTraits" autocapitalizationType="sentences"/>
|
||||
|
@ -33,7 +36,7 @@
|
|||
</connections>
|
||||
</textView>
|
||||
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="ZSw-Rd-B64" userLabel="Separator">
|
||||
<rect key="frame" x="60" y="42" width="260" height="1"/>
|
||||
<rect key="frame" x="60" y="43" width="260" height="1"/>
|
||||
<color key="backgroundColor" red="0.0" green="0.0" blue="0.0" alpha="0.12" colorSpace="calibratedRGB"/>
|
||||
<constraints>
|
||||
<constraint firstAttribute="height" constant="1" id="hIQ-vD-PeI"/>
|
||||
|
|
Loading…
Add table
Reference in a new issue