forked from organicmaps/organicmaps
[ios] Review fixes.
This commit is contained in:
parent
966d821003
commit
70c61b34ec
21 changed files with 197 additions and 196 deletions
|
@ -77,12 +77,12 @@ static NSString * const kStatisticsEvent = @"Pedestrian Share Alert";
|
|||
|
||||
- (void)rotate:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration
|
||||
{
|
||||
// Overriden implemantation left empty since this view is added to the view controller handling device rotation
|
||||
// Overridden implemantation left empty since this view is added to the view controller handling device rotation
|
||||
}
|
||||
|
||||
- (void)addControllerViewToWindow
|
||||
{
|
||||
// Overriden implemantation left empty to let sharing view appear above
|
||||
// Overridden implemantation left empty to let sharing view appear above
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
|
@ -10,4 +10,4 @@ typedef NS_OPTIONS(NSUInteger, MWMAuthorizationButtonType)
|
|||
};
|
||||
|
||||
UIColor * MWMAuthorizationButtonBackgroundColor(MWMAuthorizationButtonType type);
|
||||
void MWMAuthorizationConfigButton(UIButton * btn, MWMAuthorizationButtonType type);
|
||||
void MWMAuthorizationConfigButton(UIButton * btn, MWMAuthorizationButtonType type);
|
||||
|
|
|
@ -23,7 +23,7 @@ UIColor * MWMAuthorizationButtonBackgroundColor(MWMAuthorizationButtonType type)
|
|||
case MWMAuthorizationButtonTypeFacebook:
|
||||
return [UIColor colorWithRed:72. / 255. green:97. / 255. blue:163. / 255. alpha:1.];
|
||||
case MWMAuthorizationButtonTypeOSM:
|
||||
return [UIColor colorWithRed:3. / 255. green:122. / 255. blue:1. alpha:1.];
|
||||
return [UIColor colorWithRed:30. / 255. green:150. / 255. blue:240. / 255. alpha:1.];
|
||||
}
|
||||
return [UIColor clearColor];
|
||||
}
|
||||
|
|
|
@ -20,10 +20,6 @@
|
|||
{
|
||||
[super viewDidLoad];
|
||||
self.backgroundImage.image = [UIImage imageWithColor:[UIColor primary]];
|
||||
|
||||
MWMAuthorizationConfigButton(self.loginGoogleButton, MWMAuthorizationButtonTypeGoogle);
|
||||
MWMAuthorizationConfigButton(self.loginFacebookButton, MWMAuthorizationButtonTypeFacebook);
|
||||
MWMAuthorizationConfigButton(self.loginOSMButton, MWMAuthorizationButtonTypeOSM);
|
||||
[self checkConnection];
|
||||
}
|
||||
|
||||
|
@ -57,6 +53,16 @@
|
|||
self.loginGoogleButton.enabled = isConnected;
|
||||
self.loginFacebookButton.enabled = isConnected;
|
||||
self.signupButton.enabled = isConnected;
|
||||
|
||||
MWMAuthorizationConfigButton(self.loginGoogleButton, MWMAuthorizationButtonTypeGoogle);
|
||||
MWMAuthorizationConfigButton(self.loginFacebookButton, MWMAuthorizationButtonTypeFacebook);
|
||||
MWMAuthorizationConfigButton(self.loginOSMButton, MWMAuthorizationButtonTypeOSM);
|
||||
|
||||
if (!isConnected)
|
||||
{
|
||||
self.loginGoogleButton.layer.borderColor = [UIColor clearColor].CGColor;
|
||||
self.loginFacebookButton.layer.borderColor = [UIColor clearColor].CGColor;
|
||||
}
|
||||
}
|
||||
|
||||
#pragma mark - Actions
|
||||
|
|
|
@ -111,8 +111,8 @@ typedef NS_OPTIONS(NSUInteger, MWMFieldCorrect)
|
|||
// TODO: Add async loader spinner
|
||||
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_BACKGROUND, 0), ^
|
||||
{
|
||||
string username = self.loginTextField.text.UTF8String;
|
||||
string password = self.passwordTextField.text.UTF8String;
|
||||
string const username = self.loginTextField.text.UTF8String;
|
||||
string const password = self.passwordTextField.text.UTF8String;
|
||||
BOOL const credentialsOK = osm::ServerApi06(username, password).CheckUserAndPassword();
|
||||
dispatch_async(dispatch_get_main_queue(), ^
|
||||
{
|
||||
|
|
|
@ -72,7 +72,7 @@ WeekDayView getWeekDayView()
|
|||
BOOL const isExpanded = delegate.openingHoursCellExpanded;
|
||||
self.middleSeparator.hidden = !isExpanded;
|
||||
self.weekDaysView.hidden = !isExpanded;
|
||||
self.editButton.hidden = NO;
|
||||
self.editButton.hidden = !isExpanded;
|
||||
self.expandImage.image = [UIImage imageNamed:isExpanded ? @"ic_arrow_gray_up" : @"ic_arrow_gray_down"];
|
||||
}
|
||||
else
|
||||
|
@ -93,11 +93,11 @@ WeekDayView getWeekDayView()
|
|||
Weekday currentDay = static_cast<Weekday>([cal component:NSCalendarUnitWeekday fromDate:[NSDate date]]);
|
||||
BOOL haveCurrentDay = NO;
|
||||
size_t timeTablesCount = timeTableSet.Size();
|
||||
BOOL const canExpand = (timeTablesCount > 1);
|
||||
BOOL const haveExpandSchedule = (timeTablesCount > 1);
|
||||
BOOL const isExpanded = self.delegate.openingHoursCellExpanded;
|
||||
self.weekDaysViewEstimatedHeight = 0.0;
|
||||
[self.weekDaysView.subviews makeObjectsPerformSelector:@selector(removeFromSuperview)];
|
||||
[self.currentDay setCanExpand:canExpand];
|
||||
[self.currentDay setCanExpand:YES];
|
||||
for (size_t idx = 0; idx < timeTablesCount; ++idx)
|
||||
{
|
||||
ui::TTimeTableProxy tt = timeTableSet.Get(idx);
|
||||
|
@ -107,12 +107,12 @@ WeekDayView getWeekDayView()
|
|||
haveCurrentDay = YES;
|
||||
[self addCurrentDay:tt];
|
||||
}
|
||||
if (canExpand && isExpanded)
|
||||
if (haveExpandSchedule && isExpanded)
|
||||
[self addWeekDays:tt];
|
||||
}
|
||||
if (!haveCurrentDay)
|
||||
[self addEmptyCurrentDay];
|
||||
if (canExpand && isExpanded)
|
||||
if (haveExpandSchedule && isExpanded)
|
||||
[self addClosedDays];
|
||||
self.weekDaysViewHeight.constant = ceil(self.weekDaysViewEstimatedHeight);
|
||||
}
|
||||
|
@ -186,9 +186,7 @@ WeekDayView getWeekDayView()
|
|||
{
|
||||
CGFloat height = self.currentDay.viewHeight;
|
||||
if (!self.currentDay.isCompatibility && self.delegate.openingHoursCellExpanded)
|
||||
height += self.weekDaysViewHeight.constant;
|
||||
if (!self.editButton.hidden)
|
||||
height += self.editButton.height;
|
||||
height += self.weekDaysViewHeight.constant + self.editButton.height;
|
||||
return ceil(height);
|
||||
}
|
||||
|
||||
|
|
|
@ -31,6 +31,7 @@ extern NSDictionary * const kMWMOpeningHoursEditorTableCells = @{
|
|||
@property (weak, nonatomic, readwrite) IBOutlet UIButton * toggleModeButton;
|
||||
|
||||
@property (nonatomic) BOOL exampleExpanded;
|
||||
@property (nonatomic) BOOL isSimpleMode;
|
||||
|
||||
@property (nonatomic) MWMOpeningHoursModel * model;
|
||||
|
||||
|
@ -71,13 +72,13 @@ extern NSDictionary * const kMWMOpeningHoursEditorTableCells = @{
|
|||
|
||||
- (void)configAdvancedEditor
|
||||
{
|
||||
[self.editorView setTextContainerInset:{12, 10, 12, 10}];
|
||||
[self setExampleExpanded:NO];
|
||||
[self.editorView setTextContainerInset:{.top = 12, .left = 10, .bottom = 12, .right = 10}];
|
||||
}
|
||||
|
||||
- (void)configData
|
||||
{
|
||||
self.model = [[MWMOpeningHoursModel alloc] initWithDelegate:self];
|
||||
self.isSimpleMode = self.model.isSimpleModeCapable;
|
||||
}
|
||||
|
||||
#pragma mark - Actions
|
||||
|
@ -183,7 +184,7 @@ extern NSDictionary * const kMWMOpeningHoursEditorTableCells = @{
|
|||
|
||||
- (IBAction)toggleMode
|
||||
{
|
||||
self.model.isSimpleMode = !self.model.isSimpleMode;
|
||||
self.isSimpleMode = !self.isSimpleMode;
|
||||
}
|
||||
|
||||
#pragma mark - UITextViewDelegate
|
||||
|
@ -195,4 +196,18 @@ extern NSDictionary * const kMWMOpeningHoursEditorTableCells = @{
|
|||
self.toggleModeButton.enabled = self.model.isSimpleModeCapable;
|
||||
}
|
||||
|
||||
#pragma mark - Properties
|
||||
|
||||
- (void)setIsSimpleMode:(BOOL)isSimpleMode
|
||||
{
|
||||
self.model.isSimpleMode = isSimpleMode;
|
||||
if (!isSimpleMode)
|
||||
self.exampleExpanded = NO;
|
||||
}
|
||||
|
||||
- (BOOL)isSimpleMode
|
||||
{
|
||||
return self.model.isSimpleMode;
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
|
@ -27,10 +27,7 @@ using namespace osmoh;
|
|||
{
|
||||
self = [super init];
|
||||
if (self)
|
||||
{
|
||||
self.delegate = delegate;
|
||||
self.isSimpleMode = self.isSimpleModeCapable;
|
||||
}
|
||||
_delegate = delegate;
|
||||
return self;
|
||||
}
|
||||
|
||||
|
@ -168,7 +165,6 @@ using namespace osmoh;
|
|||
id<MWMOpeningHoursModelProtocol> delegate = self.delegate;
|
||||
if (isSimpleMode && MakeTimeTableSet(osmoh::OpeningHours(delegate.openingHours.UTF8String), timeTableSet))
|
||||
{
|
||||
_isSimpleMode = YES;
|
||||
delegate.tableView.hidden = NO;
|
||||
delegate.advancedEditor.hidden = YES;
|
||||
[delegate.toggleModeButton setTitle:L(@"advanced_mode") forState:UIControlStateNormal];
|
||||
|
@ -179,7 +175,6 @@ using namespace osmoh;
|
|||
}
|
||||
else
|
||||
{
|
||||
_isSimpleMode = NO;
|
||||
[self updateOpeningHours];
|
||||
delegate.tableView.hidden = YES;
|
||||
delegate.advancedEditor.hidden = NO;
|
||||
|
|
|
@ -15,7 +15,7 @@ static NSString * const kEmailRegexPattern = @"[A-Z0-9a-z._%+-]+@[A-Za-z0-9.-]+\
|
|||
error:&err];
|
||||
NSAssert(!err, @"Invalid regular expression");
|
||||
NSMutableArray<NSString *> * matches = [@[] mutableCopy];
|
||||
NSRange const range = {0, string.length};
|
||||
NSRange const range{0, string.length};
|
||||
[regex enumerateMatchesInString:string
|
||||
options:NSMatchingReportProgress
|
||||
range:range
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
return [[MWMInputPasswordValidator alloc] init];
|
||||
if ([validator isEqualToString:[MWMInputEmailValidator className]])
|
||||
return [[MWMInputEmailValidator alloc] init];
|
||||
NSAssert(false, @"Invalid validator requested.");
|
||||
return [[MWMInputValidator alloc] init];
|
||||
}
|
||||
|
||||
|
|
|
@ -269,9 +269,8 @@ extern CGFloat const kBasePlacePageViewTitleBottomOffset = 2.;
|
|||
|
||||
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
|
||||
{
|
||||
|
||||
MWMPlacePageMetadataType currentType = (MWMPlacePageMetadataType)[self.entity.metadataTypes[indexPath.row] integerValue];
|
||||
|
||||
MWMPlacePageEntity * entity = self.entity;
|
||||
MWMPlacePageMetadataType const currentType = [entity getType:indexPath.row];
|
||||
if (currentType == MWMPlacePageMetadataTypeBookmark)
|
||||
{
|
||||
[self.bookmarkSizingCell config:self.ownerPlacePage forHeight:YES];
|
||||
|
@ -279,8 +278,7 @@ extern CGFloat const kBasePlacePageViewTitleBottomOffset = 2.;
|
|||
}
|
||||
else if (currentType == MWMPlacePageMetadataTypeOpenHours)
|
||||
{
|
||||
[self.openingHoursSizingCell configWithInfo:self.entity.metadataValues[indexPath.row]
|
||||
delegate:self];
|
||||
[self.openingHoursSizingCell configWithInfo:[entity getValue:currentType] delegate:self];
|
||||
return self.openingHoursSizingCell.cellHeight;
|
||||
}
|
||||
else if (currentType == MWMPlacePageMetadataTypeEditButton)
|
||||
|
@ -294,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 = self.entity.metadataValues[indexPath.row];
|
||||
label.text = [entity getValue:currentType];
|
||||
[label sizeToFit];
|
||||
CGFloat const defaultCellOffset = 24.;
|
||||
return MAX(label.height + defaultCellOffset, defaultCellHeight);
|
||||
|
@ -302,13 +300,13 @@ extern CGFloat const kBasePlacePageViewTitleBottomOffset = 2.;
|
|||
|
||||
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
|
||||
{
|
||||
return self.entity.metadataTypes.count;
|
||||
return [self.entity getTypesCount];
|
||||
}
|
||||
|
||||
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
|
||||
{
|
||||
MWMPlacePageMetadataType currentType = (MWMPlacePageMetadataType)[self.entity.metadataTypes[indexPath.row] integerValue];
|
||||
|
||||
MWMPlacePageEntity * entity = self.entity;
|
||||
MWMPlacePageMetadataType const currentType = [entity getType:indexPath.row];
|
||||
if (currentType == MWMPlacePageMetadataTypeBookmark)
|
||||
{
|
||||
MWMPlacePageBookmarkCell * cell = (MWMPlacePageBookmarkCell *)[tableView dequeueReusableCellWithIdentifier:kPlacePageBookmarkCellIdentifier];
|
||||
|
@ -320,8 +318,7 @@ extern CGFloat const kBasePlacePageViewTitleBottomOffset = 2.;
|
|||
{
|
||||
MWMPlacePageOpeningHoursCell * cell = (MWMPlacePageOpeningHoursCell *)
|
||||
[tableView dequeueReusableCellWithIdentifier:kPlacePageOpeningHoursCellIdentifier];
|
||||
[cell configWithInfo:self.entity.metadataValues[indexPath.row]
|
||||
delegate:self];
|
||||
[cell configWithInfo:[entity getValue:currentType] delegate:self];
|
||||
return cell;
|
||||
}
|
||||
else if (currentType == MWMPlacePageMetadataTypeEditButton)
|
||||
|
@ -337,7 +334,7 @@ extern CGFloat const kBasePlacePageViewTitleBottomOffset = 2.;
|
|||
MWMPlacePageInfoCell * cell = (MWMPlacePageInfoCell *)[tableView dequeueReusableCellWithIdentifier:cellIdentifier];
|
||||
|
||||
cell.currentEntity = self.entity;
|
||||
[cell configureWithType:currentType info:self.entity.metadataValues[indexPath.row]];
|
||||
[cell configureWithType:currentType info:[entity getValue:currentType]];
|
||||
return cell;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
#import "MWMBookmarkColorCell.h"
|
||||
#import "UIColor+MapsMeColor.h"
|
||||
|
||||
extern NSArray * const kBookmarkColorsVariant;
|
||||
|
||||
@interface MWMBookmarkColorCell ()
|
||||
|
||||
@property (copy, nonatomic) NSString * currentImageName;
|
||||
|
|
|
@ -6,7 +6,16 @@
|
|||
#import "UIColor+MapsMeColor.h"
|
||||
#import "UIViewController+navigation.h"
|
||||
|
||||
extern NSArray * const kBookmarkColorsVariant;
|
||||
static NSArray * const kBookmarkColorsVariant = @[
|
||||
@"placemark-red",
|
||||
@"placemark-yellow",
|
||||
@"placemark-blue",
|
||||
@"placemark-green",
|
||||
@"placemark-purple",
|
||||
@"placemark-orange",
|
||||
@"placemark-brown",
|
||||
@"placemark-pink"
|
||||
];
|
||||
|
||||
static NSString * const kBookmarkColorCellIdentifier = @"MWMBookmarkColorCell";
|
||||
|
||||
|
|
|
@ -28,7 +28,6 @@
|
|||
- (void)changeBookmarkCategory;
|
||||
- (void)changeBookmarkDescription;
|
||||
- (void)editPlaceTime;
|
||||
- (void)login;
|
||||
- (void)share;
|
||||
- (void)route;
|
||||
- (void)reloadBookmark;
|
||||
|
|
|
@ -35,15 +35,18 @@ static NSString * const kPlacePageViewCenterKeyPath = @"center";
|
|||
options:NSKeyValueObservingOptionNew
|
||||
context:nullptr];
|
||||
}
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self
|
||||
selector:@selector(keyboardWillShow:)
|
||||
name:UIKeyboardWillShowNotification
|
||||
object:nil];
|
||||
dispatch_async(dispatch_get_main_queue(), ^
|
||||
{
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self
|
||||
selector:@selector(keyboardWillShow:)
|
||||
name:UIKeyboardWillShowNotification
|
||||
object:nil];
|
||||
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self
|
||||
selector:@selector(keyboardWillHide)
|
||||
name:UIKeyboardWillHideNotification
|
||||
object:nil];
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self
|
||||
selector:@selector(keyboardWillHide)
|
||||
name:UIKeyboardWillHideNotification
|
||||
object:nil];
|
||||
});
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
@ -199,7 +202,7 @@ static NSString * const kPlacePageViewCenterKeyPath = @"center";
|
|||
- (void)willStartEditingBookmarkTitle
|
||||
{
|
||||
[[Statistics instance] logEvent:kStatEventName(kStatPlacePage, kStatRename)];
|
||||
// This method should be overriden.
|
||||
// This method should be оverridden.
|
||||
}
|
||||
|
||||
- (void)willFinishEditingBookmarkTitle:(NSString *)title
|
||||
|
@ -210,17 +213,17 @@ static NSString * const kPlacePageViewCenterKeyPath = @"center";
|
|||
|
||||
- (IBAction)didTap:(UITapGestureRecognizer *)sender
|
||||
{
|
||||
// This method should be overriden if you want to process custom tap.
|
||||
// This method should be оverridden if you want to process custom tap.
|
||||
}
|
||||
|
||||
- (IBAction)didPan:(UIPanGestureRecognizer *)sender
|
||||
{
|
||||
// This method should be overriden if you want to process custom pan.
|
||||
// This method should be оverridden if you want to process custom pan.
|
||||
}
|
||||
|
||||
- (void)refresh
|
||||
{
|
||||
// This method should be overriden.
|
||||
// This method should be оverridden.
|
||||
}
|
||||
|
||||
#pragma mark - Properties
|
||||
|
|
|
@ -45,14 +45,10 @@ typedef NS_ENUM (NSUInteger, MWMPlacePageEntityType)
|
|||
@property (nonatomic) int typeDescriptionValue;
|
||||
|
||||
@property (nonatomic) BookmarkAndCategory bac;
|
||||
@property (nonatomic) ms::LatLon ll;
|
||||
@property (weak, nonatomic) MWMPlacePageViewManager * manager;
|
||||
|
||||
// Automatically checks if DMS format should be used.
|
||||
- (NSString *)coordinates;
|
||||
@property (nonatomic, readonly) ms::LatLon latlon;
|
||||
|
||||
- (NSArray *)metadataTypes;
|
||||
- (NSArray *)metadataValues;
|
||||
- (void)enableEditing;
|
||||
- (void)insertBookmarkInTypes;
|
||||
- (void)removeBookmarkFromTypes;
|
||||
|
@ -60,4 +56,10 @@ typedef NS_ENUM (NSUInteger, MWMPlacePageEntityType)
|
|||
- (instancetype)initWithUserMark:(UserMark const *)mark;
|
||||
- (void)synchronize;
|
||||
|
||||
- (void)toggleCoordinateSystem;
|
||||
|
||||
- (NSUInteger)getTypesCount;
|
||||
- (MWMPlacePageMetadataType)getType:(NSUInteger)index;
|
||||
- (NSString *)getValue:(MWMPlacePageMetadataType)type;
|
||||
|
||||
@end
|
||||
|
|
|
@ -3,74 +3,54 @@
|
|||
#import "MapViewController.h"
|
||||
#include "platform/measurement_utils.hpp"
|
||||
|
||||
extern NSArray * const kBookmarkColorsVariant = @[
|
||||
@"placemark-red",
|
||||
@"placemark-yellow",
|
||||
@"placemark-blue",
|
||||
@"placemark-green",
|
||||
@"placemark-purple",
|
||||
@"placemark-orange",
|
||||
@"placemark-brown",
|
||||
@"placemark-pink"
|
||||
];
|
||||
extern NSString * const kUserDefaultsLatLonAsDMSKey = @"UserDefaultsLatLonAsDMS";
|
||||
static NSArray * const kPatternTypesArray = @[
|
||||
@(MWMPlacePageMetadataTypePostcode),
|
||||
@(MWMPlacePageMetadataTypePhoneNumber),
|
||||
@(MWMPlacePageMetadataTypeWebsite),
|
||||
@(MWMPlacePageMetadataTypeURL),
|
||||
@(MWMPlacePageMetadataTypeEmail),
|
||||
@(MWMPlacePageMetadataTypeOpenHours),
|
||||
@(MWMPlacePageMetadataTypeWiFi),
|
||||
@(MWMPlacePageMetadataTypeCoordinate)
|
||||
];
|
||||
|
||||
using feature::Metadata;
|
||||
|
||||
@interface MWMPlacePageEntity ()
|
||||
extern NSString * const kUserDefaultsLatLonAsDMSKey = @"UserDefaultsLatLonAsDMS";
|
||||
|
||||
@property (nonatomic) NSMutableArray * metaTypes;
|
||||
@property (nonatomic) NSMutableArray * metaValues;
|
||||
static array<MWMPlacePageMetadataType, 8> const kPatternTypesArray{
|
||||
{MWMPlacePageMetadataTypePostcode, MWMPlacePageMetadataTypePhoneNumber,
|
||||
MWMPlacePageMetadataTypeWebsite, MWMPlacePageMetadataTypeURL, MWMPlacePageMetadataTypeEmail,
|
||||
MWMPlacePageMetadataTypeOpenHours, MWMPlacePageMetadataTypeWiFi,
|
||||
MWMPlacePageMetadataTypeCoordinate}};
|
||||
|
||||
@end
|
||||
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}};
|
||||
|
||||
@implementation MWMPlacePageEntity
|
||||
|
||||
- (instancetype)initWithUserMark:(UserMark const *)mark
|
||||
{
|
||||
vector<MWMPlacePageMetadataType> m_types;
|
||||
map<MWMPlacePageMetadataType, string> m_values;
|
||||
}
|
||||
|
||||
- (instancetype)initWithUserMark:(UserMark const *)userMark
|
||||
{
|
||||
NSAssert(userMark, @"userMark can not be nil.");
|
||||
self = [super init];
|
||||
if (self)
|
||||
{
|
||||
self.metaTypes = [NSMutableArray array];
|
||||
self.metaValues = [NSMutableArray array];
|
||||
[self configureWithUserMark:mark];
|
||||
}
|
||||
|
||||
[self configureWithUserMark:userMark];
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)configureWithUserMark:(UserMark const *)mark
|
||||
{
|
||||
UserMark::Type const type = mark->GetMarkType();
|
||||
self.ll = mark->GetLatLon();
|
||||
|
||||
typedef UserMark::Type Type;
|
||||
switch (type)
|
||||
_latlon = mark->GetLatLon();
|
||||
using Type = UserMark::Type;
|
||||
switch (mark->GetMarkType())
|
||||
{
|
||||
case Type::API:
|
||||
{
|
||||
ApiMarkPoint const * apiMark = static_cast<ApiMarkPoint const *>(mark);
|
||||
[self configureForApi:apiMark];
|
||||
[self configureForApi:static_cast<ApiMarkPoint const *>(mark)];
|
||||
break;
|
||||
}
|
||||
case Type::DEBUG_MARK:
|
||||
break;
|
||||
case Type::MY_POSITION:
|
||||
{
|
||||
MyPositionMarkPoint const * myPositionMark = static_cast<MyPositionMarkPoint const *>(mark);
|
||||
[self configureForMyPosition:myPositionMark];
|
||||
[self configureForMyPosition:static_cast<MyPositionMarkPoint const *>(mark)];
|
||||
break;
|
||||
}
|
||||
case Type::SEARCH:
|
||||
[self configureForSearch:static_cast<SearchMarkPoint const *>(mark)];
|
||||
break;
|
||||
|
@ -83,6 +63,25 @@ using feature::Metadata;
|
|||
}
|
||||
}
|
||||
|
||||
- (void)addMetaType:(MWMPlacePageMetadataType)type
|
||||
{
|
||||
if (find(m_types.begin(), m_types.end(), type) == m_types.end())
|
||||
m_types.emplace_back(type);
|
||||
}
|
||||
|
||||
- (void)removeMetaType:(MWMPlacePageMetadataType)type
|
||||
{
|
||||
auto it = find(m_types.begin(), m_types.end(), type);
|
||||
if (it != m_types.end())
|
||||
m_types.erase(it);
|
||||
}
|
||||
|
||||
- (void)addMetaType:(MWMPlacePageMetadataType)type value:(string const &)value
|
||||
{
|
||||
[self addMetaType:type];
|
||||
m_values.emplace(type, value);
|
||||
}
|
||||
|
||||
- (void)configureForBookmark:(UserMark const *)bookmark
|
||||
{
|
||||
Framework & f = GetFramework();
|
||||
|
@ -125,8 +124,7 @@ using feature::Metadata;
|
|||
{
|
||||
self.title = L(@"my_position");
|
||||
self.type = MWMPlacePageEntityTypeMyPosition;
|
||||
[self.metaTypes addObject:kPatternTypesArray.lastObject];
|
||||
[self.metaValues addObject:[self coordinates]];
|
||||
[self addMetaType:MWMPlacePageMetadataTypeCoordinate];
|
||||
}
|
||||
|
||||
- (void)configureForApi:(ApiMarkPoint const *)apiMark
|
||||
|
@ -134,8 +132,7 @@ using feature::Metadata;
|
|||
self.type = MWMPlacePageEntityTypeAPI;
|
||||
self.title = @(apiMark->GetName().c_str());
|
||||
self.category = @(GetFramework().GetApiDataHolder().GetAppTitle().c_str());
|
||||
[self.metaTypes addObject:kPatternTypesArray.lastObject];
|
||||
[self.metaValues addObject:[self coordinates]];
|
||||
[self addMetaType:MWMPlacePageMetadataTypeCoordinate];
|
||||
}
|
||||
|
||||
- (void)configureEntityWithMetadata:(Metadata const &)metadata addressInfo:(search::AddressInfo const &)info
|
||||
|
@ -201,95 +198,83 @@ using feature::Metadata;
|
|||
case Metadata::FMD_POSTCODE:
|
||||
case Metadata::FMD_INTERNET:
|
||||
{
|
||||
NSString * v;
|
||||
if (type == Metadata::FMD_INTERNET)
|
||||
v = L(@"WiFi_available");
|
||||
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
|
||||
v = @(metadata.Get(type).c_str());
|
||||
|
||||
NSNumber const * t = [self typeFromMetadata:type];
|
||||
[self.metaTypes addObject:t];
|
||||
[self.metaValues addObject:v];
|
||||
break;
|
||||
{
|
||||
NSAssert(false, @"Unhandled meta type, see kMetaTypesMap.");
|
||||
}
|
||||
}
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
NSUInteger swappedIndex = 0;
|
||||
for (NSNumber * pattern in kPatternTypesArray)
|
||||
auto begin = kPatternTypesArray.begin();
|
||||
auto end = kPatternTypesArray.end();
|
||||
sort(m_types.begin(), m_types.end(), [&](MWMPlacePageMetadataType a, MWMPlacePageMetadataType b)
|
||||
{
|
||||
NSUInteger const index = [self.metaTypes indexOfObject:pattern];
|
||||
if (index == NSNotFound)
|
||||
continue;
|
||||
[self.metaTypes exchangeObjectAtIndex:index withObjectAtIndex:swappedIndex];
|
||||
[self.metaValues exchangeObjectAtIndex:index withObjectAtIndex:swappedIndex];
|
||||
swappedIndex++;
|
||||
}
|
||||
return find(begin, end, a) < find(begin, end, b);
|
||||
});
|
||||
|
||||
[self.metaTypes addObject:kPatternTypesArray.lastObject];
|
||||
[self.metaValues addObject:[self coordinates]];
|
||||
}
|
||||
|
||||
- (NSArray *)metadataTypes
|
||||
{
|
||||
return (NSArray *)self.metaTypes;
|
||||
}
|
||||
|
||||
- (NSArray *)metadataValues
|
||||
{
|
||||
return (NSArray *)self.metaValues;
|
||||
[self addMetaType:MWMPlacePageMetadataTypeCoordinate];
|
||||
}
|
||||
|
||||
- (void)enableEditing
|
||||
{
|
||||
NSNumber * editType = @(MWMPlacePageMetadataTypeEditButton);
|
||||
if (![self.metaTypes containsObject:editType])
|
||||
[self.metaTypes addObject:editType];
|
||||
[self addMetaType:MWMPlacePageMetadataTypeEditButton];
|
||||
}
|
||||
|
||||
- (void)insertBookmarkInTypes
|
||||
{
|
||||
NSNumber * bookmarkType = @(MWMPlacePageMetadataTypeBookmark);
|
||||
if (![self.metaTypes containsObject:bookmarkType])
|
||||
[self.metaTypes addObject:bookmarkType];
|
||||
[self addMetaType:MWMPlacePageMetadataTypeBookmark];
|
||||
}
|
||||
|
||||
- (void)removeBookmarkFromTypes
|
||||
{
|
||||
[self.metaTypes removeObject:@(MWMPlacePageMetadataTypeBookmark)];
|
||||
[self removeMetaType:MWMPlacePageMetadataTypeBookmark];
|
||||
}
|
||||
|
||||
- (NSNumber *)typeFromMetadata:(uint8_t)type
|
||||
- (void)toggleCoordinateSystem
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case Metadata::FMD_URL:
|
||||
return @(MWMPlacePageMetadataTypeURL);
|
||||
case Metadata::FMD_WEBSITE:
|
||||
return @(MWMPlacePageMetadataTypeWebsite);
|
||||
case Metadata::FMD_PHONE_NUMBER:
|
||||
return @(MWMPlacePageMetadataTypePhoneNumber);
|
||||
case Metadata::FMD_OPEN_HOURS:
|
||||
return @(MWMPlacePageMetadataTypeOpenHours);
|
||||
case Metadata::FMD_EMAIL:
|
||||
return @(MWMPlacePageMetadataTypeEmail);
|
||||
case Metadata::FMD_POSTCODE:
|
||||
return @(MWMPlacePageMetadataTypePostcode);
|
||||
case Metadata::FMD_INTERNET:
|
||||
return @(MWMPlacePageMetadataTypeWiFi);
|
||||
default:
|
||||
return nil;
|
||||
}
|
||||
NSUserDefaults * ud = [NSUserDefaults standardUserDefaults];
|
||||
[ud setBool:![ud boolForKey:kUserDefaultsLatLonAsDMSKey] forKey:kUserDefaultsLatLonAsDMSKey];
|
||||
[ud synchronize];
|
||||
}
|
||||
|
||||
- (NSString *)coordinates
|
||||
#pragma mark - Getters
|
||||
|
||||
- (NSUInteger)getTypesCount
|
||||
{
|
||||
BOOL const useDMSFormat = [[NSUserDefaults standardUserDefaults] boolForKey:kUserDefaultsLatLonAsDMSKey];
|
||||
return @((useDMSFormat ? MeasurementUtils::FormatLatLon(self.ll.lat, self.ll.lon).c_str()
|
||||
: MeasurementUtils::FormatLatLonAsDMS(self.ll.lat, self.ll.lon, 2).c_str()));
|
||||
return m_types.size();
|
||||
}
|
||||
|
||||
- (MWMPlacePageMetadataType)getType:(NSUInteger)index
|
||||
{
|
||||
NSAssert(index < [self getTypesCount], @"Invalid meta index");
|
||||
return m_types[index];
|
||||
}
|
||||
|
||||
- (NSString *)getValue:(MWMPlacePageMetadataType)type
|
||||
{
|
||||
if (type == MWMPlacePageMetadataTypeCoordinate)
|
||||
return [self coordinate];
|
||||
auto it = m_values.find(type);
|
||||
return it != m_values.end() ? @(it->second.c_str()) : @"";
|
||||
}
|
||||
|
||||
- (NSString *)coordinate
|
||||
{
|
||||
BOOL const useDMSFormat =
|
||||
[[NSUserDefaults standardUserDefaults] boolForKey:kUserDefaultsLatLonAsDMSKey];
|
||||
ms::LatLon const latlon = self.latlon;
|
||||
return @((useDMSFormat ? MeasurementUtils::FormatLatLon(latlon.lat, latlon.lon)
|
||||
: MeasurementUtils::FormatLatLonAsDMS(latlon.lat, latlon.lon, 2))
|
||||
.c_str());
|
||||
}
|
||||
|
||||
#pragma mark - Bookmark editing
|
||||
|
|
|
@ -8,14 +8,14 @@
|
|||
#include "platform/settings.hpp"
|
||||
#include "platform/measurement_utils.hpp"
|
||||
|
||||
extern NSString * const kUserDefaultsLatLonAsDMSKey;
|
||||
|
||||
@interface MWMPlacePageInfoCell () <UITextViewDelegate>
|
||||
|
||||
@property (weak, nonatomic, readwrite) IBOutlet UIImageView * icon;
|
||||
@property (weak, nonatomic, readwrite) IBOutlet id textContainer;
|
||||
|
||||
@property (weak, nonatomic) IBOutlet UIButton * upperButton;
|
||||
@property (weak, nonatomic) IBOutlet UIImageView * toggleImage;
|
||||
|
||||
@property (nonatomic) MWMPlacePageMetadataType type;
|
||||
|
||||
@end
|
||||
|
@ -26,10 +26,7 @@ extern NSString * const kUserDefaultsLatLonAsDMSKey;
|
|||
{
|
||||
[super awakeFromNib];
|
||||
if ([self.textContainer isKindOfClass:[UITextView class]])
|
||||
{
|
||||
CGFloat const topInset = 12.0;
|
||||
[self.textContainer setTextContainerInset:{topInset, 0, 0, 0}];
|
||||
}
|
||||
[self.textContainer setTextContainerInset:{.top = 12, 0, 0, 0}];
|
||||
}
|
||||
|
||||
- (void)configureWithType:(MWMPlacePageMetadataType)type info:(NSString *)info;
|
||||
|
@ -39,21 +36,27 @@ extern NSString * const kUserDefaultsLatLonAsDMSKey;
|
|||
{
|
||||
case MWMPlacePageMetadataTypeURL:
|
||||
case MWMPlacePageMetadataTypeWebsite:
|
||||
self.toggleImage.hidden = YES;
|
||||
typeName = @"website";
|
||||
break;
|
||||
case MWMPlacePageMetadataTypeEmail:
|
||||
self.toggleImage.hidden = YES;
|
||||
typeName = @"email";
|
||||
break;
|
||||
case MWMPlacePageMetadataTypePhoneNumber:
|
||||
self.toggleImage.hidden = YES;
|
||||
typeName = @"phone_number";
|
||||
break;
|
||||
case MWMPlacePageMetadataTypeCoordinate:
|
||||
self.toggleImage.hidden = NO;
|
||||
typeName = @"coordinate";
|
||||
break;
|
||||
case MWMPlacePageMetadataTypePostcode:
|
||||
self.toggleImage.hidden = YES;
|
||||
typeName = @"postcode";
|
||||
break;
|
||||
case MWMPlacePageMetadataTypeWiFi:
|
||||
self.toggleImage.hidden = YES;
|
||||
typeName = @"wifi";
|
||||
break;
|
||||
case MWMPlacePageMetadataTypeBookmark:
|
||||
|
@ -109,19 +112,12 @@ extern NSString * const kUserDefaultsLatLonAsDMSKey;
|
|||
break;
|
||||
case MWMPlacePageMetadataTypeCoordinate:
|
||||
[[Statistics instance] logEvent:kStatEventName(kStatPlacePage, kStatToggleCoordinates)];
|
||||
[self.currentEntity toggleCoordinateSystem];
|
||||
[self.textContainer setText:[self.currentEntity getValue:MWMPlacePageMetadataTypeCoordinate]];
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
if (self.type != MWMPlacePageMetadataTypeCoordinate)
|
||||
return;
|
||||
NSUserDefaults * defaults = [NSUserDefaults standardUserDefaults];
|
||||
BOOL const showLatLonAsDMS = [defaults boolForKey:kUserDefaultsLatLonAsDMSKey];
|
||||
[defaults setBool:!showLatLonAsDMS forKey:kUserDefaultsLatLonAsDMSKey];
|
||||
[defaults synchronize];
|
||||
|
||||
// @NOTE: coordinates method depends on kUserDefaultsLatLonAsDMSKey value above.
|
||||
[self.textContainer setText:[self.currentEntity coordinates]];
|
||||
}
|
||||
|
||||
- (void)longTap:(UILongPressGestureRecognizer *)sender
|
||||
|
|
|
@ -81,11 +81,9 @@ typedef NS_ENUM(NSUInteger, MWMPlacePageManagerState)
|
|||
|
||||
- (void)showPlacePageWithUserMark:(unique_ptr<UserMarkCopy>)userMark
|
||||
{
|
||||
NSAssert(userMark, @"userMark cannot be nil");
|
||||
NSAssert(userMark, @"userMark can not be nil.");
|
||||
m_userMark = move(userMark);
|
||||
[[MapsAppDelegate theApp].m_locationManager start:self];
|
||||
// [self.entity enableEditing];
|
||||
|
||||
[self reloadPlacePage];
|
||||
}
|
||||
|
||||
|
@ -258,7 +256,7 @@ typedef NS_ENUM(NSUInteger, MWMPlacePageManagerState)
|
|||
[Alohalytics logEvent:kAlohalyticsTapEventKey withValue:@"ppShare"];
|
||||
MWMPlacePageEntity * entity = self.entity;
|
||||
NSString * title = entity.bookmarkTitle ? entity.bookmarkTitle : entity.title;
|
||||
CLLocationCoordinate2D const coord = CLLocationCoordinate2DMake(entity.ll.lat, entity.ll.lon);
|
||||
CLLocationCoordinate2D const coord = CLLocationCoordinate2DMake(entity.latlon.lat, entity.latlon.lon);
|
||||
MWMActivityViewController * shareVC =
|
||||
[MWMActivityViewController shareControllerForLocationTitle:title
|
||||
location:coord
|
||||
|
|
|
@ -801,10 +801,8 @@ typedef NS_ENUM(NSUInteger, UserTouchesAction)
|
|||
{
|
||||
self.skipDismissOnViewDisappear = YES;
|
||||
MWMPlacePageEntity * entity = sender;
|
||||
NSUInteger const timeIndex = [entity.metadataTypes indexOfObject:@(MWMPlacePageMetadataTypeOpenHours)];
|
||||
BOOL const haveTime = (timeIndex != NSNotFound);
|
||||
MWMOpeningHoursEditorViewController * dvc = segue.destinationViewController;
|
||||
dvc.openingHours = haveTime ? entity.metadataValues[timeIndex] : @"";
|
||||
dvc.openingHours = [entity getValue:MWMPlacePageMetadataTypeOpenHours];
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -82,6 +82,7 @@
|
|||
<connections>
|
||||
<outlet property="icon" destination="xwC-DR-6Il" id="vcm-nJ-D7N"/>
|
||||
<outlet property="textContainer" destination="viE-zJ-wsl" id="0bz-b0-s3h"/>
|
||||
<outlet property="toggleImage" destination="RZw-oW-agi" id="0md-TS-JkM"/>
|
||||
<outlet property="upperButton" destination="vu9-VL-9jn" id="MPi-9Q-hFZ"/>
|
||||
</connections>
|
||||
<point key="canvasLocation" x="120" y="300"/>
|
||||
|
|
Loading…
Add table
Reference in a new issue