From 209baa23cb90e53caf9c567baa946192996a01f3 Mon Sep 17 00:00:00 2001 From: Ilya Grechuhin Date: Fri, 9 Sep 2016 18:48:52 +0300 Subject: [PATCH 1/2] [ios] Removed IB_DESIGNABLE. --- .../Search/TabButtons/MWMSearchTabButtonsView.h | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/iphone/Maps/Classes/CustomViews/MapViewControls/Search/TabButtons/MWMSearchTabButtonsView.h b/iphone/Maps/Classes/CustomViews/MapViewControls/Search/TabButtons/MWMSearchTabButtonsView.h index 432b6f6c3c..05545efcf7 100644 --- a/iphone/Maps/Classes/CustomViews/MapViewControls/Search/TabButtons/MWMSearchTabButtonsView.h +++ b/iphone/Maps/Classes/CustomViews/MapViewControls/Search/TabButtons/MWMSearchTabButtonsView.h @@ -6,12 +6,11 @@ @end -IB_DESIGNABLE @interface MWMSearchTabButtonsView : UIView @property (nonatomic) BOOL selected; -@property (nonatomic) IBInspectable UIImage * iconImage; -@property (nonatomic) IBInspectable NSString * localizedText; +@property (nonatomic) UIImage * iconImage; +@property (nonatomic) NSString * localizedText; @end From ba8a5c67ae2a6d04f20baad208bd775650b76c8e Mon Sep 17 00:00:00 2001 From: Ilya Grechuhin Date: Fri, 9 Sep 2016 18:49:33 +0300 Subject: [PATCH 2/2] [ios] Fixed MWMNoMapsView layout. --- .../MWMSearchTabbedCollectionViewCell.xib | 2 +- .../MapDownloader/NoMaps/MWMNoMapsView.mm | 99 ++++++++++-- iphone/Maps/Mapsme.storyboard | 153 +++++++++--------- 3 files changed, 171 insertions(+), 83 deletions(-) diff --git a/iphone/Maps/Classes/CustomViews/MapViewControls/Search/TabbedView/MWMSearchTabbedCollectionViewCell.xib b/iphone/Maps/Classes/CustomViews/MapViewControls/Search/TabbedView/MWMSearchTabbedCollectionViewCell.xib index 05fc074a0e..3cde026bb6 100644 --- a/iphone/Maps/Classes/CustomViews/MapViewControls/Search/TabbedView/MWMSearchTabbedCollectionViewCell.xib +++ b/iphone/Maps/Classes/CustomViews/MapViewControls/Search/TabbedView/MWMSearchTabbedCollectionViewCell.xib @@ -33,7 +33,7 @@ - + diff --git a/iphone/Maps/Classes/MapDownloader/NoMaps/MWMNoMapsView.mm b/iphone/Maps/Classes/MapDownloader/NoMaps/MWMNoMapsView.mm index ad18697548..7324e0096b 100644 --- a/iphone/Maps/Classes/MapDownloader/NoMaps/MWMNoMapsView.mm +++ b/iphone/Maps/Classes/MapDownloader/NoMaps/MWMNoMapsView.mm @@ -1,42 +1,121 @@ #import "MWMNoMapsView.h" +#import "Common.h" @interface MWMNoMapsView () @property (weak, nonatomic) IBOutlet UIImageView * image; +@property (weak, nonatomic) IBOutlet UILabel * title; +@property (weak, nonatomic) IBOutlet UILabel * text; @property (weak, nonatomic) IBOutlet NSLayoutConstraint * containerWidth; @property (weak, nonatomic) IBOutlet NSLayoutConstraint * containerHeight; +@property (weak, nonatomic) IBOutlet NSLayoutConstraint * containerTopOffset; +@property (weak, nonatomic) IBOutlet NSLayoutConstraint * containerBottomOffset; @property (weak, nonatomic) IBOutlet NSLayoutConstraint * imageMinHeight; @property (weak, nonatomic) IBOutlet NSLayoutConstraint * imageHeight; @property (weak, nonatomic) IBOutlet NSLayoutConstraint * titleImageOffset; +@property (weak, nonatomic) IBOutlet NSLayoutConstraint * titleTopOffset; +@property (weak, nonatomic) IBOutlet NSLayoutConstraint * textTopOffset; @end @implementation MWMNoMapsView -- (void)setFrame:(CGRect)frame +- (void)awakeFromNib { - super.frame = frame; - [self configForSize:self.frame.size]; + [super awakeFromNib]; + if (!IPAD) + { + if (isIOS7) + { + self.containerWidth.priority = UILayoutPriorityFittingSizeLevel; + self.containerHeight.priority = UILayoutPriorityFittingSizeLevel; + } + else + { + self.containerWidth.active = NO; + self.containerHeight.active = NO; + } + } + else + { + if (isIOS7) + self.containerTopOffset.priority = UILayoutPriorityFittingSizeLevel; + else + self.containerTopOffset.active = NO; + } + [[NSNotificationCenter defaultCenter] addObserver:self + selector:@selector(keyboardWillShow:) + name:UIKeyboardWillShowNotification + object:nil]; + + [[NSNotificationCenter defaultCenter] addObserver:self + selector:@selector(keyboardWillHide:) + name:UIKeyboardWillHideNotification + object:nil]; } -- (void)setBounds:(CGRect)bounds +- (void)dealloc { - super.bounds = bounds; - [self configForSize:self.bounds.size]; + [[NSNotificationCenter defaultCenter] removeObserver:self]; +} + +- (void)keyboardWillShow:(NSNotification *)notification +{ + CGSize const keyboardSize = [notification.userInfo[UIKeyboardFrameBeginUserInfoKey] CGRectValue].size; + CGFloat const bottomInset = MIN(keyboardSize.height, keyboardSize.width); + + NSNumber * rate = notification.userInfo[UIKeyboardAnimationDurationUserInfoKey]; + [self.superview layoutIfNeeded]; + [UIView animateWithDuration:rate.floatValue animations:^ + { + self.containerBottomOffset.constant = bottomInset; + [self.superview layoutIfNeeded]; + }]; +} + +- (void)keyboardWillHide:(NSNotification *)notification +{ + NSNumber * rate = notification.userInfo[UIKeyboardAnimationDurationUserInfoKey]; + [self.superview layoutIfNeeded]; + [UIView animateWithDuration:rate.floatValue animations:^ + { + self.containerBottomOffset.constant = 0; + [self.superview layoutIfNeeded]; + }]; +} + +- (void)layoutSubviews +{ + [super layoutSubviews]; + [self configForSize:self.frame.size]; } - (void)configForSize:(CGSize)size { - CGSize const iPadSize = {520, 534}; + CGSize const iPadSize = {520, 600}; CGSize const newSize = IPAD ? iPadSize : size; CGFloat const width = newSize.width; CGFloat const height = newSize.height; BOOL const hideImage = (self.imageHeight.multiplier * height <= self.imageMinHeight.constant); - self.titleImageOffset.priority = hideImage ? UILayoutPriorityDefaultLow : UILayoutPriorityDefaultHigh; + if (hideImage) + { + self.titleImageOffset.priority = UILayoutPriorityDefaultLow; + self.title.hidden = self.title.minY < self.titleTopOffset.constant; + self.text.hidden = self.text.minY < self.textTopOffset.constant; + } + else + { + self.titleImageOffset.priority = UILayoutPriorityDefaultHigh; + self.title.hidden = NO; + self.text.hidden = NO; + } self.image.hidden = hideImage; - self.containerWidth.constant = width; - self.containerHeight.constant = height; + if (IPAD) + { + self.containerWidth.constant = width; + self.containerHeight.constant = height; + } } @end diff --git a/iphone/Maps/Mapsme.storyboard b/iphone/Maps/Mapsme.storyboard index b6ef5ca4e9..bb2dd2f2a8 100644 --- a/iphone/Maps/Mapsme.storyboard +++ b/iphone/Maps/Mapsme.storyboard @@ -78,7 +78,7 @@ - +