diff --git a/iphone/Maps/Classes/CustomViews/MapViewControls/LocationButton/MWMLocationButtonView.mm b/iphone/Maps/Classes/CustomViews/MapViewControls/LocationButton/MWMLocationButtonView.mm index 4453e21996..1c5a7b1dd4 100644 --- a/iphone/Maps/Classes/CustomViews/MapViewControls/LocationButton/MWMLocationButtonView.mm +++ b/iphone/Maps/Classes/CustomViews/MapViewControls/LocationButton/MWMLocationButtonView.mm @@ -93,7 +93,6 @@ @(location::State::Follow).stringValue : @"follow", @(location::State::RotateAndFollow).stringValue : @"followandrotate"}; NSString const * const changeAnimation = [NSString stringWithFormat:@"%@_to_%@_", stateMap[@(beginState).stringValue], stateMap[@(endState).stringValue]]; - NSLog(@"changeAnimation: %@", changeAnimation); static NSUInteger const animationImagesCount = 6; NSMutableArray * const animationImages = [NSMutableArray arrayWithCapacity:animationImagesCount]; for (NSUInteger i = 0; i < animationImagesCount; ++i) diff --git a/iphone/Maps/Classes/CustomViews/MapViewControls/MWMMapViewControlsManager.mm b/iphone/Maps/Classes/CustomViews/MapViewControls/MWMMapViewControlsManager.mm index 7d6ac3b2e9..0a18e39564 100644 --- a/iphone/Maps/Classes/CustomViews/MapViewControls/MWMMapViewControlsManager.mm +++ b/iphone/Maps/Classes/CustomViews/MapViewControls/MWMMapViewControlsManager.mm @@ -6,22 +6,19 @@ // Copyright (c) 2015 MapsWithMe. All rights reserved. // +#import "MapViewController.h" +#import "MWMLocationButton.h" #import "MWMMapViewControlsManager.h" #import "MWMSideMenuManager.h" #import "MWMZoomButtons.h" -#import "MWMLocationButton.h" -#import "MWMMapViewControlsWrapper.h" -#import "MapViewController.h" #include "Framework.h" @interface MWMMapViewControlsManager() -@property (nonatomic) MWMSideMenuManager * menuManager; @property (nonatomic) MWMZoomButtons * zoomButtons; @property (nonatomic) MWMLocationButton * locationButton; - -@property (nonatomic) MWMMapViewControlsWrapper * viewWrapper; +@property (nonatomic) MWMSideMenuManager * menuManager; @end @@ -34,12 +31,9 @@ self = [super init]; if (!self) return nil; - self.viewWrapper = [[MWMMapViewControlsWrapper alloc] initWithParentView:controller.view]; - if (!self.viewWrapper) - return nil; - self.menuManager = [[MWMSideMenuManager alloc] initWithParentView:self.viewWrapper andController:controller]; - self.zoomButtons = [[MWMZoomButtons alloc] initWithParentView:self.viewWrapper]; - self.locationButton = [[MWMLocationButton alloc] initWithParentView:self.viewWrapper]; + self.zoomButtons = [[MWMZoomButtons alloc] initWithParentView:controller.view]; + self.locationButton = [[MWMLocationButton alloc] initWithParentView:controller.view]; + self.menuManager = [[MWMSideMenuManager alloc] initWithParentController:controller]; self.hidden = NO; self.zoomHidden = NO; self.menuHidden = NO; diff --git a/iphone/Maps/Classes/CustomViews/MapViewControls/MWMMapViewControlsWrapper.h b/iphone/Maps/Classes/CustomViews/MapViewControls/MWMMapViewControlsWrapper.h deleted file mode 100644 index 5391379793..0000000000 --- a/iphone/Maps/Classes/CustomViews/MapViewControls/MWMMapViewControlsWrapper.h +++ /dev/null @@ -1,19 +0,0 @@ -// -// MWMMapViewControlsWrapper.h -// Maps -// -// Created by Ilya Grechuhin on 02.06.15. -// Copyright (c) 2015 MapsWithMe. All rights reserved. -// - -#import - -@interface MWMMapViewControlsWrapper : UIView - -- (instancetype)init __attribute__((unavailable("init is not available"))); -- (instancetype)initWithFrame:(CGRect)frame __attribute__((unavailable("initWithFrame is not available"))); -- (instancetype)initWithCoder:(NSCoder *)aDecoder __attribute__((unavailable("initWithCoder is not available"))); - -- (instancetype)initWithParentView:(UIView *)view; - -@end diff --git a/iphone/Maps/Classes/CustomViews/MapViewControls/MWMMapViewControlsWrapper.mm b/iphone/Maps/Classes/CustomViews/MapViewControls/MWMMapViewControlsWrapper.mm deleted file mode 100644 index 69ffd5974d..0000000000 --- a/iphone/Maps/Classes/CustomViews/MapViewControls/MWMMapViewControlsWrapper.mm +++ /dev/null @@ -1,30 +0,0 @@ -// -// MWMMapViewControlsWrapper.mm -// Maps -// -// Created by Ilya Grechuhin on 02.06.15. -// Copyright (c) 2015 MapsWithMe. All rights reserved. -// - -#import "MWMMapViewControlsWrapper.h" - -@implementation MWMMapViewControlsWrapper - -- (instancetype)initWithParentView:(UIView *)view -{ - self = [super initWithFrame:view.bounds]; - if (!self) - return nil; - [view addSubview:self]; - self.contentScaleFactor = view.contentScaleFactor; - self.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight; - return self; -} - -- (void)layoutSubviews -{ - [super layoutSubviews]; - self.frame = self.superview.bounds; -} - -@end diff --git a/iphone/Maps/Classes/CustomViews/MapViewControls/SideMenu/MWMSideMenuButton.h b/iphone/Maps/Classes/CustomViews/MapViewControls/SideMenu/MWMSideMenuButton.h index ef8b017034..16a4f8ba17 100644 --- a/iphone/Maps/Classes/CustomViews/MapViewControls/SideMenu/MWMSideMenuButton.h +++ b/iphone/Maps/Classes/CustomViews/MapViewControls/SideMenu/MWMSideMenuButton.h @@ -13,10 +13,9 @@ @property (weak, nonatomic) id delegate; -- (void)addSelfToView:(UIView *)parentView; -- (void)addSelfHiddenToView:(UIView *)parentView; - - (instancetype)initWithFrame:(CGRect)frame __attribute__((unavailable("initWithFrame is not available"))); - (instancetype)init __attribute__((unavailable("init is not available"))); +- (void)setup; + @end diff --git a/iphone/Maps/Classes/CustomViews/MapViewControls/SideMenu/MWMSideMenuButton.mm b/iphone/Maps/Classes/CustomViews/MapViewControls/SideMenu/MWMSideMenuButton.mm index f9a399a11b..2751dcb26d 100644 --- a/iphone/Maps/Classes/CustomViews/MapViewControls/SideMenu/MWMSideMenuButton.mm +++ b/iphone/Maps/Classes/CustomViews/MapViewControls/SideMenu/MWMSideMenuButton.mm @@ -6,8 +6,8 @@ // Copyright (c) 2015 MapsWithMe. All rights reserved. // -#import "MWMSideMenuButton.h" #import "MWMMapViewControlsCommon.h" +#import "MWMSideMenuButton.h" #import "UIKitCategories.h" @interface MWMSideMenuButton() @@ -51,22 +51,6 @@ [self setNeedsLayout]; } -- (void)addSelfToView:(UIView *)parentView -{ - self.hidden = NO; - if (self.superview == parentView) - return; - [parentView addSubview:self]; - [self setup]; -} - -- (void)addSelfHiddenToView:(UIView *)parentView -{ - super.hidden = YES; - [parentView addSubview:self]; - [self setup]; -} - - (void)layoutSubviews { [super layoutSubviews]; diff --git a/iphone/Maps/Classes/CustomViews/MapViewControls/SideMenu/MWMSideMenuManager.h b/iphone/Maps/Classes/CustomViews/MapViewControls/SideMenu/MWMSideMenuManager.h index 5492cdd6e9..e47e9a357b 100644 --- a/iphone/Maps/Classes/CustomViews/MapViewControls/SideMenu/MWMSideMenuManager.h +++ b/iphone/Maps/Classes/CustomViews/MapViewControls/SideMenu/MWMSideMenuManager.h @@ -22,6 +22,6 @@ typedef NS_ENUM(NSUInteger, MWMSideMenuState) @property (nonatomic) MWMSideMenuState state; - (instancetype)init __attribute__((unavailable("init is not available"))); -- (instancetype)initWithParentView:(UIView *)parentView andController:(MapViewController *)controller; +- (instancetype)initWithParentController:(MapViewController *)controller; @end diff --git a/iphone/Maps/Classes/CustomViews/MapViewControls/SideMenu/MWMSideMenuManager.mm b/iphone/Maps/Classes/CustomViews/MapViewControls/SideMenu/MWMSideMenuManager.mm index 2038f8a283..382a2e4d9c 100644 --- a/iphone/Maps/Classes/CustomViews/MapViewControls/SideMenu/MWMSideMenuManager.mm +++ b/iphone/Maps/Classes/CustomViews/MapViewControls/SideMenu/MWMSideMenuManager.mm @@ -6,19 +6,20 @@ // Copyright (c) 2015 MapsWithMe. All rights reserved. // -#import "MWMSideMenuManager.h" -#import "MWMSideMenuDelegate.h" -#import "MWMSideMenuButton.h" -#import "MWMSideMenuView.h" #import "BookmarksRootVC.h" #import "CountryTreeVC.h" -#import "SettingsAndMoreVC.h" -#import "MapsAppDelegate.h" -#import "LocationManager.h" -#import "ShareActionSheet.h" -#import "MapViewController.h" -#import "MWMMapViewControlsManager.h" #import "Framework.h" +#import "LocationManager.h" +#import "MapsAppDelegate.h" +#import "MapViewController.h" +#import "MWMMapViewControlsCommon.h" +#import "MWMMapViewControlsManager.h" +#import "MWMSideMenuButton.h" +#import "MWMSideMenuDelegate.h" +#import "MWMSideMenuManager.h" +#import "MWMSideMenuView.h" +#import "SettingsAndMoreVC.h" +#import "ShareActionSheet.h" #import "3party/Alohalytics/src/alohalytics_objc.h" @@ -31,7 +32,6 @@ extern NSString * const kAlohalyticsTapEventKey; @interface MWMSideMenuManager() @property (weak, nonatomic) MapViewController * controller; -@property (weak, nonatomic) UIView * parentView; @property (nonatomic) IBOutlet MWMSideMenuButton * menuButton; @property (nonatomic) IBOutlet MWMSideMenuView * sideMenu; @@ -39,12 +39,11 @@ extern NSString * const kAlohalyticsTapEventKey; @implementation MWMSideMenuManager -- (instancetype)initWithParentView:(UIView *)parentView andController:(MapViewController *)controller +- (instancetype)initWithParentController:(MapViewController *)controller { self = [super init]; if (self) { - self.parentView = parentView; self.controller = controller; [[NSBundle mainBundle] loadNibNamed:kMWMSideMenuViewsNibName owner:self options:nil]; self.menuButton.delegate = self; @@ -103,7 +102,7 @@ extern NSString * const kAlohalyticsTapEventKey; double const gY = MercatorBounds::LatToY(coord.latitude); ShareInfo * const info = [[ShareInfo alloc] initWithText:nil gX:gX gY:gY myPosition:YES]; self.controller.shareActionSheet = [[ShareActionSheet alloc] initWithInfo:info viewController:self.controller]; - UIView const * const parentView = self.parentView; + UIView const * const parentView = self.controller.view; [self.controller.shareActionSheet showFromRect:CGRectMake(parentView.midX, parentView.height - 40.0, 0.0, 0.0)]; } @@ -142,6 +141,21 @@ extern NSString * const kAlohalyticsTapEventKey; }); } +- (void)replaceView:(UIView *)viewOut withView:(UIView *)viewIn +{ + if (viewIn.superview == viewIn) + return; + [self.controller.view insertSubview:viewIn aboveSubview:viewOut]; + [UIView animateWithDuration:framesDuration(3) animations:^ + { + viewOut.alpha = 0.0; + } + completion:^(BOOL finished) + { + [viewOut removeFromSuperview]; + }]; +} + #pragma mark - Properties - (void)setState:(MWMSideMenuState)state @@ -151,16 +165,17 @@ extern NSString * const kAlohalyticsTapEventKey; { case MWMSideMenuStateActive: [Alohalytics logEvent:kAlohalyticsTapEventKey withValue:@"menu"]; - [self.sideMenu addSelfToView:self.parentView]; - [self.menuButton removeFromSuperview]; + [self replaceView:self.menuButton withView:self.sideMenu]; + [self.sideMenu setup]; break; case MWMSideMenuStateInactive: - [self.menuButton addSelfToView:self.parentView]; - [self.sideMenu removeFromSuperviewAnimated]; + [self replaceView:self.sideMenu withView:self.menuButton]; + [self.menuButton setup]; + self.menuButton.hidden = NO; break; case MWMSideMenuStateHidden: - [self.menuButton addSelfHiddenToView:self.parentView]; - [self.sideMenu removeFromSuperview]; + [self replaceView:self.sideMenu withView:self.menuButton]; + self.menuButton.hidden = YES; break; } } diff --git a/iphone/Maps/Classes/CustomViews/MapViewControls/SideMenu/MWMSideMenuView.h b/iphone/Maps/Classes/CustomViews/MapViewControls/SideMenu/MWMSideMenuView.h index 3ff948215b..cbbcfe0650 100644 --- a/iphone/Maps/Classes/CustomViews/MapViewControls/SideMenu/MWMSideMenuView.h +++ b/iphone/Maps/Classes/CustomViews/MapViewControls/SideMenu/MWMSideMenuView.h @@ -18,7 +18,6 @@ - (instancetype)initWithFrame:(CGRect)frame __attribute__((unavailable("initWithFrame is not available"))); - (instancetype)init __attribute__((unavailable("init is not available"))); -- (void)addSelfToView:(UIView *)parentView; -- (void)removeFromSuperviewAnimated; +- (void)setup; @end diff --git a/iphone/Maps/Classes/CustomViews/MapViewControls/SideMenu/MWMSideMenuView.mm b/iphone/Maps/Classes/CustomViews/MapViewControls/SideMenu/MWMSideMenuView.mm index 891b2baae0..71e268206e 100644 --- a/iphone/Maps/Classes/CustomViews/MapViewControls/SideMenu/MWMSideMenuView.mm +++ b/iphone/Maps/Classes/CustomViews/MapViewControls/SideMenu/MWMSideMenuView.mm @@ -6,9 +6,9 @@ // Copyright (c) 2015 MapsWithMe. All rights reserved. // +#import "MWMMapViewControlsCommon.h" #import "MWMSideMenuView.h" #import "UIKitCategories.h" -#import "MWMMapViewControlsCommon.h" static CGSize const kBadgeSize = CGSizeMake(24.0, 24.0); @@ -82,26 +82,6 @@ static CGSize const kBadgeSize = CGSizeMake(24.0, 24.0); [self setNeedsLayout]; } -- (void)addSelfToView:(UIView *)parentView -{ - if (self.superview == parentView) - return; - [parentView addSubview:self]; - [self setup]; -} - -- (void)removeFromSuperviewAnimated -{ - [UIView animateWithDuration:framesDuration(3) animations:^ - { - self.alpha = 0.0; - } - completion:^(BOOL finished) - { - [super removeFromSuperview]; - }]; -} - - (CGFloat)offsetBetweenButtons { CGFloat offset = 66.0; diff --git a/iphone/Maps/Maps.xcodeproj/project.pbxproj b/iphone/Maps/Maps.xcodeproj/project.pbxproj index 659e30cf92..a6451f2c4a 100644 --- a/iphone/Maps/Maps.xcodeproj/project.pbxproj +++ b/iphone/Maps/Maps.xcodeproj/project.pbxproj @@ -13,7 +13,6 @@ 1DF5F4E00D08C38300B7A737 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1DF5F4DF0D08C38300B7A737 /* UIKit.framework */; }; 288765080DF74369002DB57D /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 288765070DF74369002DB57D /* CoreGraphics.framework */; }; 28AD73880D9D96C1002E5188 /* MainWindow.xib in Resources */ = {isa = PBXBuildFile; fileRef = 28AD73870D9D96C1002E5188 /* MainWindow.xib */; }; - 340506E31B1E05D5007BC7AD /* MWMMapViewControlsWrapper.mm in Sources */ = {isa = PBXBuildFile; fileRef = 340506E21B1E05D5007BC7AD /* MWMMapViewControlsWrapper.mm */; }; 340F24631B14910500F874CD /* RouteState.mm in Sources */ = {isa = PBXBuildFile; fileRef = 340F24621B14910500F874CD /* RouteState.mm */; }; 343F262E1AEFC4A300388A6D /* MWMFrameworkUtils.mm in Sources */ = {isa = PBXBuildFile; fileRef = 343F262D1AEFC4A300388A6D /* MWMFrameworkUtils.mm */; }; 343F26301AEFDB1A00388A6D /* Framework.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 343F262F1AEFDB1A00388A6D /* Framework.cpp */; }; @@ -315,8 +314,6 @@ 28A0AB4B0D9B1048005BE974 /* Maps_Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; lineEnding = 0; path = Maps_Prefix.pch; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.objc; }; 28AD73870D9D96C1002E5188 /* MainWindow.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = MainWindow.xib; sourceTree = SOURCE_ROOT; }; 29B97316FDCFA39411CA2CEA /* main.mm */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.objcpp; fileEncoding = 4; path = main.mm; sourceTree = ""; }; - 340506E11B1E05D5007BC7AD /* MWMMapViewControlsWrapper.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MWMMapViewControlsWrapper.h; sourceTree = ""; }; - 340506E21B1E05D5007BC7AD /* MWMMapViewControlsWrapper.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MWMMapViewControlsWrapper.mm; sourceTree = ""; }; 340F24611B14910500F874CD /* RouteState.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RouteState.h; sourceTree = ""; }; 340F24621B14910500F874CD /* RouteState.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = RouteState.mm; sourceTree = ""; }; 340F24641B15F01D00F874CD /* MWMSideMenuDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MWMSideMenuDelegate.h; sourceTree = ""; }; @@ -989,8 +986,6 @@ children = ( 34BC72101B0DECAE0012A34B /* MWMMapViewControlsManager.h */, 34BC72111B0DECAE0012A34B /* MWMMapViewControlsManager.mm */, - 340506E11B1E05D5007BC7AD /* MWMMapViewControlsWrapper.h */, - 340506E21B1E05D5007BC7AD /* MWMMapViewControlsWrapper.mm */, 34BC720A1B0DECAE0012A34B /* LocationButton */, 34BC72121B0DECAE0012A34B /* SideMenu */, 34BC721B1B0DECAE0012A34B /* ZoomButtons */, @@ -1937,7 +1932,6 @@ F6DBF9B61AA8779300F2EC2C /* CALayer+RuntimeAttributes.m in Sources */, FA36B80D15403A4F004560CC /* BookmarksVC.mm in Sources */, A32B6D4D1A14980500E54A65 /* iosOGLContextFactory.mm in Sources */, - 340506E31B1E05D5007BC7AD /* MWMMapViewControlsWrapper.mm in Sources */, 9769D6EF1912BF3000CA6158 /* ContainerView.mm in Sources */, FAF457E715597D4600DCCC49 /* Framework.cpp in Sources */, 97CC93BB19599F4700369B42 /* SearchSuggestCell.m in Sources */,