forked from organicmaps/organicmaps
[ios] Added animation to iPad place page && fixed bugs.
This commit is contained in:
parent
fad1f704cb
commit
377513b29c
5 changed files with 93 additions and 51 deletions
|
@ -7,18 +7,30 @@
|
|||
|
||||
@implementation AddSetVC
|
||||
|
||||
- (id)init
|
||||
- (instancetype)init
|
||||
{
|
||||
self = [super initWithStyle:UITableViewStyleGrouped];
|
||||
if (self)
|
||||
{
|
||||
self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemSave target:self action:@selector(onSaveClicked)];
|
||||
self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCancel target:self action:@selector(onCancelClicked)];
|
||||
self.title = L(@"add_new_set");
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)viewDidLoad
|
||||
{
|
||||
[super viewDidLoad];
|
||||
self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemSave target:self action:@selector(onSaveClicked)];
|
||||
UIImage * backImage = [UIImage imageNamed:@"NavigationBarBackButton"];
|
||||
UIButton * backButton = [[UIButton alloc] initWithFrame:CGRectMake(0., 0., backImage.size.width, backImage.size.height)];
|
||||
[backButton addTarget:self action:@selector(onCancelClicked) forControlEvents:UIControlEventTouchUpInside];
|
||||
[backButton setImage:backImage forState:UIControlStateNormal];
|
||||
self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:backButton];
|
||||
self.title = L(@"add_new_set");
|
||||
}
|
||||
|
||||
- (void)viewWillAppear:(BOOL)animated
|
||||
{
|
||||
[super viewWillAppear:animated];
|
||||
self.navigationController.navigationBar.hidden = NO;
|
||||
}
|
||||
|
||||
- (void)onCancelClicked
|
||||
{
|
||||
[self.navigationController popViewControllerAnimated:YES];
|
||||
|
|
|
@ -29,7 +29,15 @@
|
|||
- (void)viewDidLoad
|
||||
{
|
||||
[super viewDidLoad];
|
||||
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];
|
||||
[backButton setImage:backImage forState:UIControlStateNormal];
|
||||
[self.navigationItem setLeftBarButtonItem:[[UIBarButtonItem alloc] initWithCustomView:backButton]];
|
||||
}
|
||||
|
||||
- (void)viewWillAppear:(BOOL)animated
|
||||
|
@ -37,15 +45,9 @@
|
|||
[super viewWillAppear:animated];
|
||||
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"];
|
||||
UIButton * backButton = [[UIButton alloc] initWithFrame:CGRectMake(0., 0., backImage.size.width, backImage.size.height)];
|
||||
[backButton addTarget:self action:@selector(backTap) forControlEvents:UIControlEventTouchUpInside];
|
||||
[backButton setImage:backImage forState:UIControlStateNormal];
|
||||
UIBarButtonItem * leftButton = [[UIBarButtonItem alloc] initWithCustomView:backButton];
|
||||
[self.navigationItem setLeftBarButtonItem:leftButton];
|
||||
}
|
||||
|
||||
- (void)backTap
|
||||
|
@ -145,7 +147,7 @@
|
|||
if (!self.iPadOwnerNavigationController)
|
||||
return;
|
||||
|
||||
[self.iPadOwnerNavigationController setNavigationBarHidden:YES];
|
||||
self.iPadOwnerNavigationController.navigationBar.hidden = YES;
|
||||
self.iPadOwnerNavigationController.view.height = self.realPlacePageHeight;
|
||||
}
|
||||
|
||||
|
|
|
@ -36,14 +36,6 @@ static NSString * const kBookmarkColorCellIdentifier = @"MWMBookmarkColorCell";
|
|||
self.title = L(@"bookmark_color");
|
||||
[self.tableView registerNib:[UINib nibWithNibName:kBookmarkColorCellIdentifier bundle:nil] forCellReuseIdentifier:kBookmarkColorCellIdentifier];
|
||||
self.colorWasChanged = NO;
|
||||
}
|
||||
|
||||
- (void)viewWillAppear:(BOOL)animated
|
||||
{
|
||||
[super viewWillAppear:animated];
|
||||
[self configureTableViewForOrientation:self.interfaceOrientation];
|
||||
[self.tableView reloadData];
|
||||
|
||||
if (!self.iPadOwnerNavigationController)
|
||||
return;
|
||||
|
||||
|
@ -54,8 +46,14 @@ static NSString * const kBookmarkColorCellIdentifier = @"MWMBookmarkColorCell";
|
|||
UIButton * backButton = [[UIButton alloc] initWithFrame:CGRectMake(0., 0., backImage.size.width, backImage.size.height)];
|
||||
[backButton addTarget:self action:@selector(backTap) forControlEvents:UIControlEventTouchUpInside];
|
||||
[backButton setImage:backImage forState:UIControlStateNormal];
|
||||
UIBarButtonItem * leftButton = [[UIBarButtonItem alloc] initWithCustomView:backButton];
|
||||
[self.navigationItem setLeftBarButtonItem:leftButton];
|
||||
[self.navigationItem setLeftBarButtonItem:[[UIBarButtonItem alloc] initWithCustomView:backButton]];
|
||||
}
|
||||
|
||||
- (void)viewWillAppear:(BOOL)animated
|
||||
{
|
||||
[super viewWillAppear:animated];
|
||||
[self configureTableViewForOrientation:self.interfaceOrientation];
|
||||
[self.tableView reloadData];
|
||||
}
|
||||
|
||||
- (void)backTap
|
||||
|
@ -115,13 +113,12 @@ static NSString * const kBookmarkColorCellIdentifier = @"MWMBookmarkColorCell";
|
|||
- (void)viewWillDisappear:(BOOL)animated
|
||||
{
|
||||
[super viewWillDisappear:animated];
|
||||
if (self.colorWasChanged)
|
||||
if (self.colorWasChanged && !self.iPadOwnerNavigationController)
|
||||
{
|
||||
[self.placePageManager reloadBookmark];
|
||||
|
||||
if (!self.iPadOwnerNavigationController)
|
||||
return;
|
||||
|
||||
[self.iPadOwnerNavigationController setNavigationBarHidden:YES];
|
||||
}
|
||||
self.iPadOwnerNavigationController.navigationBar.hidden = YES;
|
||||
self.iPadOwnerNavigationController.view.height = self.realPlacePageHeight;
|
||||
}
|
||||
|
||||
|
@ -153,6 +150,11 @@ static NSString * const kBookmarkColorCellIdentifier = @"MWMBookmarkColorCell";
|
|||
{
|
||||
self.colorWasChanged = YES;
|
||||
self.placePageManager.entity.bookmarkColor = kBookmarkColorsVariant[indexPath.row];
|
||||
if (!self.iPadOwnerNavigationController)
|
||||
return;
|
||||
|
||||
[self.placePageManager reloadBookmark];
|
||||
GetFramework().Invalidate();
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
#import "UIKitCategories.h"
|
||||
|
||||
static NSString * const kBookmarkDescriptionViewControllerNibName = @"MWMBookmarkDescriptionViewController";
|
||||
static CGFloat const kIpadPlacePageDefaultHeight = 288.;
|
||||
|
||||
typedef NS_ENUM(NSUInteger, BookmarkDescriptionState)
|
||||
{
|
||||
|
@ -58,8 +59,17 @@ typedef NS_ENUM(NSUInteger, BookmarkDescriptionState)
|
|||
self.state = BookmarkDescriptionStateViewHTML;
|
||||
else
|
||||
self.state = BookmarkDescriptionStateEditText;
|
||||
|
||||
if (self.iPadOwnerNavigationController)
|
||||
{
|
||||
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];
|
||||
[backButton setImage:backImage forState:UIControlStateNormal];
|
||||
[self.navigationItem setLeftBarButtonItem:[[UIBarButtonItem alloc] initWithCustomView:backButton]];
|
||||
return;
|
||||
}
|
||||
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self
|
||||
selector:@selector(keyboardWillShown:)
|
||||
|
@ -72,12 +82,13 @@ typedef NS_ENUM(NSUInteger, BookmarkDescriptionState)
|
|||
|
||||
- (void)viewWillAppear:(BOOL)animated
|
||||
{
|
||||
[super viewWillAppear:animated];
|
||||
if (!self.iPadOwnerNavigationController)
|
||||
return;
|
||||
|
||||
self.realPlacePageHeight = self.iPadOwnerNavigationController.view.height;
|
||||
CGFloat const bottomOffset = 88.;
|
||||
self.iPadOwnerNavigationController.view.height = self.textView.height + bottomOffset;
|
||||
CGFloat const bottomOffset = 12.;
|
||||
self.iPadOwnerNavigationController.view.height = kIpadPlacePageDefaultHeight;
|
||||
self.textView.height = kIpadPlacePageDefaultHeight - bottomOffset;
|
||||
self.webView.height = kIpadPlacePageDefaultHeight - bottomOffset;
|
||||
}
|
||||
|
||||
- (void)viewWillDisappear:(BOOL)animated
|
||||
|
@ -86,7 +97,7 @@ typedef NS_ENUM(NSUInteger, BookmarkDescriptionState)
|
|||
if (!self.iPadOwnerNavigationController)
|
||||
return;
|
||||
|
||||
[self.iPadOwnerNavigationController setNavigationBarHidden:YES];
|
||||
self.iPadOwnerNavigationController.navigationBar.hidden = YES;
|
||||
self.iPadOwnerNavigationController.view.height = self.realPlacePageHeight;
|
||||
}
|
||||
|
||||
|
|
|
@ -17,6 +17,8 @@
|
|||
#import "MWMBookmarkDescriptionViewController.h"
|
||||
|
||||
extern CGFloat kBookmarkCellHeight;
|
||||
static CGFloat const kLeftOffset = 12.;
|
||||
static CGFloat const kTopOffset = 36.;
|
||||
|
||||
@interface MWMiPadNavigationController : UINavigationController
|
||||
|
||||
|
@ -30,6 +32,7 @@ extern CGFloat kBookmarkCellHeight;
|
|||
if (self)
|
||||
{
|
||||
[self setNavigationBarHidden:YES];
|
||||
[self.navigationBar setTranslucent:NO];
|
||||
self.view.autoresizingMask = UIViewAutoresizingNone;
|
||||
}
|
||||
return self;
|
||||
|
@ -69,37 +72,49 @@ extern CGFloat kBookmarkCellHeight;
|
|||
- (void)configure
|
||||
{
|
||||
[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];
|
||||
|
||||
UIView * view = self.manager.ownerViewController.view;
|
||||
CGFloat const topOffset = 36.;
|
||||
CGFloat const leftOffset = 12.;
|
||||
CGFloat const defaultWidth = 360.;
|
||||
CGFloat const actionBarHeight = self.actionBar.height;
|
||||
CGFloat const height = self.basePlacePageView.height + self.anchorImageView.height + actionBarHeight - 1;
|
||||
CGFloat const actionBarHeight = 58.;
|
||||
CGFloat const defaultHeight = self.basePlacePageView.height + self.anchorImageView.height + actionBarHeight - 1;
|
||||
|
||||
self.navigationController.view.frame = CGRectMake(leftOffset, topOffset, defaultWidth, height);
|
||||
self.viewController.view.frame = self.navigationController.view.frame;
|
||||
[self.manager.ownerViewController addChildViewController:self.navigationController];
|
||||
[view addSubview:self.navigationController.view];
|
||||
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.extendedPlacePageView.size = self.navigationController.view.size;
|
||||
[self.viewController.view addSubview:self.extendedPlacePageView];
|
||||
self.extendedPlacePageView.origin = CGPointZero;
|
||||
[self.viewController.view addSubview:self.actionBar];
|
||||
self.extendedPlacePageView.frame = CGRectMake(0., 0., defaultWidth, defaultHeight);
|
||||
self.anchorImageView.image = nil;
|
||||
self.anchorImageView.backgroundColor = [UIColor whiteColor];
|
||||
[self.extendedPlacePageView addSubview:self.actionBar];
|
||||
self.actionBar.frame = CGRectMake(0., self.extendedPlacePageView.maxY - actionBarHeight, defaultWidth, actionBarHeight);
|
||||
self.actionBar.width = defaultWidth;
|
||||
self.actionBar.origin = CGPointMake(0., defaultHeight - actionBarHeight);
|
||||
[view addSubview:self.navigationController.view];
|
||||
}
|
||||
|
||||
- (void)show
|
||||
{
|
||||
[UIView animateWithDuration:0.2f animations:^
|
||||
{
|
||||
self.navigationController.view.center = CGPointMake(kLeftOffset + self.navigationController.view.width / 2., kTopOffset + self.navigationController.view.height / 2.);
|
||||
}];
|
||||
}
|
||||
|
||||
- (void)dismiss
|
||||
{
|
||||
[self.navigationController.view removeFromSuperview];
|
||||
[self.navigationController removeFromParentViewController];
|
||||
[super dismiss];
|
||||
[UIView animateWithDuration:0.2f animations:^
|
||||
{
|
||||
self.navigationController.view.center = CGPointMake( - self.navigationController.view.width / 2. - kLeftOffset , kTopOffset);
|
||||
}
|
||||
completion:^(BOOL finished)
|
||||
{
|
||||
[self.navigationController.view removeFromSuperview];
|
||||
[self.navigationController removeFromParentViewController];
|
||||
[super dismiss];
|
||||
}];
|
||||
}
|
||||
|
||||
- (void)addBookmark
|
||||
|
|
Loading…
Add table
Reference in a new issue