diff --git a/iphone/Maps/Bookmarks/AddSetVC.mm b/iphone/Maps/Bookmarks/AddSetVC.mm index 4ebbc2728b..922a19ca37 100644 --- a/iphone/Maps/Bookmarks/AddSetVC.mm +++ b/iphone/Maps/Bookmarks/AddSetVC.mm @@ -2,6 +2,7 @@ #import "AddSetVC.h" #import "Framework.h" #import "UIKitCategories.h" +#import "UIViewController+Navigation.h" #define TEXT_FIELD_TAG 666 @@ -17,11 +18,7 @@ { [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]; + [(UIViewController *)self showBackButton]; self.title = L(@"add_new_set"); } diff --git a/iphone/Maps/Bookmarks/SelectSetVC.mm b/iphone/Maps/Bookmarks/SelectSetVC.mm index cc44298132..301b2cf6e2 100644 --- a/iphone/Maps/Bookmarks/SelectSetVC.mm +++ b/iphone/Maps/Bookmarks/SelectSetVC.mm @@ -5,6 +5,7 @@ #import "UIKitCategories.h" #import "MWMPlacePageViewManager.h" #import "MWMPlacePageEntity.h" +#import "UIViewController+Navigation.h" @interface SelectSetVC () @@ -25,31 +26,23 @@ return self; } -- (void)viewDidLoad -{ - [super viewDidLoad]; - if (!self.iPadOwnerNavigationController) - return; - [self.iPadOwnerNavigationController setNavigationBarHidden:NO]; - 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 { [super viewWillAppear:animated]; if (!self.iPadOwnerNavigationController) return; + [self.iPadOwnerNavigationController setNavigationBarHidden:NO]; + [(UIViewController *)self showBackButton]; CGFloat const bottomOffset = 88.; self.iPadOwnerNavigationController.view.height = self.tableView.height + bottomOffset; } - (void)backTap { + if (self.iPadOwnerNavigationController) + [self.iPadOwnerNavigationController setNavigationBarHidden:YES]; + [self.navigationController popViewControllerAnimated:YES]; } @@ -139,13 +132,4 @@ } } -- (void)viewWillDisappear:(BOOL)animated -{ - [super viewWillDisappear:animated]; - if (!self.iPadOwnerNavigationController) - return; - - self.iPadOwnerNavigationController.navigationBar.hidden = YES; -} - @end diff --git a/iphone/Maps/Classes/MWMBasePlacePageView.mm b/iphone/Maps/Classes/MWMBasePlacePageView.mm index 0ebe134b7d..4639079f5c 100644 --- a/iphone/Maps/Classes/MWMBasePlacePageView.mm +++ b/iphone/Maps/Classes/MWMBasePlacePageView.mm @@ -79,7 +79,7 @@ extern CGFloat const kBookmarkCellHeight = 135.; [self layoutSubviews]; } -static CGFloat const kPlacePageTitleKoefficient = 0.6375; +static CGFloat const kPlacePageTitleKoefficient = 0.63; static CGFloat const kLeftOffset = 16.; static CGFloat const kDirectionArrowSide = 32.; static CGFloat const kOffsetFromTitleToDistance = 12.; @@ -108,7 +108,6 @@ static CGFloat const kTitleBottomOffset = 2.; self.titleLabel.origin = CGPointMake(kLeftOffset, topOffset); self.typeLabel.origin = CGPointMake(kLeftOffset, typeMinY); - [self layoutDistanceLabelWithPlacePageWidth:placePageWidth]; [self.typeDescriptionView removeFromSuperview]; if (isExtendedType) [self layoutTypeDescription]; @@ -116,6 +115,7 @@ static CGFloat const kTitleBottomOffset = 2.; CGFloat const typeHeight = self.typeLabel.text.length > 0 ? self.typeLabel.height : self.typeDescriptionView.height; self.featureTable.minY = typeMinY + typeHeight + typeBottomOffset; self.separatorView.minY = self.featureTable.minY - 1; + [self layoutDistanceLabelWithPlacePageWidth:placePageWidth]; self.featureTable.height = self.featureTable.contentSize.height; self.height = typeBottomOffset + kTitleBottomOffset + self.titleLabel.height + self.typeLabel.height + self.featureTable.height; } @@ -142,13 +142,11 @@ static CGFloat const kTitleBottomOffset = 2.; CGFloat const distanceLabelWidthPositionLeft = placePageWidth - maximumTitleWidth - kDirectionArrowSide - 2 * kLeftOffset - kOffsetFromDistanceToArrow - kOffsetFromTitleToDistance; self.distanceLabel.width = distanceLabelWidthPositionLeft; [self.distanceLabel sizeToFit]; - CGFloat const titleCenterY = self.titleLabel.center.y; CGFloat const directionArrowMinX = placePageWidth - kLeftOffset - kDirectionArrowSide; CGFloat const distanceLabelMinX = directionArrowMinX - self.distanceLabel.width - kOffsetFromDistanceToArrow; - CGFloat const distanceLabelMinY = titleCenterY - self.distanceLabel.height / 2.; - CGFloat const directionArrowMinY = titleCenterY - kDirectionArrowSide / 2.; - self.distanceLabel.origin = CGPointMake(distanceLabelMinX, distanceLabelMinY); - self.directionArrow.center = CGPointMake(directionArrowMinX + kDirectionArrowSide / 2., directionArrowMinY + kDirectionArrowSide / 2.); + CGFloat const directionArrowCenterY = self.separatorView.maxY / 2.; + self.directionArrow.center = CGPointMake(directionArrowMinX + kDirectionArrowSide / 2., directionArrowCenterY); + self.distanceLabel.origin = CGPointMake(distanceLabelMinX, directionArrowCenterY - self.distanceLabel.height / 2.); self.directionButton.origin = self.directionArrow.origin; } diff --git a/iphone/Maps/Classes/MWMBookmarkColorCell.xib b/iphone/Maps/Classes/MWMBookmarkColorCell.xib index 25e935444f..516007831b 100644 --- a/iphone/Maps/Classes/MWMBookmarkColorCell.xib +++ b/iphone/Maps/Classes/MWMBookmarkColorCell.xib @@ -1,8 +1,8 @@ - + - + @@ -11,16 +11,9 @@ - + - diff --git a/iphone/Maps/Classes/MWMBookmarkColorViewController.mm b/iphone/Maps/Classes/MWMBookmarkColorViewController.mm index fa54c23d10..1543b0d37e 100644 --- a/iphone/Maps/Classes/MWMBookmarkColorViewController.mm +++ b/iphone/Maps/Classes/MWMBookmarkColorViewController.mm @@ -11,6 +11,7 @@ #import "MWMBookmarkColorCell.h" #import "MWMPlacePageEntity.h" #import "MWMPlacePageViewManager.h" +#import "UIViewController+navigation.h" extern NSArray * const kBookmarkColorsVariant; @@ -31,20 +32,9 @@ static NSString * const kBookmarkColorCellIdentifier = @"MWMBookmarkColorCell"; - (void)viewDidLoad { [super viewDidLoad]; - [self.iPadOwnerNavigationController setNavigationBarHidden:NO]; self.title = L(@"bookmark_color"); [self.tableView registerNib:[UINib nibWithNibName:kBookmarkColorCellIdentifier bundle:nil] forCellReuseIdentifier:kBookmarkColorCellIdentifier]; self.colorWasChanged = NO; - if (!self.iPadOwnerNavigationController) - return; - - 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]; - [self.navigationItem setLeftBarButtonItem:[[UIBarButtonItem alloc] initWithCustomView:backButton]]; } - (void)viewWillAppear:(BOOL)animated @@ -52,10 +42,20 @@ static NSString * const kBookmarkColorCellIdentifier = @"MWMBookmarkColorCell"; [super viewWillAppear:animated]; [self configureTableViewForOrientation:self.interfaceOrientation]; [self.tableView reloadData]; + if (!self.iPadOwnerNavigationController) + return; + + [self.iPadOwnerNavigationController setNavigationBarHidden:NO]; + CGFloat const bottomOffset = 88.; + self.iPadOwnerNavigationController.view.height = self.tableView.height + bottomOffset; + [self showBackButton]; } - (void)backTap { + if (self.iPadOwnerNavigationController) + [self.iPadOwnerNavigationController setNavigationBarHidden:YES]; + [self.navigationController popViewControllerAnimated:YES]; } @@ -113,8 +113,6 @@ static NSString * const kBookmarkColorCellIdentifier = @"MWMBookmarkColorCell"; [super viewWillDisappear:animated]; if (self.colorWasChanged && !self.iPadOwnerNavigationController) [self.placePageManager reloadBookmark]; - else - self.iPadOwnerNavigationController.navigationBar.hidden = YES; } @end diff --git a/iphone/Maps/Classes/MWMBookmarkDescriptionViewController.mm b/iphone/Maps/Classes/MWMBookmarkDescriptionViewController.mm index 0a83e931aa..4d6e2c5b81 100644 --- a/iphone/Maps/Classes/MWMBookmarkDescriptionViewController.mm +++ b/iphone/Maps/Classes/MWMBookmarkDescriptionViewController.mm @@ -11,6 +11,7 @@ #import "MWMPlacePage.h" #import "MWMPlacePageEntity.h" #import "UIKitCategories.h" +#import "UIViewController+Navigation.h" static NSString * const kBookmarkDescriptionViewControllerNibName = @"MWMBookmarkDescriptionViewController"; static CGFloat const kIpadPlacePageDefaultHeight = 288.; @@ -38,7 +39,6 @@ typedef NS_ENUM(NSUInteger, BookmarkDescriptionState) @implementation MWMBookmarkDescriptionViewController - - (instancetype)initWithPlacePageManager:(MWMPlacePageViewManager *)manager { self = [super initWithNibName:kBookmarkDescriptionViewControllerNibName bundle:nil]; @@ -51,7 +51,6 @@ typedef NS_ENUM(NSUInteger, BookmarkDescriptionState) - (void)viewDidLoad { [super viewDidLoad]; - [self.iPadOwnerNavigationController setNavigationBarHidden:NO]; self.navigationItem.title = L(@"description"); MWMPlacePageEntity const * entity = self.manager.entity; @@ -63,11 +62,8 @@ typedef NS_ENUM(NSUInteger, BookmarkDescriptionState) 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]]; + UIBarButtonItem * leftButton = [[UIBarButtonItem alloc] initWithCustomView:self.backButton]; + [self.navigationItem setLeftBarButtonItem:leftButton]; return; } @@ -85,21 +81,14 @@ typedef NS_ENUM(NSUInteger, BookmarkDescriptionState) [super viewWillAppear:animated]; if (!self.iPadOwnerNavigationController) return; + + [self.iPadOwnerNavigationController setNavigationBarHidden:NO]; CGFloat const bottomOffset = 12.; self.iPadOwnerNavigationController.view.height = kIpadPlacePageDefaultHeight; self.textView.height = kIpadPlacePageDefaultHeight - bottomOffset; self.webView.height = kIpadPlacePageDefaultHeight - bottomOffset; } -- (void)viewWillDisappear:(BOOL)animated -{ - [super viewWillDisappear:animated]; - if (!self.iPadOwnerNavigationController) - return; - - self.iPadOwnerNavigationController.navigationBar.hidden = YES; -} - - (void)setState:(BookmarkDescriptionState)state { MWMPlacePageEntity * entity = self.manager.entity; @@ -155,7 +144,7 @@ typedef NS_ENUM(NSUInteger, BookmarkDescriptionState) - (void)configureNavigationBarForView { - self.leftButton = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"NavigationBarBackButton"] style:UIBarButtonItemStylePlain target:self action:@selector(backTap)]; + self.leftButton = [[UIBarButtonItem alloc] initWithCustomView:self.backButton]; self.rightButton = [[UIBarButtonItem alloc] initWithTitle:L(@"edit") style:UIBarButtonItemStylePlain target:self action:@selector(editTap)]; [self setupButtons]; } @@ -204,7 +193,7 @@ typedef NS_ENUM(NSUInteger, BookmarkDescriptionState) [self.navigationController popViewControllerAnimated:YES]; return; } - + [self.iPadOwnerNavigationController setNavigationBarHidden:YES]; [UIView animateWithDuration:0.1 animations:^ { self.iPadOwnerNavigationController.view.height = self.realPlacePageHeight; @@ -250,4 +239,17 @@ typedef NS_ENUM(NSUInteger, BookmarkDescriptionState) return YES; } +#pragma mark - Buttons + +- (UIButton *)backButton +{ + UIImage * backImage = [UIImage imageNamed:@"NavigationBarBackButton"]; + CGFloat const imageSide = backImage.size.width; + UIButton * button = [[UIButton alloc] initWithFrame:CGRectMake(0., 0., imageSide, imageSide)]; + [button setImage:backImage forState:UIControlStateNormal]; + [button addTarget:self action:@selector(backTap) forControlEvents:UIControlEventTouchUpInside]; + button.imageEdgeInsets = UIEdgeInsetsMake(0., -imageSide, 0., 0.); + return button; +} + @end diff --git a/iphone/Maps/Classes/MWMPlacePageBookmarkCell.mm b/iphone/Maps/Classes/MWMPlacePageBookmarkCell.mm index 520488b4e9..f83db6a089 100644 --- a/iphone/Maps/Classes/MWMPlacePageBookmarkCell.mm +++ b/iphone/Maps/Classes/MWMPlacePageBookmarkCell.mm @@ -22,6 +22,7 @@ extern NSString * const kBookmarkCellWebViewDidFinishLoadContetnNotification = @ @property (weak, nonatomic, readwrite) IBOutlet UIButton * categoryButton; @property (weak, nonatomic, readwrite) IBOutlet UIButton * markButton; @property (weak, nonatomic, readwrite) IBOutlet UILabel * descriptionLabel; +@property (weak, nonatomic) IBOutlet UIImageView * icon; @property (weak, nonatomic) IBOutlet UIView * firstSeparatorView; @property (weak, nonatomic) IBOutlet UIView * secondSeparatorView; @@ -67,6 +68,13 @@ extern NSString * const kBookmarkCellWebViewDidFinishLoadContetnNotification = @ [textField resignFirstResponder]; } +- (void)layoutSubviews +{ + CGFloat const leftOffset = 16.; + CGFloat const topOffset = 14.; + self.icon.origin = CGPointMake(leftOffset, topOffset); +} + - (BOOL)textFieldShouldClear:(UITextField *)textField { return YES; diff --git a/iphone/Maps/Classes/MWMPlacePageInfoCell.mm b/iphone/Maps/Classes/MWMPlacePageInfoCell.mm index a986f77780..f2d5eef232 100644 --- a/iphone/Maps/Classes/MWMPlacePageInfoCell.mm +++ b/iphone/Maps/Classes/MWMPlacePageInfoCell.mm @@ -61,7 +61,7 @@ extern NSString * const kUserDefaultsLatLonAsDMSKey; UIImage * image = [UIImage imageNamed:imageName]; self.type = type; - [self.imageView setImage:image]; + self.icon.image = image; if ([self.textContainer isKindOfClass:[UITextView class]]) [self.textContainer setAttributedText:[[NSAttributedString alloc] initWithString:info attributes:@{NSFontAttributeName : [UIFont fontWithName:@"HelveticaNeue-Light" size:16.]}]]; @@ -78,6 +78,14 @@ extern NSString * const kUserDefaultsLatLonAsDMSKey; return YES; } +- (void)layoutSubviews +{ + CGFloat const leftOffset = 16.; + CGFloat const topOffset = 14.;; + self.icon.origin = CGPointMake(leftOffset, topOffset); + [self.textContainer setMinX:3 * leftOffset]; +} + - (IBAction)cellTap { if (self.type != MWMPlacePageMetadataTypeCoordinate) diff --git a/iphone/Maps/Classes/MWMiPadPlacePage.mm b/iphone/Maps/Classes/MWMiPadPlacePage.mm index 431f0f0ce5..80c9079e18 100644 --- a/iphone/Maps/Classes/MWMiPadPlacePage.mm +++ b/iphone/Maps/Classes/MWMiPadPlacePage.mm @@ -15,13 +15,14 @@ #import "SelectSetVC.h" #import "UIViewController+Navigation.h" #import "MWMBookmarkDescriptionViewController.h" +#import "ViewController.h" extern CGFloat kBookmarkCellHeight; static CGFloat const kLeftOffset = 12.; static CGFloat const kTopOffset = 36.; static CGFloat const kBottomOffset = 12.; -@interface MWMiPadPlacePageViewController : UIViewController +@interface MWMiPadPlacePageViewController : ViewController @end @@ -74,7 +75,7 @@ static CGFloat const kBottomOffset = 12.; - (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; + CGFloat const height = count > 1 ? ((UIViewController *)self.viewControllers[count - 2]).view.height : 0.0; [UIView animateWithDuration:0.1 animations:^ { diff --git a/iphone/Maps/Classes/PlacePageBookmarkCell.xib b/iphone/Maps/Classes/PlacePageBookmarkCell.xib index d50f8e90f1..343250755c 100644 --- a/iphone/Maps/Classes/PlacePageBookmarkCell.xib +++ b/iphone/Maps/Classes/PlacePageBookmarkCell.xib @@ -20,21 +20,20 @@ - + - + - - - + + + + + + + - + @@ -101,6 +104,7 @@ + @@ -109,6 +113,7 @@ + diff --git a/iphone/Maps/Classes/PlacePageInfoCell.xib b/iphone/Maps/Classes/PlacePageInfoCell.xib index f67d2d9d8b..7fe4ff4bf2 100644 --- a/iphone/Maps/Classes/PlacePageInfoCell.xib +++ b/iphone/Maps/Classes/PlacePageInfoCell.xib @@ -1,8 +1,8 @@ - + - + @@ -11,15 +11,15 @@ - + - + - + diff --git a/iphone/Maps/Classes/PlacePageLinkCell.xib b/iphone/Maps/Classes/PlacePageLinkCell.xib index eae94364b6..5b02a00ea7 100644 --- a/iphone/Maps/Classes/PlacePageLinkCell.xib +++ b/iphone/Maps/Classes/PlacePageLinkCell.xib @@ -1,8 +1,8 @@ - + - + @@ -11,18 +11,18 @@ - + - + - + - + Lorem ipsum dolor sit er elit lamet, consectetaur cillium adipisicing pecu, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Nam liber te conscient to factor tum poen legum odioque civiuda. @@ -32,7 +32,7 @@ - + @@ -40,7 +40,7 @@ - + diff --git a/iphone/Maps/Classes/PlacePageNavigationBar.xib b/iphone/Maps/Classes/PlacePageNavigationBar.xib index 1817ae2a94..09272916cf 100644 --- a/iphone/Maps/Classes/PlacePageNavigationBar.xib +++ b/iphone/Maps/Classes/PlacePageNavigationBar.xib @@ -1,8 +1,8 @@ - + - + @@ -14,7 +14,7 @@