forked from organicmaps/organicmaps
[ios] Fixed status bar update.
This commit is contained in:
parent
19cf4cdc46
commit
1f38344c87
8 changed files with 103 additions and 97 deletions
|
@ -8,6 +8,8 @@
|
|||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
@class MWMPlacePageViewManager;
|
||||
|
||||
@interface MWMDirectionView : UIView
|
||||
|
||||
@property (weak, nonatomic) IBOutlet UILabel * titleLabel;
|
||||
|
@ -16,7 +18,12 @@
|
|||
@property (weak, nonatomic) IBOutlet UIImageView * directionArrow;
|
||||
@property (weak, nonatomic) IBOutlet UIView * contentView;
|
||||
|
||||
+ (MWMDirectionView *)directionViewForViewController:(UIViewController *)viewController;
|
||||
- (instancetype)initWithManager:(MWMPlacePageViewManager *)manager;
|
||||
- (void)setDirectionArrowTransform:(CGAffineTransform)transform;
|
||||
|
||||
- (instancetype)initWithCoder:(NSCoder *)aDecoder __attribute__((unavailable("initWithCoder is not available")));
|
||||
- (instancetype)initWithFrame:(CGRect)frame __attribute__((unavailable("initWithFrame is not available")));
|
||||
- (instancetype)init __attribute__((unavailable("init is not available")));
|
||||
|
||||
|
||||
@end
|
||||
|
|
|
@ -7,107 +7,89 @@
|
|||
//
|
||||
|
||||
#import "MWMDirectionView.h"
|
||||
#import "MWMPlacePageViewManager.h"
|
||||
#import "UIKitCategories.h"
|
||||
#import "MapsAppDelegate.h"
|
||||
|
||||
static NSString * const kDirectionViewNibName = @"MWMDirectionView";
|
||||
static CGFloat const kDirectionArrowSide = IPAD ? 260. : 160.;
|
||||
|
||||
@interface MWMDirectionView ()
|
||||
|
||||
@property (weak, nonatomic) UIViewController * ownerController;
|
||||
@property (weak, nonatomic) MWMPlacePageViewManager * manager;
|
||||
@property (nonatomic) CGSize defaultSize;
|
||||
|
||||
@end
|
||||
|
||||
@implementation MWMDirectionView
|
||||
|
||||
+ (MWMDirectionView *)directionViewForViewController:(UIViewController *)viewController
|
||||
- (instancetype)initWithManager:(MWMPlacePageViewManager *)manager
|
||||
{
|
||||
MWMDirectionView * view = [[[NSBundle mainBundle] loadNibNamed:kDirectionViewNibName owner:nil options:nil] firstObject];
|
||||
view.ownerController = viewController;
|
||||
view.directionArrow.size = CGSizeMake(kDirectionArrowSide, kDirectionArrowSide);
|
||||
view.directionArrow.image = [UIImage imageNamed:IPAD ? @"direction_big" : @"direction_mini"];
|
||||
[view configure];
|
||||
return view;
|
||||
self = [[[NSBundle mainBundle] loadNibNamed:kDirectionViewNibName owner:nil options:nil] firstObject];
|
||||
[self setup:manager];
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)configure
|
||||
- (void)setup:(MWMPlacePageViewManager *)manager
|
||||
{
|
||||
self.manager = manager;
|
||||
self.directionArrow.size = CGSizeMake(kDirectionArrowSide, kDirectionArrowSide);
|
||||
self.directionArrow.image = [UIImage imageNamed:IPAD ? @"direction_big" : @"direction_mini"];
|
||||
|
||||
NSString * const kFontName = @"HelveticaNeue";
|
||||
self.titleLabel.font = self.distanceLabel.font = IPAD ? [UIFont fontWithName:kFontName size:52.] : [UIFont fontWithName:kFontName size:32.];
|
||||
self.typeLabel.font = IPAD ? [UIFont fontWithName:kFontName size:24.] : [UIFont fontWithName:kFontName size:16.];
|
||||
|
||||
self.autoresizingMask = self.contentView.autoresizingMask = UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth;
|
||||
self.directionArrow.autoresizingMask = UIViewAutoresizingNone;
|
||||
self.frame = self.ownerController.view.frame;
|
||||
UIView * window = [UIApplication sharedApplication].delegate.window;
|
||||
[self addToView:window];
|
||||
}
|
||||
|
||||
- (void)addToView:(UIView *)view
|
||||
{
|
||||
if ([view.subviews containsObject:self])
|
||||
return;
|
||||
|
||||
[view addSubview:self];
|
||||
[(MapsAppDelegate *)[UIApplication sharedApplication].delegate disableStandby];
|
||||
}
|
||||
|
||||
- (void)layoutSubviews
|
||||
{
|
||||
CGSize const size = [[UIScreen mainScreen] bounds].size;
|
||||
self.frame = self.superview.bounds;
|
||||
CGSize const size = self.superview.size;
|
||||
self.size = size;
|
||||
CGFloat const minimumBorderOffset = 40.;
|
||||
BOOL const isLandscape = size.width > size.height;
|
||||
|
||||
switch (self.ownerController.interfaceOrientation)
|
||||
if (isLandscape)
|
||||
{
|
||||
case UIInterfaceOrientationLandscapeLeft:
|
||||
case UIInterfaceOrientationLandscapeRight:
|
||||
{
|
||||
CGFloat const defaultWidth = size.width - 3. * minimumBorderOffset - kDirectionArrowSide;
|
||||
[self resizeLabelsWithWidth:defaultWidth];
|
||||
CGFloat const titleOffset = 8.;
|
||||
CGFloat const typeOffset = 24.;
|
||||
CGFloat const contentViewHeight = size.height - 2. * minimumBorderOffset;
|
||||
CGFloat const contentViewOffset = (size.width - self.titleLabel.width - minimumBorderOffset - self.directionArrow.width) / 2.;
|
||||
CGFloat const contentViewWidth = self.titleLabel.width + minimumBorderOffset + self.directionArrow.width;
|
||||
self.contentView.frame = CGRectMake(contentViewOffset, minimumBorderOffset, contentViewWidth, contentViewHeight);
|
||||
self.directionArrow.center = CGPointMake(kDirectionArrowSide / 2., self.contentView.height / 2.);
|
||||
CGFloat const directionArrowOffsetX = self.directionArrow.maxX + minimumBorderOffset;
|
||||
CGFloat const actualLabelsBlockHeight = self.titleLabel.height + titleOffset + self.typeLabel.height + typeOffset + self.distanceLabel.height;
|
||||
CGFloat const labelsBlockTopOffset = (contentViewHeight - actualLabelsBlockHeight) / 2.;
|
||||
self.titleLabel.origin = CGPointMake(directionArrowOffsetX, labelsBlockTopOffset);
|
||||
self.titleLabel.textAlignment = NSTextAlignmentLeft;
|
||||
self.typeLabel.origin = CGPointMake(directionArrowOffsetX, self.titleLabel.maxY + titleOffset);
|
||||
self.typeLabel.textAlignment = NSTextAlignmentLeft;
|
||||
self.distanceLabel.origin = CGPointMake(directionArrowOffsetX, self.typeLabel.maxY + typeOffset);
|
||||
self.distanceLabel.textAlignment = NSTextAlignmentLeft;
|
||||
break;
|
||||
}
|
||||
case UIInterfaceOrientationPortrait:
|
||||
case UIInterfaceOrientationPortraitUpsideDown:
|
||||
{
|
||||
CGFloat const defaultWidth = size.width - 2. * minimumBorderOffset;
|
||||
[self resizeLabelsWithWidth:defaultWidth];
|
||||
CGFloat const titleOffset = IPAD ? 12. : 8.;
|
||||
CGFloat const arrowOffset = IPAD ? 80. : 40.;
|
||||
CGFloat const contentViewActualHeight = self.titleLabel.height + titleOffset + self.typeLabel.height + 2. * arrowOffset + kDirectionArrowSide + self.distanceLabel.height;
|
||||
CGFloat const contentViewSize = size.height > contentViewActualHeight ? contentViewActualHeight : size.height;
|
||||
CGFloat const yOffset = (size.height - contentViewSize) / 2.;
|
||||
self.contentView.frame = CGRectMake(minimumBorderOffset, yOffset, defaultWidth, contentViewSize);
|
||||
CGFloat const xOffset = self.contentView.width / 2.;
|
||||
self.titleLabel.origin = CGPointMake(xOffset - self.titleLabel.width / 2., 0.);
|
||||
self.titleLabel.textAlignment = NSTextAlignmentCenter;
|
||||
self.typeLabel.origin = CGPointMake(xOffset - self.typeLabel.width / 2., self.titleLabel.maxY + titleOffset);
|
||||
self.typeLabel.textAlignment = NSTextAlignmentCenter;
|
||||
self.directionArrow.center = CGPointMake(xOffset, self.typeLabel.maxY + arrowOffset + kDirectionArrowSide / 2.);
|
||||
self.distanceLabel.origin = CGPointMake(xOffset - self.distanceLabel.width / 2., self.directionArrow.maxY + arrowOffset);
|
||||
self.distanceLabel.textAlignment = NSTextAlignmentCenter;
|
||||
break;
|
||||
}
|
||||
case UIInterfaceOrientationUnknown:
|
||||
break;
|
||||
CGFloat const defaultWidth = size.width - 3. * minimumBorderOffset - kDirectionArrowSide;
|
||||
[self resizeLabelsWithWidth:defaultWidth];
|
||||
CGFloat const titleOffset = 8.;
|
||||
CGFloat const typeOffset = 24.;
|
||||
CGFloat const contentViewHeight = size.height - 2. * minimumBorderOffset;
|
||||
CGFloat const contentViewOffset = (size.width - self.titleLabel.width - minimumBorderOffset - self.directionArrow.width) / 2.;
|
||||
CGFloat const contentViewWidth = self.titleLabel.width + minimumBorderOffset + self.directionArrow.width;
|
||||
self.contentView.frame = CGRectMake(contentViewOffset, minimumBorderOffset, contentViewWidth, contentViewHeight);
|
||||
self.directionArrow.center = CGPointMake(kDirectionArrowSide / 2., self.contentView.height / 2.);
|
||||
CGFloat const directionArrowOffsetX = self.directionArrow.maxX + minimumBorderOffset;
|
||||
CGFloat const actualLabelsBlockHeight = self.titleLabel.height + titleOffset + self.typeLabel.height + typeOffset + self.distanceLabel.height;
|
||||
CGFloat const labelsBlockTopOffset = (contentViewHeight - actualLabelsBlockHeight) / 2.;
|
||||
self.titleLabel.origin = CGPointMake(directionArrowOffsetX, labelsBlockTopOffset);
|
||||
self.titleLabel.textAlignment = NSTextAlignmentLeft;
|
||||
self.typeLabel.origin = CGPointMake(directionArrowOffsetX, self.titleLabel.maxY + titleOffset);
|
||||
self.typeLabel.textAlignment = NSTextAlignmentLeft;
|
||||
self.distanceLabel.origin = CGPointMake(directionArrowOffsetX, self.typeLabel.maxY + typeOffset);
|
||||
self.distanceLabel.textAlignment = NSTextAlignmentLeft;
|
||||
}
|
||||
else
|
||||
{
|
||||
CGFloat const defaultWidth = size.width - 2. * minimumBorderOffset;
|
||||
[self resizeLabelsWithWidth:defaultWidth];
|
||||
CGFloat const titleOffset = IPAD ? 12. : 8.;
|
||||
CGFloat const arrowOffset = IPAD ? 80. : 40.;
|
||||
CGFloat const contentViewActualHeight = self.titleLabel.height + titleOffset + self.typeLabel.height + 2. * arrowOffset + kDirectionArrowSide + self.distanceLabel.height;
|
||||
CGFloat const contentViewSize = size.height > contentViewActualHeight ? contentViewActualHeight : size.height;
|
||||
CGFloat const yOffset = (size.height - contentViewSize) / 2.;
|
||||
self.contentView.frame = CGRectMake(minimumBorderOffset, yOffset, defaultWidth, contentViewSize);
|
||||
CGFloat const xOffset = self.contentView.width / 2.;
|
||||
self.titleLabel.origin = CGPointMake(xOffset - self.titleLabel.width / 2., 0.);
|
||||
self.titleLabel.textAlignment = NSTextAlignmentCenter;
|
||||
self.typeLabel.origin = CGPointMake(xOffset - self.typeLabel.width / 2., self.titleLabel.maxY + titleOffset);
|
||||
self.typeLabel.textAlignment = NSTextAlignmentCenter;
|
||||
self.directionArrow.center = CGPointMake(xOffset, self.typeLabel.maxY + arrowOffset + kDirectionArrowSide / 2.);
|
||||
self.distanceLabel.origin = CGPointMake(xOffset - self.distanceLabel.width / 2., self.directionArrow.maxY + arrowOffset);
|
||||
self.distanceLabel.textAlignment = NSTextAlignmentCenter;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -124,15 +106,11 @@ static CGFloat const kDirectionArrowSide = IPAD ? 260. : 160.;
|
|||
self.directionArrow.transform = transform;
|
||||
}
|
||||
|
||||
- (IBAction)tap
|
||||
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
|
||||
{
|
||||
[self removeFromSuperview];
|
||||
}
|
||||
|
||||
- (void)removeFromSuperview
|
||||
{
|
||||
[(MapsAppDelegate *)[UIApplication sharedApplication].delegate enableStandby];
|
||||
[super removeFromSuperview];
|
||||
// Prevent super call to stop event propagation
|
||||
// [super touchesBegan:touches withEvent:event];
|
||||
[self.manager hideDirectionView];
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="7702" systemVersion="14D131" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none">
|
||||
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="7706" systemVersion="14D136" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none">
|
||||
<dependencies>
|
||||
<deployment identifier="iOS"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="7701"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="7703"/>
|
||||
</dependencies>
|
||||
<objects>
|
||||
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner"/>
|
||||
|
@ -52,15 +52,9 @@
|
|||
<outlet property="distanceLabel" destination="izl-Ei-GSs" id="I3d-IM-XhG"/>
|
||||
<outlet property="titleLabel" destination="6QE-ZP-1Wz" id="ywn-Qi-Mhf"/>
|
||||
<outlet property="typeLabel" destination="pJJ-Om-WmO" id="9kH-tO-qTP"/>
|
||||
<outletCollection property="gestureRecognizers" destination="lOu-cy-wFh" appends="YES" id="Caw-W1-B4s"/>
|
||||
</connections>
|
||||
<point key="canvasLocation" x="360" y="226"/>
|
||||
</view>
|
||||
<tapGestureRecognizer id="lOu-cy-wFh">
|
||||
<connections>
|
||||
<action selector="tap" destination="hge-yy-9dK" id="uEi-g2-I4S"/>
|
||||
</connections>
|
||||
</tapGestureRecognizer>
|
||||
</objects>
|
||||
<simulatedMetricsContainer key="defaultSimulatedMetrics">
|
||||
<simulatedStatusBarMetrics key="statusBar"/>
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
@property (nonatomic, readonly) MWMPlacePageEntity * entity;
|
||||
@property (nonatomic) MWMPlacePageNavigationBar * iPhoneNavigationBar;
|
||||
@property (nonatomic) CGFloat topBound;
|
||||
@property (nonatomic, readonly) BOOL isDirectionViewShown;
|
||||
|
||||
- (instancetype)initWithViewController:(UIViewController<MWMPlacePageViewManagerDelegate> *)viewController;
|
||||
- (void)showPlacePageWithUserMark:(unique_ptr<UserMarkCopy>)userMark;
|
||||
|
@ -33,6 +34,7 @@
|
|||
- (void)reloadBookmark;
|
||||
- (void)dragPlacePage:(CGPoint)point;
|
||||
- (void)showDirectionViewWithTitle:(NSString *)title type:(NSString *)type;
|
||||
- (void)hideDirectionView;
|
||||
- (void)addSubviews:(NSArray *)views withNavigationController:(UINavigationController *)controller;
|
||||
|
||||
- (instancetype)init __attribute__((unavailable("init is unavailable, call initWithViewController: instead")));
|
||||
|
|
|
@ -278,14 +278,38 @@ typedef NS_ENUM(NSUInteger, MWMPlacePageManagerState)
|
|||
|
||||
- (void)showDirectionViewWithTitle:(NSString *)title type:(NSString *)type
|
||||
{
|
||||
self.directionView = [MWMDirectionView directionViewForViewController:self.ownerViewController];
|
||||
self.directionView.titleLabel.text = title;
|
||||
self.directionView.typeLabel.text = type;
|
||||
UIViewController<MWMPlacePageViewManagerDelegate> * ovc = self.ownerViewController;
|
||||
MWMDirectionView * directionView = self.directionView;
|
||||
directionView.titleLabel.text = title;
|
||||
directionView.typeLabel.text = type;
|
||||
[ovc.view addSubview:directionView];
|
||||
[directionView setNeedsLayout];
|
||||
[ovc updateStatusBarStyle];
|
||||
[(MapsAppDelegate *)[UIApplication sharedApplication].delegate disableStandby];
|
||||
[self updateDistance];
|
||||
}
|
||||
|
||||
- (void)hideDirectionView
|
||||
{
|
||||
[self.directionView removeFromSuperview];
|
||||
[self.ownerViewController updateStatusBarStyle];
|
||||
[(MapsAppDelegate *)[UIApplication sharedApplication].delegate enableStandby];
|
||||
}
|
||||
|
||||
#pragma mark - Properties
|
||||
|
||||
- (MWMDirectionView *)directionView
|
||||
{
|
||||
if (!_directionView)
|
||||
_directionView = [[MWMDirectionView alloc] initWithManager:self];
|
||||
return _directionView;
|
||||
}
|
||||
|
||||
- (BOOL)isDirectionViewShown
|
||||
{
|
||||
return self.directionView.superview;
|
||||
}
|
||||
|
||||
- (void)setTopBound:(CGFloat)bound
|
||||
{
|
||||
_topBound = bound;
|
||||
|
|
|
@ -10,5 +10,6 @@
|
|||
|
||||
- (void)dragPlacePage:(CGPoint)point;
|
||||
- (void)addPlacePageViews:(NSArray *)views;
|
||||
- (void)updateStatusBarStyle;
|
||||
|
||||
@end
|
|
@ -610,7 +610,7 @@ typedef NS_OPTIONS(NSUInteger, MapInfoView)
|
|||
else
|
||||
{
|
||||
UIStatusBarStyle style = UIStatusBarStyleDefault;
|
||||
if (self.searchView.state != SearchViewStateHidden || self.controlsManager.menuState == MWMSideMenuStateActive)
|
||||
if (self.searchView.state != SearchViewStateHidden || self.controlsManager.menuState == MWMSideMenuStateActive || self.placePageManager.isDirectionViewShown || GetFramework().GetMapStyle() == MapStyleDark)
|
||||
style = UIStatusBarStyleLightContent;
|
||||
return style;
|
||||
}
|
||||
|
@ -943,7 +943,6 @@ typedef NS_OPTIONS(NSUInteger, MapInfoView)
|
|||
GetFramework().ActivateUserMark(NULL);
|
||||
break;
|
||||
}
|
||||
[self updateStatusBarStyle];
|
||||
}
|
||||
|
||||
- (void)searchViewDidEnterState:(SearchViewState)state
|
||||
|
@ -959,6 +958,7 @@ typedef NS_OPTIONS(NSUInteger, MapInfoView)
|
|||
[self clearMapInfoViewFlag:MapInfoViewSearch];
|
||||
break;
|
||||
}
|
||||
[self updateStatusBarStyle];
|
||||
}
|
||||
|
||||
#pragma mark - Layout
|
||||
|
|
|
@ -387,17 +387,17 @@ static BOOL keyboardLoaded = NO;
|
|||
// Hook for shell command on change map style
|
||||
BOOL const isDark = [cmd isEqualToString:@"mapstyle:dark"];
|
||||
BOOL const isLight = isDark ? NO : [cmd isEqualToString:@"mapstyle:light"];
|
||||
|
||||
|
||||
if (!isDark && !isLight)
|
||||
return NO;
|
||||
|
||||
// close Search panel
|
||||
[self searchBarDidPressCancelButton:nil];
|
||||
|
||||
// change map style
|
||||
MapStyle const mapStyle = isDark ? MapStyleDark : MapStyleLight;
|
||||
[[MapsAppDelegate theApp] setMapStyle: mapStyle];
|
||||
|
||||
|
||||
// close Search panel
|
||||
[self searchBarDidPressCancelButton:nil];
|
||||
|
||||
return YES;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue