Merge pull request #326 from igrechuhin/ig-master

[ios] Place page layout fixes.
This commit is contained in:
Vlad Mihaylenko 2015-10-21 16:10:06 +03:00
commit 8ba49e5c95
7 changed files with 51 additions and 29 deletions

View file

@ -157,6 +157,7 @@ typedef NS_ENUM(NSUInteger, BookmarkDescriptionState)
- (void)cancelTap
{
[self.textView resignFirstResponder];
if (self.manager.entity.isHTMLDescription)
self.state = BookmarkDescriptionStateViewHTML;
else
@ -168,12 +169,7 @@ typedef NS_ENUM(NSUInteger, BookmarkDescriptionState)
MWMPlacePageEntity * entity = self.manager.entity;
entity.bookmarkDescription = self.textView.text;
[entity synchronize];
[self.textView resignFirstResponder];
if (entity.isHTMLDescription)
self.state = BookmarkDescriptionStateViewHTML;
else
[self popViewController];
[self cancelTap];
}
- (void)backTap

View file

@ -31,7 +31,7 @@
- (void)route;
- (void)reloadBookmark;
- (void)apiBack;
- (void)willStartEditingBookmarkTitle:(CGFloat)keyboardHeight;
- (void)willStartEditingBookmarkTitle;
- (void)willFinishEditingBookmarkTitle:(NSString *)title;
- (void)addPlacePageShadowToView:(UIView *)view offset:(CGSize)offset;
@ -41,6 +41,8 @@
- (void)setDistance:(NSString *)distance;
- (void)updateMyPositionStatus:(NSString *)status;
- (void)keyboardWillChangeFrame:(NSNotification *)aNotification;
- (instancetype)init __attribute__((unavailable("call initWithManager: instead")));
@end

View file

@ -36,6 +36,15 @@ static NSString * const kPlacePageViewCenterKeyPath = @"center";
options:NSKeyValueObservingOptionNew
context:nullptr];
}
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(keyboardWillChangeFrame:)
name:UIKeyboardWillChangeFrameNotification
object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(keyboardWillHide)
name:UIKeyboardWillHideNotification
object:nil];
}
return self;
}
@ -46,6 +55,18 @@ static NSString * const kPlacePageViewCenterKeyPath = @"center";
{
[self.extendedPlacePageView removeObserver:self forKeyPath:kPlacePageViewCenterKeyPath];
}
[[NSNotificationCenter defaultCenter] removeObserver:self];
}
- (void)keyboardWillChangeFrame:(NSNotification *)aNotification
{
NSDictionary * info = [aNotification userInfo];
self.keyboardHeight = [info[UIKeyboardFrameEndUserInfoKey] CGRectValue].size.height;
}
- (void)keyboardWillHide
{
self.keyboardHeight = 0.0;
}
- (void)observeValueForKeyPath:(NSString *)keyPath
@ -98,7 +119,6 @@ static NSString * const kPlacePageViewCenterKeyPath = @"center";
{
[self.basePlacePageView removeBookmark];
[self.manager removeBookmark];
self.keyboardHeight = 0.;
}
- (void)share
@ -165,16 +185,10 @@ static NSString * const kPlacePageViewCenterKeyPath = @"center";
[self.basePlacePageView reloadBookmarkCell];
}
- (void)willStartEditingBookmarkTitle:(CGFloat)keyboardHeight
{
self.keyboardHeight = keyboardHeight;
}
- (void)willFinishEditingBookmarkTitle:(NSString *)title
{
self.basePlacePageView.titleLabel.text = title;
[self.basePlacePageView layoutIfNeeded];
self.keyboardHeight = 0.;
}
- (IBAction)didTap:(UITapGestureRecognizer *)sender

View file

@ -96,10 +96,8 @@ static NSUInteger sWebViewHeight = 0;
- (void)keyboardWillShown:(NSNotification *)aNotification
{
NSDictionary const * info = [aNotification userInfo];
CGSize const kbSize = [info[UIKeyboardFrameEndUserInfoKey] CGRectValue].size;
if ([self.title isEditing])
[self.placePage willStartEditingBookmarkTitle:kbSize.height];
[self.placePage willStartEditingBookmarkTitle];
}
- (void)keyboardWillBeHidden

View file

@ -141,9 +141,8 @@ static CGFloat const kKeyboardOffset = 12.;
}];
}
- (void)willStartEditingBookmarkTitle:(CGFloat)keyboardHeight
- (void)willStartEditingBookmarkTitle
{
[super willStartEditingBookmarkTitle:keyboardHeight];
[self updatePlacePagePosition];
}
@ -191,6 +190,7 @@ static CGFloat const kKeyboardOffset = 12.;
MWMBookmarkDescriptionViewController * controller = [[MWMBookmarkDescriptionViewController alloc] initWithPlacePageManager:self.manager];
controller.iPadOwnerNavigationController = self.navigationController;
[self.navigationController pushViewController:controller animated:YES];
[self updatePlacePageLayoutAnimated:NO];
}
- (IBAction)didPan:(UIPanGestureRecognizer *)sender
@ -238,8 +238,10 @@ static CGFloat const kKeyboardOffset = 12.;
UITableView * featureTable = self.basePlacePageView.featureTable;
CGFloat const height = self.navigationController.view.height;
CGFloat const tableContentHeight = featureTable.contentSize.height;
CGFloat const headerViewHeight = self.basePlacePageView.separatorView.maxY;
CGFloat const availableTableHeight = height - headerViewHeight - self.actionBar.height;
CGFloat const headerHeight = self.basePlacePageView.separatorView.maxY;
CGFloat const actionBarHeight = self.actionBar.height;
CGFloat const anchorHeight = self.anchorImageView.height;
CGFloat const availableTableHeight = height - headerHeight - actionBarHeight - anchorHeight;
CGFloat const externalHeight = tableContentHeight - availableTableHeight;
if (externalHeight > 0.)
{
@ -248,22 +250,35 @@ static CGFloat const kKeyboardOffset = 12.;
}
else
{
[featureTable setContentOffset:CGPointZero animated:YES];
featureTable.contentInset = UIEdgeInsetsZero;
featureTable.scrollEnabled = NO;
}
}
- (void)keyboardWillChangeFrame:(NSNotification *)aNotification
{
[super keyboardWillChangeFrame:aNotification];
[self updateHeight];
}
- (CGFloat)getAvailableHeight
{
CGFloat const bottomOffset = self.keyboardHeight > 0.0 ? kKeyboardOffset : kBottomOffset;
return self.parentViewHeight - self.keyboardHeight - kTopOffset - bottomOffset;
CGFloat const availableHeight = self.parentViewHeight - self.keyboardHeight - kTopOffset - bottomOffset;
return availableHeight;
}
#pragma mark - Properties
- (void)setHeight:(CGFloat)height
{
_height = MIN(height, [self getAvailableHeight]);
_height = height;
[self updateHeight];
}
- (void)updateHeight
{
_height = MIN(_height, [self getAvailableHeight]);
self.navigationController.view.height = _height;
self.extendedPlacePageView.height = _height;
}

View file

@ -131,9 +131,8 @@ typedef NS_ENUM(NSUInteger, MWMiPhoneLandscapePlacePageState)
}
}
- (void)willStartEditingBookmarkTitle:(CGFloat)keyboardHeight
- (void)willStartEditingBookmarkTitle
{
[super willStartEditingBookmarkTitle:keyboardHeight];
CGFloat const statusBarHeight = [[UIApplication sharedApplication] statusBarFrame].size.height;
MWMBasePlacePageView const * basePlacePageView = self.basePlacePageView;
UITableView const * tableView = basePlacePageView.featureTable;

View file

@ -220,9 +220,8 @@ typedef NS_ENUM(NSUInteger, MWMiPhonePortraitPlacePageState)
}
}
- (void)willStartEditingBookmarkTitle:(CGFloat)keyboardHeight
- (void)willStartEditingBookmarkTitle
{
[super willStartEditingBookmarkTitle:keyboardHeight];
self.state = MWMiPhonePortraitPlacePageStateOpen;
}
@ -270,7 +269,6 @@ typedef NS_ENUM(NSUInteger, MWMiPhonePortraitPlacePageState)
__strong MWMiPhonePortraitPlacePage * self = weakSelf;
if (self.state == MWMiPhonePortraitPlacePageStateClosed)
{
self.keyboardHeight = 0.;
[self.manager dismissPlacePage];
}
else