[ios] Fixed place page layout.

This commit is contained in:
Ilya Grechuhin 2015-10-23 13:38:49 +03:00
parent 4ba64f36cd
commit 0d9c941cff
10 changed files with 120 additions and 89 deletions

View file

@ -1,8 +1,8 @@
#import "SelectSetVC.h"
#import "AddSetVC.h"
#import "MWMPlacePageViewManager.h"
#import "Common.h"
#import "MWMPlacePageEntity.h"
#import "MWMPlacePageViewManager.h"
#import "SelectSetVC.h"
#import "UIViewController+Navigation.h"
#include "Framework.h"
@ -29,20 +29,22 @@
- (void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
if (!self.iPadOwnerNavigationController)
return;
[self.iPadOwnerNavigationController setNavigationBarHidden:NO];
[(UIViewController *)self showBackButton];
CGFloat const bottomOffset = 88.;
self.iPadOwnerNavigationController.view.height = self.tableView.height + bottomOffset;
if (self.iPadOwnerNavigationController)
{
[(UIViewController *)self showBackButton];
[self.tableView reloadData];
CGFloat const navBarHeight = self.navigationController.navigationBar.height;
[UIView animateWithDuration:kDefaultAnimationDuration animations:^
{
[self.manager changeHeight:self.tableView.contentSize.height + navBarHeight];
}];
}
}
- (void)popViewController
{
if (self.iPadOwnerNavigationController)
[self.iPadOwnerNavigationController setNavigationBarHidden:YES];
[self.iPadOwnerNavigationController setNavigationBarHidden:YES];
[self.navigationController popViewControllerAnimated:YES];
}

View file

@ -18,7 +18,6 @@
if (textField.text.length == 0)
return YES;
[textField resignFirstResponder];
[self.delegate onDone:textField.text];
return NO;
}

View file

@ -8,7 +8,7 @@
<objects>
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner"/>
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
<tableViewCell contentMode="scaleToFill" selectionStyle="default" indentationWidth="10" id="KGk-i7-Jjw" customClass="AddSetTableViewCell">
<tableViewCell contentMode="scaleToFill" selectionStyle="none" indentationWidth="10" id="KGk-i7-Jjw" customClass="AddSetTableViewCell">
<rect key="frame" x="0.0" y="0.0" width="320" height="44"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="KGk-i7-Jjw" id="H2p-sc-9uM">

View file

@ -26,7 +26,6 @@ typedef NS_ENUM(NSUInteger, BookmarkDescriptionState)
@property (weak, nonatomic) MWMPlacePageViewManager * manager;
@property (nonatomic) BookmarkDescriptionState state;
@property (nonatomic) CGFloat realPlacePageHeight;
@end
@ -59,7 +58,6 @@ typedef NS_ENUM(NSUInteger, BookmarkDescriptionState)
if (self.iPadOwnerNavigationController)
{
self.realPlacePageHeight = self.iPadOwnerNavigationController.view.height;
UIBarButtonItem * leftButton = [[UIBarButtonItem alloc] initWithCustomView:self.backButton];
[self.navigationItem setLeftBarButtonItem:leftButton];
return;
@ -69,9 +67,6 @@ typedef NS_ENUM(NSUInteger, BookmarkDescriptionState)
- (void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
if (!self.iPadOwnerNavigationController)
return;
[self.iPadOwnerNavigationController setNavigationBarHidden:NO];
}
@ -182,20 +177,8 @@ typedef NS_ENUM(NSUInteger, BookmarkDescriptionState)
- (void)popViewController
{
if (!self.iPadOwnerNavigationController)
{
[self.navigationController popViewControllerAnimated:YES];
return;
}
[self.iPadOwnerNavigationController setNavigationBarHidden:YES];
[UIView animateWithDuration:kDefaultAnimationDuration animations:^
{
self.iPadOwnerNavigationController.view.height = self.realPlacePageHeight;
}
completion:^(BOOL finished)
{
[self.navigationController popViewControllerAnimated:YES];
}];
[self.navigationController popViewControllerAnimated:YES];
}
#pragma mark - Notifications

View file

@ -1,8 +1,8 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="8191" systemVersion="15A284" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="9059" systemVersion="15B42" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES">
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="8154"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="9049"/>
</dependencies>
<objects>
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner" customClass="MWMBookmarkDescriptionViewController">

View file

@ -32,6 +32,7 @@
- (void)showDirectionViewWithTitle:(NSString *)title type:(NSString *)type;
- (void)hideDirectionView;
- (void)addSubviews:(NSArray *)views withNavigationController:(UINavigationController *)controller;
- (void)changeHeight:(CGFloat)height;
- (instancetype)init __attribute__((unavailable("call initWithViewController: instead")));

View file

@ -334,6 +334,13 @@ typedef NS_ENUM(NSUInteger, MWMPlacePageManagerState)
[(MapsAppDelegate *)[UIApplication sharedApplication].delegate enableStandby];
}
- (void)changeHeight:(CGFloat)height
{
if (!IPAD)
return;
((MWMiPadPlacePage *)self.placePage).height = height;
}
#pragma mark - Properties
- (MWMDirectionView *)directionView

View file

@ -2,6 +2,8 @@
@interface MWMiPadPlacePage : MWMPlacePage
@property (nonatomic) CGFloat height;
- (void)updatePlacePageLayoutAnimated:(BOOL)animated;
@end

View file

@ -16,10 +16,26 @@ static CGFloat const kKeyboardOffset = 12.;
@interface MWMiPadPlacePageViewController : ViewController
@property (nonatomic) UIView * placePageView;
@property (nonatomic) UIView * actionBarView;
@end
@implementation MWMiPadPlacePageViewController
- (instancetype)initWithPlacepageView:(UIView *)ppView actionBar:(UIView *)actionBar
{
self = [super init];
if (self)
{
self.placePageView = ppView;
self.actionBarView = actionBar;
[self.view addSubview:ppView];
[self.view addSubview:actionBar];
}
return self;
}
- (void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
@ -31,25 +47,23 @@ static CGFloat const kKeyboardOffset = 12.;
@interface MWMiPadNavigationController : UINavigationController
@property (weak, nonatomic) MWMiPadPlacePage * placePage;
@property (nonatomic) CGFloat height;
@end
@implementation MWMiPadNavigationController
- (instancetype)initWithViews:(NSArray *)views
- (instancetype)initWithViewController:(UIViewController *)viewController frame:(CGRect)frame
{
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;
if (self)
{
self.view.frame = viewController.view.frame = frame;
[self setNavigationBarHidden:YES];
[self.navigationBar setTranslucent:NO];
self.view.autoresizingMask = UIViewAutoresizingNone;
}
return self;
}
@ -66,18 +80,46 @@ static CGFloat const kKeyboardOffset = 12.;
- (UIViewController *)popViewControllerAnimated:(BOOL)animated
{
[self.view endEditing:YES];
NSUInteger const count = self.viewControllers.count;
CGFloat const height = count > 1 ? ((UIViewController *)self.viewControllers[count - 2]).view.height : 0.0;
[UIView animateWithDuration:kDefaultAnimationDuration animations:^
{
self.view.height = height;
}
completion:^(BOOL finished)
UIViewController * viewController = self.viewControllers.lastObject;
if (count == 2)
{
[super popViewControllerAnimated:animated];
}];
return self.viewControllers.lastObject;
[self.placePage updatePlacePageLayoutAnimated:YES];
}
else
{
CGFloat const height = count > 1 ? ((UIViewController *)self.viewControllers[count - 2]).view.height : 0.0;
[UIView animateWithDuration:kDefaultAnimationDuration animations:^
{
self.height = height;
}
completion:^(BOOL finished)
{
[super popViewControllerAnimated:animated];
}];
}
return viewController;
}
- (void)setHeight:(CGFloat)height
{
self.view.height = height;
UIViewController * vc = self.topViewController;
vc.view.height = height;
if ([vc isKindOfClass:[MWMiPadPlacePageViewController class]])
{
MWMiPadPlacePageViewController * ppVC = (MWMiPadPlacePageViewController *)vc;
ppVC.placePageView.height = height;
ppVC.actionBarView.origin = {0, height - ppVC.actionBarView.height};
}
}
- (CGFloat)height
{
return self.view.height;
}
@end
@ -85,7 +127,6 @@ static CGFloat const kKeyboardOffset = 12.;
@interface MWMiPadPlacePage ()
@property (nonatomic) MWMiPadNavigationController * navigationController;
@property (nonatomic) CGFloat height;
@end
@ -96,15 +137,26 @@ static CGFloat const kKeyboardOffset = 12.;
[super configure];
CGFloat const defaultWidth = 360.;
[self updatePlacePageLayoutAnimated:NO];
[self addPlacePageShadowToView:self.navigationController.view offset:CGSizeMake(0.0, -2.0)];
CGFloat const actionBarHeight = self.actionBar.height;
self.height =
self.basePlacePageView.height + self.anchorImageView.height + actionBarHeight - 1;
self.extendedPlacePageView.frame = {{0, 0}, {defaultWidth, self.height}};
self.actionBar.frame = {{0, self.height - actionBarHeight},{defaultWidth, actionBarHeight}};
MWMiPadPlacePageViewController * viewController =
[[MWMiPadPlacePageViewController alloc] initWithPlacepageView:self.extendedPlacePageView
actionBar:self.actionBar];
self.navigationController = [[MWMiPadNavigationController alloc]
initWithViewController:viewController
frame:{{-defaultWidth, self.topBound + kTopOffset},
{defaultWidth, self.height}}];
self.navigationController.placePage = self;
[self updatePlacePagePosition];
[self addPlacePageShadowToView:self.navigationController.view offset:{0, -2}];
[self.manager addSubviews:@[self.navigationController.view] withNavigationController:self.navigationController];
self.navigationController.view.frame = CGRectMake( -defaultWidth, self.topBound + kTopOffset, defaultWidth, self.height);
self.extendedPlacePageView.frame = CGRectMake(0., 0., defaultWidth, self.height);
[self.manager addSubviews:@[ self.navigationController.view ]
withNavigationController:self.navigationController];
self.anchorImageView.image = nil;
self.anchorImageView.backgroundColor = [UIColor whiteColor];
self.actionBar.width = defaultWidth;
[self configureContentInset];
}
@ -219,7 +271,10 @@ static CGFloat const kKeyboardOffset = 12.;
{
[UIView animateWithDuration:animated ? kDefaultAnimationDuration : 0.0 animations:^
{
self.height = self.basePlacePageView.height + self.anchorImageView.height + self.actionBar.height - 1;
CGFloat const ppHeight = self.basePlacePageView.height;
CGFloat const anchorHeight = self.anchorImageView.height;
CGFloat const actionBarHeight = self.actionBar.height;
self.height = ppHeight + anchorHeight + actionBarHeight - 1;
[self updatePlacePagePosition];
}];
}
@ -256,13 +311,13 @@ static CGFloat const kKeyboardOffset = 12.;
- (void)keyboardWillShow:(NSNotification *)aNotification
{
[super keyboardWillShow:aNotification];
[self updateHeight];
[self updatePlacePageLayoutAnimated:YES];
}
- (void)keyboardWillHide
{
[super keyboardWillHide];
[self updateHeight];
[self updatePlacePageLayoutAnimated:YES];
}
- (CGFloat)getAvailableHeight
@ -276,25 +331,7 @@ static CGFloat const kKeyboardOffset = 12.;
- (void)setHeight:(CGFloat)height
{
_height = height;
[self updateHeight];
}
- (void)updateHeight
{
_height = MIN(_height, [self getAvailableHeight]);
self.navigationController.view.height = _height;
self.extendedPlacePageView.height = _height;
self.actionBar.origin = CGPointMake(0., _height - self.actionBar.height);
}
- (MWMiPadNavigationController *)navigationController
{
if (!_navigationController)
{
_navigationController = [[MWMiPadNavigationController alloc] initWithViews:@[self.extendedPlacePageView, self.actionBar]];
}
return _navigationController;
_height = self.navigationController.height = MIN(height, [self getAvailableHeight]);
}
- (void)setTopBound:(CGFloat)topBound

View file

@ -109,7 +109,7 @@
34CFFE8B1B7DE6FD009D0C9F /* MWMSearchManager.mm in Sources */ = {isa = PBXBuildFile; fileRef = 34CFFE8A1B7DE6FD009D0C9F /* MWMSearchManager.mm */; };
34CFFE8D1B7DE71C009D0C9F /* MWMSearchView.xib in Resources */ = {isa = PBXBuildFile; fileRef = 34CFFE8C1B7DE71C009D0C9F /* MWMSearchView.xib */; };
34CFFE901B7DE83D009D0C9F /* MWMSearchView.mm in Sources */ = {isa = PBXBuildFile; fileRef = 34CFFE8F1B7DE83D009D0C9F /* MWMSearchView.mm */; };
34D15BA81BD8F93C00C8BCBE /* AddSetTableViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 34D15BA61BD8F93C00C8BCBE /* AddSetTableViewCell.m */; };
34D15BA81BD8F93C00C8BCBE /* AddSetTableViewCell.mm in Sources */ = {isa = PBXBuildFile; fileRef = 34D15BA61BD8F93C00C8BCBE /* AddSetTableViewCell.mm */; };
34D15BA91BD8F93C00C8BCBE /* AddSetTableViewCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = 34D15BA71BD8F93C00C8BCBE /* AddSetTableViewCell.xib */; };
34DF4D111AE77B9F0012702D /* MWMWKInterfaceController.mm in Sources */ = {isa = PBXBuildFile; fileRef = 34DF4D101AE77B9F0012702D /* MWMWKInterfaceController.mm */; };
34F45E8E1B96E88100AC93F8 /* MWMSearchTabButtonsView.mm in Sources */ = {isa = PBXBuildFile; fileRef = 34F45E8D1B96E88100AC93F8 /* MWMSearchTabButtonsView.mm */; };
@ -557,7 +557,7 @@
34CFFE8E1B7DE83D009D0C9F /* MWMSearchView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MWMSearchView.h; sourceTree = "<group>"; };
34CFFE8F1B7DE83D009D0C9F /* MWMSearchView.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MWMSearchView.mm; sourceTree = "<group>"; };
34D15BA51BD8F93C00C8BCBE /* AddSetTableViewCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AddSetTableViewCell.h; sourceTree = "<group>"; };
34D15BA61BD8F93C00C8BCBE /* AddSetTableViewCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AddSetTableViewCell.m; sourceTree = "<group>"; };
34D15BA61BD8F93C00C8BCBE /* AddSetTableViewCell.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = AddSetTableViewCell.mm; sourceTree = "<group>"; };
34D15BA71BD8F93C00C8BCBE /* AddSetTableViewCell.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = AddSetTableViewCell.xib; sourceTree = "<group>"; };
34DF4D0F1AE77B9F0012702D /* MWMWKInterfaceController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MWMWKInterfaceController.h; sourceTree = "<group>"; };
34DF4D101AE77B9F0012702D /* MWMWKInterfaceController.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MWMWKInterfaceController.mm; sourceTree = "<group>"; };
@ -2092,7 +2092,7 @@
FAAEA7D4161D8D3100CCD661 /* BookmarksRootVC.h */,
FAAEA7D3161D8D3100CCD661 /* BookmarksRootVC.mm */,
34D15BA51BD8F93C00C8BCBE /* AddSetTableViewCell.h */,
34D15BA61BD8F93C00C8BCBE /* AddSetTableViewCell.m */,
34D15BA61BD8F93C00C8BCBE /* AddSetTableViewCell.mm */,
34D15BA71BD8F93C00C8BCBE /* AddSetTableViewCell.xib */,
);
name = Bookmarks;
@ -2591,7 +2591,7 @@
6C24A3B21AD7D65500A47B99 /* MWMWatchEventInfo.mm in Sources */,
ED48BBBA17C2B1E2003E7E92 /* CircleView.mm in Sources */,
340E10631B949D1900D975D5 /* MWMSearchBookmarksManager.mm in Sources */,
34D15BA81BD8F93C00C8BCBE /* AddSetTableViewCell.m in Sources */,
34D15BA81BD8F93C00C8BCBE /* AddSetTableViewCell.mm in Sources */,
34CFFE901B7DE83D009D0C9F /* MWMSearchView.mm in Sources */,
F6FE2C151B04A44E009814AA /* MWMPlacePageEntity.mm in Sources */,
34B82AB21B8344E300180497 /* MWMSearchTextField.mm in Sources */,