diff options
author | Ilya Grechuhin <i.grechuhin@mapswithme.com> | 2015-06-16 14:32:16 +0300 |
---|---|---|
committer | Alex Zolotarev <alex@maps.me> | 2015-09-23 02:52:40 +0300 |
commit | 00c153b50ff6c92c312fb9fdc7662df4eef54388 (patch) | |
tree | 419ad82fedd1d550b3c4b3da916ff6bd7aabe1a8 /iphone/Maps/Classes/MWMiPhonePortraitPlacePage.mm | |
parent | 279c4e252521359d59d76e533b7cde41a74183e9 (diff) |
[ios] Added place page dragging support.
Diffstat (limited to 'iphone/Maps/Classes/MWMiPhonePortraitPlacePage.mm')
-rw-r--r-- | iphone/Maps/Classes/MWMiPhonePortraitPlacePage.mm | 30 |
1 files changed, 26 insertions, 4 deletions
diff --git a/iphone/Maps/Classes/MWMiPhonePortraitPlacePage.mm b/iphone/Maps/Classes/MWMiPhonePortraitPlacePage.mm index f472e633dd..3aa2570807 100644 --- a/iphone/Maps/Classes/MWMiPhonePortraitPlacePage.mm +++ b/iphone/Maps/Classes/MWMiPhonePortraitPlacePage.mm @@ -20,6 +20,8 @@ #include "Framework.h" +static NSString * const kPlacePageViewDragKeyPath = @"center"; + typedef NS_ENUM(NSUInteger, MWMiPhonePortraitPlacePageState) { MWMiPhonePortraitPlacePageStateClosed, @@ -37,6 +39,27 @@ typedef NS_ENUM(NSUInteger, MWMiPhonePortraitPlacePageState) @implementation MWMiPhonePortraitPlacePage +- (instancetype)initWithManager:(MWMPlacePageViewManager *)manager +{ + self = [super initWithManager:manager]; + if (self) + { + [self.extendedPlacePageView addObserver:self forKeyPath:kPlacePageViewDragKeyPath options:NSKeyValueObservingOptionNew context:nullptr]; + } + return self; +} + +- (void)dealloc +{ + [self.extendedPlacePageView removeObserver:self forKeyPath:kPlacePageViewDragKeyPath]; +} + +- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context +{ + if ([self.extendedPlacePageView isEqual:object] && [keyPath isEqualToString:kPlacePageViewDragKeyPath]) + [self.manager dragPlacePage:self.extendedPlacePageView.origin]; +} + - (void)configure { [super configure]; @@ -92,18 +115,17 @@ typedef NS_ENUM(NSUInteger, MWMiPhonePortraitPlacePageState) BOOL const isLandscape = size.width > size.height; CGFloat const width = isLandscape ? size.height : size.width; CGFloat const height = isLandscape ? size.width : size.height; - static CGFloat const kPlacePageBottomOffset = 30.; + static CGFloat const kPlacePageBottomOffset = 31.; switch (state) { case MWMiPhonePortraitPlacePageStateClosed: -// GetFramework().GetBalloonManager().RemovePin(); self.targetPoint = CGPointMake(self.extendedPlacePageView.width / 2., self.extendedPlacePageView.height * 2.); break; case MWMiPhonePortraitPlacePageStatePreview: { CGFloat const typeHeight = self.basePlacePageView.typeLabel.text.length > 0 ? self.basePlacePageView.typeLabel.height : self.basePlacePageView.typeDescriptionView.height; - CGFloat const h = height - (self.basePlacePageView.titleLabel.height + kPlacePageBottomOffset + typeHeight + self.actionBar.height + 1); + CGFloat const h = height - (self.basePlacePageView.titleLabel.height + kPlacePageBottomOffset + typeHeight + self.actionBar.height); self.targetPoint = CGPointMake(width / 2., height + h); [MWMPlacePageNavigationBar dismissNavigationBar]; @@ -113,7 +135,7 @@ typedef NS_ENUM(NSUInteger, MWMiPhonePortraitPlacePageState) case MWMiPhonePortraitPlacePageStateOpen: { CGFloat const typeHeight = self.basePlacePageView.typeLabel.text.length > 0 ? self.basePlacePageView.typeLabel.height : self.basePlacePageView.typeDescriptionView.height; - CGFloat const h = height - (self.basePlacePageView.titleLabel.height + kPlacePageBottomOffset + typeHeight + [(UITableView *)self.basePlacePageView.featureTable height] + self.actionBar.height + 1 + self.keyboardHeight); + CGFloat const h = height - (self.basePlacePageView.titleLabel.height + kPlacePageBottomOffset + typeHeight + [(UITableView *)self.basePlacePageView.featureTable height] + self.actionBar.height + self.keyboardHeight); self.targetPoint = CGPointMake(width / 2., height + h); if (self.targetPoint.y <= height) |