diff --git a/iphone/Maps/Bookmarks/BookmarksRootVC.mm b/iphone/Maps/Bookmarks/BookmarksRootVC.mm index 77f2ad1ec0..b2600575b4 100644 --- a/iphone/Maps/Bookmarks/BookmarksRootVC.mm +++ b/iphone/Maps/Bookmarks/BookmarksRootVC.mm @@ -219,7 +219,7 @@ } else { - BookmarksVC * bvc = [[BookmarksVC alloc] initWithCategory:static_cast(indexPath.row)]; + BookmarksVC * bvc = [[BookmarksVC alloc] initWithCategory:indexPath.row]; [self.navigationController pushViewController:bvc animated:YES]; } } diff --git a/iphone/Maps/Bookmarks/BookmarksVC.h b/iphone/Maps/Bookmarks/BookmarksVC.h index f19b207856..2d855a805a 100644 --- a/iphone/Maps/Bookmarks/BookmarksVC.h +++ b/iphone/Maps/Bookmarks/BookmarksVC.h @@ -2,9 +2,9 @@ @interface BookmarksVC : MWMTableViewController { - int m_categoryIndex; + NSUInteger m_categoryIndex; } -- (instancetype)initWithCategory:(int)index; +- (instancetype)initWithCategory:(NSUInteger)index; @end diff --git a/iphone/Maps/Bookmarks/BookmarksVC.mm b/iphone/Maps/Bookmarks/BookmarksVC.mm index 94ddc78439..5d71ae1edb 100644 --- a/iphone/Maps/Bookmarks/BookmarksVC.mm +++ b/iphone/Maps/Bookmarks/BookmarksVC.mm @@ -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(indexPath.row), m_categoryIndex}); + f.ShowBookmark({static_cast(indexPath.row), m_categoryIndex}); [self.navigationController popToRootViewControllerAnimated:YES]; } } @@ -294,7 +294,7 @@ extern NSString * const kBookmarksChangedNotification = @"BookmarksChangedNotifi } else { - BookmarkAndCategory bookmarkAndCategory{static_cast(indexPath.row), m_categoryIndex}; + BookmarkAndCategory bookmarkAndCategory{static_cast(indexPath.row), m_categoryIndex}; NSValue * value = [NSValue valueWithBytes:&bookmarkAndCategory objCType:@encode(BookmarkAndCategory)]; [[NSNotificationCenter defaultCenter] postNotificationName:BOOKMARK_DELETED_NOTIFICATION object:value]; BookmarkCategory::Guard guard(*cat); diff --git a/iphone/Maps/Bookmarks/SelectSetVC.mm b/iphone/Maps/Bookmarks/SelectSetVC.mm index c3952b5cb4..b5efb6c83f 100644 --- a/iphone/Maps/Bookmarks/SelectSetVC.mm +++ b/iphone/Maps/Bookmarks/SelectSetVC.mm @@ -85,11 +85,13 @@ - (void)moveBookmarkToSetWithIndex:(int)setIndex { BookmarkAndCategory bac; - bac.m_bookmarkIndex = static_cast(GetFramework().MoveBookmark(m_bac.m_bookmarkIndex, m_bac.m_categoryIndex, setIndex)); + bac.m_bookmarkIndex = static_cast( + 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()); } diff --git a/iphone/Maps/Classes/Common.h b/iphone/Maps/Classes/Common.h index 3edad113fc..fa47fd513d 100644 --- a/iphone/Maps/Classes/Common.h +++ b/iphone/Maps/Classes/Common.h @@ -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() { diff --git a/iphone/Maps/Classes/CustomViews/MapViewControls/MWMMapViewControlsManager.mm b/iphone/Maps/Classes/CustomViews/MapViewControls/MWMMapViewControlsManager.mm index 06f83de0a5..d018df6039 100644 --- a/iphone/Maps/Classes/CustomViews/MapViewControls/MWMMapViewControlsManager.mm +++ b/iphone/Maps/Classes/CustomViews/MapViewControls/MWMMapViewControlsManager.mm @@ -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)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)featureHolder -{ - return self.placePageManager; -} - +- (id)featureHolder { return self.placePageManager; } @end diff --git a/iphone/Maps/Classes/CustomViews/MapViewControls/Search/TabbedView/BookmarksTab/MWMSearchBookmarksCell.mm b/iphone/Maps/Classes/CustomViews/MapViewControls/Search/TabbedView/BookmarksTab/MWMSearchBookmarksCell.mm index 3d2ac72aa7..54cf32d377 100644 --- a/iphone/Maps/Classes/CustomViews/MapViewControls/Search/TabbedView/BookmarksTab/MWMSearchBookmarksCell.mm +++ b/iphone/Maps/Classes/CustomViews/MapViewControls/Search/TabbedView/BookmarksTab/MWMSearchBookmarksCell.mm @@ -57,7 +57,7 @@ - (IBAction)openBookmarks { - BookmarksVC * bvc = [[BookmarksVC alloc] initWithCategory:static_cast(self.index)]; + BookmarksVC * bvc = [[BookmarksVC alloc] initWithCategory:self.index]; UINavigationController * rootVC = (UINavigationController *)UIApplication.sharedApplication.delegate.window.rootViewController; [rootVC pushViewController:bvc animated:YES]; } diff --git a/iphone/Maps/Classes/CustomViews/NavigationDashboard/Views/RoutePreview/MWMRoutePreview.mm b/iphone/Maps/Classes/CustomViews/NavigationDashboard/Views/RoutePreview/MWMRoutePreview.mm index 43cc667092..3f4c4ca4cc 100644 --- a/iphone/Maps/Classes/CustomViews/NavigationDashboard/Views/RoutePreview/MWMRoutePreview.mm +++ b/iphone/Maps/Classes/CustomViews/NavigationDashboard/Views/RoutePreview/MWMRoutePreview.mm @@ -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 diff --git a/iphone/Maps/Classes/MWMActionBarButton.mm b/iphone/Maps/Classes/MWMActionBarButton.mm index 361ec00a44..1362d6b1ec 100644 --- a/iphone/Maps/Classes/MWMActionBarButton.mm +++ b/iphone/Maps/Classes/MWMActionBarButton.mm @@ -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]; } diff --git a/iphone/Maps/Classes/MWMBookmarkCell.h b/iphone/Maps/Classes/MWMBookmarkCell.h index a9c30ab996..a4b5313b0b 100644 --- a/iphone/Maps/Classes/MWMBookmarkCell.h +++ b/iphone/Maps/Classes/MWMBookmarkCell.h @@ -1,6 +1,7 @@ #import "MWMTableViewCell.h" -@protocol MWMPlacePageButtonsProtocol, MWMPlacePageCellUpdateProtocol; +@protocol MWMPlacePageButtonsProtocol +, MWMPlacePageCellUpdateProtocol; @interface MWMBookmarkCell : MWMTableViewCell diff --git a/iphone/Maps/Classes/MWMBookmarkCell.mm b/iphone/Maps/Classes/MWMBookmarkCell.mm index 4698529b7d..ab7b2efcf7 100644 --- a/iphone/Maps/Classes/MWMBookmarkCell.mm +++ b/iphone/Maps/Classes/MWMBookmarkCell.mm @@ -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)updateCellDelegate editBookmarkDelegate:(id)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 * 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 diff --git a/iphone/Maps/Classes/MWMDirectionView.mm b/iphone/Maps/Classes/MWMDirectionView.mm index a5625a0796..9026fc4638 100644 --- a/iphone/Maps/Classes/MWMDirectionView.mm +++ b/iphone/Maps/Classes/MWMDirectionView.mm @@ -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"; diff --git a/iphone/Maps/Classes/MWMEditBookmarkController.h b/iphone/Maps/Classes/MWMEditBookmarkController.h index 3e6ae72c9d..1f0ae89665 100644 --- a/iphone/Maps/Classes/MWMEditBookmarkController.h +++ b/iphone/Maps/Classes/MWMEditBookmarkController.h @@ -5,7 +5,7 @@ @interface MWMEditBookmarkController : MWMTableViewController -@property (weak, nonatomic) MWMPlacePageData * data; +@property(weak, nonatomic) MWMPlacePageData * data; @property (nonatomic) MWMPlacePageViewManager * manager; @end diff --git a/iphone/Maps/Classes/MWMEditBookmarkController.mm b/iphone/Maps/Classes/MWMEditBookmarkController.mm index 6374b6a2fc..569090c24b 100644 --- a/iphone/Maps/Classes/MWMEditBookmarkController.mm +++ b/iphone/Maps/Classes/MWMEditBookmarkController.mm @@ -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(guard.m_controller.GetUserMarkForEdit(bac.m_bookmarkIndex)); + static_cast(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(); } diff --git a/iphone/Maps/Classes/MWMOpeningHours.h b/iphone/Maps/Classes/MWMOpeningHours.h index 70558501c5..4b04abdd20 100644 --- a/iphone/Maps/Classes/MWMOpeningHours.h +++ b/iphone/Maps/Classes/MWMOpeningHours.h @@ -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)processRawString:(NSString *)str; diff --git a/iphone/Maps/Classes/MWMOpeningHours.mm b/iphone/Maps/Classes/MWMOpeningHours.mm index 62fe8b8e53..619ec8ca40 100644 --- a/iphone/Maps/Classes/MWMOpeningHours.mm +++ b/iphone/Maps/Classes/MWMOpeningHours.mm @@ -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 & 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 & allDays) void addUnhandledDays(ui::TOpeningDays const & days, vector & 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 & allDays) cal.locale = [NSLocale currentLocale]; auto const timeTablesSize = timeTableSet.Size(); - auto const today = static_cast([cal components:NSCalendarUnitWeekday fromDate:[NSDate date]].weekday); + auto const today = + static_cast([cal components:NSCalendarUnitWeekday fromDate:[NSDate date]].weekday); auto const unhandledDays = timeTableSet.GetUnhandledDays(); /// Schedule contains more than one rule for all days or unhandled days. diff --git a/iphone/Maps/Classes/MWMOpeningHoursCell.mm b/iphone/Maps/Classes/MWMOpeningHoursCell.mm index 850eaac266..3d88c25dd2 100644 --- a/iphone/Maps/Classes/MWMOpeningHoursCell.mm +++ b/iphone/Maps/Classes/MWMOpeningHoursCell.mm @@ -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 kOHClasses = {{@"_MWMOHHeaderCell", @"_MWMOHSubCell"}}; +array 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 () +@interface MWMOpeningHoursCell () @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 * 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 diff --git a/iphone/Maps/Classes/MWMOpeningHoursCell.xib b/iphone/Maps/Classes/MWMOpeningHoursCell.xib index b2a38316d1..332ef90ed9 100644 --- a/iphone/Maps/Classes/MWMOpeningHoursCell.xib +++ b/iphone/Maps/Classes/MWMOpeningHoursCell.xib @@ -1,5 +1,5 @@ - - + + @@ -18,22 +18,22 @@ - + - - - - + + + + - + diff --git a/iphone/Maps/Classes/MWMPPView.h b/iphone/Maps/Classes/MWMPPView.h index 60049b831b..8423995b77 100644 --- a/iphone/Maps/Classes/MWMPPView.h +++ b/iphone/Maps/Classes/MWMPPView.h @@ -1,6 +1,6 @@ #pragma mark - MWMPPScrollView -@protocol MWMPlacePageViewUpdateProtocol +@protocol MWMPlacePageViewUpdateProtocol - (void)updateWithHeight:(CGFloat)height; @@ -28,4 +28,3 @@ - (void)hideTableView:(BOOL)isHidden; @end - diff --git a/iphone/Maps/Classes/MWMPPView.mm b/iphone/Maps/Classes/MWMPPView.mm index d6c80dd84a..a94c6150d4 100644 --- a/iphone/Maps/Classes/MWMPPView.mm +++ b/iphone/Maps/Classes/MWMPPView.mm @@ -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 - diff --git a/iphone/Maps/Classes/MWMPlacePageActionBar.h b/iphone/Maps/Classes/MWMPlacePageActionBar.h index 1ccd7465c5..20c9cf9c11 100644 --- a/iphone/Maps/Classes/MWMPlacePageActionBar.h +++ b/iphone/Maps/Classes/MWMPlacePageActionBar.h @@ -1,7 +1,7 @@ @class MWMPlacePageViewManager; @class MWMPlacePageData; -@protocol MWMActionBarSharedData +@protocol MWMActionBarSharedData - (BOOL)isBookmark; - (BOOL)isBooking; diff --git a/iphone/Maps/Classes/MWMPlacePageActionBar.mm b/iphone/Maps/Classes/MWMPlacePageActionBar.mm index 2701045a79..f18a1c5a18 100644 --- a/iphone/Maps/Classes/MWMPlacePageActionBar.mm +++ b/iphone/Maps/Classes/MWMPlacePageActionBar.mm @@ -34,8 +34,8 @@ extern NSString * const kAlohalyticsTapEventKey; + (MWMPlacePageActionBar *)actionBarWithDelegate:(id)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>(isIOS7 ? self.placePageManager.entity : self.data); + auto data = + static_cast>(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>(IPAD ? self.placePageManager.entity : self.data); + auto data = + static_cast>(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 diff --git a/iphone/Maps/Classes/MWMPlacePageBookmarkCell.mm b/iphone/Maps/Classes/MWMPlacePageBookmarkCell.mm index 024d8c303c..c9a256babd 100644 --- a/iphone/Maps/Classes/MWMPlacePageBookmarkCell.mm +++ b/iphone/Maps/Classes/MWMPlacePageBookmarkCell.mm @@ -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" diff --git a/iphone/Maps/Classes/MWMPlacePageBookmarkDelegate.h b/iphone/Maps/Classes/MWMPlacePageBookmarkDelegate.h index e0e7202e92..12d87fcbbb 100644 --- a/iphone/Maps/Classes/MWMPlacePageBookmarkDelegate.h +++ b/iphone/Maps/Classes/MWMPlacePageBookmarkDelegate.h @@ -1,4 +1,4 @@ -@protocol MWMPlacePageBookmarkDelegate +@protocol MWMPlacePageBookmarkDelegate @required - (void)editBookmarkTap; diff --git a/iphone/Maps/Classes/MWMPlacePageButtonCell.h b/iphone/Maps/Classes/MWMPlacePageButtonCell.h index 3c6c282b80..2f431e5453 100644 --- a/iphone/Maps/Classes/MWMPlacePageButtonCell.h +++ b/iphone/Maps/Classes/MWMPlacePageButtonCell.h @@ -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)delegate NS_AVAILABLE_IOS(8_0); diff --git a/iphone/Maps/Classes/MWMPlacePageButtonCell.mm b/iphone/Maps/Classes/MWMPlacePageButtonCell.mm index 203bc3bfbd..c74eeaf26e 100644 --- a/iphone/Maps/Classes/MWMPlacePageButtonCell.mm +++ b/iphone/Maps/Classes/MWMPlacePageButtonCell.mm @@ -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 () @@ -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)delegate +- (void)setEnabled:(BOOL)enabled { self.titleButton.enabled = enabled; } +- (BOOL)isEnabled { return self.titleButton.isEnabled; } +- (void)configForRow:(place_page::ButtonsRows)row + withDelegate:(id)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; } } diff --git a/iphone/Maps/Classes/MWMPlacePageCellUpdateProtocol.h b/iphone/Maps/Classes/MWMPlacePageCellUpdateProtocol.h index 3b4bcfe7c1..de12777fcb 100644 --- a/iphone/Maps/Classes/MWMPlacePageCellUpdateProtocol.h +++ b/iphone/Maps/Classes/MWMPlacePageCellUpdateProtocol.h @@ -1,4 +1,4 @@ -@protocol MWMPlacePageCellUpdateProtocol +@protocol MWMPlacePageCellUpdateProtocol - (void)updateCellWithForceReposition:(BOOL)isForceReposition; diff --git a/iphone/Maps/Classes/MWMPlacePageData.h b/iphone/Maps/Classes/MWMPlacePageData.h index 4496f1df43..e1a7ee0c9b 100644 --- a/iphone/Maps/Classes/MWMPlacePageData.h +++ b/iphone/Maps/Classes/MWMPlacePageData.h @@ -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 diff --git a/iphone/Maps/Classes/MWMPlacePageData.mm b/iphone/Maps/Classes/MWMPlacePageData.mm index 15c934909b..223ee7693d 100644 --- a/iphone/Maps/Classes/MWMPlacePageData.mm +++ b/iphone/Maps/Classes/MWMPlacePageData.mm @@ -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(f.LastEditedBMCategory()); + auto const categoryIndex = f.LastEditedBMCategory(); BookmarkData bmData{m_info.FormatNewBookmarkName(), f.LastEditedBMType()}; - auto const bookmarkIndex = - static_cast(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(guard.m_controller.GetUserMarkForEdit(bookmarkIndex)); + auto bookmark = static_cast(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 const &)sections -{ - return m_sections; -} - -- (vector const &)metainfoRows -{ - return m_metainfoRows; -} - -- (vector const &)buttonsRows -{ - return m_buttonsRows; -} - +- (vector const &)sections { return m_sections; } +- (vector const &)metainfoRows { return m_metainfoRows; } +- (vector 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]; diff --git a/iphone/Maps/Classes/MWMPlacePageEntity.mm b/iphone/Maps/Classes/MWMPlacePageEntity.mm index fc31f06d48..16bc21df9c 100644 --- a/iphone/Maps/Classes/MWMPlacePageEntity.mm +++ b/iphone/Maps/Classes/MWMPlacePageEntity.mm @@ -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()); diff --git a/iphone/Maps/Classes/MWMPlacePageInfoCell.h b/iphone/Maps/Classes/MWMPlacePageInfoCell.h index daae2878a7..5a57318b23 100644 --- a/iphone/Maps/Classes/MWMPlacePageInfoCell.h +++ b/iphone/Maps/Classes/MWMPlacePageInfoCell.h @@ -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; diff --git a/iphone/Maps/Classes/MWMPlacePageInfoCell.mm b/iphone/Maps/Classes/MWMPlacePageInfoCell.mm index 7c394bed07..f558b9d3b2 100644 --- a/iphone/Maps/Classes/MWMPlacePageInfoCell.mm +++ b/iphone/Maps/Classes/MWMPlacePageInfoCell.mm @@ -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 diff --git a/iphone/Maps/Classes/MWMPlacePageLayout.h b/iphone/Maps/Classes/MWMPlacePageLayout.h index e0e8d41aaa..a1ee45a0e4 100644 --- a/iphone/Maps/Classes/MWMPlacePageLayout.h +++ b/iphone/Maps/Classes/MWMPlacePageLayout.h @@ -1,13 +1,13 @@ #include "storage/storage_defines.hpp" -@protocol MWMPlacePageLayoutDelegate +@protocol MWMPlacePageLayoutDelegate - (void)onTopBoundChanged:(CGFloat)bound; - (void)shouldDestroyLayout; @end -@protocol MWMPlacePageLayoutDataSource +@protocol MWMPlacePageLayoutDataSource - (NSString *)distanceToObject; - (void)downloadSelectedArea; @@ -21,7 +21,8 @@ @interface MWMPlacePageLayout : NSObject - (instancetype)initWithOwnerView:(UIView *)view - delegate:(id)delegate + delegate:(id)delegate dataSource:(id)dataSource; - (void)layoutWithSize:(CGSize const &)size; diff --git a/iphone/Maps/Classes/MWMPlacePageLayout.mm b/iphone/Maps/Classes/MWMPlacePageLayout.mm index b8e4a55a3c..992b1d2b96 100644 --- a/iphone/Maps/Classes/MWMPlacePageLayout.mm +++ b/iphone/Maps/Classes/MWMPlacePageLayout.mm @@ -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 kPreviewCells = {{@"MWMPlacePagePreviewCell"}}; array kBookmarkCells = {{@"MWMBookmarkCell"}}; -array kMetaInfoCells = {{@"MWMOpeningHoursCell", @"PlacePageLinkCell", @"PlacePageInfoCell", @"PlacePageLinkCell", @"PlacePageLinkCell", @"PlacePageInfoCell", @"PlacePageInfoCell", @"PlacePageInfoCell", @"PlacePageInfoCell"}}; +array kMetaInfoCells = { + {@"MWMOpeningHoursCell", @"PlacePageLinkCell", @"PlacePageInfoCell", @"PlacePageLinkCell", + @"PlacePageLinkCell", @"PlacePageInfoCell", @"PlacePageInfoCell", @"PlacePageInfoCell", + @"PlacePageInfoCell"}}; array 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 () +@interface MWMPlacePageLayout () @property(weak, nonatomic) MWMPlacePageData * data; @property(weak, nonatomic) UIView * ownerView; -@property(weak, nonatomic) id delegate; +@property(weak, nonatomic) + id + delegate; @property(weak, nonatomic) id dataSource; @property(nonatomic) MWMPPScrollView * scrollView; @@ -81,7 +98,8 @@ void animate(TMWMVoidBlock animate, TMWMVoidBlock completion = nil) @implementation MWMPlacePageLayout - (instancetype)initWithOwnerView:(UIView *)view - delegate:(id)delegate + delegate:(id)delegate dataSource:(id)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(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>(self.data)]; - [self registerCells]; + [self.actionBar configureWithData:static_cast>(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(place_page::Sections::Bookmark)]; + NSIndexSet * set = + [NSIndexSet indexSetWithIndex:static_cast(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 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 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(row)]; UITableViewCell * c = [tableView dequeueReusableCellWithIdentifier:cellName]; switch (row) { case MetainfoRows::OpeningHours: - [static_cast(c) configureWithOpeningHours:[self.data stringForRow:row] - updateLayoutDelegate:self - isClosedNow:self.data.schedule == OpeningHours::Closed]; + { + [static_cast(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(c) configWithRow:row data:self.data]; + { + [static_cast(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]; diff --git a/iphone/Maps/Classes/MWMPlacePageManager.h b/iphone/Maps/Classes/MWMPlacePageManager.h index 65609662f7..4dd468d61c 100644 --- a/iphone/Maps/Classes/MWMPlacePageManager.h +++ b/iphone/Maps/Classes/MWMPlacePageManager.h @@ -1,5 +1,5 @@ #import "MWMPlacePageProtocol.h" -@interface MWMPlacePageManager : NSObject +@interface MWMPlacePageManager : NSObject @end diff --git a/iphone/Maps/Classes/MWMPlacePageManager.mm b/iphone/Maps/Classes/MWMPlacePageManager.mm index c4f6d65022..487075bc78 100644 --- a/iphone/Maps/Classes/MWMPlacePageManager.mm +++ b/iphone/Maps/Classes/MWMPlacePageManager.mm @@ -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 +#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 #include "geometry/distance_on_sphere.hpp" #include "platform/measurement_utils.hpp" -@interface MWMPlacePageManager() -@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(progress.first) / progress.second]; + [self.layout + processDownloaderEventWithStatus:storage::NodeStatus::Downloading + progress:static_cast(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>(self.data)]; + MWMActivityViewController * shareVC = [MWMActivityViewController + shareControllerForPlacePageObject:static_cast>(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)coordinator +- (void)viewWillTransitionToSize:(CGSize)size + withTransitionCoordinator:(id)coordinator { - [coordinator animateAlongsideTransition:^(id context) { - [self->_layout layoutWithSize:size]; - } completion:^(id context) { }]; + [coordinator + animateAlongsideTransition:^(id context) { + [self.layout layoutWithSize:size]; + } + completion:^(id 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 diff --git a/iphone/Maps/Classes/MWMPlacePagePreviewCell.h b/iphone/Maps/Classes/MWMPlacePagePreviewCell.h index dde52ca55b..7d5a18f22d 100644 --- a/iphone/Maps/Classes/MWMPlacePagePreviewCell.h +++ b/iphone/Maps/Classes/MWMPlacePagePreviewCell.h @@ -15,9 +15,8 @@ - (void)setDownloadingProgress:(CGFloat)progress; - (void)configure:(MWMPlacePageData *)data - updateLayoutDelegate:(id)delegate - dataSource:(id)dataSource; - + updateLayoutDelegate:(id)delegate + dataSource:(id)dataSource; - (MWMCircularProgress *)mapDownloadProgress; diff --git a/iphone/Maps/Classes/MWMPlacePagePreviewCell.mm b/iphone/Maps/Classes/MWMPlacePagePreviewCell.mm index 952140042d..558a9c0986 100644 --- a/iphone/Maps/Classes/MWMPlacePagePreviewCell.mm +++ b/iphone/Maps/Classes/MWMPlacePagePreviewCell.mm @@ -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 kPPPClasses = {{@"_MWMPPPTitle", - @"_MWMPPPExternalTitle", - @"_MWMPPPSubtitle", - @"_MWMPPPSchedule", - @"_MWMPPPBooking", - @"_MWMPPPAddress"}}; +array kPPPClasses = {{@"_MWMPPPTitle", @"_MWMPPPExternalTitle", @"_MWMPPPSubtitle", + @"_MWMPPPSchedule", @"_MWMPPPBooking", @"_MWMPPPAddress"}}; enum class Labels { @@ -128,7 +124,8 @@ CGFloat const kCompressedTableViewLeading = 56; #pragma mark - Public -@interface MWMPlacePagePreviewCell () +@interface MWMPlacePagePreviewCell () { vector 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)delegate - dataSource:(id)dataSource + updateLayoutDelegate:(id)delegate + dataSource:(id)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]; } diff --git a/iphone/Maps/Classes/MWMPlacePagePreviewCell.xib b/iphone/Maps/Classes/MWMPlacePagePreviewCell.xib index 7d9a6b3066..48d3368a6c 100644 --- a/iphone/Maps/Classes/MWMPlacePagePreviewCell.xib +++ b/iphone/Maps/Classes/MWMPlacePagePreviewCell.xib @@ -1,5 +1,5 @@ - - + + @@ -12,13 +12,13 @@ - + - + diff --git a/iphone/Maps/Classes/MWMPlacePageProtocol.h b/iphone/Maps/Classes/MWMPlacePageProtocol.h index af0e6a4c35..f9d26162aa 100644 --- a/iphone/Maps/Classes/MWMPlacePageProtocol.h +++ b/iphone/Maps/Classes/MWMPlacePageProtocol.h @@ -4,7 +4,7 @@ @class MWMPlacePageEntity, MWMViewController; -@protocol MWMActionBarProtocol +@protocol MWMActionBarProtocol - (void)routeFrom; - (void)routeTo; @@ -21,7 +21,7 @@ @end -@protocol MWMPlacePageButtonsProtocol +@protocol MWMPlacePageButtonsProtocol - (void)editPlace; - (void)addPlace; @@ -33,19 +33,17 @@ struct FeatureID; -@protocol MWMFeatureHolder +@protocol MWMFeatureHolder - (FeatureID const &)featureId; @end -@protocol MWMPlacePageProtocol +@protocol MWMPlacePageProtocol -@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; diff --git a/iphone/Maps/Classes/MWMPlacePageViewManager.h b/iphone/Maps/Classes/MWMPlacePageViewManager.h index 37e46f782a..f495df9592 100644 --- a/iphone/Maps/Classes/MWMPlacePageViewManager.h +++ b/iphone/Maps/Classes/MWMPlacePageViewManager.h @@ -6,14 +6,13 @@ @class MWMPlacePageEntity, MWMPlacePageNavigationBar, MWMViewController; -@interface MWMPlacePageViewManager : NSObject +@interface MWMPlacePageViewManager : NSObject @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 diff --git a/iphone/Maps/Classes/MWMPlacePageViewManager.mm b/iphone/Maps/Classes/MWMPlacePageViewManager.mm index f5033f8128..556b8c6f09 100644 --- a/iphone/Maps/Classes/MWMPlacePageViewManager.mm +++ b/iphone/Maps/Classes/MWMPlacePageViewManager.mm @@ -33,7 +33,6 @@ extern NSString * const kBookmarksChangedNotification; @interface MWMPlacePageViewManager () -@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>(entity)]; + MWMActivityViewController * shareVC = [MWMActivityViewController + shareControllerForPlacePageObject:static_cast>(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(f.LastEditedBMCategory()); - auto const bookmarkIndex = - static_cast(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 {} diff --git a/iphone/Maps/Classes/MapViewController.mm b/iphone/Maps/Classes/MapViewController.mm index 6448ee8cdf..a72dd8cc29 100644 --- a/iphone/Maps/Classes/MapViewController.mm +++ b/iphone/Maps/Classes/MapViewController.mm @@ -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; diff --git a/iphone/Maps/Classes/Share/MWMActivityViewController.mm b/iphone/Maps/Classes/Share/MWMActivityViewController.mm index 40b689b646..740d5a13a2 100644 --- a/iphone/Maps/Classes/Share/MWMActivityViewController.mm +++ b/iphone/Maps/Classes/Share/MWMActivityViewController.mm @@ -34,8 +34,7 @@ + (instancetype)shareControllerForPlacePageObject:(id)object; { - MWMShareActivityItem * item = - [[MWMShareActivityItem alloc] initForPlacePageObject:object]; + MWMShareActivityItem * item = [[MWMShareActivityItem alloc] initForPlacePageObject:object]; return [[self alloc] initWithActivityItem:item]; } diff --git a/iphone/Maps/Classes/Share/MWMShareActivityItem.h b/iphone/Maps/Classes/Share/MWMShareActivityItem.h index 8e7b0826b8..765b2ccfcb 100644 --- a/iphone/Maps/Classes/Share/MWMShareActivityItem.h +++ b/iphone/Maps/Classes/Share/MWMShareActivityItem.h @@ -1,10 +1,9 @@ namespace ms { class LatLon; - } // namespace ms -@protocol MWMPlacePageObject +@protocol MWMPlacePageObject - (BOOL)isMyPosition; - (BOOL)isBooking; diff --git a/iphone/Maps/Classes/Share/MWMShareActivityItem.mm b/iphone/Maps/Classes/Share/MWMShareActivityItem.mm index 1693884555..9eada7509e 100644 --- a/iphone/Maps/Classes/Share/MWMShareActivityItem.mm +++ b/iphone/Maps/Classes/Share/MWMShareActivityItem.mm @@ -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; diff --git a/iphone/Maps/Classes/_MWMOHSubCell.xib b/iphone/Maps/Classes/_MWMOHSubCell.xib index 8178c5b348..912829519e 100644 --- a/iphone/Maps/Classes/_MWMOHSubCell.xib +++ b/iphone/Maps/Classes/_MWMOHSubCell.xib @@ -1,7 +1,6 @@ - - + + - @@ -15,7 +14,7 @@ - + diff --git a/iphone/Maps/Classes/_MWMPPPExternalTitle.xib b/iphone/Maps/Classes/_MWMPPPExternalTitle.xib index ac06db4e02..43eb986cc6 100644 --- a/iphone/Maps/Classes/_MWMPPPExternalTitle.xib +++ b/iphone/Maps/Classes/_MWMPPPExternalTitle.xib @@ -1,5 +1,5 @@ - - + + @@ -42,7 +42,7 @@ - + diff --git a/iphone/Maps/Classes/_MWMPPPSchedule.xib b/iphone/Maps/Classes/_MWMPPPSchedule.xib index 8547909882..94cba8ae7a 100644 --- a/iphone/Maps/Classes/_MWMPPPSchedule.xib +++ b/iphone/Maps/Classes/_MWMPPPSchedule.xib @@ -1,5 +1,5 @@ - - + + @@ -42,7 +42,7 @@ - + diff --git a/iphone/Maps/Classes/_MWMPPPSubtitle.xib b/iphone/Maps/Classes/_MWMPPPSubtitle.xib index 97276ad5a2..4104c1730f 100644 --- a/iphone/Maps/Classes/_MWMPPPSubtitle.xib +++ b/iphone/Maps/Classes/_MWMPPPSubtitle.xib @@ -1,5 +1,5 @@ - - + + @@ -42,7 +42,7 @@ - + diff --git a/iphone/Maps/Classes/_MWMPPPTitle.xib b/iphone/Maps/Classes/_MWMPPPTitle.xib index 89e2c75e20..0a5a9c5874 100644 --- a/iphone/Maps/Classes/_MWMPPPTitle.xib +++ b/iphone/Maps/Classes/_MWMPPPTitle.xib @@ -1,5 +1,5 @@ - - + + @@ -42,7 +42,7 @@ - + diff --git a/iphone/Maps/Maps.xcodeproj/project.pbxproj b/iphone/Maps/Maps.xcodeproj/project.pbxproj index 40f6c29316..4dbeed55be 100644 --- a/iphone/Maps/Maps.xcodeproj/project.pbxproj +++ b/iphone/Maps/Maps.xcodeproj/project.pbxproj @@ -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 = ""; }; F6791B111C43DEA7007A8A6E /* MWMStartButton.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MWMStartButton.h; sourceTree = ""; }; F6791B121C43DEA7007A8A6E /* MWMStartButton.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MWMStartButton.mm; sourceTree = ""; }; + F67E751B1DB635FE00D6741F /* MWMPPView.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = MWMPPView.xib; sourceTree = ""; }; + F68FCB831DA7BBA6007CC7D7 /* MWMTaxiPreviewDataSource.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = MWMTaxiPreviewDataSource.h; path = Views/RoutePreview/MWMTaxiPreviewDataSource.h; sourceTree = ""; }; + F68FCB841DA7BBA6007CC7D7 /* MWMTaxiPreviewDataSource.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = MWMTaxiPreviewDataSource.mm; path = Views/RoutePreview/MWMTaxiPreviewDataSource.mm; sourceTree = ""; }; + F68FCB871DA7BD20007CC7D7 /* MWMTaxiPreviewCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MWMTaxiPreviewCell.h; sourceTree = ""; }; + F68FCB881DA7BD20007CC7D7 /* MWMTaxiPreviewCell.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MWMTaxiPreviewCell.mm; sourceTree = ""; }; + F68FCB891DA7BD20007CC7D7 /* MWMTaxiPreviewCell.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = MWMTaxiPreviewCell.xib; sourceTree = ""; }; F69E911A1D994CF000D7A778 /* MWMOpeningHoursCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MWMOpeningHoursCell.h; sourceTree = ""; }; F69E911B1D994CF000D7A778 /* MWMOpeningHoursCell.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MWMOpeningHoursCell.mm; sourceTree = ""; }; F69E911F1D994D1A00D7A778 /* MWMOpeningHoursCell.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = MWMOpeningHoursCell.xib; sourceTree = ""; }; @@ -1576,11 +1583,6 @@ F69E91251D99513100D7A778 /* _MWMOHSubCell.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = _MWMOHSubCell.xib; sourceTree = ""; }; F69E91281D9A877A00D7A778 /* MWMOpeningHours.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MWMOpeningHours.h; sourceTree = ""; }; F69E91291D9A877A00D7A778 /* MWMOpeningHours.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MWMOpeningHours.mm; sourceTree = ""; }; - F68FCB831DA7BBA6007CC7D7 /* MWMTaxiPreviewDataSource.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = MWMTaxiPreviewDataSource.h; path = Views/RoutePreview/MWMTaxiPreviewDataSource.h; sourceTree = ""; }; - F68FCB841DA7BBA6007CC7D7 /* MWMTaxiPreviewDataSource.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = MWMTaxiPreviewDataSource.mm; path = Views/RoutePreview/MWMTaxiPreviewDataSource.mm; sourceTree = ""; }; - F68FCB871DA7BD20007CC7D7 /* MWMTaxiPreviewCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MWMTaxiPreviewCell.h; sourceTree = ""; }; - F68FCB881DA7BD20007CC7D7 /* MWMTaxiPreviewCell.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MWMTaxiPreviewCell.mm; sourceTree = ""; }; - F68FCB891DA7BD20007CC7D7 /* MWMTaxiPreviewCell.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = MWMTaxiPreviewCell.xib; sourceTree = ""; }; F6A218471CA3F26800BE2CC6 /* MWMEditorViralActivityItem.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MWMEditorViralActivityItem.h; sourceTree = ""; }; F6A218481CA3F26800BE2CC6 /* MWMEditorViralActivityItem.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MWMEditorViralActivityItem.mm; sourceTree = ""; }; F6A750B71BE8C74400981B41 /* MWMSearchHistoryMyPositionCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MWMSearchHistoryMyPositionCell.h; sourceTree = ""; }; @@ -1666,7 +1668,6 @@ F6F533A21B3C248900C1940B /* UIColor+MapsMeColor.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = "UIColor+MapsMeColor.mm"; sourceTree = ""; }; F6F722F61AE1572400DA3DA1 /* MWMiPhonePortraitPlacePage.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MWMiPhonePortraitPlacePage.h; sourceTree = ""; }; F6F722F71AE1572400DA3DA1 /* MWMiPhonePortraitPlacePage.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MWMiPhonePortraitPlacePage.mm; sourceTree = ""; }; - F6F78B541D770F97008A1A9A /* MWMPPView.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = MWMPPView.xib; sourceTree = ""; }; F6F778781DABC6D800B603E7 /* MWMTaxiCollectionLayout.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MWMTaxiCollectionLayout.h; sourceTree = ""; }; F6F778791DABC6D800B603E7 /* MWMTaxiCollectionLayout.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MWMTaxiCollectionLayout.mm; sourceTree = ""; }; F6F9BD221AD3C3A600308C33 /* Macros.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Macros.h; path = ../Macros.h; sourceTree = ""; }; @@ -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 = ""; @@ -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 */, diff --git a/map/bookmark.hpp b/map/bookmark.hpp index 2fb0280e6b..ba2ad7c232 100644 --- a/map/bookmark.hpp +++ b/map/bookmark.hpp @@ -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::max() && + m_categoryIndex != numeric_limits::max(); + }; - int m_bookmarkIndex = -1; - int m_categoryIndex = -1; + size_t m_bookmarkIndex = numeric_limits::max(); + size_t m_categoryIndex = numeric_limits::max(); }; diff --git a/map/place_page_info.cpp b/map/place_page_info.cpp index 20a5b97ba9..8e63bc5803 100644 --- a/map/place_page_info.cpp +++ b/map/place_page_info.cpp @@ -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); }