[ios] Fixed layout bugs.

This commit is contained in:
Ilya Grechuhin 2015-06-24 14:02:29 +03:00 committed by Alex Zolotarev
parent d0c5e0a09e
commit 965f1f0381
21 changed files with 295 additions and 227 deletions

View file

@ -10,13 +10,6 @@
#import <Foundation/Foundation.h>
typedef NS_ENUM(NSUInteger, MWMMapViewControlsButton)
{
MWMMapViewControlsButtonZoom,
MWMMapViewControlsButtonMenu,
MWMMapViewControlsButtonLocation
};
@class MapViewController;
@interface MWMMapViewControlsManager : NSObject
@ -28,8 +21,7 @@ typedef NS_ENUM(NSUInteger, MWMMapViewControlsButton)
- (instancetype)init __attribute__((unavailable("init is not available")));
- (instancetype)initWithParentController:(MapViewController *)controller;
- (void)resetZoomButtonsVisibility;
- (void)moveButton:(MWMMapViewControlsButton)button toDefaultPosition:(BOOL)defaultPosition;
- (void)setTopBound:(CGFloat)bound;
- (void)setBottomBound:(CGFloat)bound;
@end

View file

@ -40,22 +40,9 @@
return self;
}
- (void)resetZoomButtonsVisibility
- (void)setTopBound:(CGFloat)bound
{
[self.zoomButtons resetVisibility];
}
- (void)moveButton:(MWMMapViewControlsButton)button toDefaultPosition:(BOOL)defaultPosition
{
switch (button)
{
case MWMMapViewControlsButtonZoom:
[self.zoomButtons moveToDefaultPosition:defaultPosition];
break;
case MWMMapViewControlsButtonMenu:
case MWMMapViewControlsButtonLocation:
break;
}
[self.zoomButtons setTopBound:bound];
}
- (void)setBottomBound:(CGFloat)bound

View file

@ -111,7 +111,7 @@ extern NSString * const kAlohalyticsTapEventKey;
{
self.controller.controlsManager.hidden = YES;
[Alohalytics logEvent:kAlohalyticsTapEventKey withValue:@"search"];
[self.controller.searchView setState:SearchViewStateFullscreen animated:YES withCallback:YES];
[self.controller.searchView setState:SearchViewStateFullscreen animated:YES];
}
- (IBAction)toggleMenu

View file

@ -15,7 +15,7 @@
- (instancetype)init __attribute__((unavailable("init is not available")));
- (instancetype)initWithParentView:(UIView *)view;
- (void)resetVisibility;
- (void)moveToDefaultPosition:(BOOL)defaultPosition;
- (void)setTopBound:(CGFloat)bound;
- (void)setBottomBound:(CGFloat)bound;
@end

View file

@ -51,9 +51,9 @@ extern NSString * const kAlohalyticsTapEventKey;
self.zoomView.hidden = !zoomButtonsEnabled;
}
- (void)moveToDefaultPosition:(BOOL)defaultPosition
- (void)setTopBound:(CGFloat)bound
{
self.zoomView.defaultPosition = defaultPosition;
self.zoomView.topBound = bound;
}
- (void)setBottomBound:(CGFloat)bound

View file

@ -10,7 +10,7 @@
@interface MWMZoomButtonsView : UIView
@property (nonatomic) BOOL defaultPosition;
@property (nonatomic) CGFloat topBound;
@property (nonatomic) CGFloat bottomBound;
- (instancetype)initWithFrame:(CGRect)frame __attribute__((unavailable("initWithFrame is not available")));

View file

@ -10,8 +10,7 @@
#import "MWMMapViewControlsCommon.h"
#import "UIKitCategories.h"
static CGFloat const kZoomViewOffsetToTopBoundDefault = 12.0;
static CGFloat const kZoomViewOffsetToTopBoundMoved = 66.0;
static CGFloat const kZoomViewOffsetToTopBound = 12.0;
static CGFloat const kZoomViewOffsetToBottomBound = 40.0;
static CGFloat const kZoomViewOffsetToFrameBound = 294.0;
static CGFloat const kZoomViewHideBoundPercent = 0.4;
@ -31,7 +30,7 @@ static CGFloat const kZoomViewHideBoundPercent = 0.4;
{
self.defaultBounds = self.bounds;
self.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
self.defaultPosition = YES;
self.topBound = 0.0;
self.bottomBound = 0.0;
}
return self;
@ -42,7 +41,7 @@ static CGFloat const kZoomViewHideBoundPercent = 0.4;
[super layoutSubviews];
self.bounds = self.defaultBounds;
[self layoutXPosition:self.hidden];
[self layoutYPosition:self.defaultPosition];
[self layoutYPosition];
}
- (void)layoutXPosition:(BOOL)hidden
@ -53,21 +52,23 @@ static CGFloat const kZoomViewHideBoundPercent = 0.4;
self.maxX = self.superview.width - kViewControlsOffsetToBounds;
}
- (void)layoutYPosition:(BOOL)defaultPosition
- (void)layoutYPosition
{
self.maxY = self.superview.height - kZoomViewOffsetToFrameBound;
if (self.bottomBound > 0.0)
self.maxY = MIN(self.maxY, self.bottomBound - kZoomViewOffsetToBottomBound);
self.minY = MAX(self.minY, defaultPosition ? kZoomViewOffsetToTopBoundDefault : kZoomViewOffsetToTopBoundMoved);
self.minY = MAX(self.minY, self.topBound + kZoomViewOffsetToTopBound);
}
- (void)moveAnimated
{
if (self.hidden)
return;
[UIView animateWithDuration:framesDuration(kMenuViewMoveFramesCount) animations:^
{
[self layoutYPosition:self.defaultPosition];
}];
{
[self layoutYPosition];
}];
}
- (void)fadeAnimatedIn:(BOOL)show
@ -98,9 +99,9 @@ static CGFloat const kZoomViewHideBoundPercent = 0.4;
}];
}
- (void)setDefaultPosition:(BOOL)defaultPosition
- (void)setTopBound:(CGFloat)topBound
{
_defaultPosition = defaultPosition;
_topBound = topBound;
[self moveAnimated];
}

View file

@ -7,6 +7,7 @@
//
#import "MWMPlacePage.h"
#import "MWMSpringAnimation.h"
@class MWMSpringAnimation;
@ -15,7 +16,7 @@
@property (nonatomic) MWMSpringAnimation * springAnimation;
- (void)cancelSpringAnimation;
- (void)startAnimatingPlacePage:(MWMPlacePage *)placePage initialVelocity:(CGPoint)velocity completion:(void (^)(void))completion;
- (void)startAnimatingPlacePage:(MWMPlacePage *)placePage initialVelocity:(CGPoint)velocity completion:(MWMSpringAnimationCompletionBlock)completion;
- (CGPoint)targetPoint;
@end

View file

@ -7,7 +7,6 @@
//
#import "MWMPlacePage+Animation.h"
#import "MWMSpringAnimation.h"
#import "MWMPlacePageViewManager.h"
#import <objc/runtime.h>
@ -35,7 +34,7 @@
self.springAnimation = nil;
}
- (void)startAnimatingPlacePage:(MWMPlacePage *)placePage initialVelocity:(CGPoint)velocity completion:(void (^)(void))completion
- (void)startAnimatingPlacePage:(MWMPlacePage *)placePage initialVelocity:(CGPoint)velocity completion:(MWMSpringAnimationCompletionBlock)completion
{
[self cancelSpringAnimation];
self.springAnimation = [MWMSpringAnimation animationWithView:placePage.extendedPlacePageView target:placePage.targetPoint velocity:velocity completion:completion];

View file

@ -17,6 +17,7 @@
@property (weak, nonatomic) IBOutlet UIImageView * anchorImageView;
@property (weak, nonatomic, readonly) MWMPlacePageViewManager * manager;
@property (nonatomic) MWMPlacePageActionBar * actionBar;
@property (nonatomic) CGFloat topBound;
- (instancetype)initWithManager:(MWMPlacePageViewManager *)manager;
- (void)show;

View file

@ -46,9 +46,6 @@ extern NSString * const kAlohalyticsTapEventKey;
MWMPlacePageEntity * entity = self.manager.entity;
[self.basePlacePageView configureWithEntity:entity];
if (!self.actionBar)
self.actionBar = [MWMPlacePageActionBar actionBarForPlacePage:self];
MWMPlacePageEntityType type = entity.type;
BOOL const isBookmark = type == MWMPlacePageEntityTypeBookmark;
self.actionBar.bookmarkButton.selected = isBookmark;
@ -162,4 +159,13 @@ extern NSString * const kAlohalyticsTapEventKey;
// This method should be ovverriden if you want to process custom pan.
}
#pragma mark - Properties
- (MWMPlacePageActionBar *)actionBar
{
if (!_actionBar)
_actionBar = [MWMPlacePageActionBar actionBarForPlacePage:self];
return _actionBar;
}
@end

View file

@ -11,15 +11,16 @@
#include "map/user_mark.hpp"
@class MWMPlacePageEntity, MWMPlacePageNavigationBar;
@protocol MWMPlacePageViewDragDelegate;
@protocol MWMPlacePageViewManagerDelegate;
@interface MWMPlacePageViewManager : NSObject
@property (weak, nonatomic, readonly) UIViewController<MWMPlacePageViewDragDelegate> * ownerViewController;
@property (weak, nonatomic, readonly) UIViewController<MWMPlacePageViewManagerDelegate> * ownerViewController;
@property (nonatomic, readonly) MWMPlacePageEntity * entity;
@property (nonatomic) MWMPlacePageNavigationBar * iPhoneNavigationBar;
@property (nonatomic) CGFloat topBound;
- (instancetype)initWithViewController:(UIViewController<MWMPlacePageViewDragDelegate> *)viewController;
- (instancetype)initWithViewController:(UIViewController<MWMPlacePageViewManagerDelegate> *)viewController;
- (void)showPlacePageWithUserMark:(unique_ptr<UserMarkCopy>)userMark;
- (void)refreshPlacePage;
- (void)dismissPlacePage;
@ -32,6 +33,7 @@
- (void)reloadBookmark;
- (void)dragPlacePage:(CGPoint)point;
- (void)showDirectionViewWithTitle:(NSString *)title type:(NSString *)type;
- (void)addSubviews:(NSArray *)views withNavigationController:(UINavigationController *)controller;
- (instancetype)init __attribute__((unavailable("init is unavailable, call initWithViewController: instead")));

View file

@ -16,7 +16,7 @@
#import "MWMPlacePage.h"
#import "MWMPlacePageActionBar.h"
#import "MWMPlacePageEntity.h"
#import "MWMPlacePageViewDragDelegate.h"
#import "MWMPlacePageViewManagerDelegate.h"
#import "MWMPlacePageViewManager.h"
#import "ShareActionSheet.h"
#import "UIKitCategories.h"
@ -36,7 +36,7 @@ typedef NS_ENUM(NSUInteger, MWMPlacePageManagerState)
unique_ptr<UserMarkCopy> m_userMark;
}
@property (weak, nonatomic) UIViewController<MWMPlacePageViewDragDelegate> * ownerViewController;
@property (weak, nonatomic) UIViewController<MWMPlacePageViewManagerDelegate> * ownerViewController;
@property (nonatomic, readwrite) MWMPlacePageEntity * entity;
@property (nonatomic) MWMPlacePage * placePage;
@property (nonatomic) MWMPlacePageManagerState state;
@ -47,7 +47,7 @@ typedef NS_ENUM(NSUInteger, MWMPlacePageManagerState)
@implementation MWMPlacePageViewManager
- (instancetype)initWithViewController:(UIViewController<MWMPlacePageViewDragDelegate> *)viewController
- (instancetype)initWithViewController:(UIViewController<MWMPlacePageViewManagerDelegate> *)viewController
{
self = [super init];
if (self)
@ -100,6 +100,7 @@ typedef NS_ENUM(NSUInteger, MWMPlacePageManagerState)
BOOL hasSpeed;
self.entity.category = [[MapsAppDelegate theApp].m_locationManager formattedSpeedAndAltitude:hasSpeed];
}
self.placePage.topBound = self.topBound;
[self.placePage configure];
[self refreshPlacePage];
}
@ -148,6 +149,13 @@ typedef NS_ENUM(NSUInteger, MWMPlacePageManagerState)
}
}
- (void)addSubviews:(NSArray *)views withNavigationController:(UINavigationController *)controller
{
if (controller)
[self.ownerViewController addChildViewController:controller];
[self.ownerViewController addPlacePageViews:views];
}
- (void)buildRoute
{
GetFramework().BuildRoute(m_userMark->GetUserMark()->GetOrg());
@ -265,4 +273,12 @@ typedef NS_ENUM(NSUInteger, MWMPlacePageManagerState)
[self updateDistance];
}
#pragma mark - Properties
- (void)setTopBound:(CGFloat)bound
{
_topBound = bound;
self.placePage.topBound = bound;
}
@end

View file

@ -1,13 +1,14 @@
//
// MWMPlacePageViewDragDelegate.h
// MWMPlacePageViewManagerDelegate.h
// Maps
//
// Created by Ilya Grechuhin on 16.06.15.
// Copyright (c) 2015 MapsWithMe. All rights reserved.
//
@protocol MWMPlacePageViewDragDelegate <NSObject>
@protocol MWMPlacePageViewManagerDelegate <NSObject>
- (void)dragPlacePage:(CGPoint)point;
- (void)addPlacePageViews:(NSArray *)views;
@end

View file

@ -20,31 +20,6 @@ extern CGFloat kBookmarkCellHeight;
static CGFloat const kLeftOffset = 12.;
static CGFloat const kTopOffset = 36.;
@interface MWMiPadNavigationController : UINavigationController
@end
@implementation MWMiPadNavigationController
- (instancetype)initWithRootViewController:(UIViewController *)rootViewController
{
self = [super initWithRootViewController:rootViewController];
if (self)
{
[self setNavigationBarHidden:YES];
[self.navigationBar setTranslucent:NO];
self.view.autoresizingMask = UIViewAutoresizingNone;
}
return self;
}
- (void)backTap:(id)sender
{
[self popViewControllerAnimated:YES];
}
@end
@interface MWMiPadPlacePageViewController : UIViewController
@end
@ -60,45 +35,39 @@ static CGFloat const kTopOffset = 36.;
@end
@interface MWMiPadPlacePage ()
@property (strong, nonatomic) MWMiPadNavigationController * navigationController;
@property (strong, nonatomic) MWMiPadPlacePageViewController * viewController;
@interface MWMiPadNavigationController : UINavigationController
@end
@implementation MWMiPadPlacePage
@implementation MWMiPadNavigationController
- (void)configure
- (instancetype)initWithViews:(NSArray *)views
{
[super configure];
UIView * view = self.manager.ownerViewController.view;
self.viewController = [[MWMiPadPlacePageViewController alloc] init];
[self.navigationController.view removeFromSuperview];
[self.navigationController removeFromParentViewController];
self.navigationController = [[MWMiPadNavigationController alloc] initWithRootViewController:self.viewController];
MWMiPadPlacePageViewController * viewController = [[MWMiPadPlacePageViewController alloc] init];
if (!viewController)
return nil;
[views enumerateObjectsUsingBlock:^(UIView * view, NSUInteger idx, BOOL *stop)
{
[viewController.view addSubview:view];
}];
self = [super initWithRootViewController:viewController];
if (!self)
return nil;
[self setNavigationBarHidden:YES];
[self.navigationBar setTranslucent:NO];
self.view.autoresizingMask = UIViewAutoresizingNone;
[self configureShadow];
return self;
}
CGFloat const defaultWidth = 360.;
CGFloat const actionBarHeight = 58.;
CGFloat const defaultHeight = self.basePlacePageView.height + self.anchorImageView.height + actionBarHeight - 1;
[self.manager.ownerViewController addChildViewController:self.navigationController];
self.navigationController.view.frame = CGRectMake( - defaultWidth, kTopOffset, defaultWidth, defaultHeight);
self.viewController.view.frame = CGRectMake(kLeftOffset, kTopOffset, defaultWidth, defaultHeight);
[self.viewController.view addSubview:self.extendedPlacePageView];
[self.viewController.view addSubview:self.actionBar];
self.extendedPlacePageView.frame = CGRectMake(0., 0., defaultWidth, defaultHeight);
self.anchorImageView.image = nil;
self.anchorImageView.backgroundColor = [UIColor whiteColor];
self.actionBar.width = defaultWidth;
self.actionBar.origin = CGPointMake(0., defaultHeight - actionBarHeight);
[view addSubview:self.navigationController.view];
- (void)backTap:(id)sender
{
[self popViewControllerAnimated:YES];
}
- (void)configureShadow
{
CALayer * layer = self.navigationController.view.layer;
CALayer * layer = self.view.layer;
layer.masksToBounds = NO;
layer.shadowColor = UIColor.blackColor.CGColor;
layer.shadowRadius = 4.;
@ -107,24 +76,62 @@ static CGFloat const kTopOffset = 36.;
layer.shouldRasterize = YES;
}
- (void)pushViewController:(UIViewController *)viewController animated:(BOOL)animated
{
viewController.view.frame = self.view.bounds;
[super pushViewController:viewController animated:animated];
}
@end
@interface MWMiPadPlacePage ()
@property (strong, nonatomic) MWMiPadNavigationController * navigationController;
@end
@implementation MWMiPadPlacePage
- (void)configure
{
[super configure];
CGFloat const defaultWidth = 360.;
CGFloat const actionBarHeight = 58.;
CGFloat const defaultHeight = self.basePlacePageView.height + self.anchorImageView.height + actionBarHeight - 1;
[self.manager addSubviews:@[self.navigationController.view] withNavigationController:self.navigationController];
self.navigationController.view.frame = CGRectMake( -defaultWidth, self.topBound + kTopOffset, defaultWidth, defaultHeight);
self.extendedPlacePageView.frame = CGRectMake(0., 0., defaultWidth, defaultHeight);
self.anchorImageView.image = nil;
self.anchorImageView.backgroundColor = [UIColor whiteColor];
self.actionBar.width = defaultWidth;
self.actionBar.origin = CGPointMake(0., defaultHeight - actionBarHeight);
}
- (void)show
{
UIView * view = self.navigationController.view;
[UIView animateWithDuration:0.2f animations:^
{
self.navigationController.view.center = CGPointMake(kLeftOffset + self.navigationController.view.width / 2., kTopOffset + self.navigationController.view.height / 2.);
view.minX = kLeftOffset;
view.alpha = 1.0;
}];
}
- (void)dismiss
{
UIView * view = self.navigationController.view;
UIViewController * controller = self.navigationController;
[UIView animateWithDuration:0.2f animations:^
{
self.navigationController.view.center = CGPointMake( - self.navigationController.view.width / 2. - kLeftOffset , kTopOffset);
view.maxX = 0.0;
view.alpha = 0.0;
}
completion:^(BOOL finished)
{
[self.navigationController.view removeFromSuperview];
[self.navigationController removeFromParentViewController];
[view removeFromSuperview];
[controller removeFromParentViewController];
[super dismiss];
}];
}
@ -142,7 +149,6 @@ static CGFloat const kTopOffset = 36.;
{
[super addBookmark];
self.navigationController.view.height += kBookmarkCellHeight;
self.viewController.view.height += kBookmarkCellHeight;
self.extendedPlacePageView.height += kBookmarkCellHeight;
self.actionBar.minY += kBookmarkCellHeight;
}
@ -151,7 +157,6 @@ static CGFloat const kTopOffset = 36.;
{
[super removeBookmark];
self.navigationController.view.height -= kBookmarkCellHeight;
self.viewController.view.height -= kBookmarkCellHeight;
self.extendedPlacePageView.height -= kBookmarkCellHeight;
self.actionBar.minY -= kBookmarkCellHeight;
}
@ -161,65 +166,62 @@ static CGFloat const kTopOffset = 36.;
MWMBookmarkColorViewController * controller = [[MWMBookmarkColorViewController alloc] initWithNibName:[MWMBookmarkColorViewController className] bundle:nil];
controller.iPadOwnerNavigationController = self.navigationController;
controller.placePageManager = self.manager;
controller.view.frame = self.viewController.view.frame;
[self.viewController.navigationController pushViewController:controller animated:YES];
[self.navigationController pushViewController:controller animated:YES];
}
- (void)changeBookmarkCategory
{
SelectSetVC * controller = [[SelectSetVC alloc] initWithPlacePageManager:self.manager];
controller.iPadOwnerNavigationController = self.navigationController;
controller.view.frame = self.viewController.view.frame;
[self.viewController.navigationController pushViewController:controller animated:YES];
[self.navigationController pushViewController:controller animated:YES];
}
- (void)changeBookmarkDescription
{
MWMBookmarkDescriptionViewController * controller = [[MWMBookmarkDescriptionViewController alloc] initWithPlacePageManager:self.manager];
controller.iPadOwnerNavigationController = self.navigationController;
[self.viewController.navigationController pushViewController:controller animated:YES];
[self.navigationController pushViewController:controller animated:YES];
}
- (IBAction)didPan:(UIPanGestureRecognizer *)sender
{
UIView * navigationControllerView = self.navigationController.view;
UIView * superview = navigationControllerView.superview;
UIView * view = self.navigationController.view;
UIView * superview = view.superview;
navigationControllerView.minX += [sender translationInView:superview].x;
navigationControllerView.minX = MIN(navigationControllerView.minX, kLeftOffset);
view.minX += [sender translationInView:superview].x;
view.minX = MIN(view.minX, kLeftOffset);
[sender setTranslation:CGPointZero inView:superview];
navigationControllerView.alpha = self.currentAlpha;
CGFloat const alpha = MAX(0.0, view.maxX) / (view.width + kLeftOffset);
view.alpha = alpha;
UIGestureRecognizerState const state = sender.state;
if (state == UIGestureRecognizerStateEnded || state == UIGestureRecognizerStateCancelled)
{
if (navigationControllerView.minX < ( - navigationControllerView.width / 8.))
{
[UIView animateWithDuration:0.2f animations:^
{
navigationControllerView.minX = - kLeftOffset - navigationControllerView.width;
navigationControllerView.alpha = self.currentAlpha;
}
completion:^(BOOL finished)
{
[self.manager dismissPlacePage];
}];
}
if (alpha < 0.8)
[self.manager dismissPlacePage];
else
{
[UIView animateWithDuration:0.2f animations:^
{
navigationControllerView.minX = kLeftOffset;
navigationControllerView.alpha = self.currentAlpha;
}];
}
[self show];
}
}
- (CGFloat)currentAlpha
#pragma mark - Properties
- (MWMiPadNavigationController *)navigationController
{
UIView * view = self.navigationController.view;
CGFloat const maxX = MAX(0., view.maxX);
return maxX / (view.width + kLeftOffset);
if (!_navigationController)
{
_navigationController = [[MWMiPadNavigationController alloc] initWithViews:@[self.extendedPlacePageView, self.actionBar]];
}
return _navigationController;
}
- (void)setTopBound:(CGFloat)topBound
{
super.topBound = topBound;
[UIView animateWithDuration:0.2f animations:^
{
self.navigationController.view.minY = topBound + kTopOffset;
}];
}
@end

View file

@ -38,26 +38,15 @@ typedef NS_ENUM(NSUInteger, MWMiPhoneLandscapePlacePageState)
- (void)configure
{
[super configure];
CGSize const size = UIScreen.mainScreen.bounds.size;
CGFloat const height = MIN(size.width, size.height);
CGFloat const offset = MIN(height, kMaximumPlacePageWidth);
UIView const * view = self.manager.ownerViewController.view;
if ([view.subviews containsObject:self.extendedPlacePageView] && self.state != MWMiPhoneLandscapePlacePageStateClosed)
return;
self.extendedPlacePageView.frame = CGRectMake(0., 0., offset, height);
self.anchorImageView.backgroundColor = [UIColor whiteColor];
self.anchorImageView.image = nil;
CGFloat const headerViewHeight = self.basePlacePageView.height - self.basePlacePageView.featureTable.height;
CGFloat const tableContentHeight = self.basePlacePageView.featureTable.contentSize.height;
self.basePlacePageView.featureTable.contentInset = UIEdgeInsetsMake(0., 0., self.actionBar.height+ (tableContentHeight - height - headerViewHeight + self.anchorImageView.height), 0.);
[view addSubview:self.extendedPlacePageView];
self.actionBar.width = offset;
self.actionBar.center = CGPointMake(self.actionBar.width / 2., height - self.actionBar.height / 2.);
self.basePlacePageView.featureTable.contentInset = UIEdgeInsetsMake(0., 0., self.actionBar.height + (tableContentHeight - height - headerViewHeight + self.anchorImageView.height), 0.);
[self.extendedPlacePageView addSubview:self.actionBar];
[self.manager addSubviews:@[self.extendedPlacePageView] withNavigationController:nil];
}
- (void)show
@ -85,10 +74,10 @@ typedef NS_ENUM(NSUInteger, MWMiPhoneLandscapePlacePageState)
{
case MWMiPhoneLandscapePlacePageStateClosed:
[self.actionBar removeFromSuperview];
self.targetPoint = CGPointMake(-offset / 2., height / 2.);
self.targetPoint = CGPointMake(-offset / 2., (height + self.topBound) / 2.);
break;
case MWMiPhoneLandscapePlacePageStateOpen:
self.targetPoint = CGPointMake(offset / 2., height / 2.);
self.targetPoint = CGPointMake(offset / 2., (height + self.topBound) / 2.);
break;
}
}
@ -140,6 +129,19 @@ typedef NS_ENUM(NSUInteger, MWMiPhoneLandscapePlacePageState)
#pragma mark - Properties
- (void)setTopBound:(CGFloat)topBound
{
super.topBound = topBound;
CGSize const size = UIScreen.mainScreen.bounds.size;
CGFloat const height = MIN(size.width, size.height);
CGFloat const offset = MIN(height, kMaximumPlacePageWidth);
self.extendedPlacePageView.frame = CGRectMake(0., topBound, offset, height - topBound);
self.actionBar.width = offset;
self.actionBar.minX = 0.0;
self.actionBar.maxY = height - topBound;
[self updateTargetPoint];
}
- (void)setTargetPoint:(CGPoint)targetPoint
{
_targetPoint = targetPoint;

View file

@ -67,19 +67,13 @@ typedef NS_ENUM(NSUInteger, MWMiPhonePortraitPlacePageState)
{
[super configure];
self.basePlacePageView.featureTable.scrollEnabled = NO;
UIView const * view = self.manager.ownerViewController.view;
if ([view.subviews containsObject:self.extendedPlacePageView])
return;
CGSize const size = UIScreen.mainScreen.bounds.size;
CGFloat const width = MIN(size.width, size.height);
CGFloat const height = MAX(size.width, size.height);
self.extendedPlacePageView.frame = CGRectMake(0., height, width, 2 * height);
[view addSubview:self.extendedPlacePageView];
self.actionBar.width = width;
self.actionBar.center = CGPointMake(width / 2., height + self.actionBar.height / 2.);
[view addSubview:self.actionBar];
[self.manager addSubviews:@[self.extendedPlacePageView, self.actionBar] withNavigationController:nil];
[UIView animateWithDuration:0.3f delay:0. options:UIViewAnimationOptionCurveEaseOut animations:^
{
self.actionBar.center = CGPointMake(width / 2., height - self.actionBar.height / 2.);

View file

@ -5,7 +5,7 @@
#import "MapViewController.h"
#import "MWMAlertViewController.h"
#import "MWMMapViewControlsManager.h"
#import "MWMPlacePageViewDragDelegate.h"
#import "MWMPlacePageViewManagerDelegate.h"
#import "MWMPlacePageViewManager.h"
#import "Reachability.h"
#import "RouteState.h"
@ -50,6 +50,12 @@ typedef NS_ENUM(NSUInteger, UserTouchesAction)
UserTouchesActionScale
};
typedef NS_OPTIONS(NSUInteger, MapInfoView)
{
MapInfoViewRoute = 1 << 0,
MapInfoViewSearch = 1 << 1
};
@interface NSValueWrapper : NSObject
-(NSValue *)getInnerValue;
@ -81,7 +87,7 @@ typedef NS_ENUM(NSUInteger, UserTouchesAction)
@end
@interface MapViewController () <RouteViewDelegate, SearchViewDelegate, MWMPlacePageViewDragDelegate>
@interface MapViewController () <RouteViewDelegate, SearchViewDelegate, MWMPlacePageViewManagerDelegate>
@property (nonatomic) UIView * routeViewWrapper;
@property (nonatomic) RouteView * routeView;
@ -97,6 +103,8 @@ typedef NS_ENUM(NSUInteger, UserTouchesAction)
@property (nonatomic) UserTouchesAction userTouchesAction;
@property (nonatomic) MapInfoView mapInfoView;
@end
@implementation MapViewController
@ -714,7 +722,7 @@ typedef NS_ENUM(NSUInteger, UserTouchesAction)
{
f.GetBalloonManager().RemovePin();
f.GetBalloonManager().Dismiss();
[self.searchView setState:SearchViewStateHidden animated:YES withCallback:YES];
[self.searchView setState:SearchViewStateHidden animated:YES];
[self performAfterDelay:0.3 block:^
{
if (self.forceRoutingStateChange == ForceRoutingStateChangeStartFollowing)
@ -794,7 +802,8 @@ typedef NS_ENUM(NSUInteger, UserTouchesAction)
{
if (!_routeView)
{
_routeView = [[RouteView alloc] initWithFrame:CGRectMake(0, 0, self.view.width, 80)];
CGFloat const routeInfoView = 68.0;
_routeView = [[RouteView alloc] initWithFrame:CGRectMake(0.0, 0.0, self.view.width, routeInfoView)];
_routeView.delegate = self;
_routeView.autoresizingMask = UIViewAutoresizingFlexibleWidth;
}
@ -808,7 +817,6 @@ typedef NS_ENUM(NSUInteger, UserTouchesAction)
_searchView = [[SearchView alloc] initWithFrame:self.view.bounds];
_searchView.delegate = self;
_searchView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
[_searchView addObserver:self forKeyPath:@"state" options:NSKeyValueObservingOptionNew context:nil];
}
return _searchView;
}
@ -884,7 +892,6 @@ typedef NS_ENUM(NSUInteger, UserTouchesAction)
- (void)dismissRouting
{
GetFramework().CloseRouting();
[self.controlsManager resetZoomButtonsVisibility];
[self.routeView setState:RouteViewStateHidden animated:YES];
self.disableStandbyOnRouteFollowing = NO;
[RouteState remove];
@ -908,14 +915,51 @@ typedef NS_ENUM(NSUInteger, UserTouchesAction)
- (void)routeViewWillEnterState:(RouteViewState)state
{
[self.controlsManager moveButton:MWMMapViewControlsButtonZoom toDefaultPosition:(state == RouteViewStateHidden)];
if (state == RouteViewStateHidden)
[self clearMapInfoViewFlag:MapInfoViewRoute];
else
[self setMapInfoViewFlag:MapInfoViewRoute];
}
#pragma mark - SearchViewDelegate
- (void)searchViewWillEnterState:(SearchViewState)state
{
self.controlsManager.hidden = (state == SearchViewStateFullscreen);
switch (state)
{
case SearchViewStateHidden:
self.controlsManager.hidden = NO;
[self moveRouteViewAnimatedtoOffset:0.0];
[self clearMapInfoViewFlag:MapInfoViewSearch];
break;
case SearchViewStateResults:
self.controlsManager.hidden = NO;
[self moveRouteViewAnimatedtoOffset:self.searchView.searchBar.maxY];
[self setMapInfoViewFlag:MapInfoViewSearch];
break;
case SearchViewStateAlpha:
self.controlsManager.hidden = NO;
[self clearMapInfoViewFlag:MapInfoViewSearch];
break;
case SearchViewStateFullscreen:
self.controlsManager.hidden = YES;
GetFramework().ActivateUserMark(NULL);
[self clearMapInfoViewFlag:MapInfoViewSearch];
break;
}
[self updateStatusBarStyle];
}
#pragma mark - Layout
- (void)moveRouteViewAnimatedtoOffset:(CGFloat)offset
{
if (!GetFramework().IsRoutingActive())
return;
[UIView animateWithDuration:0.3 animations:^
{
self.routeViewWrapper.minY = MAX(offset - [self.searchView defaultSearchBarMinY], 0.0);
}];
}
#pragma mark - UIKitViews delegates
@ -935,39 +979,21 @@ typedef NS_ENUM(NSUInteger, UserTouchesAction)
}
}
#pragma mark - MWMPlacePageViewDragDelegate
#pragma mark - MWMPlacePageViewManagerDelegate
- (void)dragPlacePage:(CGPoint)point
{
[self.controlsManager setBottomBound:point.y];
}
- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context
- (void)addPlacePageViews:(NSArray *)views
{
if (object == self.searchView && [keyPath isEqualToString:@"state"])
[views enumerateObjectsUsingBlock:^(UIView * view, NSUInteger idx, BOOL *stop)
{
[self updateStatusBarStyle];
if (self.searchView.state == SearchViewStateFullscreen)
{
GetFramework().ActivateUserMark(NULL);
}
else if (self.searchView.state == SearchViewStateResults)
{
[UIView animateWithDuration:0.3 animations:^
{
if (GetFramework().IsRoutingActive())
self.routeViewWrapper.minY = self.searchView.searchBar.maxY - 20;
}];
}
else if (self.searchView.state == SearchViewStateHidden)
{
[UIView animateWithDuration:0.3 animations:^
{
if (GetFramework().IsRoutingActive())
self.routeViewWrapper.minY = 0;
}];
}
}
if ([self.view.subviews containsObject:view])
return;
[self.view insertSubview:view belowSubview:self.searchView];
}];
}
#pragma mark - Public methods
@ -1003,7 +1029,7 @@ typedef NS_ENUM(NSUInteger, UserTouchesAction)
}
[self dismissPopover];
[self.searchView setState:SearchViewStateHidden animated:YES withCallback:YES];
[self.searchView setState:SearchViewStateHidden animated:YES];
_apiMode = apiMode;
@ -1063,8 +1089,48 @@ NSInteger compareAddress(id l, id r, void * context)
[self invalidate];
}
- (void)updateInfoViews
{
CGFloat topBound = 0.0;
if ([self testMapInfoViewFlag:MapInfoViewRoute])
{
CGRect const routeRect = self.routeViewWrapper.frame;
topBound = MAX(topBound, routeRect.origin.y + routeRect.size.height);
}
if ([self testMapInfoViewFlag:MapInfoViewSearch])
{
CGRect const searchRect = self.searchView.infoRect;
topBound = MAX(topBound, searchRect.origin.y + searchRect.size.height);
}
[self.controlsManager setTopBound:topBound];
[self.placePageManager setTopBound:topBound];
}
#pragma mark - Properties
- (BOOL)testMapInfoViewFlag:(MapInfoView)flag
{
return (self.mapInfoView & flag) == flag;
}
- (void)setMapInfoViewFlag:(MapInfoView)flag
{
if (![self testMapInfoViewFlag:flag])
self.mapInfoView |= flag;
}
- (void)clearMapInfoViewFlag:(MapInfoView)flag
{
if ([self testMapInfoViewFlag:flag])
self.mapInfoView &= ~flag;
}
- (void)setMapInfoView:(MapInfoView)mapInfoView
{
_mapInfoView = mapInfoView;
[self updateInfoViews];
}
- (void)setRestoreRouteDestination:(m2::PointD)restoreRouteDestination
{
_restoreRouteDestination = restoreRouteDestination;

View file

@ -21,9 +21,12 @@ typedef NS_ENUM(NSUInteger, SearchViewState) {
@property (nonatomic) SearchBar * searchBar;
- (void)setState:(SearchViewState)state animated:(BOOL)animated withCallback:(BOOL)withCallback;
- (void)setState:(SearchViewState)state animated:(BOOL)animated;
- (CGFloat)defaultSearchBarMinY;
@property (weak, nonatomic) id <SearchViewDelegate> delegate;
@property (readonly, nonatomic) SearchViewState state;
@property (nonatomic, readonly) SearchViewState state;
@property (nonatomic, readonly) CGRect infoRect;
@end

View file

@ -141,8 +141,7 @@ typedef NS_ENUM(NSUInteger, CellType)
self.searchBar.midX = self.width / 2;
[self setState:SearchViewStateHidden animated:NO withCallback:NO];
[self addObserver:self forKeyPath:@"state" options:NSKeyValueObservingOptionNew context:nil];
[self setState:SearchViewStateHidden animated:NO];
if ([self.tableView respondsToSelector:@selector(registerClass:forCellReuseIdentifier:)])
{
@ -159,19 +158,13 @@ typedef NS_ENUM(NSUInteger, CellType)
return self;
}
- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context
{
if (object == self && [keyPath isEqualToString:@"state"])
[self setState:self.state animated:YES withCallback:NO];
}
static BOOL keyboardLoaded = NO;
- (void)setState:(SearchViewState)state animated:(BOOL)animated withCallback:(BOOL)withCallback
- (void)setState:(SearchViewState)state animated:(BOOL)animated
{
[self.delegate searchViewWillEnterState:state];
// Clear search results on the map when clear in the search bar on the map is pressed or when we reopen search dialog
if ((_state == SearchViewStateResults && state == SearchViewStateHidden) || state == SearchViewStateFullscreen)
// Clear search results on the map when clear in the search bar on the map is pressed
if (_state == SearchViewStateResults && state == SearchViewStateHidden)
[self clearSearchResultsMode];
UIViewAnimationOptions const options = UIViewAnimationOptionCurveEaseInOut;
@ -258,12 +251,7 @@ static BOOL keyboardLoaded = NO;
} completion:nil];
[self.searchBar.textField resignFirstResponder];
}
if (withCallback)
[self willChangeValueForKey:@"state"];
_state = state;
if (withCallback)
[self didChangeValueForKey:@"state"];
GetFramework().Invalidate();
}
@ -377,7 +365,7 @@ static BOOL keyboardLoaded = NO;
- (void)searchBarDidPressClearButton:(SearchBar *)searchBar
{
if (self.state == SearchViewStateResults)
[self setState:SearchViewStateHidden animated:YES withCallback:YES];
[self setState:SearchViewStateHidden animated:YES];
else
[self.searchBar.textField becomeFirstResponder];
@ -389,7 +377,7 @@ static BOOL keyboardLoaded = NO;
{
self.searchBar.textField.text = nil;
[self textFieldTextChanged:nil];
[self setState:SearchViewStateHidden animated:YES withCallback:YES];
[self setState:SearchViewStateHidden animated:YES];
}
// TODO: This code only for demonstration purposes and will be removed soon
@ -454,7 +442,7 @@ static BOOL keyboardLoaded = NO;
{
if (self.state == SearchViewStateResults)
[self clearSearchResultsMode];
[self setState:SearchViewStateFullscreen animated:YES withCallback:YES];
[self setState:SearchViewStateFullscreen animated:YES];
}
- (void)showOnMap
@ -492,7 +480,7 @@ static BOOL keyboardLoaded = NO;
f.StartInteractiveSearch(params);
[self setState:SearchViewStateResults animated:YES withCallback:YES];
[self setState:SearchViewStateResults animated:YES];
}
- (BOOL)isShowingCategories
@ -674,7 +662,7 @@ static BOOL keyboardLoaded = NO;
{
NSInteger const position = [self searchResultPositionForIndexPath:indexPath];
search::Result const & result = [self.wrapper resultWithPosition:position];
[self setState:SearchViewStateHidden animated:YES withCallback:YES];
[self setState:SearchViewStateHidden animated:YES];
GetFramework().ShowSearchResult(result);
break;
}
@ -814,4 +802,11 @@ static BOOL keyboardLoaded = NO;
[[NSNotificationCenter defaultCenter] removeObserver:self];
}
#pragma mark - Properties
- (CGRect)infoRect
{
return [self convertRect:self.topBackgroundView.frame toView:self.superview];
}
@end

View file

@ -343,7 +343,7 @@
340F24611B14910500F874CD /* RouteState.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RouteState.h; sourceTree = "<group>"; };
340F24621B14910500F874CD /* RouteState.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = RouteState.mm; sourceTree = "<group>"; };
340F24641B15F01D00F874CD /* MWMSideMenuDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MWMSideMenuDelegate.h; sourceTree = "<group>"; };
342E75A11B302FCC00A8635F /* MWMPlacePageViewDragDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MWMPlacePageViewDragDelegate.h; sourceTree = "<group>"; };
342E75A11B302FCC00A8635F /* MWMPlacePageViewManagerDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MWMPlacePageViewManagerDelegate.h; sourceTree = "<group>"; };
343F262C1AEFC4A300388A6D /* MWMFrameworkUtils.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MWMFrameworkUtils.h; sourceTree = "<group>"; };
343F262D1AEFC4A300388A6D /* MWMFrameworkUtils.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MWMFrameworkUtils.mm; sourceTree = "<group>"; };
343F262F1AEFDB1A00388A6D /* Framework.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = Framework.cpp; path = ../../Classes/Framework.cpp; sourceTree = "<group>"; };
@ -1498,7 +1498,7 @@
children = (
F653D4211AE9398700282659 /* MWMPlacePageViewManager.h */,
F653D4221AE9398700282659 /* MWMPlacePageViewManager.mm */,
342E75A11B302FCC00A8635F /* MWMPlacePageViewDragDelegate.h */,
342E75A11B302FCC00A8635F /* MWMPlacePageViewManagerDelegate.h */,
);
name = PlacePageManager;
sourceTree = "<group>";