From 41b431de52608d99419c9874082d6322a6920213 Mon Sep 17 00:00:00 2001 From: Ilya Grechuhin Date: Fri, 2 Oct 2015 18:17:31 +0300 Subject: [PATCH] [ios] Added bottom menu. --- .../MWMBottomMenuCollectionViewCell.h | 11 + .../MWMBottomMenuCollectionViewCell.mm | 48 ++ ...MBottomMenuCollectionViewLandscapeCell.xib | 86 ++++ ...WMBottomMenuCollectionViewPortraitCell.xib | 105 ++++ .../BottomMenu/MWMBottomMenuLayout.h | 6 + .../BottomMenu/MWMBottomMenuLayout.mm | 48 ++ .../BottomMenu/MWMBottomMenuView.h | 22 + .../BottomMenu/MWMBottomMenuView.mm | 330 +++++++++++++ .../BottomMenu/MWMBottomMenuViewController.h | 26 + .../BottomMenu/MWMBottomMenuViewController.mm | 460 ++++++++++++++++++ .../MWMBottomMenuViewController.xib | 239 +++++++++ .../MWMMapViewControlsManager.h | 6 +- .../MWMMapViewControlsManager.mm | 86 ++-- .../MapViewControls/Search/MWMSearchManager.h | 1 - .../Search/MWMSearchManager.mm | 32 +- iphone/Maps/Classes/MapViewController.mm | 6 +- iphone/Maps/Maps.xcodeproj/project.pbxproj | 44 ++ 17 files changed, 1501 insertions(+), 55 deletions(-) create mode 100644 iphone/Maps/Classes/CustomViews/MapViewControls/BottomMenu/MWMBottomMenuCollectionViewCell.h create mode 100644 iphone/Maps/Classes/CustomViews/MapViewControls/BottomMenu/MWMBottomMenuCollectionViewCell.mm create mode 100644 iphone/Maps/Classes/CustomViews/MapViewControls/BottomMenu/MWMBottomMenuCollectionViewLandscapeCell.xib create mode 100644 iphone/Maps/Classes/CustomViews/MapViewControls/BottomMenu/MWMBottomMenuCollectionViewPortraitCell.xib create mode 100644 iphone/Maps/Classes/CustomViews/MapViewControls/BottomMenu/MWMBottomMenuLayout.h create mode 100644 iphone/Maps/Classes/CustomViews/MapViewControls/BottomMenu/MWMBottomMenuLayout.mm create mode 100644 iphone/Maps/Classes/CustomViews/MapViewControls/BottomMenu/MWMBottomMenuView.h create mode 100644 iphone/Maps/Classes/CustomViews/MapViewControls/BottomMenu/MWMBottomMenuView.mm create mode 100644 iphone/Maps/Classes/CustomViews/MapViewControls/BottomMenu/MWMBottomMenuViewController.h create mode 100644 iphone/Maps/Classes/CustomViews/MapViewControls/BottomMenu/MWMBottomMenuViewController.mm create mode 100644 iphone/Maps/Classes/CustomViews/MapViewControls/BottomMenu/MWMBottomMenuViewController.xib diff --git a/iphone/Maps/Classes/CustomViews/MapViewControls/BottomMenu/MWMBottomMenuCollectionViewCell.h b/iphone/Maps/Classes/CustomViews/MapViewControls/BottomMenu/MWMBottomMenuCollectionViewCell.h new file mode 100644 index 0000000000..85fc67f47b --- /dev/null +++ b/iphone/Maps/Classes/CustomViews/MapViewControls/BottomMenu/MWMBottomMenuCollectionViewCell.h @@ -0,0 +1,11 @@ +@interface MWMBottomMenuCollectionViewCell : UICollectionViewCell + +@property(weak, nonatomic) IBOutlet UIImageView * icon; + +- (void)configureWithIconName:(NSString *)iconName + label:(NSString *)label + badgeCount:(NSUInteger)badgeCount; + +- (void)highlighted:(BOOL)highlighted; + +@end diff --git a/iphone/Maps/Classes/CustomViews/MapViewControls/BottomMenu/MWMBottomMenuCollectionViewCell.mm b/iphone/Maps/Classes/CustomViews/MapViewControls/BottomMenu/MWMBottomMenuCollectionViewCell.mm new file mode 100644 index 0000000000..07ced07569 --- /dev/null +++ b/iphone/Maps/Classes/CustomViews/MapViewControls/BottomMenu/MWMBottomMenuCollectionViewCell.mm @@ -0,0 +1,48 @@ +#import "MWMBottomMenuCollectionViewCell.h" +#import "UIFont+MapsMeFonts.h" +#import "UIColor+MapsMeColor.h" + +@interface MWMBottomMenuCollectionViewCell () + +@property(weak, nonatomic) IBOutlet UILabel * label; +@property(weak, nonatomic) IBOutlet UIView * badgeBackground; +@property(weak, nonatomic) IBOutlet UILabel * badgeCount; +@property(weak, nonatomic) IBOutlet UIView * separator; + +@property(nonatomic) BOOL isWideMenu; + +@property(copy, nonatomic) NSString * iconName; + +@end + +@implementation MWMBottomMenuCollectionViewCell + +- (void)configureWithIconName:(NSString *)iconName + label:(NSString *)label + badgeCount:(NSUInteger)badgeCount +{ + self.iconName = iconName; + self.icon.image = [UIImage imageNamed:iconName]; + self.label.text = label; + if (badgeCount > 0) + { + self.badgeBackground.hidden = NO; + self.badgeCount.hidden = NO; + self.badgeCount.text = @(badgeCount).stringValue; + } + else + { + self.badgeBackground.hidden = YES; + self.badgeCount.hidden = YES; + } + [self highlighted:NO]; +} + +- (void)highlighted:(BOOL)highlighted +{ + NSString * pressed = highlighted ? @"_press" : @""; + self.icon.image = [UIImage imageNamed:[self.iconName stringByAppendingString:pressed]]; + self.label.textColor = highlighted ? [UIColor blackHintText] : [UIColor blackPrimaryText]; +} + +@end diff --git a/iphone/Maps/Classes/CustomViews/MapViewControls/BottomMenu/MWMBottomMenuCollectionViewLandscapeCell.xib b/iphone/Maps/Classes/CustomViews/MapViewControls/BottomMenu/MWMBottomMenuCollectionViewLandscapeCell.xib new file mode 100644 index 0000000000..d5eb2b59b6 --- /dev/null +++ b/iphone/Maps/Classes/CustomViews/MapViewControls/BottomMenu/MWMBottomMenuCollectionViewLandscapeCell.xib @@ -0,0 +1,86 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/iphone/Maps/Classes/CustomViews/MapViewControls/BottomMenu/MWMBottomMenuCollectionViewPortraitCell.xib b/iphone/Maps/Classes/CustomViews/MapViewControls/BottomMenu/MWMBottomMenuCollectionViewPortraitCell.xib new file mode 100644 index 0000000000..da267be1b3 --- /dev/null +++ b/iphone/Maps/Classes/CustomViews/MapViewControls/BottomMenu/MWMBottomMenuCollectionViewPortraitCell.xib @@ -0,0 +1,105 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/iphone/Maps/Classes/CustomViews/MapViewControls/BottomMenu/MWMBottomMenuLayout.h b/iphone/Maps/Classes/CustomViews/MapViewControls/BottomMenu/MWMBottomMenuLayout.h new file mode 100644 index 0000000000..9bce32f2ef --- /dev/null +++ b/iphone/Maps/Classes/CustomViews/MapViewControls/BottomMenu/MWMBottomMenuLayout.h @@ -0,0 +1,6 @@ +@interface MWMBottomMenuLayout : UICollectionViewLayout + +@property(nonatomic) NSUInteger buttonsCount; +@property(nonatomic) CGFloat layoutThreshold; + +@end diff --git a/iphone/Maps/Classes/CustomViews/MapViewControls/BottomMenu/MWMBottomMenuLayout.mm b/iphone/Maps/Classes/CustomViews/MapViewControls/BottomMenu/MWMBottomMenuLayout.mm new file mode 100644 index 0000000000..e8e643da41 --- /dev/null +++ b/iphone/Maps/Classes/CustomViews/MapViewControls/BottomMenu/MWMBottomMenuLayout.mm @@ -0,0 +1,48 @@ +#import "MWMBottomMenuLayout.h" + +@implementation MWMBottomMenuLayout + +- (CGSize)collectionViewContentSize +{ + return self.collectionView.frame.size; +} + +- (UICollectionViewLayoutAttributes *)layoutAttributesForItemAtIndexPath:(NSIndexPath *)indexPath +{ + UICollectionViewLayoutAttributes * attr = + [UICollectionViewLayoutAttributes layoutAttributesForCellWithIndexPath:indexPath]; + CGSize const size = self.collectionView.frame.size; + CGFloat const position = (CGFloat)indexPath.item / self.buttonsCount; + attr.hidden = (size.width == 0.0 || size.height == 0.0); + if (size.width > self.layoutThreshold) + { + CGFloat const xPos = nearbyint(position * size.width); + CGFloat const width = nearbyint(size.width / self.buttonsCount); + attr.frame = {{xPos, 0.0}, {width, size.height}}; + } + else + { + CGFloat const yPos = nearbyint(position * size.height); + CGFloat const height = nearbyint(size.height / self.buttonsCount); + attr.frame = {{0.0, yPos}, {size.width, height}}; + } + return attr; +} + +- (NSArray *)layoutAttributesForElementsInRect:(CGRect)rect +{ + NSMutableArray * attrs = [NSMutableArray arrayWithCapacity:self.buttonsCount]; + for (NSUInteger index = 0; index < self.buttonsCount; index++) + { + NSIndexPath * indexPath = [NSIndexPath indexPathForItem:index inSection:0]; + [attrs addObject:[self layoutAttributesForItemAtIndexPath:indexPath]]; + } + return attrs; +} + +- (BOOL)shouldInvalidateLayoutForBoundsChange:(CGRect)newBounds +{ + return YES; +} + +@end diff --git a/iphone/Maps/Classes/CustomViews/MapViewControls/BottomMenu/MWMBottomMenuView.h b/iphone/Maps/Classes/CustomViews/MapViewControls/BottomMenu/MWMBottomMenuView.h new file mode 100644 index 0000000000..2a2bcd072c --- /dev/null +++ b/iphone/Maps/Classes/CustomViews/MapViewControls/BottomMenu/MWMBottomMenuView.h @@ -0,0 +1,22 @@ + +typedef NS_ENUM(NSUInteger, MWMBottomMenuState) +{ + MWMBottomMenuStateHidden, + MWMBottomMenuStateInactive, + MWMBottomMenuStateActive, + MWMBottomMenuStateCompact, + MWMBottomMenuStateText, + MWMBottomMenuStatePlanning, + MWMBottomMenuStateGo +}; + +@interface MWMBottomMenuView : SolidTouchView + +@property(nonatomic) MWMBottomMenuState state; + +@property(nonatomic) CGFloat leftBound; +@property(nonatomic) CGFloat layoutThreshold; + +@property(nonatomic) BOOL searchIsActive; + +@end diff --git a/iphone/Maps/Classes/CustomViews/MapViewControls/BottomMenu/MWMBottomMenuView.mm b/iphone/Maps/Classes/CustomViews/MapViewControls/BottomMenu/MWMBottomMenuView.mm new file mode 100644 index 0000000000..0ff61a56fb --- /dev/null +++ b/iphone/Maps/Classes/CustomViews/MapViewControls/BottomMenu/MWMBottomMenuView.mm @@ -0,0 +1,330 @@ +#import "Common.h" +#import "MWMBottomMenuView.h" +#import "UIButton+RuntimeAttributes.h" +#import "UIColor+MapsMeColor.h" + +#include "Framework.h" + +@interface MWMBottomMenuView () + +@property(weak, nonatomic) IBOutlet UIView * mainButtons; +@property(weak, nonatomic) IBOutlet UIView * separator; +@property(weak, nonatomic) IBOutlet UICollectionView * additionalButtons; + +@property(weak, nonatomic) IBOutlet UIView * downloadBadge; + +@property(weak, nonatomic) IBOutlet UIButton * locationButton; +@property(weak, nonatomic) IBOutlet UIButton * p2pButton; +@property(weak, nonatomic) IBOutlet UIButton * searchButton; +@property(weak, nonatomic) IBOutlet UIButton * bookmarksButton; +@property(weak, nonatomic) IBOutlet UIButton * menuButton; + +@property(weak, nonatomic) IBOutlet UIButton * goButton; + +@property(weak, nonatomic) IBOutlet UILabel * streetLabel; + +@property(nonatomic) CGFloat layoutDuration; + +@end + +@implementation MWMBottomMenuView + +- (void)awakeFromNib +{ + [super awakeFromNib]; + self.additionalButtons.hidden = self.goButton.hidden = self.streetLabel.hidden = self.downloadBadge.hidden = YES; +} + +- (void)layoutSubviews +{ + [self refreshOnOrientationChange]; + if (self.layoutDuration > 0.0) + { + CGFloat const duration = self.layoutDuration; + self.layoutDuration = 0.0; + [self layoutIfNeeded]; + [UIView animateWithDuration:duration + animations:^ + { + [self layoutGeometry]; + [self layoutIfNeeded]; + }]; + } + else + { + [self layoutGeometry]; + } + [UIView animateWithDuration:kDefaultAnimationDuration animations:^{ [self updateAlphaAndColor]; } + completion:^(BOOL finished) { [self updateVisibility]; }]; + [self layoutWidgets]; + [super layoutSubviews]; +} + +- (void)updateAlphaAndColor +{ + switch (self.state) + { + case MWMBottomMenuStateHidden: + break; + case MWMBottomMenuStateInactive: + self.backgroundColor = [UIColor menuBackground]; + self.p2pButton.alpha = self.searchButton.alpha = self.bookmarksButton.alpha = 1.0; + self.downloadBadge.alpha = 1.0; + self.goButton.alpha = 0.0; + self.streetLabel.alpha = 0.0; + break; + case MWMBottomMenuStateActive: + self.backgroundColor = [UIColor whiteColor]; + self.p2pButton.alpha = self.searchButton.alpha = self.bookmarksButton.alpha = 1.0; + self.downloadBadge.alpha = 0.0; + self.goButton.alpha = 0.0; + self.streetLabel.alpha = 0.0; + break; + case MWMBottomMenuStateCompact: + if (!IPAD) + self.p2pButton.alpha = self.searchButton.alpha = self.bookmarksButton.alpha = 0.0; + self.downloadBadge.alpha = 0.0; + self.goButton.alpha = 0.0; + self.streetLabel.alpha = 0.0; + break; + case MWMBottomMenuStatePlanning: + [self.goButton setBackgroundImage:nil forState:UIControlStateNormal]; + [self.goButton setBackgroundImage:nil forState:UIControlStateHighlighted]; + self.goButton.backgroundColor = [UIColor clearColor]; + [self.goButton setTitleColor:[UIColor blackHintText] forState:UIControlStateNormal]; + self.p2pButton.alpha = self.searchButton.alpha = self.bookmarksButton.alpha = 0.0; + self.goButton.alpha = 1.0; + self.streetLabel.alpha = 0.0; + break; + case MWMBottomMenuStateGo: + [self.goButton setBackgroundImage:nil forState:UIControlStateNormal]; + [self.goButton setBackgroundImage:nil forState:UIControlStateHighlighted]; + self.goButton.backgroundColor = [UIColor linkBlue]; + [self.goButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal]; + self.p2pButton.alpha = self.searchButton.alpha = self.bookmarksButton.alpha = 0.0; + self.goButton.alpha = 1.0; + self.streetLabel.alpha = 0.0; + break; + case MWMBottomMenuStateText: + self.p2pButton.alpha = self.searchButton.alpha = self.bookmarksButton.alpha = 0.0; + self.goButton.alpha = 0.0; + self.streetLabel.alpha = 1.0; + break; + } +} + +- (void)updateVisibility +{ + switch (self.state) + { + case MWMBottomMenuStateHidden: + break; + case MWMBottomMenuStateInactive: + self.separator.hidden = self.additionalButtons.hidden = YES; + self.goButton.hidden = YES; + self.streetLabel.hidden = YES; + break; + case MWMBottomMenuStateActive: + self.downloadBadge.hidden = YES; + self.goButton.hidden = YES; + self.streetLabel.hidden = YES; + break; + case MWMBottomMenuStateCompact: + if (!IPAD) + self.p2pButton.hidden = self.searchButton.hidden = self.bookmarksButton.hidden = YES; + self.downloadBadge.hidden = YES; + self.goButton.hidden = YES; + self.streetLabel.hidden = YES; + break; + case MWMBottomMenuStatePlanning: + self.p2pButton.hidden = self.searchButton.hidden = self.bookmarksButton.hidden = YES; + self.streetLabel.hidden = YES; + break; + case MWMBottomMenuStateGo: + self.p2pButton.hidden = self.searchButton.hidden = self.bookmarksButton.hidden = YES; + [self.goButton setBackgroundColor:[UIColor linkBlue] forState:UIControlStateNormal]; + [self.goButton setBackgroundColor:[UIColor linkBlueDark] forState:UIControlStateHighlighted]; + self.streetLabel.hidden = YES; + break; + case MWMBottomMenuStateText: + self.p2pButton.hidden = self.searchButton.hidden = self.bookmarksButton.hidden = YES; + self.goButton.hidden = YES; + break; + } +} + +- (void)layoutWidgets +{ + UIView * superView = self.superview; + CGFloat const contentScaleFactor = superView.contentScaleFactor; + m2::PointD const pivot(superView.width * contentScaleFactor - 36.0, + (superView.height - self.mainButtons.height) * contentScaleFactor - 24.0); + auto & infoDisplay = GetFramework().GetInformationDisplay(); + infoDisplay.SetWidgetPivot(InformationDisplay::WidgetType::Ruler, pivot); + infoDisplay.SetWidgetPivot(InformationDisplay::WidgetType::CopyrightLabel, pivot); +} + +- (void)layoutGeometry +{ + switch (self.state) + { + case MWMBottomMenuStateHidden: + self.minY = self.superview.height; + return; + case MWMBottomMenuStateInactive: + case MWMBottomMenuStateCompact: + case MWMBottomMenuStatePlanning: + case MWMBottomMenuStateGo: + case MWMBottomMenuStateText: + self.separator.height = self.additionalButtons.height = 0.0; + break; + case MWMBottomMenuStateActive: + self.additionalButtons.height = self.width > self.layoutThreshold ? 64.0 : 148.0; + break; + } + CGFloat const width = self.superview.width - self.leftBound; + CGFloat const height = self.mainButtons.height + self.separator.height + self.additionalButtons.height; + self.frame = {{self.superview.width - width, self.superview.height - height}, {width, height}}; +} + +- (void)updateMenuButtonFromState:(MWMBottomMenuState)fromState toState:(MWMBottomMenuState)toState +{ + if (fromState == MWMBottomMenuStateActive || toState == MWMBottomMenuStateActive) + [self morphMenuButtonTemplate:@"ic_menu_" toState:toState]; + else if (fromState == MWMBottomMenuStateCompact || toState == MWMBottomMenuStateCompact) + [self morphMenuButtonTemplate:@"ic_menu_rotate_" toState:toState]; + [self refreshMenuButtonState]; +} + +- (void)morphMenuButtonTemplate:(NSString *)morphTemplate toState:(MWMBottomMenuState)toState +{ + BOOL const direct = toState == MWMBottomMenuStateActive || toState == MWMBottomMenuStateCompact; + UIButton * btn = self.menuButton; + NSUInteger const morphImagesCount = 6; + NSUInteger const startValue = direct ? 1 : morphImagesCount; + NSUInteger const endValue = direct ? morphImagesCount + 1 : 0; + NSInteger const stepValue = direct ? 1 : -1; + NSMutableArray * morphImages = [NSMutableArray arrayWithCapacity:morphImagesCount]; + for (NSUInteger i = startValue, j = 0; i != endValue; i += stepValue, j++) + morphImages[j] = [UIImage imageNamed:[morphTemplate stringByAppendingString:@(i).stringValue]]; + btn.imageView.animationImages = morphImages; + btn.imageView.animationRepeatCount = 1; + btn.imageView.image = morphImages.lastObject; + [btn.imageView startAnimating]; +} + +- (void)refreshMenuButtonState +{ + dispatch_async(dispatch_get_main_queue(), ^ + { + if (self.menuButton.imageView.isAnimating) + { + [self refreshMenuButtonState]; + } + else + { + UIButton * btn = self.menuButton; + switch (self.state) + { + case MWMBottomMenuStateHidden: + case MWMBottomMenuStateInactive: + case MWMBottomMenuStatePlanning: + case MWMBottomMenuStateGo: + case MWMBottomMenuStateText: + [btn setImage:[UIImage imageNamed:@"ic_menu"] forState:UIControlStateNormal]; + [btn setImage:[UIImage imageNamed:@"ic_menu_press"] forState:UIControlStateHighlighted]; + break; + case MWMBottomMenuStateActive: + [btn setImage:[UIImage imageNamed:@"ic_menu_down"] forState:UIControlStateNormal]; + [btn setImage:[UIImage imageNamed:@"ic_menu_down_press"] + forState:UIControlStateHighlighted]; + break; + case MWMBottomMenuStateCompact: + [btn setImage:[UIImage imageNamed:@"ic_menu_left"] forState:UIControlStateNormal]; + [btn setImage:[UIImage imageNamed:@"ic_menu_left_press"] + forState:UIControlStateHighlighted]; + break; + } + } + }); +} + +- (void)refreshOnOrientationChange +{ + if (IPAD || self.state != MWMBottomMenuStateCompact) + return; + BOOL const isPortrait = self.superview.width < self.superview.height; + if (isPortrait) + self.leftBound = 0.0; +} + +#pragma mark - Properties + +- (void)setFrame:(CGRect)frame +{ + CGFloat const minWidth = self.locationButton.width + self.menuButton.width; + frame.size.width = MAX(minWidth, frame.size.width); + super.frame = frame; +} + +- (void)setState:(MWMBottomMenuState)state +{ + if (_state == state) + return; + self.layoutDuration = kDefaultAnimationDuration; + switch (state) + { + case MWMBottomMenuStateHidden: + break; + case MWMBottomMenuStateInactive: + _leftBound = 0.0; + self.downloadBadge.hidden = + GetFramework().GetCountryTree().GetActiveMapLayout().GetOutOfDateCount() == 0; + self.p2pButton.hidden = self.searchButton.hidden = self.bookmarksButton.hidden = NO; + self.layoutDuration = + (_state == MWMBottomMenuStateCompact && !IPAD) ? 0.0 : kDefaultAnimationDuration; + if (_state != MWMBottomMenuStateGo && _state != MWMBottomMenuStatePlanning && + _state != MWMBottomMenuStateText) + [self updateMenuButtonFromState:_state toState:state]; + break; + case MWMBottomMenuStateActive: + [self updateMenuButtonFromState:_state toState:state]; + self.separator.hidden = self.additionalButtons.hidden = NO; + self.p2pButton.hidden = self.searchButton.hidden = self.bookmarksButton.hidden = NO; + break; + case MWMBottomMenuStateCompact: + self.layoutDuration = IPAD ? kDefaultAnimationDuration : 0.0; + [self updateMenuButtonFromState:_state toState:state]; + break; + case MWMBottomMenuStatePlanning: + self.goButton.hidden = NO; + self.goButton.enabled = NO; + [self updateMenuButtonFromState:_state toState:state]; + break; + case MWMBottomMenuStateGo: + self.goButton.hidden = NO; + self.goButton.enabled = YES; + [self updateMenuButtonFromState:_state toState:state]; + break; + case MWMBottomMenuStateText: + self.streetLabel.hidden = NO; + [self updateMenuButtonFromState:_state toState:state]; + break; + } + _state = state; + [self setNeedsLayout]; +} + +- (void)setLeftBound:(CGFloat)leftBound +{ + _leftBound = leftBound; + self.state = leftBound > 1.0 ? MWMBottomMenuStateCompact : MWMBottomMenuStateInactive; + [self setNeedsLayout]; +} + +- (void)setSearchIsActive:(BOOL)searchIsActive +{ + _searchIsActive = self.searchButton.selected = searchIsActive; +} + +@end diff --git a/iphone/Maps/Classes/CustomViews/MapViewControls/BottomMenu/MWMBottomMenuViewController.h b/iphone/Maps/Classes/CustomViews/MapViewControls/BottomMenu/MWMBottomMenuViewController.h new file mode 100644 index 0000000000..164502b04d --- /dev/null +++ b/iphone/Maps/Classes/CustomViews/MapViewControls/BottomMenu/MWMBottomMenuViewController.h @@ -0,0 +1,26 @@ + +#import "MWMBottomMenuView.h" + +@class MapViewController; + +@protocol MWMBottomMenuControllerProtocol + +- (void)actionDownloadMaps; +- (void)closeInfoScreens; + +@end + +@interface MWMBottomMenuViewController : UIViewController + +@property(nonatomic) MWMBottomMenuState state; + +@property(nonatomic) CGFloat leftBound; + +- (instancetype)initWithParentController:(MapViewController *)controller + delegate:(id)delegate; + +- (void)setStreetName:(NSString *)streetName; +- (void)setPlanning; +- (void)setGo; + +@end diff --git a/iphone/Maps/Classes/CustomViews/MapViewControls/BottomMenu/MWMBottomMenuViewController.mm b/iphone/Maps/Classes/CustomViews/MapViewControls/BottomMenu/MWMBottomMenuViewController.mm new file mode 100644 index 0000000000..ac93388a09 --- /dev/null +++ b/iphone/Maps/Classes/CustomViews/MapViewControls/BottomMenu/MWMBottomMenuViewController.mm @@ -0,0 +1,460 @@ +#import "BookmarksRootVC.h" +#import "Common.h" +#import "MapsAppDelegate.h" +#import "MapViewController.h" +#import "MWMActivityViewController.h" +#import "MWMBottomMenuCollectionViewCell.h" +#import "MWMBottomMenuLayout.h" +#import "MWMBottomMenuView.h" +#import "MWMBottomMenuViewController.h" +#import "MWMMapViewControlsManager.h" +#import "MWMSearchManager.h" +#import "SettingsAndMoreVC.h" +#import "UIColor+MapsMeColor.h" +#import "UIKitCategories.h" + +#import "3party/Alohalytics/src/alohalytics_objc.h" + +#include "Framework.h" + +extern NSString * const kAlohalyticsTapEventKey; +extern NSString * const kSearchStateWillChangeNotification; +extern NSString * const kSearchStateKey; + +static NSString * const kCollectionCellPortrait = @"MWMBottomMenuCollectionViewPortraitCell"; +static NSString * const kCollectionCelllandscape = @"MWMBottomMenuCollectionViewLandscapeCell"; + +static CGFloat const kLayoutThreshold = 420.0; + +typedef NS_ENUM(NSUInteger, MWMBottomMenuViewCell) +{ + MWMBottomMenuViewCellDownload, + MWMBottomMenuViewCellSettings, + MWMBottomMenuViewCellShare, + MWMBottomMenuViewCellCount +}; + +@interface MWMBottomMenuViewController () + +@property(weak, nonatomic) MapViewController * controller; +@property(weak, nonatomic) IBOutlet UICollectionView * buttonsCollectionView; + +@property(weak, nonatomic) IBOutlet UIButton * locationButton; +@property(weak, nonatomic) IBOutlet UICollectionView * additionalButtons; +@property(weak, nonatomic) IBOutlet UILabel * streetLabel; + +@property(weak, nonatomic) id delegate; + +@property(nonatomic) BOOL searchIsActive; + +@property(nonatomic) SolidTouchView * dimBackground; + +@property(nonatomic) MWMBottomMenuState restoreState; + +@property(nonatomic) int locationListenerSlot; + +@end + +@implementation MWMBottomMenuViewController + +- (instancetype)initWithParentController:(MapViewController *)controller + delegate:(id)delegate +{ + self = [super init]; + if (self) + { + _controller = controller; + _delegate = delegate; + [controller addChildViewController:self]; + MWMBottomMenuView * view = (MWMBottomMenuView *)self.view; + [controller.view addSubview:view]; + view.maxY = controller.view.height; + [[NSNotificationCenter defaultCenter] addObserver:self + selector:@selector(searchStateWillChange:) + name:kSearchStateWillChangeNotification + object:nil]; + } + return self; +} + +- (void)dealloc +{ + [[NSNotificationCenter defaultCenter] removeObserver:self]; +} + +- (void)viewDidLoad +{ + [super viewDidLoad]; + [self setupCollectionView]; +} + +- (void)viewWillAppear:(BOOL)animated +{ + [super viewWillAppear:animated]; + [self configLocationListener]; + [self onLocationStateModeChanged:GetFramework().GetLocationState()->GetMode()]; +} + +- (void)viewWillDisappear:(BOOL)animated +{ + [super viewWillDisappear:animated]; + GetFramework().GetLocationState()->RemoveStateModeListener(self.locationListenerSlot); +} + +#pragma mark - Layout + +- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation + duration:(NSTimeInterval)duration +{ + [self.additionalButtons reloadData]; +} + +- (void)viewWillTransitionToSize:(CGSize)size + withTransitionCoordinator:(id)coordinator +{ + [self.additionalButtons reloadData]; +} + +#pragma mark - Routing state + +- (void)setStreetName:(NSString *)streetName +{ + self.state = MWMBottomMenuStateText; + self.streetLabel.text = streetName; +} + +- (void)setPlanning +{ + if (IPAD) + return; + self.state = MWMBottomMenuStatePlanning; +} + +- (void)setGo +{ + if (IPAD) + return; + self.state = MWMBottomMenuStateGo; +} + +#pragma mark - Location button + +- (void)configLocationListener +{ + typedef void (*LocationStateModeFnT)(id, SEL, location::State::Mode); + SEL locationStateModeSelector = @selector(onLocationStateModeChanged:); + LocationStateModeFnT locationStateModeFn = + (LocationStateModeFnT)[self methodForSelector:locationStateModeSelector]; + + self.locationListenerSlot = GetFramework().GetLocationState()->AddStateModeListener( + bind(locationStateModeFn, self, locationStateModeSelector, _1)); +} + +- (void)onLocationStateModeChanged:(location::State::Mode)state +{ + UIButton * locBtn = self.locationButton; + [locBtn.imageView.layer removeAllAnimations]; + switch (state) + { + case location::State::Mode::UnknownPosition: + [locBtn setImage:[UIImage imageNamed:@"ic_menu_location_off_mode_light"] + forState:UIControlStateNormal]; + break; + case location::State::Mode::PendingPosition: + { + [locBtn setImage:[UIImage imageNamed:@"ic_menu_location_pending"] + forState:UIControlStateNormal]; + CABasicAnimation * rotation; + rotation = [CABasicAnimation animationWithKeyPath:@"transform.rotation.z"]; + rotation.duration = kDefaultAnimationDuration; + rotation.toValue = @(M_PI * 2.0 * rotation.duration); + rotation.cumulative = YES; + rotation.repeatCount = MAXFLOAT; + [locBtn.imageView.layer addAnimation:rotation forKey:@"locationImage"]; + break; + } + case location::State::Mode::NotFollow: + [locBtn setImage:[UIImage imageNamed:@"ic_menu_location_get_position"] + forState:UIControlStateNormal]; + break; + case location::State::Mode::Follow: + [locBtn setImage:[UIImage imageNamed:@"ic_menu_location_follow"] forState:UIControlStateNormal]; + break; + case location::State::Mode::RotateAndFollow: + UIButton * btn = self.locationButton; + NSUInteger const morphImagesCount = 6; + NSUInteger const startValue = 1; + NSUInteger const endValue = morphImagesCount + 1; + NSMutableArray * morphImages = [NSMutableArray arrayWithCapacity:morphImagesCount]; + for (NSUInteger i = startValue, j = 0; i != endValue; i++, j++) + morphImages[j] = [UIImage imageNamed:[@"ic_follow_mode_light_" stringByAppendingString:@(i).stringValue]]; + btn.imageView.animationImages = morphImages; + btn.imageView.animationRepeatCount = 1; + btn.imageView.image = morphImages.lastObject; + [btn.imageView startAnimating]; + break; + } +} + +#pragma mark - Notifications + +- (void)searchStateWillChange:(NSNotification *)notification +{ + MWMSearchManagerState state = + MWMSearchManagerState([[notification userInfo][kSearchStateKey] unsignedIntegerValue]); + self.searchIsActive = state != MWMSearchManagerStateHidden; +} + +#pragma mark - Setup + +- (void)setupCollectionView +{ + [self.buttonsCollectionView registerNib:[UINib nibWithNibName:kCollectionCellPortrait bundle:nil] + forCellWithReuseIdentifier:kCollectionCellPortrait]; + [self.buttonsCollectionView registerNib:[UINib nibWithNibName:kCollectionCelllandscape bundle:nil] + forCellWithReuseIdentifier:kCollectionCelllandscape]; + MWMBottomMenuLayout * cvLayout = + (MWMBottomMenuLayout *)self.buttonsCollectionView.collectionViewLayout; + cvLayout.buttonsCount = MWMBottomMenuViewCellCount; + cvLayout.layoutThreshold = kLayoutThreshold; + ((MWMBottomMenuView *)self.view).layoutThreshold = kLayoutThreshold; +} + +#pragma mark - UICollectionViewDataSource + +- (NSInteger)collectionView:(nonnull UICollectionView *)collectionView + numberOfItemsInSection:(NSInteger)section +{ + return MWMBottomMenuViewCellCount; +} + +- (nonnull UICollectionViewCell *)collectionView:(nonnull UICollectionView *)collectionView + cellForItemAtIndexPath:(nonnull NSIndexPath *)indexPath +{ + BOOL const isWideMenu = self.view.width > kLayoutThreshold; + MWMBottomMenuCollectionViewCell * cell = + [collectionView dequeueReusableCellWithReuseIdentifier:isWideMenu ? kCollectionCelllandscape + : kCollectionCellPortrait + forIndexPath:indexPath]; + switch (indexPath.item) + { + case MWMBottomMenuViewCellDownload: + { + NSUInteger const badgeCount = + GetFramework().GetCountryTree().GetActiveMapLayout().GetOutOfDateCount(); + [cell configureWithIconName:@"ic_menu_download" + label:L(@"download_maps") + badgeCount:badgeCount]; + } + break; + case MWMBottomMenuViewCellSettings: + [cell configureWithIconName:@"ic_menu_settings" label:L(@"settings") badgeCount:0]; + break; + case MWMBottomMenuViewCellShare: + [cell configureWithIconName:@"ic_menu_share" label:L(@"share_my_location") badgeCount:0]; + break; + case MWMBottomMenuViewCellCount: + break; + } + return cell; +} + +#pragma mark - UICollectionViewDelegate + +- (void)collectionView:(nonnull UICollectionView *)collectionView + didSelectItemAtIndexPath:(nonnull NSIndexPath *)indexPath +{ + switch (indexPath.item) + { + case MWMBottomMenuViewCellDownload: + [self menuActionDownloadMaps]; + break; + case MWMBottomMenuViewCellSettings: + [self menuActionOpenSettings]; + break; + case MWMBottomMenuViewCellShare: + [self menuActionShareLocation]; + break; + case MWMBottomMenuViewCellCount: + break; + } +} + +- (void)collectionView:(nonnull UICollectionView *)collectionView + didHighlightItemAtIndexPath:(nonnull NSIndexPath *)indexPath +{ + MWMBottomMenuCollectionViewCell * cell = + (MWMBottomMenuCollectionViewCell *)[collectionView cellForItemAtIndexPath:indexPath]; + [cell highlighted:YES]; +} + +- (void)collectionView:(nonnull UICollectionView *)collectionView + didUnhighlightItemAtIndexPath:(nonnull NSIndexPath *)indexPath +{ + MWMBottomMenuCollectionViewCell * cell = + (MWMBottomMenuCollectionViewCell *)[collectionView cellForItemAtIndexPath:indexPath]; + [cell highlighted:NO]; +} + +#pragma mark - Buttons actions + +- (void)menuActionDownloadMaps +{ + self.state = MWMBottomMenuStateInactive; + [self.delegate actionDownloadMaps]; +} + +- (void)menuActionOpenSettings +{ + self.state = MWMBottomMenuStateInactive; + [Alohalytics logEvent:kAlohalyticsTapEventKey withValue:@"settingsAndMore"]; + SettingsAndMoreVC * const vc = [[SettingsAndMoreVC alloc] initWithStyle:UITableViewStyleGrouped]; + [self.controller.navigationController pushViewController:vc animated:YES]; +} + +- (void)menuActionShareLocation +{ + [Alohalytics logEvent:kAlohalyticsTapEventKey withValue:@"share@"]; + CLLocation * location = [MapsAppDelegate theApp].m_locationManager.lastLocation; + if (!location) + { + [[[UIAlertView alloc] initWithTitle:L(@"unknown_current_position") + message:nil + delegate:nil + cancelButtonTitle:L(@"ok") + otherButtonTitles:nil] show]; + return; + } + CLLocationCoordinate2D const coord = location.coordinate; + NSIndexPath * cellIndex = [NSIndexPath indexPathForItem:MWMBottomMenuViewCellShare inSection:0]; + MWMBottomMenuCollectionViewCell * cell = + (MWMBottomMenuCollectionViewCell *)[self.additionalButtons cellForItemAtIndexPath:cellIndex]; + MWMActivityViewController * shareVC = + [MWMActivityViewController shareControllerForLocationTitle:nil location:coord myPosition:YES]; + [shareVC presentInParentViewController:self.controller anchorView:cell.icon]; +} + +- (IBAction)locationButtonTouchUpInside:(UIButton *)sender +{ + GetFramework().GetLocationState()->SwitchToNextMode(); +} + +- (IBAction)point2PointButtonTouchUpInside:(UIButton *)sender +{ +} + +- (IBAction)searchButtonTouchUpInside:(UIButton *)sender +{ + self.state = MWMBottomMenuStateInactive; + [Alohalytics logEvent:kAlohalyticsTapEventKey withValue:@"search"]; + self.controller.controlsManager.searchHidden = self.searchIsActive; +} + +- (IBAction)bookmarksButtonTouchUpInside:(UIButton *)sender +{ + self.state = MWMBottomMenuStateInactive; + [Alohalytics logEvent:kAlohalyticsTapEventKey withValue:@"bookmarks"]; + BookmarksRootVC * const vc = [[BookmarksRootVC alloc] init]; + [self.controller.navigationController pushViewController:vc animated:YES]; +} + +- (IBAction)menuButtonTouchUpInside:(UIButton *)sender +{ + switch (self.state) + { + case MWMBottomMenuStateHidden: + NSAssert(false, @"Incorrect state"); + break; + case MWMBottomMenuStateInactive: + case MWMBottomMenuStatePlanning: + case MWMBottomMenuStateGo: + case MWMBottomMenuStateText: + self.state = MWMBottomMenuStateActive; + break; + case MWMBottomMenuStateActive: + self.state = self.restoreState; + break; + case MWMBottomMenuStateCompact: + [self.delegate closeInfoScreens]; + break; + } +} +- (IBAction)goButtonTouchUpInside:(UIButton *)sender +{ +} + +- (void)dimBackgroundTap +{ + self.state = self.restoreState; +} + +- (void)toggleDimBackgroundVisible:(BOOL)visible +{ + if (visible) + [self.controller.view insertSubview:self.dimBackground belowSubview:self.view]; + self.dimBackground.alpha = visible ? 0.0 : 0.8; + [UIView animateWithDuration:kDefaultAnimationDuration animations:^ + { + self.dimBackground.alpha = visible ? 0.8 : 0.0; + } + completion:^(BOOL finished) + { + if (!visible) + { + [self.dimBackground removeFromSuperview]; + self.dimBackground = nil; + } + }]; +} + +#pragma mark - Properties + +- (SolidTouchView *)dimBackground +{ + if (!_dimBackground) + { + _dimBackground = [[SolidTouchView alloc] initWithFrame:self.controller.view.bounds]; + _dimBackground.backgroundColor = [UIColor fadeBackground]; + _dimBackground.autoresizingMask = + UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight; + UITapGestureRecognizer * tap = + [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(dimBackgroundTap)]; + [_dimBackground addGestureRecognizer:tap]; + } + return _dimBackground; +} + +- (void)setState:(MWMBottomMenuState)state +{ + if (state == MWMBottomMenuStateActive) + self.restoreState = self.state; + [self toggleDimBackgroundVisible:state == MWMBottomMenuStateActive]; + ((MWMBottomMenuView *)self.view).state = state; +} + +- (MWMBottomMenuState)state +{ + return ((MWMBottomMenuView *)self.view).state; +} + +- (void)setLeftBound:(CGFloat)leftBound +{ + ((MWMBottomMenuView *)self.view).leftBound = leftBound; +} + +- (CGFloat)leftBound +{ + return ((MWMBottomMenuView *)self.view).leftBound; +} + +- (void)setSearchIsActive:(BOOL)searchIsActive +{ + ((MWMBottomMenuView *)self.view).searchIsActive = searchIsActive; +} + +- (BOOL)searchIsActive +{ + return ((MWMBottomMenuView *)self.view).searchIsActive; +} + +@end diff --git a/iphone/Maps/Classes/CustomViews/MapViewControls/BottomMenu/MWMBottomMenuViewController.xib b/iphone/Maps/Classes/CustomViews/MapViewControls/BottomMenu/MWMBottomMenuViewController.xib new file mode 100644 index 0000000000..d508039d6e --- /dev/null +++ b/iphone/Maps/Classes/CustomViews/MapViewControls/BottomMenu/MWMBottomMenuViewController.xib @@ -0,0 +1,239 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/iphone/Maps/Classes/CustomViews/MapViewControls/MWMMapViewControlsManager.h b/iphone/Maps/Classes/CustomViews/MapViewControls/MWMMapViewControlsManager.h index a38f34c0c0..dc9a7bf661 100644 --- a/iphone/Maps/Classes/CustomViews/MapViewControls/MWMMapViewControlsManager.h +++ b/iphone/Maps/Classes/CustomViews/MapViewControls/MWMMapViewControlsManager.h @@ -1,5 +1,5 @@ +#import "MWMBottomMenuViewController.h" #import "MWMNavigationDashboardManager.h" -#import "MWMSideMenuManager.h" #include "map/user_mark.hpp" #include "platform/location.hpp" @@ -10,8 +10,8 @@ @property (nonatomic) BOOL hidden; @property (nonatomic) BOOL zoomHidden; -@property (nonatomic) BOOL locationHidden; -@property (nonatomic) MWMSideMenuState menuState; +//@property (nonatomic) BOOL locationHidden; +@property (nonatomic) MWMBottomMenuState menuState; @property (nonatomic, readonly) MWMNavigationDashboardState navigationState; @property (nonatomic) BOOL searchHidden; diff --git a/iphone/Maps/Classes/CustomViews/MapViewControls/MWMMapViewControlsManager.mm b/iphone/Maps/Classes/CustomViews/MapViewControls/MWMMapViewControlsManager.mm index a56dee54d3..7f3cc23a99 100644 --- a/iphone/Maps/Classes/CustomViews/MapViewControls/MWMMapViewControlsManager.mm +++ b/iphone/Maps/Classes/CustomViews/MapViewControls/MWMMapViewControlsManager.mm @@ -3,14 +3,12 @@ #import "MapViewController.h" #import "MWMAlertViewController.h" #import "MWMAPIBar.h" -#import "MWMLocationButton.h" +#import "MWMBottomMenuViewController.h" #import "MWMMapViewControlsManager.h" #import "MWMPlacePageViewManager.h" #import "MWMPlacePageViewManagerDelegate.h" #import "MWMSearchManager.h" #import "MWMSearchView.h" -#import "MWMSideMenuManager.h" -#import "MWMSideMenuManagerDelegate.h" #import "MWMZoomButtons.h" #import "RouteState.h" @@ -22,11 +20,11 @@ extern NSString * const kAlohalyticsTapEventKey; @interface MWMMapViewControlsManager ()< MWMPlacePageViewManagerProtocol, MWMNavigationDashboardManagerProtocol, - MWMSideMenuManagerProtocol, MWMSearchManagerProtocol, MWMSearchViewProtocol> + MWMSearchManagerProtocol, MWMSearchViewProtocol, MWMBottomMenuControllerProtocol> @property (nonatomic) MWMZoomButtons * zoomButtons; -@property (nonatomic) MWMLocationButton * locationButton; -@property (nonatomic) MWMSideMenuManager * menuManager; +//@property (nonatomic) MWMLocationButton * locationButton; +@property (nonatomic) MWMBottomMenuViewController * menuController; @property (nonatomic) MWMPlacePageViewManager * placePageManager; @property (nonatomic) MWMNavigationDashboardManager * navigationManager; @property (nonatomic) MWMSearchManager * searchManager; @@ -52,14 +50,13 @@ extern NSString * const kAlohalyticsTapEventKey; return nil; self.ownerController = controller; self.zoomButtons = [[MWMZoomButtons alloc] initWithParentView:controller.view]; - self.locationButton = [[MWMLocationButton alloc] initWithParentView:controller.view]; - self.menuManager = [[MWMSideMenuManager alloc] initWithParentController:controller delegate:self]; self.placePageManager = [[MWMPlacePageViewManager alloc] initWithViewController:controller delegate:self]; self.navigationManager = [[MWMNavigationDashboardManager alloc] initWithParentView:controller.view delegate:self]; self.searchManager = [[MWMSearchManager alloc] initWithParentView:controller.view delegate:self]; + self.menuController = [[MWMBottomMenuViewController alloc] initWithParentController:controller delegate:self]; self.hidden = NO; self.zoomHidden = NO; - self.menuState = MWMSideMenuStateInactive; + self.menuState = MWMBottomMenuStateInactive; return self; } @@ -68,6 +65,7 @@ extern NSString * const kAlohalyticsTapEventKey; - (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration { + [self.menuController willRotateToInterfaceOrientation:toInterfaceOrientation duration:duration]; [self.placePageManager willRotateToInterfaceOrientation:toInterfaceOrientation]; [self.navigationManager willRotateToInterfaceOrientation:toInterfaceOrientation]; [self.searchManager willRotateToInterfaceOrientation:toInterfaceOrientation duration:duration]; @@ -77,6 +75,7 @@ extern NSString * const kAlohalyticsTapEventKey; - (void)viewWillTransitionToSize:(CGSize)size withTransitionCoordinator:(id)coordinator { + [self.menuController viewWillTransitionToSize:size withTransitionCoordinator:coordinator]; [self.placePageManager viewWillTransitionToSize:size withTransitionCoordinator:coordinator]; [self.navigationManager viewWillTransitionToSize:size withTransitionCoordinator:coordinator]; [self.searchManager viewWillTransitionToSize:size withTransitionCoordinator:coordinator]; @@ -113,10 +112,6 @@ extern NSString * const kAlohalyticsTapEventKey; #pragma mark - MWMSearchManagerProtocol -- (void)searchViewWillEnterState:(MWMSearchManagerState)state -{ -} - - (void)searchViewDidEnterState:(MWMSearchManagerState)state { if (state == MWMSearchManagerStateHidden) @@ -140,10 +135,11 @@ extern NSString * const kAlohalyticsTapEventKey; - (void)sideMenuDidUpdateLayout { - [self.zoomButtons setBottomBound:self.menuManager.menuButtonFrameWithSpacing.origin.y]; +// [self.zoomButtons setBottomBound:self.menuManager.menuButtonFrameWithSpacing.origin.y]; + [self.zoomButtons setBottomBound:0.0]; } -#pragma mark - MWMSearchManagerProtocol & MWMSideMenuManagerProtocol +#pragma mark - MWMSearchManagerProtocol & MWMBottomMenuControllerProtocol - (void)actionDownloadMaps { @@ -152,12 +148,33 @@ extern NSString * const kAlohalyticsTapEventKey; [self.ownerController.navigationController pushViewController:vc animated:YES]; } +#pragma mark - MWMBottomMenuControllerProtocol + +- (void)closeInfoScreens +{ + if (IPAD) + { + self.searchManager.state = MWMSearchManagerStateHidden; + } + else + { + CGSize const ownerViewSize = self.ownerController.view.size; + if (ownerViewSize.width > ownerViewSize.height) + [self.placePageManager hidePlacePage]; + } +} + #pragma mark - MWMPlacePageViewManagerDelegate -- (void)dragPlacePage:(CGPoint)point +- (void)dragPlacePage:(CGRect)frame { - CGFloat const bound = MIN(self.menuManager.menuButtonFrameWithSpacing.origin.y, point.y); - [self.zoomButtons setBottomBound:bound]; + if (IPAD) + return; + CGSize const ownerViewSize = self.ownerController.view.size; + if (ownerViewSize.width > ownerViewSize.height) + self.menuController.leftBound = frame.origin.x + frame.size.width; + else + [self.zoomButtons setBottomBound:frame.origin.y]; } - (void)placePageDidClose @@ -169,12 +186,11 @@ extern NSString * const kAlohalyticsTapEventKey; - (void)addPlacePageViews:(NSArray *)views { UIView * ownerView = self.ownerController.view; - UIView * searchView = self.searchManager.view; for (UIView * view in views) - { - if (![ownerView.subviews containsObject:view]) - [ownerView insertSubview:view belowSubview:searchView]; - } + [ownerView addSubview:view]; + [ownerView bringSubviewToFront:self.searchManager.view]; + if (IPAD) + [ownerView bringSubviewToFront:self.menuController.view]; } - (void)updateStatusBarStyle @@ -293,7 +309,7 @@ extern NSString * const kAlohalyticsTapEventKey; _hidden = hidden; self.zoomHidden = _zoomHidden; self.menuState = _menuState; - self.locationHidden = _locationHidden; +// self.locationHidden = _locationHidden; GetFramework().SetFullScreenMode(hidden); } @@ -303,16 +319,16 @@ extern NSString * const kAlohalyticsTapEventKey; self.zoomButtons.hidden = self.hidden || zoomHidden; } -- (void)setMenuState:(MWMSideMenuState)menuState +- (void)setMenuState:(MWMBottomMenuState)menuState { _menuState = menuState; - self.menuManager.state = self.hidden ? MWMSideMenuStateHidden : menuState; + self.menuController.state = self.hidden ? MWMBottomMenuStateHidden : menuState; } -- (MWMSideMenuState)menuState +- (MWMBottomMenuState)menuState { - if (self.menuManager.state == MWMSideMenuStateActive) - return MWMSideMenuStateActive; + if (self.menuController.state == MWMBottomMenuStateActive) + return MWMBottomMenuStateActive; return _menuState; } @@ -321,11 +337,11 @@ extern NSString * const kAlohalyticsTapEventKey; return self.navigationManager.state; } -- (void)setLocationHidden:(BOOL)locationHidden -{ - _locationHidden = locationHidden; - self.locationButton.hidden = self.hidden || locationHidden; -} +//- (void)setLocationHidden:(BOOL)locationHidden +//{ +// _locationHidden = locationHidden; +// self.locationButton.hidden = self.hidden || locationHidden; +//} - (BOOL)isDirectionViewShown { @@ -343,7 +359,7 @@ extern NSString * const kAlohalyticsTapEventKey; { if (!IPAD) return; - _leftBound = self.placePageManager.leftBound = self.navigationManager.leftBound = leftBound; + _leftBound = self.placePageManager.leftBound = self.navigationManager.leftBound = self.menuController.leftBound = leftBound; } - (BOOL)searchHidden diff --git a/iphone/Maps/Classes/CustomViews/MapViewControls/Search/MWMSearchManager.h b/iphone/Maps/Classes/CustomViews/MapViewControls/Search/MWMSearchManager.h index 9e24680222..202b1b3437 100644 --- a/iphone/Maps/Classes/CustomViews/MapViewControls/Search/MWMSearchManager.h +++ b/iphone/Maps/Classes/CustomViews/MapViewControls/Search/MWMSearchManager.h @@ -11,7 +11,6 @@ typedef NS_ENUM(NSUInteger, MWMSearchManagerState) @protocol MWMSearchManagerProtocol -- (void)searchViewWillEnterState:(MWMSearchManagerState)state; - (void)searchViewDidEnterState:(MWMSearchManagerState)state; - (void)actionDownloadMaps; diff --git a/iphone/Maps/Classes/CustomViews/MapViewControls/Search/MWMSearchManager.mm b/iphone/Maps/Classes/CustomViews/MapViewControls/Search/MWMSearchManager.mm index 7a0dfb5929..fd1e093c8c 100644 --- a/iphone/Maps/Classes/CustomViews/MapViewControls/Search/MWMSearchManager.mm +++ b/iphone/Maps/Classes/CustomViews/MapViewControls/Search/MWMSearchManager.mm @@ -12,6 +12,8 @@ #include "map/active_maps_layout.hpp" extern NSString * const kAlohalyticsTapEventKey; +extern NSString * const kSearchStateWillChangeNotification = @"SearchStateWillChangeNotification"; +extern NSString * const kSearchStateKey = @"SearchStateKey"; @interface MWMSearchManager ()