[ios] Fixed PP reopen bug. Code cleanup.

This commit is contained in:
Ilya Grechuhin 2015-06-25 11:55:32 +03:00 committed by Alex Zolotarev
parent 9de3f407e7
commit 688307aee3
4 changed files with 27 additions and 51 deletions

View file

@ -9,7 +9,6 @@
@interface SelectSetVC () <AddSetVCDelegate>
@property (weak, nonatomic) MWMPlacePageViewManager * manager;
@property (nonatomic) CGFloat realPlacePageHeight;
@end
@ -32,7 +31,6 @@
if (!self.iPadOwnerNavigationController)
return;
[self.iPadOwnerNavigationController setNavigationBarHidden:NO];
self.realPlacePageHeight = self.iPadOwnerNavigationController.view.height;
UIImage * backImage = [UIImage imageNamed:@"NavigationBarBackButton"];
UIButton * backButton = [[UIButton alloc] initWithFrame:CGRectMake(0., 0., backImage.size.width, backImage.size.height)];
[backButton addTarget:self action:@selector(backTap) forControlEvents:UIControlEventTouchUpInside];
@ -52,7 +50,7 @@
- (void)backTap
{
[self popViewController];
[self.navigationController popViewControllerAnimated:YES];
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
@ -137,26 +135,8 @@
{
[self moveBookmarkToSetWithIndex:static_cast<int>(indexPath.row)];
[self.manager reloadBookmark];
[self popViewController];
}
}
- (void)popViewController
{
if (!self.iPadOwnerNavigationController)
{
[self.navigationController popViewControllerAnimated:YES];
return;
}
[UIView animateWithDuration:0.1 animations:^
{
self.iPadOwnerNavigationController.view.height = self.realPlacePageHeight;
}
completion:^(BOOL finished)
{
[self.navigationController popViewControllerAnimated:YES];
}];
}
- (void)viewWillDisappear:(BOOL)animated

View file

@ -19,7 +19,6 @@ static NSString * const kBookmarkColorCellIdentifier = @"MWMBookmarkColorCell";
@interface MWMBookmarkColorViewController ()
@property (weak, nonatomic) IBOutlet UITableView * tableView;
@property (nonatomic) CGFloat realPlacePageHeight;
@property (nonatomic) BOOL colorWasChanged;
@end
@ -39,7 +38,6 @@ static NSString * const kBookmarkColorCellIdentifier = @"MWMBookmarkColorCell";
if (!self.iPadOwnerNavigationController)
return;
self.realPlacePageHeight = self.iPadOwnerNavigationController.view.height;
CGFloat const bottomOffset = 88.;
self.iPadOwnerNavigationController.view.height = self.tableView.height + bottomOffset;
UIImage * backImage = [UIImage imageNamed:@"NavigationBarBackButton"];
@ -58,7 +56,7 @@ static NSString * const kBookmarkColorCellIdentifier = @"MWMBookmarkColorCell";
- (void)backTap
{
[self popViewController];
[self.navigationController popViewControllerAnimated:YES];
}
- (void)configureTableViewForOrientation:(UIInterfaceOrientation)orientation
@ -110,33 +108,13 @@ static NSString * const kBookmarkColorCellIdentifier = @"MWMBookmarkColorCell";
return YES;
}
- (void)popViewController
{
if (!self.iPadOwnerNavigationController)
{
[self.navigationController popViewControllerAnimated:YES];
return;
}
[UIView animateWithDuration:0.1 animations:^
{
self.iPadOwnerNavigationController.view.height = self.realPlacePageHeight;
}
completion:^(BOOL finished)
{
[self.navigationController popViewControllerAnimated:YES];
}];
}
- (void)viewWillDisappear:(BOOL)animated
{
[super viewWillDisappear:animated];
if (self.colorWasChanged && !self.iPadOwnerNavigationController)
{
[self.placePageManager reloadBookmark];
return;
}
self.iPadOwnerNavigationController.navigationBar.hidden = YES;
else
self.iPadOwnerNavigationController.navigationBar.hidden = YES;
}
@end

View file

@ -71,6 +71,22 @@ static CGFloat const kBottomOffset = 12.;
[super pushViewController:viewController animated:animated];
}
- (UIViewController *)popViewControllerAnimated:(BOOL)animated
{
NSUInteger const count = self.viewControllers.count;
CGFloat const height = count > 1 ? ((UIViewController *)self.viewControllers[count - 2]).view.height + self.navigationBar.height: 0.0;
[UIView animateWithDuration:0.1 animations:^
{
self.view.height = height;
}
completion:^(BOOL finished)
{
[super popViewControllerAnimated:animated];
}];
return self.viewControllers.lastObject;
}
@end
@interface MWMiPadPlacePage ()
@ -210,7 +226,7 @@ static CGFloat const kBottomOffset = 12.;
- (void)updatePlacePagePosition
{
UIView * view = self.navigationController.view;
view.maxY = self.availableHeight + kTopOffset;
view.maxY = [self getAvailableHeight] + kTopOffset;
view.minY = MIN(view.minY, self.topBound + kTopOffset);
[self configureContentInset];
}
@ -235,7 +251,7 @@ static CGFloat const kBottomOffset = 12.;
}
}
- (CGFloat)availableHeight
- (CGFloat)getAvailableHeight
{
return self.parentViewHeight - self.keyboardHeight - kTopOffset - kBottomOffset;
}
@ -244,7 +260,7 @@ static CGFloat const kBottomOffset = 12.;
- (void)setHeight:(CGFloat)height
{
_height = MIN(height, self.availableHeight);
_height = MIN(height, [self getAvailableHeight]);
self.navigationController.view.height = _height;
self.extendedPlacePageView.height = _height;
}

View file

@ -69,10 +69,12 @@ typedef NS_ENUM(NSUInteger, MWMiPhonePortraitPlacePageState)
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);
UIView * ppv = self.extendedPlacePageView;
ppv.frame = CGRectMake(0., height, width, 2 * height);
_targetPoint = ppv.center;
self.actionBar.width = width;
self.actionBar.center = CGPointMake(width / 2., height + self.actionBar.height / 2.);
[self.manager addSubviews:@[self.extendedPlacePageView, self.actionBar] withNavigationController:nil];
[self.manager addSubviews:@[ppv, self.actionBar] withNavigationController:nil];
[UIView animateWithDuration:0.3f delay:0. options:UIViewAnimationOptionCurveEaseOut animations:^
{
self.actionBar.center = CGPointMake(width / 2., height - self.actionBar.height / 2.);