[ios] Review fixes

This commit is contained in:
VladiMihaylenko 2016-10-06 14:19:33 +03:00
parent 54798069b3
commit 1ab061d3ac
55 changed files with 613 additions and 734 deletions

View file

@ -219,7 +219,7 @@
}
else
{
BookmarksVC * bvc = [[BookmarksVC alloc] initWithCategory:static_cast<int>(indexPath.row)];
BookmarksVC * bvc = [[BookmarksVC alloc] initWithCategory:indexPath.row];
[self.navigationController pushViewController:bvc animated:YES];
}
}

View file

@ -2,9 +2,9 @@
@interface BookmarksVC : MWMTableViewController <UITextFieldDelegate>
{
int m_categoryIndex;
NSUInteger m_categoryIndex;
}
- (instancetype)initWithCategory:(int)index;
- (instancetype)initWithCategory:(NSUInteger)index;
@end

View file

@ -38,7 +38,7 @@ extern NSString * const kBookmarksChangedNotification = @"BookmarksChangedNotifi
@implementation BookmarksVC
- (instancetype)initWithCategory:(int)index
- (instancetype)initWithCategory:(NSUInteger)index
{
self = [super initWithStyle:UITableViewStyleGrouped];
if (self)
@ -236,7 +236,7 @@ extern NSString * const kBookmarksChangedNotification = @"BookmarksChangedNotifi
// Same as "Close".
MapViewController * mapVC = self.navigationController.viewControllers.firstObject;
mapVC.controlsManager.searchHidden = YES;
f.ShowBookmark({static_cast<int>(indexPath.row), m_categoryIndex});
f.ShowBookmark({static_cast<size_t>(indexPath.row), m_categoryIndex});
[self.navigationController popToRootViewControllerAnimated:YES];
}
}
@ -294,7 +294,7 @@ extern NSString * const kBookmarksChangedNotification = @"BookmarksChangedNotifi
}
else
{
BookmarkAndCategory bookmarkAndCategory{static_cast<int>(indexPath.row), m_categoryIndex};
BookmarkAndCategory bookmarkAndCategory{static_cast<size_t>(indexPath.row), m_categoryIndex};
NSValue * value = [NSValue valueWithBytes:&bookmarkAndCategory objCType:@encode(BookmarkAndCategory)];
[[NSNotificationCenter defaultCenter] postNotificationName:BOOKMARK_DELETED_NOTIFICATION object:value];
BookmarkCategory::Guard guard(*cat);

View file

@ -85,11 +85,13 @@
- (void)moveBookmarkToSetWithIndex:(int)setIndex
{
BookmarkAndCategory bac;
bac.m_bookmarkIndex = static_cast<int>(GetFramework().MoveBookmark(m_bac.m_bookmarkIndex, m_bac.m_categoryIndex, setIndex));
bac.m_bookmarkIndex = static_cast<size_t>(
GetFramework().MoveBookmark(m_bac.m_bookmarkIndex, m_bac.m_categoryIndex, setIndex));
bac.m_categoryIndex = setIndex;
m_bac = bac;
BookmarkCategory const * category = GetFramework().GetBookmarkManager().GetBmCategory(bac.m_categoryIndex);
BookmarkCategory const * category =
GetFramework().GetBookmarkManager().GetBmCategory(bac.m_categoryIndex);
self.category = @(category->GetName().c_str());
}

View file

@ -63,8 +63,7 @@ static inline BOOL isIOSVersionLessThan(NSUInteger version)
return isIOSVersionLessThan([NSString stringWithFormat:@"%@", @(version)]);
}
static BOOL const isIOS7 = isIOSVersionLessThan(8);
static BOOL const isIOS8 = !isIOS7 && isIOSVersionLessThan(9);
static BOOL const isIOS8 = isIOSVersionLessThan(9);
static inline BOOL isInterfaceRightToLeft()
{

View file

@ -69,6 +69,7 @@ extern NSString * const kAlohalyticsTapEventKey;
self.ownerController = controller;
self.hidden = NO;
self.sideButtonsHidden = NO;
self.isDirectionViewHidden = YES;
self.menuState = MWMBottomMenuStateInactive;
self.menuRestoreState = MWMBottomMenuStateInactive;
return self;
@ -293,24 +294,7 @@ extern NSString * const kAlohalyticsTapEventKey;
{
if (IPAD)
return;
if (isIOS7)
{
CGSize const ownerViewSize = self.ownerController.view.size;
if (ownerViewSize.width > ownerViewSize.height)
{
CGFloat const leftBound = frame.origin.x + frame.size.width;
self.menuController.leftBound = leftBound;
[MWMNavigationDashboardManager manager].leftBound = leftBound;
}
else
{
[self.sideButtons setBottomBound:frame.origin.y];
}
}
else
{
[self.sideButtons setBottomBound:frame.origin.y];
}
[self.sideButtons setBottomBound:frame.origin.y];
}
- (void)addPlacePageViews:(NSArray *)views
@ -467,13 +451,12 @@ extern NSString * const kAlohalyticsTapEventKey;
return _menuController;
}
- (id)placePageManager
- (id<MWMPlacePageProtocol>)placePageManager
{
auto const PlacePageClass = isIOS7 || IPAD ? [MWMPlacePageViewManager class] : [MWMPlacePageManager class];
auto const PlacePageClass = IPAD ? [MWMPlacePageViewManager class] : [MWMPlacePageManager class];
if (!_placePageManager)
_placePageManager =
[[PlacePageClass alloc] initWithViewController:self.ownerController];
_placePageManager = [[PlacePageClass alloc] init];
return _placePageManager;
}
@ -564,9 +547,5 @@ extern NSString * const kAlohalyticsTapEventKey;
#pragma mark - MWMFeatureHolder
- (id<MWMFeatureHolder>)featureHolder
{
return self.placePageManager;
}
- (id<MWMFeatureHolder>)featureHolder { return self.placePageManager; }
@end

View file

@ -57,7 +57,7 @@
- (IBAction)openBookmarks
{
BookmarksVC * bvc = [[BookmarksVC alloc] initWithCategory:static_cast<int>(self.index)];
BookmarksVC * bvc = [[BookmarksVC alloc] initWithCategory:self.index];
UINavigationController * rootVC = (UINavigationController *)UIApplication.sharedApplication.delegate.window.rootViewController;
[rootVC pushViewController:bvc animated:YES];
}

View file

@ -22,7 +22,6 @@ CGFloat constexpr kAdditionalHeight = 20.;
@property(weak, nonatomic) IBOutlet UIView * pedestrian;
@property(weak, nonatomic) IBOutlet UIView * vehicle;
@property(weak, nonatomic) IBOutlet UIView * bicycle;
@property(weak, nonatomic) IBOutlet UIView * taxi;
@property(weak, nonatomic) IBOutlet NSLayoutConstraint * planningRouteViewHeight;
@property(weak, nonatomic) IBOutlet UIButton * extendButton;
@property(weak, nonatomic) IBOutlet UIButton * goButton;
@ -80,7 +79,6 @@ CGFloat constexpr kAdditionalHeight = 20.;
[self addProgress:self.vehicle imageName:@"ic_drive" routerType:type::Vehicle];
[self addProgress:self.pedestrian imageName:@"ic_walk" routerType:type::Pedestrian];
[self addProgress:self.bicycle imageName:@"ic_bike_route" routerType:type::Bicycle];
[self addProgress:self.taxi imageName:@"ic_taxi" routerType:type::Taxi];
}
- (void)addProgress:(UIView *)parentView

View file

@ -1,5 +1,5 @@
#import "Common.h"
#import "MWMActionBarButton.h"
#import "Common.h"
#import "MWMButton.h"
#import "UIColor+MapsMeColor.h"
@ -96,8 +96,6 @@ NSString * titleForButton(EButton type, BOOL isSelected)
button.delegate = delegate;
button.type = type;
[view addSubview:button];
if (isIOS7)
button.autoresizingMask = UIViewAutoresizingNone;
[button configButton:isSelected];
}

View file

@ -1,6 +1,7 @@
#import "MWMTableViewCell.h"
@protocol MWMPlacePageButtonsProtocol, MWMPlacePageCellUpdateProtocol;
@protocol MWMPlacePageButtonsProtocol
, MWMPlacePageCellUpdateProtocol;
@interface MWMBookmarkCell : MWMTableViewCell

View file

@ -1,5 +1,5 @@
#import "MWMPlacePageCellUpdateProtocol.h"
#import "MWMBookmarkCell.h"
#import "MWMPlacePageCellUpdateProtocol.h"
#import "MWMPlacePageProtocol.h"
#import "UIColor+MapsMeColor.h"
@ -8,8 +8,8 @@
namespace
{
void * kContext = &kContext;
// https://developer.apple.com/library/content/documentation/Cocoa/Conceptual/KeyValueObserving/Articles/KVOBasics.html
NSString * const kTextViewContentSizeKeyPath = @"contentSize";
} // namespace
@interface MWMBookmarkCell ()
@ -29,7 +29,7 @@ NSString * const kTextViewContentSizeKeyPath = @"contentSize";
@property(copy, nonatomic) NSAttributedString * attributedHTML;
@property (nonatomic) BOOL isOpen;
@property(nonatomic) BOOL isOpen;
@end
@ -41,11 +41,7 @@ NSString * const kTextViewContentSizeKeyPath = @"contentSize";
[self registerObserver];
}
- (void)dealloc
{
[self unregisterObserver];
}
- (void)dealloc { [self unregisterObserver]; }
- (void)unregisterObserver
{
[self.textView removeObserver:self forKeyPath:kTextViewContentSizeKeyPath context:kContext];
@ -53,7 +49,10 @@ NSString * const kTextViewContentSizeKeyPath = @"contentSize";
- (void)registerObserver
{
[self.textView addObserver:self forKeyPath:kTextViewContentSizeKeyPath options:NSKeyValueObservingOptionNew context:kContext];
[self.textView addObserver:self
forKeyPath:kTextViewContentSizeKeyPath
options:NSKeyValueObservingOptionNew
context:kContext];
}
- (void)observeValueForKeyPath:(NSString *)keyPath
@ -64,12 +63,12 @@ NSString * const kTextViewContentSizeKeyPath = @"contentSize";
if (context == kContext)
{
NSValue * s = change[@"new"];
CGFloat const height = s.CGSizeValue.height;
auto const height = s.CGSizeValue.height;
auto const boundedHeight = self.textViewHeight.constant;
if (height < boundedHeight || self.isOpen)
if (height <= boundedHeight || self.isOpen)
[self stateOpen:YES];
else if (height > boundedHeight && !self.isOpen)
else
[self stateOpen:NO];
[self setNeedsLayout];
@ -83,7 +82,7 @@ NSString * const kTextViewContentSizeKeyPath = @"contentSize";
- (void)configureWithText:(NSString *)text
updateCellDelegate:(id<MWMPlacePageCellUpdateProtocol>)updateCellDelegate
editBookmarkDelegate:(id<MWMPlacePageButtonsProtocol>)editBookmarkDelegate
isHTML:(BOOL)isHTML
isHTML:(BOOL)isHTML
{
self.attributedHTML = nil;
self.isOpen = NO;
@ -93,17 +92,11 @@ NSString * const kTextViewContentSizeKeyPath = @"contentSize";
self.editBookmarkDelegate = editBookmarkDelegate;
if (!text.length)
{
[self configWithEmptyDescription];
}
else if (isHTML)
{
[self configHTML:text];
}
else
{
[self configPlain:text];
}
}
- (void)configWithEmptyDescription
@ -121,7 +114,10 @@ NSString * const kTextViewContentSizeKeyPath = @"contentSize";
[self stopSpinner];
self.textViewZeroHeight.active = NO;
self.textView.attributedText = self.attributedHTML;
if (fabs(self.textView.contentSize.height - 0.5) < 1)
// In case when after setting attributed text into textView its content height is about 0 but
// not 0 (e.g. 0.33).
// When it happens we need to call sizeToFit to display bookmark description.
if (self.textView.contentSize.height < 1)
[self.textView sizeToFit];
}
else
@ -132,21 +128,21 @@ NSString * const kTextViewContentSizeKeyPath = @"contentSize";
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
NSDictionary<NSString *, id> * attr = @{
NSForegroundColorAttributeName : [UIColor blackPrimaryText],
NSFontAttributeName : [UIFont regular16]
};
NSForegroundColorAttributeName : [UIColor blackPrimaryText],
NSFontAttributeName : [UIFont regular16]
};
NSError * error = nil;
NSMutableAttributedString * str = [[NSMutableAttributedString alloc]
initWithData:[text dataUsingEncoding:NSUnicodeStringEncoding]
options:@{
NSDocumentTypeDocumentAttribute : NSHTMLTextDocumentType
}
documentAttributes:nil
error:&error];
initWithData:[text dataUsingEncoding:NSUnicodeStringEncoding]
options:@{
NSDocumentTypeDocumentAttribute : NSHTMLTextDocumentType
}
documentAttributes:nil
error:&error];
if (error)
{
// If we failed while attempting to render html than just show plain text in bookmark.
// Ussualy there is a problem only in iOS7.
// Usually there is a problem only in iOS7.
self.attributedHTML = [[NSAttributedString alloc] initWithString:text attributes:attr];
}
else
@ -156,7 +152,6 @@ NSString * const kTextViewContentSizeKeyPath = @"contentSize";
}
dispatch_async(dispatch_get_main_queue(), ^{
[self configHTML:nil];
});
});
@ -178,14 +173,13 @@ NSString * const kTextViewContentSizeKeyPath = @"contentSize";
- (void)startSpinner
{
// self.textViewZeroHeight.active = YES;
self.editButton.hidden = YES;
NSUInteger const animationImagesCount = 12;
NSMutableArray * animationImages = [NSMutableArray arrayWithCapacity:animationImagesCount];
NSString * postfix = [UIColor isNightMode] ? @"dark" : @"light";
for (NSUInteger i = 0; i < animationImagesCount; ++i)
animationImages[i] =
[UIImage imageNamed:[NSString stringWithFormat:@"Spinner_%@_%@", @(i + 1), postfix]];
[UIImage imageNamed:[NSString stringWithFormat:@"Spinner_%@_%@", @(i + 1), postfix]];
self.spinner.animationDuration = 0.8;
self.spinner.animationImages = animationImages;
@ -205,12 +199,7 @@ NSString * const kTextViewContentSizeKeyPath = @"contentSize";
self.isOpen = YES;
[self stateOpen:YES];
[self setNeedsLayout];
// [self.delegate updateCellWithForceReposition:NO];
}
- (IBAction)editTap
{
[self.editBookmarkDelegate editBookmark];
}
- (IBAction)editTap { [self.editBookmarkDelegate editBookmark]; }
@end

View file

@ -1,8 +1,8 @@
#import "MapsAppDelegate.h"
#import "MapViewController.h"
#import "MWMMapViewControlsManager.h"
#import "MWMDirectionView.h"
#import "MWMMapViewControlsManager.h"
#import "MWMPlacePageViewManager.h"
#import "MapViewController.h"
#import "MapsAppDelegate.h"
#import "UIFont+MapsMeFonts.h"
static NSString * const kDirectionViewNibName = @"MWMDirectionView";

View file

@ -5,7 +5,7 @@
@interface MWMEditBookmarkController : MWMTableViewController
@property (weak, nonatomic) MWMPlacePageData * data;
@property(weak, nonatomic) MWMPlacePageData * data;
@property (nonatomic) MWMPlacePageViewManager * manager;
@end

View file

@ -1,8 +1,8 @@
#import "MWMEditBookmarkController.h"
#import "Common.h"
#import "MWMBookmarkColorViewController.h"
#import "MWMBookmarkTitleCell.h"
#import "MWMButtonCell.h"
#import "MWMBookmarkColorViewController.h"
#import "MWMEditBookmarkController.h"
#import "MWMNoteCell.h"
#import "MWMPlacePageData.h"
#import "MWMPlacePageEntity.h"
@ -52,8 +52,9 @@ enum RowInMetaInfo
- (void)viewDidLoad
{
[super viewDidLoad];
NSAssert(self.manager || self.data, @"Entity and data can't be nil both!");
if (isIOS7 || IPAD)
auto data = self.data;
NSAssert(self.manager || data, @"Entity and data can't be nil both!");
if (IPAD)
{
MWMPlacePageEntity * en = self.manager.entity;
self.cachedDescription = en.bookmarkDescription;
@ -64,10 +65,10 @@ enum RowInMetaInfo
}
else
{
self.cachedDescription = self.data.bookmarkDescription;
self.cachedTitle = self.data.externalTitle ? self.data.externalTitle : self.data.title;
self.cachedCategory = self.data.bookmarkCategory;
self.cachedColor = self.data.bookmarkColor;
self.cachedDescription = data.bookmarkDescription;
self.cachedTitle = data.externalTitle ? data.externalTitle : data.title;
self.cachedCategory = data.bookmarkCategory;
self.cachedColor = data.bookmarkColor;
}
[self configNavBar];
@ -107,7 +108,7 @@ enum RowInMetaInfo
- (void)onSave
{
[self.view endEditing:YES];
if (isIOS7 || IPAD)
if (IPAD)
{
MWMPlacePageEntity * en = self.manager.entity;
en.bookmarkDescription = self.cachedDescription;
@ -121,7 +122,7 @@ enum RowInMetaInfo
else
{
Framework & f = GetFramework();
auto const bac = self.data.bac;
auto const & bac = self.data.bac;
BookmarkCategory * category = f.GetBmCategory(bac.m_categoryIndex);
if (!category)
return;
@ -129,7 +130,7 @@ enum RowInMetaInfo
{
BookmarkCategory::Guard guard(*category);
Bookmark * bookmark =
static_cast<Bookmark *>(guard.m_controller.GetUserMarkForEdit(bac.m_bookmarkIndex));
static_cast<Bookmark *>(guard.m_controller.GetUserMarkForEdit(bac.m_bookmarkIndex));
if (!bookmark)
return;
@ -137,7 +138,7 @@ enum RowInMetaInfo
bookmark->SetDescription(self.cachedDescription.UTF8String);
bookmark->SetName(self.cachedTitle.UTF8String);
}
category->SaveToKMLFile();
f.UpdatePlacePageInfoForCurrentSelection();
}

View file

@ -1,17 +1,20 @@
#include "std/string.hpp"
#include "std/vector.hpp"
namespace osmoh
{
struct Day
{
Day(NSString * workingDays, NSString * workingTimes, NSString * breaks) : m_workingDays(workingDays),
m_workingTimes(workingTimes),
m_breaks(breaks) {}
explicit Day(NSString * workingDays) : m_workingDays(workingDays),
m_isOpen(false) {}
Day(NSString * workingDays, NSString * workingTimes, NSString * breaks)
: m_workingDays(workingDays), m_workingTimes(workingTimes), m_breaks(breaks)
{
}
explicit Day(NSString * workingDays) : m_workingDays(workingDays), m_isOpen(false) {}
NSString * TodayTime() const
{
return m_workingTimes ? [NSString stringWithFormat:@"%@ %@", m_workingDays, m_workingTimes] : m_workingDays;
return m_workingTimes ? [NSString stringWithFormat:@"%@ %@", m_workingDays, m_workingTimes]
: m_workingDays;
}
NSString * m_workingDays;
@ -22,9 +25,6 @@ struct Day
} // namespace osmoh
#include "std/string.hpp"
#include "std/vector.hpp"
@interface MWMOpeningHours : NSObject
+ (vector<osmoh::Day>)processRawString:(NSString *)str;

View file

@ -1,7 +1,6 @@
#import "MWMOpeningHours.h"
#import "MWMOpeningHoursCommon.h"
#include "3party/opening_hours/opening_hours.hpp"
#include "editor/opening_hours_ui.hpp"
#include "editor/ui2oh.hpp"
@ -14,16 +13,18 @@ namespace
NSString * stringFromTimeSpan(Timespan const & timeSpan)
{
return [NSString stringWithFormat:@"%@-%@", stringFromTime(timeSpan.GetStart()),
stringFromTime(timeSpan.GetEnd())];
stringFromTime(timeSpan.GetEnd())];
}
NSString * breaksFromClosedTime(TTimespans const & closedTimes)
{
NSMutableString * breaks = [@"" mutableCopy];
for (auto & ct : closedTimes)
auto const size = closedTimes.size();
for (size_t i = 0; i < size; i++)
{
[breaks appendString:@"\n"];
[breaks appendString:stringFromTimeSpan(ct)];
if (i)
[breaks appendString:@"\n"];
[breaks appendString:stringFromTimeSpan(closedTimes[i])];
}
return breaks.copy;
}
@ -63,7 +64,7 @@ void addDay(ui::TimeTable const & tt, vector<Day> & allDays)
NSString * breaks;
if (tt.IsTwentyFourHours())
{
workingTimes = L(@"twentyfour_seven");
workingTimes = L(@"editor_time_allday");
}
else
{
@ -75,10 +76,8 @@ void addDay(ui::TimeTable const & tt, vector<Day> & allDays)
void addUnhandledDays(ui::TOpeningDays const & days, vector<Day> & allDays)
{
if (days.empty())
return;
allDays.emplace_back(stringFromOpeningDays(days));
if (!days.empty())
allDays.emplace_back(stringFromOpeningDays(days));
}
} // namespace
@ -98,7 +97,8 @@ void addUnhandledDays(ui::TOpeningDays const & days, vector<Day> & allDays)
cal.locale = [NSLocale currentLocale];
auto const timeTablesSize = timeTableSet.Size();
auto const today = static_cast<Weekday>([cal components:NSCalendarUnitWeekday fromDate:[NSDate date]].weekday);
auto const today =
static_cast<Weekday>([cal components:NSCalendarUnitWeekday fromDate:[NSDate date]].weekday);
auto const unhandledDays = timeTableSet.GetUnhandledDays();
/// Schedule contains more than one rule for all days or unhandled days.

View file

@ -1,13 +1,13 @@
#import "MWMOpeningHoursCell.h"
#import "Common.h"
#import "MWMOpeningHours.h"
#import "MWMOpeningHoursCell.h"
#import "MWMPlacePageCellUpdateProtocol.h"
#include "std/array.hpp"
namespace
{
array<NSString *, 2> kOHClasses = {{@"_MWMOHHeaderCell", @"_MWMOHSubCell"}};
array<NSString *, 2> kOHClasses = {{@"_MWMOHHeaderCell", @"_MWMOHSubCell"}};
void * kContext = &kContext;
NSString * const kTableViewContentSizeKeyPath = @"contentSize";
@ -35,19 +35,20 @@ NSString * const kTableViewContentSizeKeyPath = @"contentSize";
return;
self.tapAction();
[UIView animateWithDuration:kDefaultAnimationDuration animations:^
{
self.arrowIcon.transform = CGAffineTransformIsIdentity(self.arrowIcon.transform) ?
CGAffineTransformMakeRotation(M_PI) :
CGAffineTransformIdentity;
}];
[UIView animateWithDuration:kDefaultAnimationDuration
animations:^{
self.arrowIcon.transform =
CGAffineTransformIsIdentity(self.arrowIcon.transform)
? CGAffineTransformMakeRotation(M_PI)
: CGAffineTransformIdentity;
}];
}
@end
#pragma mark - _MWMOHSubCell
@interface _MWMOHSubCell :MWMTableViewCell
@interface _MWMOHSubCell : MWMTableViewCell
@property(weak, nonatomic) IBOutlet UILabel * days;
@property(weak, nonatomic) IBOutlet UILabel * schedule;
@ -60,7 +61,7 @@ NSString * const kTableViewContentSizeKeyPath = @"contentSize";
@end
@interface MWMOpeningHoursCell () <UITableViewDelegate, UITableViewDataSource>
@interface MWMOpeningHoursCell ()<UITableViewDelegate, UITableViewDataSource>
@property(weak, nonatomic) IBOutlet UITableView * tableView;
@property(weak, nonatomic) IBOutlet NSLayoutConstraint * tableViewHeight;
@ -94,14 +95,13 @@ NSString * const kTableViewContentSizeKeyPath = @"contentSize";
{
self.tableView.delegate = nil;
self.tableView.dataSource = nil;
self.isExtended = NO;
self.delegate = delegate;
self.isClosedNow = isClosedNow;
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0), ^
{
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0), ^{
self->m_days = [MWMOpeningHours processRawString:openningHours];
dispatch_async(dispatch_get_main_queue(), ^
{
dispatch_async(dispatch_get_main_queue(), ^{
self.tableView.delegate = self;
self.tableView.dataSource = self;
[self.tableView reloadData];
@ -116,20 +116,22 @@ NSString * const kTableViewContentSizeKeyPath = @"contentSize";
return self.isExtended ? m_days.size() : 1;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
- (UITableViewCell *)tableView:(UITableView *)tableView
cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
auto const & day = m_days[indexPath.row];
BOOL const isSeparatorHidden = self.isExtended ? indexPath.row == 0 : indexPath.row == m_days.size() - 1;
BOOL const isSeparatorHidden =
self.isExtended ? indexPath.row == 0 : indexPath.row == m_days.size() - 1;
if (indexPath.row == 0)
{
_MWMOHHeaderCell * cell = [tableView dequeueReusableCellWithIdentifier:[_MWMOHHeaderCell className]];
_MWMOHHeaderCell * cell =
[tableView dequeueReusableCellWithIdentifier:[_MWMOHHeaderCell className]];
cell.today.text = day.TodayTime();
cell.breaks.text = day.m_breaks;
cell.closedNow.text = self.isClosedNow ? L(@"closed_now") : nil;;
cell.closedNow.text = self.isClosedNow ? L(@"closed_now") : nil;
if (m_days.size() > 1)
{
cell.tapAction = ^
{
cell.tapAction = ^{
self.isExtended = !self.isExtended;
NSMutableArray<NSIndexPath *> * ip = [@[] mutableCopy];
@ -138,9 +140,11 @@ NSString * const kTableViewContentSizeKeyPath = @"contentSize";
[ip addObject:[NSIndexPath indexPathForRow:i inSection:0]];
if (self.isExtended)
[self.tableView insertRowsAtIndexPaths:ip withRowAnimation:UITableViewRowAnimationAutomatic];
[self.tableView insertRowsAtIndexPaths:ip
withRowAnimation:UITableViewRowAnimationAutomatic];
else
[self.tableView deleteRowsAtIndexPaths:ip withRowAnimation:UITableViewRowAnimationAutomatic];
[self.tableView deleteRowsAtIndexPaths:ip
withRowAnimation:UITableViewRowAnimationAutomatic];
};
cell.arrowIcon.hidden = NO;
}
@ -165,11 +169,7 @@ NSString * const kTableViewContentSizeKeyPath = @"contentSize";
#pragma mark - Observer's methods
- (void)dealloc
{
[self unregisterObserver];
}
- (void)dealloc { [self unregisterObserver]; }
- (void)observeValueForKeyPath:(NSString *)keyPath
ofObject:(id)object
change:(NSDictionary *)change
@ -195,6 +195,9 @@ NSString * const kTableViewContentSizeKeyPath = @"contentSize";
- (void)registerObserver
{
[self.tableView addObserver:self forKeyPath:kTableViewContentSizeKeyPath options:NSKeyValueObservingOptionNew context:kContext];
[self.tableView addObserver:self
forKeyPath:kTableViewContentSizeKeyPath
options:NSKeyValueObservingOptionNew
context:kContext];
}
@end

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="11201" systemVersion="15G31" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" colorMatched="YES">
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="11201" systemVersion="16A323" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" colorMatched="YES">
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="11161"/>
@ -18,22 +18,22 @@
<tableView clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" scrollEnabled="NO" style="plain" separatorStyle="none" allowsSelection="NO" rowHeight="44" sectionHeaderHeight="28" sectionFooterHeight="28" translatesAutoresizingMaskIntoConstraints="NO" id="JR5-1q-ZuW">
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<constraints>
<constraint firstAttribute="height" constant="43" id="zPP-L9-sbu"/>
<constraint firstAttribute="height" priority="750" constant="43" id="JLa-25-thU"/>
</constraints>
<color key="separatorColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
<inset key="separatorInset" minX="60" minY="0.0" maxX="0.0" maxY="0.0"/>
</tableView>
</subviews>
<constraints>
<constraint firstAttribute="bottom" secondItem="JR5-1q-ZuW" secondAttribute="bottom" id="4pR-Dy-zHh"/>
<constraint firstAttribute="trailing" secondItem="JR5-1q-ZuW" secondAttribute="trailing" id="91Y-Dy-VMP"/>
<constraint firstItem="JR5-1q-ZuW" firstAttribute="top" secondItem="ab9-am-bMR" secondAttribute="top" id="YAo-QJ-Csl"/>
<constraint firstItem="JR5-1q-ZuW" firstAttribute="leading" secondItem="ab9-am-bMR" secondAttribute="leading" id="kCy-x0-QCT"/>
<constraint firstAttribute="trailing" secondItem="JR5-1q-ZuW" secondAttribute="trailing" id="59Z-Q5-25r"/>
<constraint firstAttribute="bottom" secondItem="JR5-1q-ZuW" secondAttribute="bottom" id="P8D-kD-kMF"/>
<constraint firstItem="JR5-1q-ZuW" firstAttribute="leading" secondItem="ab9-am-bMR" secondAttribute="leading" id="Xox-6I-JsG"/>
<constraint firstItem="JR5-1q-ZuW" firstAttribute="top" secondItem="ab9-am-bMR" secondAttribute="top" id="hgZ-Jr-yDd"/>
</constraints>
</tableViewCellContentView>
<connections>
<outlet property="tableView" destination="JR5-1q-ZuW" id="Qyu-x3-lTv"/>
<outlet property="tableViewHeight" destination="zPP-L9-sbu" id="fEr-dw-NvK"/>
<outlet property="tableViewHeight" destination="JLa-25-thU" id="dtQ-TV-gso"/>
</connections>
<point key="canvasLocation" x="-872.5" y="-141"/>
</tableViewCell>

View file

@ -1,6 +1,6 @@
#pragma mark - MWMPPScrollView
@protocol MWMPlacePageViewUpdateProtocol <NSObject>
@protocol MWMPlacePageViewUpdateProtocol<NSObject>
- (void)updateWithHeight:(CGFloat)height;
@ -28,4 +28,3 @@
- (void)hideTableView:(BOOL)isHidden;
@end

View file

@ -1,12 +1,15 @@
#import "Common.h"
#import "MWMPPView.h"
#import "UIColor+MapsMeColor.h"
namespace
{
// https://developer.apple.com/library/content/documentation/Cocoa/Conceptual/KeyValueObserving/Articles/KVOBasics.html
void * kContext = &kContext;
NSString * const kTableViewContentSizeKeyPath = @"contentSize";
CGFloat const kTableViewTopInset = -36;
} // namespace
} // namespace
#pragma mark - MWMPPScrollView
@ -22,9 +25,8 @@ NSString * const kTableViewContentSizeKeyPath = @"contentSize";
- (BOOL)pointInside:(CGPoint)point withEvent:(UIEvent *)event
{
if (point.y > [self convertRect:self.inactiveView.bounds fromView:self.inactiveView].origin.y)
return YES;
return NO;
UIView * v = self.inactiveView;
return point.y > [self convertRect:v.bounds fromView:v].origin.y;
}
@end
@ -58,7 +60,7 @@ NSString * const kTableViewContentSizeKeyPath = @"contentSize";
{
NSValue * s = change[@"new"];
CGFloat const height = s.CGSizeValue.height;
if (fabs(height - self.currentContentHeight) > 0.5)
if (!equalScreenDimensions(height, self.currentContentHeight))
{
self.currentContentHeight = height;
self.height = height + self.top.height;
@ -74,18 +76,22 @@ NSString * const kTableViewContentSizeKeyPath = @"contentSize";
- (void)awakeFromNib
{
[super awakeFromNib];
[self.tableView addObserver:self forKeyPath:kTableViewContentSizeKeyPath options:NSKeyValueObservingOptionNew context:kContext];
[self.tableView addObserver:self
forKeyPath:kTableViewContentSizeKeyPath
options:NSKeyValueObservingOptionNew
context:kContext];
self.tableView.estimatedRowHeight = 44.;
self.tableView.rowHeight = UITableViewAutomaticDimension;
self.tableView.contentInset = {.top = -36};
self.tableView.contentInset = {.top = kTableViewTopInset};
NSUInteger const animationImagesCount = 12;
NSUInteger constexpr animationImagesCount = 12;
NSMutableArray * animationImages = [NSMutableArray arrayWithCapacity:animationImagesCount];
NSString * postfix = [UIColor isNightMode] ? @"dark" : @"light";
for (NSUInteger i = 0; i < animationImagesCount; ++i)
animationImages[i] = [UIImage imageNamed:[NSString stringWithFormat:@"Spinner_%@_%@", @(i+1), postfix]];
animationImages[i] =
[UIImage imageNamed:[NSString stringWithFormat:@"Spinner_%@_%@", @(i + 1), postfix]];
self.spinner.animationDuration = 0.8;
self.spinner.animationImages = animationImages;
@ -98,4 +104,3 @@ NSString * const kTableViewContentSizeKeyPath = @"contentSize";
}
@end

View file

@ -1,7 +1,7 @@
@class MWMPlacePageViewManager;
@class MWMPlacePageData;
@protocol MWMActionBarSharedData <NSObject>
@protocol MWMActionBarSharedData<NSObject>
- (BOOL)isBookmark;
- (BOOL)isBooking;

View file

@ -34,8 +34,8 @@ extern NSString * const kAlohalyticsTapEventKey;
+ (MWMPlacePageActionBar *)actionBarWithDelegate:(id<MWMActionBarProtocol>)delegate
{
MWMPlacePageActionBar * bar = [[NSBundle.mainBundle loadNibNamed:[self className] owner:nil options:nil]
firstObject];
MWMPlacePageActionBar * bar =
[[NSBundle.mainBundle loadNibNamed:[self className] owner:nil options:nil] firstObject];
bar.delegate = delegate;
return bar;
}
@ -52,8 +52,7 @@ extern NSString * const kAlohalyticsTapEventKey;
+ (MWMPlacePageActionBar *)actionBarForPlacePageManager:(MWMPlacePageViewManager *)placePageManager
{
MWMPlacePageActionBar * bar =
[[NSBundle.mainBundle loadNibNamed:[self className] owner:nil options:nil]
firstObject];
[[NSBundle.mainBundle loadNibNamed:[self className] owner:nil options:nil] firstObject];
[bar configureWithPlacePageManager:placePageManager];
return bar;
}
@ -71,7 +70,8 @@ extern NSString * const kAlohalyticsTapEventKey;
{
m_visibleButtons.clear();
m_additionalButtons.clear();
auto data = static_cast<id<MWMActionBarSharedData>>(isIOS7 ? self.placePageManager.entity : self.data);
auto data =
static_cast<id<MWMActionBarSharedData>>(IPAD ? self.placePageManager.entity : self.data);
NSString * phone = data.phoneNumber;
BOOL const isIphone = [[UIDevice currentDevice].model isEqualToString:@"iPhone"];
@ -214,7 +214,8 @@ extern NSString * const kAlohalyticsTapEventKey;
- (void)showActionSheet
{
NSString * cancel = L(@"cancel");
auto data = static_cast<id<MWMActionBarSharedData>>(IPAD ? self.placePageManager.entity : self.data);
auto data =
static_cast<id<MWMActionBarSharedData>>(IPAD ? self.placePageManager.entity : self.data);
BOOL const isTitleNotEmpty = data.title.length > 0;
NSString * title = isTitleNotEmpty ? data.title : data.subtitle;
NSString * subtitle = isTitleNotEmpty ? data.subtitle : nil;
@ -266,7 +267,7 @@ extern NSString * const kAlohalyticsTapEventKey;
[super layoutSubviews];
self.width = self.superview.width;
if (IPAD)
self.origin = {0, self.superview.height - 48};
self.origin = {0, self.superview.height - self.height};
self.separator.width = self.width;
CGFloat const buttonWidth = self.width / self.buttons.count;
@ -277,11 +278,6 @@ extern NSString * const kAlohalyticsTapEventKey;
}
}
- (void)setFrame:(CGRect)frame
{
[super setFrame:frame];
}
#pragma mark - Properties
- (void)setIsBookmark:(BOOL)isBookmark

View file

@ -1,6 +1,6 @@
#import "MWMPlacePageBookmarkCell.h"
#import "MWMPlacePageBookmarkDelegate.h"
#import "Common.h"
#import "MWMPlacePageBookmarkDelegate.h"
#import "MapViewController.h"
#import "Statistics.h"
#import "UIColor+MapsMeColor.h"

View file

@ -1,4 +1,4 @@
@protocol MWMPlacePageBookmarkDelegate <NSObject>
@protocol MWMPlacePageBookmarkDelegate<NSObject>
@required
- (void)editBookmarkTap;

View file

@ -1,6 +1,6 @@
#import "MWMTableViewCell.h"
#import "MWMPlacePageEntity.h"
#import "MWMPlacePageData.h"
#import "MWMPlacePageEntity.h"
#import "MWMTableViewCell.h"
@class MWMPlacePageViewManager;
@ -8,7 +8,8 @@
@interface MWMPlacePageButtonCell : MWMTableViewCell
- (void)config:(MWMPlacePageViewManager *)manager forType:(MWMPlacePageCellType)type NS_DEPRECATED_IOS(7_0, 8_0);
- (void)config:(MWMPlacePageViewManager *)manager
forType:(MWMPlacePageCellType)type NS_DEPRECATED_IOS(7_0, 8_0, "Use configForRow:withDelegate: instead");
- (void)configForRow:(place_page::ButtonsRows)row
withDelegate:(id<MWMPlacePageButtonsProtocol>)delegate NS_AVAILABLE_IOS(8_0);

View file

@ -1,9 +1,9 @@
#import "Common.h"
#import "MWMPlacePageButtonCell.h"
#import "Common.h"
#import "MWMFrameworkListener.h"
#import "MWMPlacePageProtocol.h"
#import "MWMPlacePageViewManager.h"
#import "UIColor+MapsMeColor.h"
#import "MWMPlacePageProtocol.h"
@interface MWMPlacePageButtonCell ()<MWMFrameworkStorageObserver>
@ -26,59 +26,56 @@
[self refreshButtonEnabledState];
}
- (void)setEnabled:(BOOL)enabled
{
self.titleButton.enabled = enabled;
}
- (BOOL)isEnabled
{
return self.titleButton.isEnabled;
}
- (void)configForRow:(place_page::ButtonsRows)row withDelegate:(id<MWMPlacePageButtonsProtocol>)delegate
- (void)setEnabled:(BOOL)enabled { self.titleButton.enabled = enabled; }
- (BOOL)isEnabled { return self.titleButton.isEnabled; }
- (void)configForRow:(place_page::ButtonsRows)row
withDelegate:(id<MWMPlacePageButtonsProtocol>)delegate
{
self.delegate = delegate;
self.rowType = row;
switch(row)
NSString * title = nil;
switch (row)
{
case place_page::ButtonsRows::AddPlace:
[self.titleButton setTitle:L(@"placepage_add_place_button") forState:UIControlStateNormal];
title = L(@"placepage_add_place_button");
break;
case place_page::ButtonsRows::EditPlace:
[self.titleButton setTitle:L(@"edit_place") forState:UIControlStateNormal];
title = L(@"edit_place");
break;
case place_page::ButtonsRows::AddBusiness:
[self.titleButton setTitle:L(@"placepage_add_business_button") forState:UIControlStateNormal];
title = L(@"placepage_add_business_button");
break;
case place_page::ButtonsRows::HotelDescription:
[self.titleButton setTitle:L(@"details") forState:UIControlStateNormal];
title = L(@"details");
break;
}
[self.titleButton setTitle:title forState:UIControlStateNormal];
}
- (IBAction)buttonTap
{
if (IPAD)
{
auto m = self.manager;
switch (self.type)
{
case MWMPlacePageCellTypeEditButton: [self.manager editPlace]; break;
case MWMPlacePageCellTypeAddBusinessButton: [self.manager addBusiness]; break;
case MWMPlacePageCellTypeAddPlaceButton: [self.manager addPlace]; break;
case MWMPlacePageCellTypeBookingMore: [self.manager book:YES]; break;
case MWMPlacePageCellTypeEditButton: [m editPlace]; break;
case MWMPlacePageCellTypeAddBusinessButton: [m addBusiness]; break;
case MWMPlacePageCellTypeAddPlaceButton: [m addPlace]; break;
case MWMPlacePageCellTypeBookingMore: [m book:YES]; break;
default: NSAssert(false, @"Incorrect cell type!"); break;
}
return;
}
using namespace place_page;
auto d = self.delegate;
switch (self.rowType)
{
case ButtonsRows::AddPlace: [self.delegate addPlace]; break;
case ButtonsRows::EditPlace: [self.delegate editPlace]; break;
case ButtonsRows::AddBusiness: [self.delegate addBusiness]; break;
case ButtonsRows::HotelDescription: [self.delegate book:YES]; break;
case ButtonsRows::AddPlace: [d addPlace]; break;
case ButtonsRows::EditPlace: [d editPlace]; break;
case ButtonsRows::AddBusiness: [d addBusiness]; break;
case ButtonsRows::HotelDescription: [d book:YES]; break;
}
}

View file

@ -1,4 +1,4 @@
@protocol MWMPlacePageCellUpdateProtocol <NSObject>
@protocol MWMPlacePageCellUpdateProtocol<NSObject>
- (void)updateCellWithForceReposition:(BOOL)isForceReposition;

View file

@ -98,6 +98,8 @@ enum class OpeningHours
// Coordinates
- (m2::PointD const &)mercator;
- (ms::LatLon)latLon;
// TODO(Vlad): Use MWMSettings to store coordinate format.
+ (void)toggleCoordinateSystem;
@end

View file

@ -52,7 +52,8 @@ using namespace place_page;
[self fillMetaInfoSection];
// There is at least one of these buttons.
if (m_info.ShouldShowAddPlace() || m_info.ShouldShowEditPlace() || m_info.ShouldShowAddBusiness() || m_info.IsSponsoredHotel())
if (m_info.ShouldShowAddPlace() || m_info.ShouldShowEditPlace() ||
m_info.ShouldShowAddBusiness() || m_info.IsSponsoredHotel())
{
m_sections.push_back(Sections::Buttons);
[self fillButtonsSection];
@ -63,40 +64,26 @@ using namespace place_page;
{
using namespace osm;
auto const availableProperties = m_info.AvailableProperties();
// We can't match each metadata property to its UI field and thats why we need to use our own enum.
// We can't match each metadata property to its UI field and thats why we need to use our own
// enum.
for (auto const p : availableProperties)
{
switch (p)
{
case Props::OpeningHours:
m_metainfoRows.push_back(MetainfoRows::OpeningHours);
break;
case Props::Phone:
m_metainfoRows.push_back(MetainfoRows::Phone);
break;
case Props::Website:
m_metainfoRows.push_back(MetainfoRows::Website);
break;
case Props::Email:
m_metainfoRows.push_back(MetainfoRows::Email);
break;
case Props::Cuisine:
m_metainfoRows.push_back(MetainfoRows::Cuisine);
break;
case Props::Operator:
m_metainfoRows.push_back(MetainfoRows::Operator);
break;
case Props::Internet:
m_metainfoRows.push_back(MetainfoRows::Internet);
break;
case Props::OpeningHours: m_metainfoRows.push_back(MetainfoRows::OpeningHours); break;
case Props::Phone: m_metainfoRows.push_back(MetainfoRows::Phone); break;
case Props::Website: m_metainfoRows.push_back(MetainfoRows::Website); break;
case Props::Email: m_metainfoRows.push_back(MetainfoRows::Email); break;
case Props::Cuisine: m_metainfoRows.push_back(MetainfoRows::Cuisine); break;
case Props::Operator: m_metainfoRows.push_back(MetainfoRows::Operator); break;
case Props::Internet: m_metainfoRows.push_back(MetainfoRows::Internet); break;
case Props::Wikipedia:
case Props::Elevation:
case Props::Stars:
case Props::Flats:
case Props::BuildingLevels:
case Props::Fax:
break;
case Props::Fax: break;
}
}
@ -132,24 +119,22 @@ using namespace place_page;
auto & bmManager = f.GetBookmarkManager();
if (isBookmark)
{
auto const categoryIndex = static_cast<int>(f.LastEditedBMCategory());
auto const categoryIndex = f.LastEditedBMCategory();
BookmarkData bmData{m_info.FormatNewBookmarkName(), f.LastEditedBMType()};
auto const bookmarkIndex =
static_cast<int>(bmManager.AddBookmark(categoryIndex,self.mercator, bmData));
auto const bookmarkIndex = bmManager.AddBookmark(categoryIndex, self.mercator, bmData);
auto category = f.GetBmCategory(categoryIndex);
NSAssert(category, @"Category can't be nullptr!");
{
BookmarkCategory::Guard guard(*category);
Bookmark * bookmark =
static_cast<Bookmark *>(guard.m_controller.GetUserMarkForEdit(bookmarkIndex));
auto bookmark = static_cast<Bookmark *>(guard.m_controller.GetUserMarkForEdit(bookmarkIndex));
f.FillBookmarkInfo(*bookmark, {bookmarkIndex, categoryIndex}, m_info);
}
m_sections.insert(m_sections.begin() + 1, Sections::Bookmark);
}
else
{
auto const bac = m_info.GetBookmarkAndCategory();
auto const & bac = m_info.GetBookmarkAndCategory();
auto category = bmManager.GetBmCategory(bac.m_categoryIndex);
NSAssert(category, @"Category can't be nullptr!");
{
@ -165,80 +150,64 @@ using namespace place_page;
#pragma mark - Getters
- (storage::TCountryId const &)countryId
{
return m_info.m_countryId;
}
- (FeatureID const &)featureId
{
return m_info.GetID();
}
- (NSString *)title
{
return @(m_info.GetTitle().c_str());
}
- (NSString *)subtitle
{
return @(m_info.GetSubtitle().c_str());
}
- (storage::TCountryId const &)countryId { return m_info.m_countryId; }
- (FeatureID const &)featureId { return m_info.GetID(); }
- (NSString *)title { return @(m_info.GetTitle().c_str()); }
- (NSString *)subtitle { return @(m_info.GetSubtitle().c_str()); }
- (place_page::OpeningHours)schedule;
{
using type = place_page::OpeningHours;
auto const raw = m_info.GetOpeningHours();
if (raw.empty())
return place_page::OpeningHours::Unknown;
return type::Unknown;
auto const t = time(nullptr);
osmoh::OpeningHours oh(raw);
if (oh.IsValid())
{
if (!oh.IsValid())
return type::Unknown;
if (oh.IsTwentyFourHours())
return type::AllDay;
if (oh.IsOpen(t))
return type::Open;
if (oh.IsClosed(t))
return type::Closed;
if (oh.IsTwentyFourHours())
return place_page::OpeningHours::AllDay;
else if (oh.IsOpen(t))
return place_page::OpeningHours::Open;
else if (oh.IsClosed(t))
return place_page::OpeningHours::Closed;
else
return place_page::OpeningHours::Unknown;
}
else
{
return place_page::OpeningHours::Unknown;
}
return type::Unknown;
}
- (NSString *)bookingRating
{
return m_info.IsHotel() ? @(m_info.GetRatingFormatted().c_str()) : nil;
return m_info.IsSponsoredHotel() ? @(m_info.GetRatingFormatted().c_str()) : nil;
}
- (NSString *)bookingApproximatePricing
{
return m_info.IsHotel() ? @(m_info.GetApproximatePricing().c_str()) : nil;
return m_info.IsSponsoredHotel() ? @(m_info.GetApproximatePricing().c_str()) : nil;
}
- (NSURL *)bookingURL
{
return m_info.IsSponsoredHotel() ? [NSURL URLWithString:@(m_info.m_sponsoredBookingUrl.c_str())] : nil;
return m_info.IsSponsoredHotel() ? [NSURL URLWithString:@(m_info.m_sponsoredBookingUrl.c_str())]
: nil;
}
- (NSURL *)bookingDescriptionURL
{
return m_info.IsSponsoredHotel() ? [NSURL URLWithString:@(m_info.m_sponsoredDescriptionUrl.c_str())] : nil;
return m_info.IsSponsoredHotel()
? [NSURL URLWithString:@(m_info.m_sponsoredDescriptionUrl.c_str())]
: nil;
}
- (NSString *)hotelId
{
return m_info.IsSponsoredHotel() ? @(m_info.GetMetadata().Get(feature::Metadata::FMD_SPONSORED_ID).c_str())
: nil;
return m_info.IsSponsoredHotel()
? @(m_info.GetMetadata().Get(feature::Metadata::FMD_SPONSORED_ID).c_str())
: nil;
}
- (void)assignOnlinePriceToLabel:(UILabel *)label
{
// TODO(Vlad): Remove similar code from MWMPlacePageEntity.mm when new iPAD place page will be finished.
NSAssert(m_info.IsSponsoredHotel(), @"Online price must be assigned to booking object!");
if (Platform::ConnectionStatus() == Platform::EConnectionType::CONNECTION_NONE)
return;
@ -253,19 +222,25 @@ using namespace place_page;
string const currency = currencyFormatter.currencyCode.UTF8String;
auto & api = GetFramework().GetBookingApi();
auto const func = [self, label, currency, currencyFormatter](string const & minPrice, string const & priceCurrency)
{
auto const func = [self, label, currency, currencyFormatter](string const & minPrice,
string const & priceCurrency) {
if (currency != priceCurrency)
return;
NSNumberFormatter * decimalFormatter = [[NSNumberFormatter alloc] init];
decimalFormatter.numberStyle = NSNumberFormatterDecimalStyle;
NSString * currencyString = [currencyFormatter stringFromNumber:[decimalFormatter numberFromString:
[@(minPrice.c_str()) stringByReplacingOccurrencesOfString:@"."
withString:decimalFormatter.decimalSeparator]]];
NSString * currencyString = [currencyFormatter
stringFromNumber:
[decimalFormatter
numberFromString:[@(minPrice.c_str())
stringByReplacingOccurrencesOfString:@"."
withString:decimalFormatter
.decimalSeparator]]];
NSString * pattern = [L(@"place_page_starting_from") stringByReplacingOccurrencesOfString:@"%s" withString:@"%@"];
NSString * pattern =
[L(@"place_page_starting_from") stringByReplacingOccurrencesOfString:@"%s"
withString:@"%@"];
dispatch_async(dispatch_get_main_queue(), ^{
label.text = [NSString stringWithFormat:pattern, currencyString];
@ -275,26 +250,19 @@ using namespace place_page;
api.GetMinPrice(self.hotelId.UTF8String, currency, func);
}
- (NSString *)address
{
return @(m_info.GetAddress().c_str());
}
- (NSString *)apiURL
{
return @(m_info.GetApiUrl().c_str());
}
- (NSString *)address { return @(m_info.GetAddress().c_str()); }
- (NSString *)apiURL { return @(m_info.GetApiUrl().c_str()); }
- (NSString *)externalTitle
{
return m_info.IsBookmark() && m_info.m_bookmarkTitle != m_info.GetTitle() ?
@(m_info.m_bookmarkTitle.c_str())
: nil;
return m_info.IsBookmark() && m_info.m_bookmarkTitle != m_info.GetTitle()
? @(m_info.m_bookmarkTitle.c_str())
: nil;
}
- (NSString *)bookmarkColor
{
return m_info.IsBookmark() ? @(m_info.m_bookmarkColorName.c_str()) : nil;;
return m_info.IsBookmark() ? @(m_info.m_bookmarkColorName.c_str()) : nil;
;
}
- (NSString *)bookmarkDescription
@ -304,7 +272,8 @@ using namespace place_page;
- (NSString *)bookmarkCategory
{
return m_info.IsBookmark() ? @(m_info.m_bookmarkCategoryName.c_str()) : nil;;
return m_info.IsBookmark() ? @(m_info.m_bookmarkCategoryName.c_str()) : nil;
;
}
- (BookmarkAndCategory)bac;
@ -312,92 +281,46 @@ using namespace place_page;
return m_info.IsBookmark() ? m_info.m_bac : BookmarkAndCategory();
}
- (vector<Sections> const &)sections
{
return m_sections;
}
- (vector<MetainfoRows> const &)metainfoRows
{
return m_metainfoRows;
}
- (vector<ButtonsRows> const &)buttonsRows
{
return m_buttonsRows;
}
- (vector<Sections> const &)sections { return m_sections; }
- (vector<MetainfoRows> const &)metainfoRows { return m_metainfoRows; }
- (vector<ButtonsRows> const &)buttonsRows { return m_buttonsRows; }
- (NSString *)stringForRow:(MetainfoRows)row
{
switch (row)
{
case MetainfoRows::OpeningHours:
return @(m_info.GetOpeningHours().c_str());
case MetainfoRows::Phone:
return @(m_info.GetPhone().c_str());
case MetainfoRows::Address:
return @(m_info.GetAddress().c_str());
case MetainfoRows::Website:
return @(m_info.GetWebsite().c_str());
case MetainfoRows::Email:
return @(m_info.GetEmail().c_str());
case MetainfoRows::OpeningHours: return @(m_info.GetOpeningHours().c_str());
case MetainfoRows::Phone: return @(m_info.GetPhone().c_str());
case MetainfoRows::Address: return @(m_info.GetAddress().c_str());
case MetainfoRows::Website: return @(m_info.GetWebsite().c_str());
case MetainfoRows::Email: return @(m_info.GetEmail().c_str());
case MetainfoRows::Cuisine:
return @(strings::JoinStrings(m_info.GetCuisines(), Info::kSubtitleSeparator).c_str());
case MetainfoRows::Operator:
return @(m_info.GetOperator().c_str());
case MetainfoRows::Internet:
return L(@"WiFi_available");
case MetainfoRows::Operator: return @(m_info.GetOperator().c_str());
case MetainfoRows::Internet: return L(@"WiFi_available");
case MetainfoRows::Coordinate:
return @(m_info.GetFormattedCoordinate([[NSUserDefaults standardUserDefaults] boolForKey:kUserDefaultsLatLonAsDMSKey]).c_str());
return @(m_info
.GetFormattedCoordinate(
[[NSUserDefaults standardUserDefaults] boolForKey:kUserDefaultsLatLonAsDMSKey])
.c_str());
}
}
#pragma mark - Helpres
- (NSString *)phoneNumber
{
return @(m_info.GetPhone().c_str());
}
- (BOOL)isBookmark
{
return m_info.IsBookmark();
}
- (BOOL)isApi
{
return m_info.HasApiUrl();
}
- (BOOL)isBooking
{
return m_info.IsHotel();
}
- (BOOL)isMyPosition
{
return m_info.IsMyPosition();
}
- (BOOL)isHTMLDescription
{
return strings::IsHTML(m_info.m_bookmarkDescription);
}
- (NSString *)phoneNumber { return @(m_info.GetPhone().c_str()); }
- (BOOL)isBookmark { return m_info.IsBookmark(); }
- (BOOL)isApi { return m_info.HasApiUrl(); }
- (BOOL)isBooking { return m_info.IsSponsoredHotel(); }
- (BOOL)isMyPosition { return m_info.IsMyPosition(); }
- (BOOL)isHTMLDescription { return strings::IsHTML(m_info.m_bookmarkDescription); }
#pragma mark - Coordinates
- (m2::PointD const &)mercator
{
return m_info.GetMercator();
}
- (ms::LatLon)latLon
{
return m_info.GetLatLon();
}
- (m2::PointD const &)mercator { return m_info.GetMercator(); }
- (ms::LatLon)latLon { return m_info.GetLatLon(); }
+ (void)toggleCoordinateSystem
{
// TODO: Move changing latlon's mode to the settings.
NSUserDefaults * ud = [NSUserDefaults standardUserDefaults];
[ud setBool:![ud boolForKey:kUserDefaultsLatLonAsDMSKey] forKey:kUserDefaultsLatLonAsDMSKey];
[ud synchronize];

View file

@ -214,10 +214,7 @@ void initFieldsMap()
return haveField ? @(it->second.c_str()) : nil;
}
- (NSURL *)bookingURL
{
return [self sponsoredUrl:NO];
}
- (NSURL *)bookingURL { return [self sponsoredUrl:NO]; }
- (NSURL *)bookingDescriptionURL { return [self sponsoredUrl:YES]; }
- (NSURL *)sponsoredUrl:(BOOL)isDescription
{
@ -238,11 +235,7 @@ void initFieldsMap()
return self.isBooking ? @(m_info.GetMetadata().Get(Metadata::FMD_SPONSORED_ID).c_str()) : nil;
}
- (NSString *)phoneNumber
{
return [self getCellValue:MWMPlacePageCellTypePhoneNumber];
}
- (NSString *)phoneNumber { return [self getCellValue:MWMPlacePageCellTypePhoneNumber]; }
- (ms::LatLon)latLon { return m_info.GetLatLon(); }
- (m2::PointD const &)mercator { return m_info.GetMercator(); }
- (NSString *)apiURL { return @(m_info.GetApiUrl().c_str()); }
@ -251,7 +244,7 @@ void initFieldsMap()
{
BOOL const useDMSFormat =
[[NSUserDefaults standardUserDefaults] boolForKey:kUserDefaultsLatLonAsDMSKey];
ms::LatLon const latlon = self.latLon;
ms::LatLon const & latlon = self.latLon;
return @((useDMSFormat ? measurement_utils::FormatLatLon(latlon.lat, latlon.lon)
: measurement_utils::FormatLatLonAsDMS(latlon.lat, latlon.lon, 2))
.c_str());

View file

@ -5,9 +5,11 @@
@interface MWMPlacePageInfoCell : MWMTableViewCell
- (void)configureWithType:(MWMPlacePageCellType)type info:(NSString *)info NS_DEPRECATED_IOS(7_0, 8_0);
- (void)configureWithType:(MWMPlacePageCellType)type
info:(NSString *)info NS_DEPRECATED_IOS(7_0, 8_0, "Use configWithRow:data: instead");
- (void)configWithRow:(place_page::MetainfoRows)row data:(MWMPlacePageData *)data NS_AVAILABLE_IOS(8_0);
- (void)configWithRow:(place_page::MetainfoRows)row
data:(MWMPlacePageData *)data NS_AVAILABLE_IOS(8_0);
@property(weak, nonatomic, readonly) IBOutlet UIImageView * icon;
@property(weak, nonatomic, readonly) IBOutlet id textContainer;

View file

@ -19,7 +19,7 @@
@property(weak, nonatomic) IBOutlet UIButton * upperButton;
@property(weak, nonatomic) IBOutlet UIImageView * toggleImage;
@property(nonatomic) MWMPlacePageCellType type NS_DEPRECATED_IOS(7_0, 8_0);
@property(nonatomic) MWMPlacePageCellType type NS_DEPRECATED_IOS(7_0, 8_0, "Use rowType instead");
@property(nonatomic) place_page::MetainfoRows rowType NS_AVAILABLE_IOS(8_0);
@property(weak, nonatomic) MWMPlacePageData * data NS_AVAILABLE_IOS(8_0);
@ -78,11 +78,9 @@
self.toggleImage.hidden = NO;
name = @"coordinate";
break;
case place_page::MetainfoRows::OpeningHours:
NSAssert(false, @"Incorrect cell type!");
break;
case place_page::MetainfoRows::OpeningHours: NSAssert(false, @"Incorrect cell type!"); break;
}
[self configWithIconName:name data:[self.data stringForRow:row]];
[self configWithIconName:name data:[data stringForRow:row]];
}
- (void)configureWithType:(MWMPlacePageCellType)type info:(NSString *)info;
@ -176,7 +174,7 @@
- (IBAction)cellTap
{
if (isIOS7)
if (IPAD)
{
switch (self.type)
{
@ -221,10 +219,8 @@
case place_page::MetainfoRows::Operator:
case place_page::MetainfoRows::OpeningHours:
case place_page::MetainfoRows::Address:
case place_page::MetainfoRows::Internet:
break;
case place_page::MetainfoRows::Internet: break;
}
}
- (void)longTap:(UILongPressGestureRecognizer *)sender

View file

@ -1,13 +1,13 @@
#include "storage/storage_defines.hpp"
@protocol MWMPlacePageLayoutDelegate <NSObject>
@protocol MWMPlacePageLayoutDelegate<NSObject>
- (void)onTopBoundChanged:(CGFloat)bound;
- (void)shouldDestroyLayout;
@end
@protocol MWMPlacePageLayoutDataSource <NSObject>
@protocol MWMPlacePageLayoutDataSource<NSObject>
- (NSString *)distanceToObject;
- (void)downloadSelectedArea;
@ -21,7 +21,8 @@
@interface MWMPlacePageLayout : NSObject
- (instancetype)initWithOwnerView:(UIView *)view
delegate:(id<MWMPlacePageLayoutDelegate, MWMPlacePageButtonsProtocol, MWMActionBarProtocol>)delegate
delegate:(id<MWMPlacePageLayoutDelegate, MWMPlacePageButtonsProtocol,
MWMActionBarProtocol>)delegate
dataSource:(id<MWMPlacePageLayoutDataSource>)dataSource;
- (void)layoutWithSize:(CGSize const &)size;

View file

@ -1,15 +1,14 @@
#import "MWMPlacePageLayout.h"
#import "MWMCircularProgress.h"
#import "MWMPPView.h"
#import "MWMPlacePageActionBar.h"
#import "MWMPlacePageCellUpdateProtocol.h"
#import "MWMPlacePageData.h"
#import "MWMPlacePageLayout.h"
#import "MWMPPView.h"
#import "MWMBookmarkCell.h"
#import "MWMOpeningHoursCell.h"
#import "MWMPlacePageBookmarkCell.h"
#import "MWMPlacePageButtonCell.h"
#import "MWMPlacePageInfoCell.h"
#import "MWMOpeningHoursCell.h"
#import "MWMPlacePagePreviewCell.h"
#import "UIColor+MapsMeColor.h"
@ -19,18 +18,30 @@
namespace
{
enum class ScrollDirection { Up, Down };
enum class ScrollDirection
{
Up,
Down
};
enum class State { Bottom, Top };
enum class State
{
Bottom,
Top
};
CGFloat const kMinOffset = 64;
CGFloat const kOpenPlacePageStopValue = 0.7;
CGFloat const kLuftDraggingOffset = 30;
array<NSString *, 1> kPreviewCells = {{@"MWMPlacePagePreviewCell"}};
array<NSString *, 1> kBookmarkCells = {{@"MWMBookmarkCell"}};
array<NSString *, 9> kMetaInfoCells = {{@"MWMOpeningHoursCell", @"PlacePageLinkCell", @"PlacePageInfoCell", @"PlacePageLinkCell", @"PlacePageLinkCell", @"PlacePageInfoCell", @"PlacePageInfoCell", @"PlacePageInfoCell", @"PlacePageInfoCell"}};
array<NSString *, 9> kMetaInfoCells = {
{@"MWMOpeningHoursCell", @"PlacePageLinkCell", @"PlacePageInfoCell", @"PlacePageLinkCell",
@"PlacePageLinkCell", @"PlacePageInfoCell", @"PlacePageInfoCell", @"PlacePageInfoCell",
@"PlacePageInfoCell"}};
array<NSString *, 1> kButtonsCells = {{@"MWMPlacePageButtonCell"}};
@ -38,23 +49,29 @@ NSTimeInterval const kAnimationDuration = 0.15;
void animate(TMWMVoidBlock animate, TMWMVoidBlock completion = nil)
{
[UIView animateWithDuration:kAnimationDuration delay:0 options:UIViewAnimationOptionCurveEaseIn animations:^{
animate();
} completion:^(BOOL finished) {
if (completion)
completion();
}];
[UIView animateWithDuration:kAnimationDuration
delay:0
options:UIViewAnimationOptionCurveEaseIn
animations:^{
animate();
}
completion:^(BOOL finished) {
if (completion)
completion();
}];
}
} // namespace
@interface MWMPlacePageLayout () <UITableViewDelegate, UITableViewDataSource,
MWMPlacePageCellUpdateProtocol, MWMPlacePageViewUpdateProtocol>
@interface MWMPlacePageLayout ()<UITableViewDelegate, UITableViewDataSource,
MWMPlacePageCellUpdateProtocol, MWMPlacePageViewUpdateProtocol>
@property(weak, nonatomic) MWMPlacePageData * data;
@property(weak, nonatomic) UIView * ownerView;
@property(weak, nonatomic) id<MWMPlacePageLayoutDelegate, MWMPlacePageButtonsProtocol, MWMActionBarProtocol> delegate;
@property(weak, nonatomic)
id<MWMPlacePageLayoutDelegate, MWMPlacePageButtonsProtocol, MWMActionBarProtocol>
delegate;
@property(weak, nonatomic) id<MWMPlacePageLayoutDataSource> dataSource;
@property(nonatomic) MWMPPScrollView * scrollView;
@ -81,7 +98,8 @@ void animate(TMWMVoidBlock animate, TMWMVoidBlock completion = nil)
@implementation MWMPlacePageLayout
- (instancetype)initWithOwnerView:(UIView *)view
delegate:(id<MWMPlacePageLayoutDelegate, MWMPlacePageButtonsProtocol, MWMActionBarProtocol>)delegate
delegate:(id<MWMPlacePageLayoutDelegate, MWMPlacePageButtonsProtocol,
MWMActionBarProtocol>)delegate
dataSource:(id<MWMPlacePageLayoutDataSource>)dataSource
{
self = [super init];
@ -99,13 +117,9 @@ void animate(TMWMVoidBlock animate, TMWMVoidBlock completion = nil)
_scrollView = [[MWMPPScrollView alloc] initWithFrame:view.frame inactiveView:_placePageView];
_portraitOpenContentOffset = MAX(size.width, size.height) * kOpenPlacePageStopValue;
_landscapeOpenContentOffset = MIN(size.width, size.height) * kOpenPlacePageStopValue;
[_ownerView addSubview:_scrollView];
[view addSubview:_scrollView];
[_scrollView addSubview:_placePageView];
auto tv = _placePageView.tableView;
[tv registerNib:[UINib nibWithNibName:kPreviewCells[0] bundle:nil] forCellReuseIdentifier:kPreviewCells[0]];
[tv registerNib:[UINib nibWithNibName:kButtonsCells[0] bundle:nil] forCellReuseIdentifier:kButtonsCells[0]];
[tv registerNib:[UINib nibWithNibName:kBookmarkCells[0] bundle:nil] forCellReuseIdentifier:kBookmarkCells[0]];
[self registerCells];
}
return self;
}
@ -113,27 +127,30 @@ void animate(TMWMVoidBlock animate, TMWMVoidBlock completion = nil)
- (void)registerCells
{
auto tv = self.placePageView.tableView;
[tv registerNib:[UINib nibWithNibName:kPreviewCells[0] bundle:nil]
forCellReuseIdentifier:kPreviewCells[0]];
[tv registerNib:[UINib nibWithNibName:kButtonsCells[0] bundle:nil]
forCellReuseIdentifier:kButtonsCells[0]];
[tv registerNib:[UINib nibWithNibName:kBookmarkCells[0] bundle:nil]
forCellReuseIdentifier:kBookmarkCells[0]];
// Register all meta info cells.
for (auto const i : self.data.metainfoRows)
{
auto name = kMetaInfoCells[static_cast<size_t>(i)];
for (auto const name : kMetaInfoCells)
[tv registerNib:[UINib nibWithNibName:name bundle:nil] forCellReuseIdentifier:name];
}
}
- (void)layoutWithSize:(CGSize const &)size
{
self.scrollView.frame = {{}, size};
self.placePageView.origin = {0., size.height};
self.actionBar.frame = {{0., size.height - 48}, {size.width, 48}};
self.actionBar.frame = {{0., size.height - self.actionBar.height},
{size.width, self.actionBar.height}};
[self.delegate onTopBoundChanged:self.scrollView.contentOffset.y];
}
- (UIView *)shareAnchor
{
return self.actionBar.shareAnchor;
}
- (UIView *)shareAnchor { return self.actionBar.shareAnchor; }
- (void)showWithData:(MWMPlacePageData *)data
{
self.isPlacePageButtonsEnabled = YES;
@ -147,8 +164,7 @@ void animate(TMWMVoidBlock animate, TMWMVoidBlock completion = nil)
[self collapse];
self.data = data;
[self.actionBar configureWithData:static_cast<id<MWMActionBarSharedData>>(self.data)];
[self registerCells];
[self.actionBar configureWithData:static_cast<id<MWMActionBarSharedData>>(data)];
[self.placePageView.tableView reloadData];
}
@ -176,14 +192,16 @@ void animate(TMWMVoidBlock animate, TMWMVoidBlock completion = nil)
- (void)close
{
animate(^ {
self.actionBar.origin = {0., self.ownerView.height};
[self.scrollView setContentOffset:{} animated:YES];
}, ^{
[self.actionBar removeFromSuperview];
self.actionBar = nil;
[self.delegate shouldDestroyLayout];
});
animate(
^{
self.actionBar.origin = {0., self.ownerView.height};
[self.scrollView setContentOffset:{} animated:YES];
},
^{
[self.actionBar removeFromSuperview];
self.actionBar = nil;
[self.delegate shouldDestroyLayout];
});
}
- (void)mwm_refreshUI
@ -195,7 +213,8 @@ void animate(TMWMVoidBlock animate, TMWMVoidBlock completion = nil)
- (void)reloadBookmarkSection:(BOOL)isBookmark
{
auto tv = self.placePageView.tableView;
NSIndexSet * set = [NSIndexSet indexSetWithIndex:static_cast<NSInteger>(place_page::Sections::Bookmark)];
NSIndexSet * set =
[NSIndexSet indexSetWithIndex:static_cast<NSInteger>(place_page::Sections::Bookmark)];
if (isBookmark)
{
@ -214,13 +233,12 @@ void animate(TMWMVoidBlock animate, TMWMVoidBlock completion = nil)
- (void)collapse
{
self.actionBar.hidden = YES;
[self.placePageView hideTableView:YES];
self.scrollView.scrollEnabled = NO;
[self.placePageView hideTableView:YES];
animate(^{
self.actionBar.origin = {0., self.ownerView.height};
[self.scrollView setContentOffset:{0., kMinOffset} animated:YES];
[self.scrollView setContentOffset:{ 0., kMinOffset } animated:YES];
});
}
@ -232,9 +250,11 @@ void animate(TMWMVoidBlock animate, TMWMVoidBlock completion = nil)
animate(^{
[self.placePageView hideTableView:NO];
self.actionBar.minY = self.actionBar.superview.height - self.actionBar.height;
self.expandedContentOffset = self.ppPreviewCell.height + self.placePageView.top.height + self.actionBar.height;
auto const targetOffset = self.state == State::Bottom ? self.expandedContentOffset : self.topContentOffset;
[self.scrollView setContentOffset:{0, targetOffset} animated:YES];
self.expandedContentOffset =
self.ppPreviewCell.height + self.placePageView.top.height + self.actionBar.height;
auto const targetOffset =
self.state == State::Bottom ? self.expandedContentOffset : self.topContentOffset;
[self.scrollView setContentOffset:{ 0, targetOffset } animated:YES];
});
}
@ -246,7 +266,8 @@ void animate(TMWMVoidBlock animate, TMWMVoidBlock completion = nil)
- (CGFloat)topContentOffset
{
auto const target = self.isPortrait ? self.portraitOpenContentOffset : self.landscapeOpenContentOffset;
auto const target =
self.isPortrait ? self.portraitOpenContentOffset : self.landscapeOpenContentOffset;
if (target > self.placePageView.height)
return self.placePageView.height;
@ -259,17 +280,18 @@ void animate(TMWMVoidBlock animate, TMWMVoidBlock completion = nil)
{
using namespace storage;
switch(status)
auto const & sections = self.data.sections;
switch (status)
{
case NodeStatus::Undefined:
{
self.isPlacePageButtonsEnabled = YES;
auto const & sections = self.data.sections;
auto const it = find(sections.begin(), sections.end(), place_page::Sections::Buttons);
if (it != sections.end())
{
[self.placePageView.tableView reloadSections:[NSIndexSet indexSetWithIndex:distance(sections.begin(), it)]
withRowAnimation:UITableViewRowAnimationAutomatic];
[self.placePageView.tableView
reloadSections:[NSIndexSet indexSetWithIndex:distance(sections.begin(), it)]
withRowAnimation:UITableViewRowAnimationAutomatic];
}
if (self.ppPreviewCell)
@ -279,46 +301,47 @@ void animate(TMWMVoidBlock animate, TMWMVoidBlock completion = nil)
break;
}
case NodeStatus::Downloading:
{
self.ppPreviewCell.mapDownloadProgress.progress = progress;
break;
}
case NodeStatus::InQueue:
{
self.ppPreviewCell.mapDownloadProgress.state = MWMCircularProgressStateSpinner;
break;
}
case NodeStatus::Error:
{
self.ppPreviewCell.mapDownloadProgress.state = MWMCircularProgressStateFailed;
break;
case NodeStatus::Partly:
break;
}
case NodeStatus::Partly: break;
case NodeStatus::OnDiskOutOfDate:
case NodeStatus::OnDisk:
{
self.isPlacePageButtonsEnabled = YES;
auto const & sections = self.data.sections;
auto const it = find(sections.begin(), sections.end(), place_page::Sections::Buttons);
if (it != sections.end())
{
[self.placePageView.tableView reloadSections:[NSIndexSet indexSetWithIndex:distance(sections.begin(), it)]
withRowAnimation:UITableViewRowAnimationAutomatic];
[self.placePageView.tableView
reloadSections:[NSIndexSet indexSetWithIndex:distance(sections.begin(), it)]
withRowAnimation:UITableViewRowAnimationAutomatic];
}
[self.ppPreviewCell setDownloaderViewHidden:YES animated:NO];
break;
}
case NodeStatus::NotDownloaded:
{
self.isPlacePageButtonsEnabled = NO;
if (self.ppPreviewCell)
[self.ppPreviewCell setDownloaderViewHidden:NO animated:NO];
else
self.isDownloaderViewShown = YES;
break;
}
}
}
#pragma mark - UIScrollViewDelegate
@ -328,24 +351,25 @@ void animate(TMWMVoidBlock animate, TMWMVoidBlock completion = nil)
if ([scrollView isEqual:self.placePageView.tableView])
return;
auto const offset = scrollView.contentOffset;
auto const & offset = scrollView.contentOffset;
id<MWMPlacePageLayoutDelegate> delegate = self.delegate;
if (offset.y <= 0)
{
[self.scrollView removeFromSuperview];
[self.actionBar removeFromSuperview];
[self.delegate shouldDestroyLayout];
[delegate shouldDestroyLayout];
return;
}
if (offset.y > self.placePageView.height + 30)
if (offset.y > self.placePageView.height + kLuftDraggingOffset)
{
auto const bounded = self.placePageView.height + 30;
auto const bounded = self.placePageView.height + kLuftDraggingOffset;
[scrollView setContentOffset:{0, bounded}];
[self.delegate onTopBoundChanged:bounded];
[delegate onTopBoundChanged:bounded];
}
else
{
[self.delegate onTopBoundChanged:offset.y];
[delegate onTopBoundChanged:offset.y];
}
self.direction = self.lastContentOffset < offset.y ? ScrollDirection::Up : ScrollDirection::Down;
@ -357,13 +381,16 @@ void animate(TMWMVoidBlock animate, TMWMVoidBlock completion = nil)
targetContentOffset:(inout CGPoint *)targetContentOffset
{
auto const actualOffset = scrollView.contentOffset.y;
auto const openOffset = self.isPortrait ? self.portraitOpenContentOffset : self.landscapeOpenContentOffset;
auto const openOffset =
self.isPortrait ? self.portraitOpenContentOffset : self.landscapeOpenContentOffset;
auto const targetOffset = (*targetContentOffset).y;
if (actualOffset > self.expandedContentOffset && actualOffset < openOffset)
{
self.state = self.direction == ScrollDirection::Up ? State::Top : State::Bottom;
(*targetContentOffset).y = self.direction == ScrollDirection::Up ? openOffset : self.expandedContentOffset;
auto const isDirectionUp = self.direction == ScrollDirection::Up;
self.state = isDirectionUp ? State::Top : State::Bottom;
(*targetContentOffset).y =
isDirectionUp ? openOffset : self.expandedContentOffset;
}
else if (actualOffset > openOffset && targetOffset < openOffset)
{
@ -389,19 +416,22 @@ void animate(TMWMVoidBlock animate, TMWMVoidBlock completion = nil)
return;
auto const actualOffset = scrollView.contentOffset.y;
auto const openOffset = self.isPortrait ? self.portraitOpenContentOffset : self.landscapeOpenContentOffset;
if (actualOffset < self.expandedContentOffset + 30)
auto const openOffset =
self.isPortrait ? self.portraitOpenContentOffset : self.landscapeOpenContentOffset;
if (actualOffset < self.expandedContentOffset + kLuftDraggingOffset)
{
self.state = State::Bottom;
animate(^{
[scrollView setContentOffset:{0, self.expandedContentOffset} animated:YES];
[scrollView setContentOffset:{ 0, self.expandedContentOffset } animated:YES];
});
}
else if (actualOffset < openOffset)
{
self.state = self.direction == ScrollDirection::Up ? State::Top : State::Bottom;
auto const isDirectionUp = self.direction == ScrollDirection::Up;
self.state = isDirectionUp ? State::Top : State::Bottom;
animate(^{
[scrollView setContentOffset:{0, self.direction == ScrollDirection::Up ? openOffset : self.expandedContentOffset}
[scrollView setContentOffset:{0, isDirectionUp ? openOffset : self.expandedContentOffset}
animated:YES];
});
}
@ -415,36 +445,42 @@ void animate(TMWMVoidBlock animate, TMWMVoidBlock completion = nil)
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
if (!self.data)
auto data = self.data;
if (!data)
return 0;
return self.data.sections.size();
return data.sections.size();
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
using namespace place_page;
switch (self.data.sections[section])
auto data = self.data;
switch (data.sections[section])
{
case Sections::Preview:
case Sections::Bookmark: return 1;
case Sections::Metainfo: return self.data.metainfoRows.size();
case Sections::Buttons: return self.data.buttonsRows.size();
case Sections::Metainfo: return data.metainfoRows.size();
case Sections::Buttons: return data.buttonsRows.size();
}
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
- (UITableViewCell *)tableView:(UITableView *)tableView
cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
using namespace place_page;
switch (self.data.sections[indexPath.section])
auto data = self.data;
id<MWMPlacePageButtonsProtocol> delegate = self.delegate;
switch (data.sections[indexPath.section])
{
case Sections::Preview:
{
if (!self.ppPreviewCell)
self.ppPreviewCell = [tableView dequeueReusableCellWithIdentifier:[MWMPlacePagePreviewCell className]];
self.ppPreviewCell =
[tableView dequeueReusableCellWithIdentifier:[MWMPlacePagePreviewCell className]];
[self.ppPreviewCell configure:self.data updateLayoutDelegate:self dataSource:self.dataSource];
[self.ppPreviewCell configure:data updateLayoutDelegate:self dataSource:self.dataSource];
[self.ppPreviewCell setDownloaderViewHidden:!self.isDownloaderViewShown animated:NO];
return self.ppPreviewCell;
@ -452,25 +488,28 @@ void animate(TMWMVoidBlock animate, TMWMVoidBlock completion = nil)
case Sections::Bookmark:
{
MWMBookmarkCell * c = [tableView dequeueReusableCellWithIdentifier:kBookmarkCells[0]];
[c configureWithText:self.data.bookmarkDescription
updateCellDelegate:self
editBookmarkDelegate:self.delegate
isHTML:self.data.isHTMLDescription];
[c configureWithText:data.bookmarkDescription
updateCellDelegate:self
editBookmarkDelegate:delegate
isHTML:data.isHTMLDescription];
return c;
}
case Sections::Metainfo:
{
auto const row = self.data.metainfoRows[indexPath.row];
auto const row = data.metainfoRows[indexPath.row];
auto cellName = kMetaInfoCells[static_cast<size_t>(row)];
UITableViewCell * c = [tableView dequeueReusableCellWithIdentifier:cellName];
switch (row)
{
case MetainfoRows::OpeningHours:
[static_cast<MWMOpeningHoursCell *>(c) configureWithOpeningHours:[self.data stringForRow:row]
updateLayoutDelegate:self
isClosedNow:self.data.schedule == OpeningHours::Closed];
{
[static_cast<MWMOpeningHoursCell *>(c)
configureWithOpeningHours:[data stringForRow:row]
updateLayoutDelegate:self
isClosedNow:data.schedule == OpeningHours::Closed];
break;
}
case MetainfoRows::Phone:
case MetainfoRows::Address:
case MetainfoRows::Website:
@ -479,16 +518,18 @@ void animate(TMWMVoidBlock animate, TMWMVoidBlock completion = nil)
case MetainfoRows::Operator:
case MetainfoRows::Internet:
case MetainfoRows::Coordinate:
[static_cast<MWMPlacePageInfoCell *>(c) configWithRow:row data:self.data];
{
[static_cast<MWMPlacePageInfoCell *>(c) configWithRow:row data:data];
break;
}
}
return c;
}
case Sections::Buttons:
{
MWMPlacePageButtonCell * c = [tableView dequeueReusableCellWithIdentifier:kButtonsCells[0]];
auto const row = self.data.buttonsRows[indexPath.row];
[c configForRow:row withDelegate:self.delegate];
auto const row = data.buttonsRows[indexPath.row];
[c configForRow:row withDelegate:delegate];
if (row != ButtonsRows::HotelDescription)
[c setEnabled:self.isPlacePageButtonsEnabled];

View file

@ -1,5 +1,5 @@
#import "MWMPlacePageProtocol.h"
@interface MWMPlacePageManager : NSObject <MWMPlacePageProtocol>
@interface MWMPlacePageManager : NSObject<MWMPlacePageProtocol>
@end

View file

@ -1,28 +1,27 @@
#import "MapViewController.h"
#import "MWMActivityViewController.h"
#import "MWMAPIBar.h"
#import "MWMCircularProgress.h"
#import "MWMPlacePageManager.h"
#import "MWMViewController.h"
#import "MWMPlacePageLayout.h"
#import "MWMPlacePageData.h"
#import <Pushwoosh/PushNotificationManager.h>
#import "MWMAPIBar.h"
#import "MWMActivityViewController.h"
#import "MWMCircularProgress.h"
#import "MWMEditBookmarkController.h"
#import "MWMFrameworkListener.h"
#import "MWMFrameworkObservers.h"
#import "MWMLocationManager.h"
#import "MWMPlacePageData.h"
#import "MWMPlacePageLayout.h"
#import "MWMRouter.h"
#import "MWMStorage.h"
#import "MWMEditBookmarkController.h"
#import "MWMViewController.h"
#import "MapViewController.h"
#import "Statistics.h"
#import <Pushwoosh/PushNotificationManager.h>
#include "geometry/distance_on_sphere.hpp"
#include "platform/measurement_utils.hpp"
@interface MWMPlacePageManager() <MWMFrameworkStorageObserver, MWMPlacePageLayoutDelegate,
@interface MWMPlacePageManager ()<MWMFrameworkStorageObserver, MWMPlacePageLayoutDelegate,
MWMPlacePageLayoutDataSource, MWMLocationObserver>
@property(weak, nonatomic) MWMViewController * ownerViewController;
@property(nonatomic) MWMPlacePageEntity * entity;
@property(nonatomic) MWMPlacePageLayout * layout;
@ -34,35 +33,32 @@
@implementation MWMPlacePageManager
- (instancetype)initWithViewController:(MWMViewController *)viewController
{
self = [super init];
if (self)
_ownerViewController = viewController;
return self;
}
- (void)showPlacePage:(place_page::Info const &)info
{
self.currentDownloaderStatus = storage::NodeStatus::Undefined;
[MWMFrameworkListener addObserver:self];
self.data = [[MWMPlacePageData alloc] initWithPlacePageInfo:info];
if (!self.layout)
{
self.layout = [[MWMPlacePageLayout alloc] initWithOwnerView:self.ownerViewController.view
delegate:self
dataSource:self];
}
[self.layout showWithData:self.data];
// Call for the first time to produce changes
[self processCountryEvent:self.data.countryId];
if (![MWMLocationManager lastHeading])
return;
[MWMLocationManager addObserver:self];
[self.layout setDistanceToObject:self.distanceToObject];
}
- (void)closePlacePage
{
[_layout close];
[self.layout close];
[MWMLocationManager removeObserver:self];
[MWMFrameworkListener removeObserver:self];
}
@ -77,16 +73,14 @@
MWMAlertViewController * avc = [MapViewController controller].alertController;
switch (nodeAttrs.m_status)
{
case NodeStatus::NotDownloaded:
case NodeStatus::Partly:
[MWMStorage downloadNode:countryId alertController:avc onSuccess:nil];
break;
case NodeStatus::Undefined:
case NodeStatus::Error: [MWMStorage retryDownloadNode:countryId]; break;
case NodeStatus::OnDiskOutOfDate: [MWMStorage updateNode:countryId alertController:avc]; break;
case NodeStatus::Downloading:
case NodeStatus::InQueue: [MWMStorage cancelDownloadNode:countryId]; break;
case NodeStatus::OnDisk: break;
case NodeStatus::NotDownloaded:
case NodeStatus::Partly: [MWMStorage downloadNode:countryId alertController:avc onSuccess:nil]; break;
case NodeStatus::Undefined:
case NodeStatus::Error: [MWMStorage retryDownloadNode:countryId]; break;
case NodeStatus::OnDiskOutOfDate: [MWMStorage updateNode:countryId alertController:avc]; break;
case NodeStatus::Downloading:
case NodeStatus::InQueue: [MWMStorage cancelDownloadNode:countryId]; break;
case NodeStatus::OnDisk: break;
}
}
@ -96,10 +90,10 @@
if (!lastLocation)
return @"";
string distance;
CLLocationCoordinate2D const coord = lastLocation.coordinate;
ms::LatLon const target = self.data.latLon;
CLLocationCoordinate2D const & coord = lastLocation.coordinate;
ms::LatLon const & target = self.data.latLon;
measurement_utils::FormatDistance(
ms::DistanceOnEarth(coord.latitude, coord.longitude, target.lat, target.lon), distance);
ms::DistanceOnEarth(coord.latitude, coord.longitude, target.lat, target.lon), distance);
return @(distance.c_str());
}
@ -109,7 +103,7 @@
{
if (countryId == kInvalidCountryId)
{
[_layout processDownloaderEventWithStatus:storage::NodeStatus::Undefined progress:0];
[self.layout processDownloaderEventWithStatus:storage::NodeStatus::Undefined progress:0];
return;
}
@ -124,35 +118,26 @@
return;
self.currentDownloaderStatus = status;
[_layout processDownloaderEventWithStatus:status progress:0];
[self.layout processDownloaderEventWithStatus:status progress:0];
}
- (void)processCountry:(TCountryId const &)countryId progress:(MapFilesDownloader::TProgress const &)progress
- (void)processCountry:(TCountryId const &)countryId
progress:(MapFilesDownloader::TProgress const &)progress
{
if (countryId == kInvalidCountryId || self.data.countryId != countryId)
return;
[_layout processDownloaderEventWithStatus:storage::NodeStatus::Downloading
progress:static_cast<CGFloat>(progress.first) / progress.second];
[self.layout
processDownloaderEventWithStatus:storage::NodeStatus::Downloading
progress:static_cast<CGFloat>(progress.first) / progress.second];
}
#pragma mark - MWMPlacePageLayout
- (MWMPlacePageLayout *)layout
{
if (!_layout)
{
_layout = [[MWMPlacePageLayout alloc] initWithOwnerView:self.ownerViewController.view
delegate:self
dataSource:self];
}
return _layout;
}
- (void)onTopBoundChanged:(CGFloat)bound
{
[[MWMMapViewControlsManager manager] dragPlacePage:{{0, self.ownerViewController.view.height - bound}, {}}];
[[MWMMapViewControlsManager manager]
dragPlacePage:{{0, self.ownerViewController.view.height - bound}, {}}];
}
- (void)shouldDestroyLayout
@ -170,29 +155,17 @@
return;
CGFloat const angle = ang::AngleTo(lastLocation.mercator, self.data.mercator) + info.m_bearing;
[_layout rotateDirectionArrowToAngle:angle];
[self.layout rotateDirectionArrowToAngle:angle];
}
- (void)onLocationUpdate:(location::GpsInfo const &)locationInfo
{
[_layout setDistanceToObject:self.distanceToObject];
}
- (void)mwm_refreshUI
{
[_layout mwm_refreshUI];
}
- (void)dismissPlacePage
{
[self closePlacePage];
}
- (void)hidePlacePage
{
[self closePlacePage];
[self.layout setDistanceToObject:self.distanceToObject];
}
- (void)mwm_refreshUI { [self.layout mwm_refreshUI]; }
- (void)dismissPlacePage { [self closePlacePage]; }
- (void)hidePlacePage { [self closePlacePage]; }
- (void)routeFrom
{
[Statistics logEvent:kStatEventName(kStatPlacePage, kStatBuildRoute)
@ -212,14 +185,15 @@
- (MWMRoutePoint)target
{
NSString * name = nil;
if (self.data.title.length > 0)
name = self.data.title;
else if (self.data.address.length > 0)
name = self.data.address;
else if (self.data.subtitle.length > 0)
name = self.data.subtitle;
else if (self.data.isBookmark)
name = self.data.externalTitle;
auto d = self.data;
if (d.title.length > 0)
name = d.title;
else if (d.address.length > 0)
name = d.address;
else if (d.subtitle.length > 0)
name = d.subtitle;
else if (d.isBookmark)
name = d.externalTitle;
else
name = L(@"placepage_unknown_place");
@ -230,8 +204,8 @@
- (void)share
{
[Statistics logEvent:kStatEventName(kStatPlacePage, kStatShare)];
MWMActivityViewController * shareVC =
[MWMActivityViewController shareControllerForPlacePageObject:static_cast<id<MWMPlacePageObject>>(self.data)];
MWMActivityViewController * shareVC = [MWMActivityViewController
shareControllerForPlacePageObject:static_cast<id<MWMPlacePageObject>>(self.data)];
[shareVC presentInParentViewController:self.ownerViewController
anchorView:self.layout.shareAnchor];
}
@ -256,7 +230,6 @@
[[MWMMapViewControlsManager manager] addPlace:NO hasPoint:YES point:self.data.mercator];
}
- (void)addBookmark
{
[self.data updateBookmarkStatus:YES];
@ -271,16 +244,12 @@
[self.layout reloadBookmarkSection:NO];
}
- (void)editBookmark
{
[[MapViewController controller] openBookmarkEditorWithData:self.data];
}
- (void)editBookmark { [[MapViewController controller] openBookmarkEditorWithData:self.data]; }
- (void)book:(BOOL)isDescription
{
NSMutableDictionary * stat = [@{ kStatProvider : kStatBooking } mutableCopy];
MWMPlacePageData * data = self.data;
auto const latLon = data.latLon;
auto const & latLon = data.latLon;
stat[kStatHotel] = data.hotelId;
stat[kStatHotelLat] = @(latLon.lat);
stat[kStatHotelLon] = @(latLon.lon);
@ -298,7 +267,7 @@
{
NSAssert(self.data.phoneNumber, @"Phone number can't be nil!");
NSString * phoneNumber = [[@"telprompt:" stringByAppendingString:self.data.phoneNumber]
stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:phoneNumber]];
}
@ -309,27 +278,31 @@
[[MapViewController controller].apiBar back];
}
- (void)viewWillTransitionToSize:(CGSize)size withTransitionCoordinator:(id<UIViewControllerTransitionCoordinator>)coordinator
- (void)viewWillTransitionToSize:(CGSize)size
withTransitionCoordinator:(id<UIViewControllerTransitionCoordinator>)coordinator
{
[coordinator animateAlongsideTransition:^(id<UIViewControllerTransitionCoordinatorContext> context) {
[self->_layout layoutWithSize:size];
} completion:^(id<UIViewControllerTransitionCoordinatorContext> context) { }];
[coordinator
animateAlongsideTransition:^(id<UIViewControllerTransitionCoordinatorContext> context) {
[self.layout layoutWithSize:size];
}
completion:^(id<UIViewControllerTransitionCoordinatorContext> context){
}];
}
#pragma mark - MWMFeatureHolder
- (FeatureID const &)featureId
{
return self.data.featureId;
}
- (FeatureID const &)featureId { return self.data.featureId; }
#pragma mark - Owner
- (MapViewController *)ownerViewController { return [MapViewController controller]; }
#pragma mark - Deprecated
@synthesize leftBound = _leftBound;
@synthesize topBound = _topBound;
- (void)setTopBound:(CGFloat)topBound {_topBound = 0;}
- (void)setLeftBound:(CGFloat)leftBound {_leftBound = 0;}
- (void)addSubviews:(NSArray *)views withNavigationController:(UINavigationController *)controller {}
- (void)setTopBound:(CGFloat)topBound { _topBound = 0; }
- (void)setLeftBound:(CGFloat)leftBound { _leftBound = 0; }
- (void)addSubviews:(NSArray *)views withNavigationController:(UINavigationController *)controller
{
}
- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)orientation {}
@end

View file

@ -15,9 +15,8 @@
- (void)setDownloadingProgress:(CGFloat)progress;
- (void)configure:(MWMPlacePageData *)data
updateLayoutDelegate:(id<MWMPlacePageCellUpdateProtocol>)delegate
dataSource:(id<MWMPlacePageLayoutDataSource>)dataSource;
updateLayoutDelegate:(id<MWMPlacePageCellUpdateProtocol>)delegate
dataSource:(id<MWMPlacePageLayoutDataSource>)dataSource;
- (MWMCircularProgress *)mapDownloadProgress;

View file

@ -1,10 +1,10 @@
#import "MWMPlacePagePreviewCell.h"
#import "Common.h"
#import "MWMCircularProgress.h"
#import "MWMDirectionView.h"
#import "MWMPlacePageCellUpdateProtocol.h"
#import "MWMPlacePageData.h"
#import "MWMPlacePageLayout.h"
#import "MWMPlacePagePreviewCell.h"
#import "MWMCircularProgress.h"
#import "UIColor+MapsmeColor.h"
#include "std/array.hpp"
@ -12,12 +12,8 @@
namespace
{
array<NSString *, 6> kPPPClasses = {{@"_MWMPPPTitle",
@"_MWMPPPExternalTitle",
@"_MWMPPPSubtitle",
@"_MWMPPPSchedule",
@"_MWMPPPBooking",
@"_MWMPPPAddress"}};
array<NSString *, 6> kPPPClasses = {{@"_MWMPPPTitle", @"_MWMPPPExternalTitle", @"_MWMPPPSubtitle",
@"_MWMPPPSchedule", @"_MWMPPPBooking", @"_MWMPPPAddress"}};
enum class Labels
{
@ -128,7 +124,8 @@ CGFloat const kCompressedTableViewLeading = 56;
#pragma mark - Public
@interface MWMPlacePagePreviewCell () <UITableViewDelegate, UITableViewDataSource, MWMCircularProgressProtocol>
@interface MWMPlacePagePreviewCell ()<UITableViewDelegate, UITableViewDataSource,
MWMCircularProgressProtocol>
{
vector<Labels> m_cells;
}
@ -170,11 +167,7 @@ CGFloat const kCompressedTableViewLeading = 56;
[self registerObserver];
}
- (void)dealloc
{
[self unregisterObserver];
}
- (void)dealloc { [self unregisterObserver]; }
- (void)observeValueForKeyPath:(NSString *)keyPath
ofObject:(id)object
change:(NSDictionary *)change
@ -184,7 +177,7 @@ CGFloat const kCompressedTableViewLeading = 56;
{
NSValue * s = change[@"new"];
CGFloat const height = s.CGSizeValue.height;
if (abs(height - self.currentContentHeight) > 0.5)
if (!equalScreenDimensions(height, self.currentContentHeight))
{
self.currentContentHeight = height;
self.tableViewHeight.constant = height;
@ -214,8 +207,9 @@ CGFloat const kCompressedTableViewLeading = 56;
- (void)rotateDirectionArrowToAngle:(CGFloat)angle
{
self.compass.layer.transform = CATransform3DMakeRotation(M_PI_2 - angle, 0, 0, 1);
self.directionView.directionArrow.layer.transform = CATransform3DMakeRotation(M_PI_2 - angle, 0, 0, 1);
auto const t = CATransform3DMakeRotation(M_PI_2 - angle, 0, 0, 1);
self.compass.layer.transform = t;
self.directionView.directionArrow.layer.transform = t;
}
- (void)setDistanceToObject:(NSString *)distance
@ -242,18 +236,18 @@ CGFloat const kCompressedTableViewLeading = 56;
- (void)registerObserver
{
[self.tableView addObserver:self forKeyPath:kTableViewContentSizeKeyPath options:NSKeyValueObservingOptionNew context:kContext];
}
- (void)setDownloadingProgress:(CGFloat)progress
{
self.mapDownloadProgress.progress = progress;
[self.tableView addObserver:self
forKeyPath:kTableViewContentSizeKeyPath
options:NSKeyValueObservingOptionNew
context:kContext];
}
- (void)setDownloadingProgress:(CGFloat)progress { self.mapDownloadProgress.progress = progress; }
- (void)setDownloaderViewHidden:(BOOL)isHidden animated:(BOOL)isAnimated
{
self.downloaderParentView.hidden = isHidden;
self.tableViewLeading.constant = isHidden ? kDefaultTableViewLeading : kCompressedTableViewLeading;
self.tableViewLeading.constant =
isHidden ? kDefaultTableViewLeading : kCompressedTableViewLeading;
[self setNeedsLayout];
if (!isHidden)
@ -261,15 +255,16 @@ CGFloat const kCompressedTableViewLeading = 56;
if (!isAnimated)
return;
[UIView animateWithDuration:kDefaultAnimationDuration animations:^{
[self layoutIfNeeded];
}];
[UIView animateWithDuration:kDefaultAnimationDuration
animations:^{
[self layoutIfNeeded];
}];
}
- (void)configure:(MWMPlacePageData *)data
updateLayoutDelegate:(id<MWMPlacePageCellUpdateProtocol>)delegate
dataSource:(id<MWMPlacePageLayoutDataSource>)dataSource
updateLayoutDelegate:(id<MWMPlacePageCellUpdateProtocol>)delegate
dataSource:(id<MWMPlacePageLayoutDataSource>)dataSource
{
self.data = data;
self.delegate = delegate;
@ -304,11 +299,13 @@ CGFloat const kCompressedTableViewLeading = 56;
return m_cells.size();
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
- (UITableViewCell *)tableView:(UITableView *)tableView
cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
auto data = self.data;
_MWMPPPCellBase * c = nil;
BOOL const isNeedToShowDistance = self.isDirectionViewAvailable && (indexPath.row == m_cells.size() - 1);
BOOL const isNeedToShowDistance =
self.isDirectionViewAvailable && (indexPath.row == m_cells.size() - 1);
switch (m_cells[indexPath.row])
{
@ -334,7 +331,7 @@ CGFloat const kCompressedTableViewLeading = 56;
{
c = [tableView dequeueReusableCellWithIdentifier:[_MWMPPPSchedule className]];
auto castedCell = static_cast<_MWMPPPSchedule *>(c);
switch(data.schedule)
switch (data.schedule)
{
case place_page::OpeningHours::AllDay:
castedCell.schedule.text = L(@"twentyfour_seven");
@ -348,9 +345,7 @@ CGFloat const kCompressedTableViewLeading = 56;
castedCell.schedule.text = L(@"closed_now");
castedCell.schedule.textColor = [UIColor red];
break;
case place_page::OpeningHours::Unknown:
NSAssert(false, @"Incorrect schedule!");
break;
case place_page::OpeningHours::Unknown: NSAssert(false, @"Incorrect schedule!"); break;
}
break;
}
@ -382,7 +377,9 @@ CGFloat const kCompressedTableViewLeading = 56;
{
cell.trailing.priority = UILayoutPriorityDefaultLow;
cell.distance.text = self.distance;
cell.tapOnDistance = ^{ [self.directionView show]; };
cell.tapOnDistance = ^{
[self.directionView show];
};
[cell.contentView setNeedsLayout];
self.compass = cell.compass;
self.trailing = cell.trailing;
@ -411,12 +408,12 @@ CGFloat const kCompressedTableViewLeading = 56;
if (!_mapDownloadProgress)
{
_mapDownloadProgress =
[MWMCircularProgress downloaderProgressForParentView:self.downloaderParentView];
[MWMCircularProgress downloaderProgressForParentView:self.downloaderParentView];
_mapDownloadProgress.delegate = self;
MWMCircularProgressStateVec const affectedStates = {MWMCircularProgressStateNormal,
MWMCircularProgressStateSelected};
MWMCircularProgressStateSelected};
[_mapDownloadProgress setImage:[UIImage imageNamed:@"ic_download"] forStates:affectedStates];
[_mapDownloadProgress setColoring:MWMButtonColoringBlue forStates:affectedStates];
}

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="11201" systemVersion="15G31" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES">
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="11201" systemVersion="16A323" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES">
<dependencies>
<deployment version="2048" identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="11161"/>
@ -12,13 +12,13 @@
<rect key="frame" x="0.0" y="0.0" width="320" height="167"/>
<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">
<frame key="frameInset" width="320" height="166.5"/>
<frame key="frameInset" width="320" height="166"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<tableView clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" scrollEnabled="NO" showsHorizontalScrollIndicator="NO" showsVerticalScrollIndicator="NO" style="plain" separatorStyle="none" allowsSelection="NO" rowHeight="44" sectionHeaderHeight="28" sectionFooterHeight="28" translatesAutoresizingMaskIntoConstraints="NO" id="tq9-b1-aiY">
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<constraints>
<constraint firstAttribute="height" relation="greaterThanOrEqual" constant="10" id="s23-Km-i33"/>
<constraint firstAttribute="height" relation="greaterThanOrEqual" priority="750" constant="10" id="s23-Km-i33"/>
</constraints>
<connections>
<outlet property="dataSource" destination="KGk-i7-Jjw" id="28P-dl-tGh"/>

View file

@ -4,7 +4,7 @@
@class MWMPlacePageEntity, MWMViewController;
@protocol MWMActionBarProtocol <NSObject>
@protocol MWMActionBarProtocol<NSObject>
- (void)routeFrom;
- (void)routeTo;
@ -21,7 +21,7 @@
@end
@protocol MWMPlacePageButtonsProtocol <NSObject>
@protocol MWMPlacePageButtonsProtocol<NSObject>
- (void)editPlace;
- (void)addPlace;
@ -33,19 +33,17 @@
struct FeatureID;
@protocol MWMFeatureHolder <NSObject>
@protocol MWMFeatureHolder<NSObject>
- (FeatureID const &)featureId;
@end
@protocol MWMPlacePageProtocol <MWMActionBarProtocol, MWMPlacePageButtonsProtocol, MWMFeatureHolder>
@protocol MWMPlacePageProtocol<MWMActionBarProtocol, MWMPlacePageButtonsProtocol, MWMFeatureHolder>
@property(weak, nonatomic, readonly) MWMViewController * ownerViewController;
@property(nonatomic) CGFloat topBound;
@property(nonatomic) CGFloat leftBound;
- (instancetype)initWithViewController:(MWMViewController *)viewController;
- (void)showPlacePage:(place_page::Info const &)info;
- (void)mwm_refreshUI;
- (void)dismissPlacePage;

View file

@ -6,14 +6,13 @@
@class MWMPlacePageEntity, MWMPlacePageNavigationBar, MWMViewController;
@interface MWMPlacePageViewManager : NSObject <MWMPlacePageProtocol>
@interface MWMPlacePageViewManager : NSObject<MWMPlacePageProtocol>
@property(weak, nonatomic, readonly) MWMViewController * ownerViewController;
@property(nonatomic, readonly) MWMPlacePageEntity * entity;
@property(nonatomic) CGFloat topBound;
@property(nonatomic) CGFloat leftBound;
- (instancetype)initWithViewController:(MWMViewController *)viewController;
- (void)showPlacePage:(place_page::Info const &)info;
- (void)refreshPlacePage;
- (void)mwm_refreshUI;
@ -40,6 +39,4 @@
- (void)addSubviews:(NSArray *)views withNavigationController:(UINavigationController *)controller;
- (void)changeHeight:(CGFloat)height;
- (instancetype)init __attribute__((unavailable("call initWithViewController: instead")));
@end

View file

@ -33,7 +33,6 @@ extern NSString * const kBookmarksChangedNotification;
@interface MWMPlacePageViewManager ()<MWMLocationObserver>
@property(weak, nonatomic) MWMViewController * ownerViewController;
@property(nonatomic, readwrite) MWMPlacePageEntity * entity;
@property(nonatomic) MWMPlacePage * placePage;
@property(nonatomic) MWMDirectionView * directionView;
@ -42,14 +41,6 @@ extern NSString * const kBookmarksChangedNotification;
@implementation MWMPlacePageViewManager
- (instancetype)initWithViewController:(MWMViewController *)viewController
{
self = [super init];
if (self)
_ownerViewController = viewController;
return self;
}
- (void)hidePlacePage { [self.placePage hide]; }
- (void)dismissPlacePage
{
@ -70,11 +61,7 @@ extern NSString * const kBookmarksChangedNotification;
[self configPlacePage];
}
- (FeatureID const &)featureId
{
return self.entity.featureID;
}
- (FeatureID const &)featureId { return self.entity.featureID; }
#pragma mark - Layout
- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)orientation
@ -215,8 +202,8 @@ extern NSString * const kBookmarksChangedNotification;
[Statistics logEvent:kStatEventName(kStatPlacePage, kStatShare)];
[Alohalytics logEvent:kAlohalyticsTapEventKey withValue:@"ppShare"];
MWMPlacePageEntity * entity = self.entity;
MWMActivityViewController * shareVC =
[MWMActivityViewController shareControllerForPlacePageObject:static_cast<id<MWMPlacePageObject>>(entity)];
MWMActivityViewController * shareVC = [MWMActivityViewController
shareControllerForPlacePageObject:static_cast<id<MWMPlacePageObject>>(entity)];
[shareVC presentInParentViewController:self.ownerViewController
anchorView:self.placePage.actionBar.shareAnchor];
}
@ -225,7 +212,7 @@ extern NSString * const kBookmarksChangedNotification;
{
NSMutableDictionary * stat = [@{ kStatProvider : kStatBooking } mutableCopy];
MWMPlacePageEntity * en = self.entity;
auto const latLon = en.latLon;
auto const & latLon = en.latLon;
stat[kStatHotel] = en.hotelId;
stat[kStatHotelLat] = @(latLon.lat);
stat[kStatHotelLon] = @(latLon.lon);
@ -281,9 +268,8 @@ extern NSString * const kBookmarksChangedNotification;
withParameters:@{kStatValue : kStatAdd}];
Framework & f = GetFramework();
BookmarkData bmData = {self.entity.titleForNewBookmark, f.LastEditedBMType()};
auto const categoryIndex = static_cast<int>(f.LastEditedBMCategory());
auto const bookmarkIndex =
static_cast<int>(f.GetBookmarkManager().AddBookmark(categoryIndex, self.entity.mercator, bmData));
auto const categoryIndex = f.LastEditedBMCategory();
auto const bookmarkIndex = f.GetBookmarkManager().AddBookmark(categoryIndex, self.entity.mercator, bmData);
self.entity.bac = {bookmarkIndex, categoryIndex};
self.entity.bookmarkTitle = @(bmData.GetName().c_str());
self.entity.bookmarkCategory = @(f.GetBmCategory(categoryIndex)->GetName().c_str());
@ -299,7 +285,8 @@ extern NSString * const kBookmarksChangedNotification;
[Statistics logEvent:kStatEventName(kStatPlacePage, kStatBookmarks)
withParameters:@{kStatValue : kStatRemove}];
Framework & f = GetFramework();
BookmarkCategory * bookmarkCategory = f.GetBookmarkManager().GetBmCategory(self.entity.bac.m_categoryIndex);
BookmarkCategory * bookmarkCategory =
f.GetBookmarkManager().GetBmCategory(self.entity.bac.m_categoryIndex);
if (bookmarkCategory)
{
{
@ -340,7 +327,7 @@ extern NSString * const kBookmarksChangedNotification;
return @"";
string distance;
CLLocationCoordinate2D const coord = lastLocation.coordinate;
ms::LatLon const target = self.entity.latLon;
ms::LatLon const & target = self.entity.latLon;
measurement_utils::FormatDistance(
ms::DistanceOnEarth(coord.latitude, coord.longitude, target.lat, target.lon), distance);
return @(distance.c_str());
@ -390,6 +377,7 @@ extern NSString * const kBookmarksChangedNotification;
return _directionView;
}
- (MapViewController *)ownerViewController { return [MapViewController controller]; }
- (void)setTopBound:(CGFloat)topBound { _topBound = self.placePage.topBound = topBound; }
- (void)setLeftBound:(CGFloat)leftBound { _leftBound = self.placePage.leftBound = leftBound; }
- (void)editBookmark {}

View file

@ -74,7 +74,6 @@ NSString * const kEditorSegue = @"Map2EditorSegue";
NSString * const kUDViralAlertWasShown = @"ViralAlertWasShown";
NSString * const kPP2BookmarkEditingSegue = @"PP2BookmarkEditing";
// The first launch after process started. Used to skip "Not follow, no position" state and to run
// locator.
BOOL gIsFirstMyPositionMode = YES;

View file

@ -34,8 +34,7 @@
+ (instancetype)shareControllerForPlacePageObject:(id<MWMPlacePageObject>)object;
{
MWMShareActivityItem * item =
[[MWMShareActivityItem alloc] initForPlacePageObject:object];
MWMShareActivityItem * item = [[MWMShareActivityItem alloc] initForPlacePageObject:object];
return [[self alloc] initWithActivityItem:item];
}

View file

@ -1,10 +1,9 @@
namespace ms
{
class LatLon;
} // namespace ms
@protocol MWMPlacePageObject <NSObject>
@protocol MWMPlacePageObject<NSObject>
- (BOOL)isMyPosition;
- (BOOL)isBooking;

View file

@ -66,9 +66,10 @@ NSString * httpGe0Url(NSString * shortUrl)
return @"";
};
ms::LatLon const ll = self.object ? self.object.latLon : ms::LatLon(self.location.latitude, self.location.longitude);
string const s = f.CodeGe0url(ll.lat, ll.lon, f.GetDrawScale(), title(self.object).UTF8String);
ms::LatLon const ll = self.object ? self.object.latLon
: ms::LatLon(self.location.latitude, self.location.longitude);
string const & s = f.CodeGe0url(ll.lat, ll.lon, f.GetDrawScale(), title(self.object).UTF8String);
NSString * url = @(s.c_str());
if (!isShort)
return url;

View file

@ -1,7 +1,6 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="11201" systemVersion="15G31" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" colorMatched="YES">
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="11201" systemVersion="16A323" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" colorMatched="YES">
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="11161"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
@ -15,7 +14,7 @@
<frame key="frameInset" width="375" height="74"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="249" verticalHuggingPriority="251" text="Пн-СБ" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="YIs-LL-j77" userLabel="Days">
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="248" verticalHuggingPriority="251" text="Sun-Wed, Fri-Sat" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="YIs-LL-j77" userLabel="Days">
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
@ -24,7 +23,7 @@
<userDefinedRuntimeAttribute type="string" keyPath="colorName" value="blackPrimaryText"/>
</userDefinedRuntimeAttributes>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="08:00 18:00" textAlignment="right" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="vjg-UU-FVu" userLabel="Schedule">
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="All Day (24 hours)" textAlignment="right" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="vjg-UU-FVu" userLabel="Schedule">
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
@ -57,8 +56,7 @@
<constraint firstItem="Qi6-29-xXe" firstAttribute="leading" secondItem="n1O-q5-zmj" secondAttribute="leading" constant="60" id="LqT-6i-l9O"/>
<constraint firstAttribute="trailing" secondItem="Qi6-29-xXe" secondAttribute="trailing" id="Mlw-ei-y2k"/>
<constraint firstItem="YIs-LL-j77" firstAttribute="leading" secondItem="n1O-q5-zmj" secondAttribute="leading" constant="60" id="Pqu-1L-AJT"/>
<constraint firstItem="vjg-UU-FVu" firstAttribute="centerY" secondItem="YIs-LL-j77" secondAttribute="centerY" id="QAo-Uc-gs4"/>
<constraint firstItem="vjg-UU-FVu" firstAttribute="leading" secondItem="YIs-LL-j77" secondAttribute="trailing" constant="131" id="S0j-ZD-Yzm"/>
<constraint firstItem="vjg-UU-FVu" firstAttribute="leading" relation="greaterThanOrEqual" secondItem="YIs-LL-j77" secondAttribute="trailing" constant="10" id="S0j-ZD-Yzm"/>
<constraint firstAttribute="trailing" secondItem="vjg-UU-FVu" secondAttribute="trailing" constant="16" id="Y3R-u7-9vy"/>
<constraint firstItem="iYw-fc-mKi" firstAttribute="top" secondItem="YIs-LL-j77" secondAttribute="bottom" constant="4" id="c2Y-bD-pvv"/>
<constraint firstAttribute="trailing" secondItem="iYw-fc-mKi" secondAttribute="trailing" constant="16" id="fDs-dk-Fok"/>

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="11201" systemVersion="15G31" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" colorMatched="YES">
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="11201" systemVersion="16A323" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" colorMatched="YES">
<dependencies>
<deployment version="2048" identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="11161"/>
@ -42,6 +42,7 @@
</connections>
</button>
</subviews>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
<constraints>
<constraint firstItem="cd6-XD-cgT" firstAttribute="leading" secondItem="6X7-5b-1LS" secondAttribute="trailing" constant="2" id="I7D-Jd-VrQ"/>
<constraint firstItem="cd6-XD-cgT" firstAttribute="top" secondItem="9gi-wZ-XKX" secondAttribute="top" id="T9w-bm-hKy"/>

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="11201" systemVersion="15G31" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" colorMatched="YES">
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="11201" systemVersion="16A323" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" colorMatched="YES">
<dependencies>
<deployment version="2048" identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="11161"/>
@ -42,7 +42,7 @@
</connections>
</button>
</subviews>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
<constraints>
<constraint firstItem="x01-my-vQm" firstAttribute="leading" secondItem="ugv-HY-Iyx" secondAttribute="leading" constant="-5" id="1zE-K7-Rvs"/>
<constraint firstItem="fMx-Ih-zpI" firstAttribute="leading" secondItem="ugv-HY-Iyx" secondAttribute="leading" id="EaO-z5-fTP"/>

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="11201" systemVersion="15G31" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" colorMatched="YES">
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="11201" systemVersion="16A323" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" colorMatched="YES">
<dependencies>
<deployment version="2048" identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="11161"/>
@ -42,7 +42,7 @@
</connections>
</button>
</subviews>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
<constraints>
<constraint firstItem="Mh6-ds-8hz" firstAttribute="centerY" secondItem="AH1-ti-uSf" secondAttribute="centerY" id="6W7-A1-jK3"/>
<constraint firstAttribute="trailing" secondItem="yNm-lW-0oC" secondAttribute="trailing" constant="-5" id="7jv-2b-lKY"/>

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="11201" systemVersion="15G31" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" colorMatched="YES">
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="11201" systemVersion="16A323" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" colorMatched="YES">
<dependencies>
<deployment version="2048" identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="11161"/>
@ -42,7 +42,7 @@
</connections>
</button>
</subviews>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
<constraints>
<constraint firstAttribute="trailing" secondItem="gea-it-ngb" secondAttribute="trailing" constant="-5" id="2bl-36-wVj"/>
<constraint firstAttribute="bottom" secondItem="gea-it-ngb" secondAttribute="bottom" constant="-5" id="AHo-pE-crR"/>

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="11201" systemVersion="15G31" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" colorMatched="YES">
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="11201" systemVersion="16A323" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" colorMatched="YES">
<dependencies>
<deployment version="2048" identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="11161"/>
@ -42,7 +42,7 @@
</connections>
</button>
</subviews>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
<constraints>
<constraint firstItem="inB-r2-gZY" firstAttribute="centerY" secondItem="tje-bl-3qK" secondAttribute="centerY" id="2yI-0o-s1V"/>
<constraint firstAttribute="bottom" secondItem="tje-bl-3qK" secondAttribute="bottom" id="6S3-rX-xPc"/>

View file

@ -788,6 +788,14 @@
F67517A31D76FC46008FE34F /* MWMPlacePageLayout.mm in Sources */ = {isa = PBXBuildFile; fileRef = F67517A11D76FC46008FE34F /* MWMPlacePageLayout.mm */; };
F6791B131C43DEA7007A8A6E /* MWMStartButton.mm in Sources */ = {isa = PBXBuildFile; fileRef = F6791B121C43DEA7007A8A6E /* MWMStartButton.mm */; };
F6791B141C43DF0B007A8A6E /* MWMStartButton.mm in Sources */ = {isa = PBXBuildFile; fileRef = F6791B121C43DEA7007A8A6E /* MWMStartButton.mm */; };
F67E751C1DB635FE00D6741F /* MWMPPView.xib in Resources */ = {isa = PBXBuildFile; fileRef = F67E751B1DB635FE00D6741F /* MWMPPView.xib */; };
F67E751D1DB635FE00D6741F /* MWMPPView.xib in Resources */ = {isa = PBXBuildFile; fileRef = F67E751B1DB635FE00D6741F /* MWMPPView.xib */; };
F68FCB851DA7BBA6007CC7D7 /* MWMTaxiPreviewDataSource.mm in Sources */ = {isa = PBXBuildFile; fileRef = F68FCB841DA7BBA6007CC7D7 /* MWMTaxiPreviewDataSource.mm */; };
F68FCB861DA7BBA6007CC7D7 /* MWMTaxiPreviewDataSource.mm in Sources */ = {isa = PBXBuildFile; fileRef = F68FCB841DA7BBA6007CC7D7 /* MWMTaxiPreviewDataSource.mm */; };
F68FCB8A1DA7BD20007CC7D7 /* MWMTaxiPreviewCell.mm in Sources */ = {isa = PBXBuildFile; fileRef = F68FCB881DA7BD20007CC7D7 /* MWMTaxiPreviewCell.mm */; };
F68FCB8B1DA7BD20007CC7D7 /* MWMTaxiPreviewCell.mm in Sources */ = {isa = PBXBuildFile; fileRef = F68FCB881DA7BD20007CC7D7 /* MWMTaxiPreviewCell.mm */; };
F68FCB8C1DA7BD20007CC7D7 /* MWMTaxiPreviewCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = F68FCB891DA7BD20007CC7D7 /* MWMTaxiPreviewCell.xib */; };
F68FCB8D1DA7BD20007CC7D7 /* MWMTaxiPreviewCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = F68FCB891DA7BD20007CC7D7 /* MWMTaxiPreviewCell.xib */; };
F69E911C1D994CF000D7A778 /* MWMOpeningHoursCell.mm in Sources */ = {isa = PBXBuildFile; fileRef = F69E911B1D994CF000D7A778 /* MWMOpeningHoursCell.mm */; };
F69E911D1D994CF000D7A778 /* MWMOpeningHoursCell.mm in Sources */ = {isa = PBXBuildFile; fileRef = F69E911B1D994CF000D7A778 /* MWMOpeningHoursCell.mm */; };
F69E91201D994D1A00D7A778 /* MWMOpeningHoursCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = F69E911F1D994D1A00D7A778 /* MWMOpeningHoursCell.xib */; };
@ -798,12 +806,6 @@
F69E91271D99513100D7A778 /* _MWMOHSubCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = F69E91251D99513100D7A778 /* _MWMOHSubCell.xib */; };
F69E912A1D9A877A00D7A778 /* MWMOpeningHours.mm in Sources */ = {isa = PBXBuildFile; fileRef = F69E91291D9A877A00D7A778 /* MWMOpeningHours.mm */; };
F69E912B1D9A877A00D7A778 /* MWMOpeningHours.mm in Sources */ = {isa = PBXBuildFile; fileRef = F69E91291D9A877A00D7A778 /* MWMOpeningHours.mm */; };
F68FCB851DA7BBA6007CC7D7 /* MWMTaxiPreviewDataSource.mm in Sources */ = {isa = PBXBuildFile; fileRef = F68FCB841DA7BBA6007CC7D7 /* MWMTaxiPreviewDataSource.mm */; };
F68FCB861DA7BBA6007CC7D7 /* MWMTaxiPreviewDataSource.mm in Sources */ = {isa = PBXBuildFile; fileRef = F68FCB841DA7BBA6007CC7D7 /* MWMTaxiPreviewDataSource.mm */; };
F68FCB8A1DA7BD20007CC7D7 /* MWMTaxiPreviewCell.mm in Sources */ = {isa = PBXBuildFile; fileRef = F68FCB881DA7BD20007CC7D7 /* MWMTaxiPreviewCell.mm */; };
F68FCB8B1DA7BD20007CC7D7 /* MWMTaxiPreviewCell.mm in Sources */ = {isa = PBXBuildFile; fileRef = F68FCB881DA7BD20007CC7D7 /* MWMTaxiPreviewCell.mm */; };
F68FCB8C1DA7BD20007CC7D7 /* MWMTaxiPreviewCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = F68FCB891DA7BD20007CC7D7 /* MWMTaxiPreviewCell.xib */; };
F68FCB8D1DA7BD20007CC7D7 /* MWMTaxiPreviewCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = F68FCB891DA7BD20007CC7D7 /* MWMTaxiPreviewCell.xib */; };
F6A218491CA3F26800BE2CC6 /* MWMEditorViralActivityItem.mm in Sources */ = {isa = PBXBuildFile; fileRef = F6A218481CA3F26800BE2CC6 /* MWMEditorViralActivityItem.mm */; };
F6A2184A1CA3F26800BE2CC6 /* MWMEditorViralActivityItem.mm in Sources */ = {isa = PBXBuildFile; fileRef = F6A218481CA3F26800BE2CC6 /* MWMEditorViralActivityItem.mm */; };
F6A750B91BE8C74400981B41 /* MWMSearchHistoryMyPositionCell.mm in Sources */ = {isa = PBXBuildFile; fileRef = F6A750B81BE8C74400981B41 /* MWMSearchHistoryMyPositionCell.mm */; };
@ -874,7 +876,6 @@
F6F533A31B3C248900C1940B /* UIColor+MapsMeColor.mm in Sources */ = {isa = PBXBuildFile; fileRef = F6F533A21B3C248900C1940B /* UIColor+MapsMeColor.mm */; };
F6F6ACFC1C15C1010060FDD0 /* MWMRecentTrackSettingsController.mm in Sources */ = {isa = PBXBuildFile; fileRef = F6C641AF1C15BBE6008FCAF3 /* MWMRecentTrackSettingsController.mm */; };
F6F722F81AE1572400DA3DA1 /* MWMiPhonePortraitPlacePage.mm in Sources */ = {isa = PBXBuildFile; fileRef = F6F722F71AE1572400DA3DA1 /* MWMiPhonePortraitPlacePage.mm */; };
F6F78B551D770F97008A1A9A /* MWMPPView.xib in Resources */ = {isa = PBXBuildFile; fileRef = F6F78B541D770F97008A1A9A /* MWMPPView.xib */; };
F6F7787A1DABC6D800B603E7 /* MWMTaxiCollectionLayout.mm in Sources */ = {isa = PBXBuildFile; fileRef = F6F778791DABC6D800B603E7 /* MWMTaxiCollectionLayout.mm */; };
F6FE2C0F1B03A006009814AA /* MWMPlacePageNavigationBar.mm in Sources */ = {isa = PBXBuildFile; fileRef = F6FE2C0E1B03A006009814AA /* MWMPlacePageNavigationBar.mm */; };
F6FE2C111B03A016009814AA /* PlacePageNavigationBar.xib in Resources */ = {isa = PBXBuildFile; fileRef = F6FE2C101B03A015009814AA /* PlacePageNavigationBar.xib */; };
@ -1569,6 +1570,12 @@
F67517A11D76FC46008FE34F /* MWMPlacePageLayout.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MWMPlacePageLayout.mm; sourceTree = "<group>"; };
F6791B111C43DEA7007A8A6E /* MWMStartButton.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MWMStartButton.h; sourceTree = "<group>"; };
F6791B121C43DEA7007A8A6E /* MWMStartButton.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MWMStartButton.mm; sourceTree = "<group>"; };
F67E751B1DB635FE00D6741F /* MWMPPView.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = MWMPPView.xib; sourceTree = "<group>"; };
F68FCB831DA7BBA6007CC7D7 /* MWMTaxiPreviewDataSource.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = MWMTaxiPreviewDataSource.h; path = Views/RoutePreview/MWMTaxiPreviewDataSource.h; sourceTree = "<group>"; };
F68FCB841DA7BBA6007CC7D7 /* MWMTaxiPreviewDataSource.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = MWMTaxiPreviewDataSource.mm; path = Views/RoutePreview/MWMTaxiPreviewDataSource.mm; sourceTree = "<group>"; };
F68FCB871DA7BD20007CC7D7 /* MWMTaxiPreviewCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MWMTaxiPreviewCell.h; sourceTree = "<group>"; };
F68FCB881DA7BD20007CC7D7 /* MWMTaxiPreviewCell.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MWMTaxiPreviewCell.mm; sourceTree = "<group>"; };
F68FCB891DA7BD20007CC7D7 /* MWMTaxiPreviewCell.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = MWMTaxiPreviewCell.xib; sourceTree = "<group>"; };
F69E911A1D994CF000D7A778 /* MWMOpeningHoursCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MWMOpeningHoursCell.h; sourceTree = "<group>"; };
F69E911B1D994CF000D7A778 /* MWMOpeningHoursCell.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MWMOpeningHoursCell.mm; sourceTree = "<group>"; };
F69E911F1D994D1A00D7A778 /* MWMOpeningHoursCell.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = MWMOpeningHoursCell.xib; sourceTree = "<group>"; };
@ -1576,11 +1583,6 @@
F69E91251D99513100D7A778 /* _MWMOHSubCell.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = _MWMOHSubCell.xib; sourceTree = "<group>"; };
F69E91281D9A877A00D7A778 /* MWMOpeningHours.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MWMOpeningHours.h; sourceTree = "<group>"; };
F69E91291D9A877A00D7A778 /* MWMOpeningHours.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MWMOpeningHours.mm; sourceTree = "<group>"; };
F68FCB831DA7BBA6007CC7D7 /* MWMTaxiPreviewDataSource.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = MWMTaxiPreviewDataSource.h; path = Views/RoutePreview/MWMTaxiPreviewDataSource.h; sourceTree = "<group>"; };
F68FCB841DA7BBA6007CC7D7 /* MWMTaxiPreviewDataSource.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = MWMTaxiPreviewDataSource.mm; path = Views/RoutePreview/MWMTaxiPreviewDataSource.mm; sourceTree = "<group>"; };
F68FCB871DA7BD20007CC7D7 /* MWMTaxiPreviewCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MWMTaxiPreviewCell.h; sourceTree = "<group>"; };
F68FCB881DA7BD20007CC7D7 /* MWMTaxiPreviewCell.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MWMTaxiPreviewCell.mm; sourceTree = "<group>"; };
F68FCB891DA7BD20007CC7D7 /* MWMTaxiPreviewCell.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = MWMTaxiPreviewCell.xib; sourceTree = "<group>"; };
F6A218471CA3F26800BE2CC6 /* MWMEditorViralActivityItem.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MWMEditorViralActivityItem.h; sourceTree = "<group>"; };
F6A218481CA3F26800BE2CC6 /* MWMEditorViralActivityItem.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MWMEditorViralActivityItem.mm; sourceTree = "<group>"; };
F6A750B71BE8C74400981B41 /* MWMSearchHistoryMyPositionCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MWMSearchHistoryMyPositionCell.h; sourceTree = "<group>"; };
@ -1666,7 +1668,6 @@
F6F533A21B3C248900C1940B /* UIColor+MapsMeColor.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = "UIColor+MapsMeColor.mm"; sourceTree = "<group>"; };
F6F722F61AE1572400DA3DA1 /* MWMiPhonePortraitPlacePage.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MWMiPhonePortraitPlacePage.h; sourceTree = "<group>"; };
F6F722F71AE1572400DA3DA1 /* MWMiPhonePortraitPlacePage.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MWMiPhonePortraitPlacePage.mm; sourceTree = "<group>"; };
F6F78B541D770F97008A1A9A /* MWMPPView.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = MWMPPView.xib; sourceTree = "<group>"; };
F6F778781DABC6D800B603E7 /* MWMTaxiCollectionLayout.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MWMTaxiCollectionLayout.h; sourceTree = "<group>"; };
F6F778791DABC6D800B603E7 /* MWMTaxiCollectionLayout.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MWMTaxiCollectionLayout.mm; sourceTree = "<group>"; };
F6F9BD221AD3C3A600308C33 /* Macros.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Macros.h; path = ../Macros.h; sourceTree = "<group>"; };
@ -3186,11 +3187,11 @@
F6E2B0051D9E815100793C36 /* Layout */ = {
isa = PBXGroup;
children = (
F6F78B541D770F97008A1A9A /* MWMPPView.xib */,
F67517A01D76FC46008FE34F /* MWMPlacePageLayout.h */,
F67517A11D76FC46008FE34F /* MWMPlacePageLayout.mm */,
F6E2B00B1D9E944600793C36 /* MWMPPView.h */,
F6E2B00C1D9E944600793C36 /* MWMPPView.mm */,
F67E751B1DB635FE00D6741F /* MWMPPView.xib */,
);
name = Layout;
sourceTree = "<group>";
@ -3550,6 +3551,7 @@
4A23D15F1B8B4DD700D4EB6F /* resources-xxhdpi_clear in Resources */,
F64F199E1AB81A00006EAF7E /* MWMDefaultAlert.xib in Resources */,
EEFE7C1512F8C9E1006AF8C3 /* fonts_whitelist.txt in Resources */,
F67E751C1DB635FE00D6741F /* MWMPPView.xib in Resources */,
F64F4B711B4A41D40081A24A /* MWMDownloaderDialogHeader.xib in Resources */,
FAFF422A1347F101009BBB14 /* World.mwm in Resources */,
F607C1891C032A8800B53A87 /* resources-hdpi_dark in Resources */,
@ -3656,7 +3658,6 @@
F634C8F31D79996D00BE04E2 /* _MWMPPPExternalTitle.xib in Resources */,
F6CB21621AEE902B00FB8963 /* PlacePageLinkCell.xib in Resources */,
3401CD781C3CED1E0028C6F8 /* MWMEditorSelectTableViewCell.xib in Resources */,
F6F78B551D770F97008A1A9A /* MWMPPView.xib in Resources */,
34B82AD11B846B2C00180497 /* MWMSearchBookmarksCell.xib in Resources */,
F64D9CA21C899C760063FA30 /* MWMEditorViralAlert.xib in Resources */,
4A7D89C61B2EBF3B00AC843E /* resources-mdpi_dark in Resources */,
@ -3727,7 +3728,6 @@
9DA46A0F1C47E92100EF52BA /* resources-xxhdpi_legacy in Resources */,
6741A9571BF340DE002C974C /* 03_jomolhari-id-a3d.ttf in Resources */,
6741A9581BF340DE002C974C /* 04_padauk.ttf in Resources */,
F6F78B561D770F97008A1A9A /* MWMPPView.xib in Resources */,
F634C8F41D79996D00BE04E2 /* _MWMPPPExternalTitle.xib in Resources */,
6741A9591BF340DE002C974C /* 05_khmeros.ttf in Resources */,
677A2DE21C0DD50900635A00 /* resources-default in Resources */,
@ -3806,6 +3806,7 @@
6741A9841BF340DE002C974C /* MWMSearchShowOnMapCell.xib in Resources */,
6741A9851BF340DE002C974C /* MWMBottomMenuCollectionViewPortraitCell.xib in Resources */,
9DA46A131C47E95700EF52BA /* drules_proto_legacy.bin in Resources */,
F67E751D1DB635FE00D6741F /* MWMPPView.xib in Resources */,
6741A9871BF340DE002C974C /* drules_proto_clear.bin in Resources */,
6741A9881BF340DE002C974C /* MWMAPIBarView.xib in Resources */,
671182E41C7F0DD800CB8177 /* WorldCoasts_obsolete.mwm in Resources */,
@ -4306,7 +4307,6 @@
34CE8A681C7740E100F4351A /* MWMStorage.mm in Sources */,
6741AA141BF340DE002C974C /* MWMMultilineLabel.mm in Sources */,
6741AA151BF340DE002C974C /* Statistics.mm in Sources */,
F6F7787B1DABC6D800B603E7 /* MWMTaxiCollectionLayout.mm in Sources */,
34C9BD051C6DB693000DC38D /* MWMViewController.mm in Sources */,
F69E912B1D9A877A00D7A778 /* MWMOpeningHours.mm in Sources */,
6741AA161BF340DE002C974C /* MWMCustomFacebookEvents.mm in Sources */,

View file

@ -183,11 +183,15 @@ protected:
struct BookmarkAndCategory
{
BookmarkAndCategory() = default;
BookmarkAndCategory(int bookmarkIndex, int categoryIndex) : m_bookmarkIndex(bookmarkIndex),
BookmarkAndCategory(size_t bookmarkIndex, size_t categoryIndex) : m_bookmarkIndex(bookmarkIndex),
m_categoryIndex(categoryIndex) {}
bool IsValid() const { return m_bookmarkIndex >= 0 && m_categoryIndex >= 0; };
bool IsValid() const
{
return m_bookmarkIndex != numeric_limits<size_t>::max() &&
m_categoryIndex != numeric_limits<size_t>::max();
};
int m_bookmarkIndex = -1;
int m_categoryIndex = -1;
size_t m_bookmarkIndex = numeric_limits<size_t>::max();
size_t m_categoryIndex = numeric_limits<size_t>::max();
};

View file

@ -107,7 +107,7 @@ string Info::FormatStars() const
string Info::GetFormattedCoordinate(bool isDMS) const
{
auto const ll = GetLatLon();
auto const & ll = GetLatLon();
return isDMS ? measurement_utils::FormatLatLon(ll.lat, ll.lon) : measurement_utils::FormatLatLonAsDMS(ll.lat, ll.lon, 2);
}