| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #import "ios/chrome/browser/ui/bookmarks/bars/bookmark_navigation_bar.h" | 5 #import "ios/chrome/browser/ui/bookmarks/bars/bookmark_navigation_bar.h" |
| 6 | 6 |
| 7 #import <QuartzCore/QuartzCore.h> | 7 #import <QuartzCore/QuartzCore.h> |
| 8 | 8 |
| 9 #include "base/mac/objc_property_releaser.h" | 9 #include "base/mac/objc_release_properties.h" |
| 10 #include "base/mac/scoped_nsobject.h" | 10 #include "base/mac/scoped_nsobject.h" |
| 11 #import "ios/chrome/browser/ui/bookmarks/bookmark_extended_button.h" | 11 #import "ios/chrome/browser/ui/bookmarks/bookmark_extended_button.h" |
| 12 #import "ios/chrome/browser/ui/bookmarks/bookmark_utils_ios.h" | 12 #import "ios/chrome/browser/ui/bookmarks/bookmark_utils_ios.h" |
| 13 #import "ios/chrome/browser/ui/rtl_geometry.h" | 13 #import "ios/chrome/browser/ui/rtl_geometry.h" |
| 14 #include "ios/chrome/browser/ui/ui_util.h" | 14 #include "ios/chrome/browser/ui/ui_util.h" |
| 15 #include "ios/chrome/grit/ios_strings.h" | 15 #include "ios/chrome/grit/ios_strings.h" |
| 16 #import "ios/third_party/material_components_ios/src/components/Typography/src/M
aterialTypography.h" | 16 #import "ios/third_party/material_components_ios/src/components/Typography/src/M
aterialTypography.h" |
| 17 #include "ui/base/l10n/l10n_util.h" | 17 #include "ui/base/l10n/l10n_util.h" |
| 18 | 18 |
| 19 namespace { | 19 namespace { |
| 20 const CGFloat kButtonHeight = 24; | 20 const CGFloat kButtonHeight = 24; |
| 21 const CGFloat kButtonWidth = 24; | 21 const CGFloat kButtonWidth = 24; |
| 22 | 22 |
| 23 // The height of the content, not including possible extra space for the status | 23 // The height of the content, not including possible extra space for the status |
| 24 // bar. | 24 // bar. |
| 25 const CGFloat kContentHeight = 56; | 25 const CGFloat kContentHeight = 56; |
| 26 // The distance between buttons. | 26 // The distance between buttons. |
| 27 const CGFloat kInterButtonMargin = 24; | 27 const CGFloat kInterButtonMargin = 24; |
| 28 }; // namespace | 28 }; // namespace |
| 29 | 29 |
| 30 @interface BookmarkNavigationBar () { | 30 @interface BookmarkNavigationBar () |
| 31 base::mac::ObjCPropertyReleaser _propertyReleaser_BookmarkNavigationBar; | |
| 32 } | |
| 33 @property(nonatomic, retain) BookmarkExtendedButton* cancelButton; | 31 @property(nonatomic, retain) BookmarkExtendedButton* cancelButton; |
| 34 // All subviews are added to |contentView|, which allows easy repositioning of | 32 // All subviews are added to |contentView|, which allows easy repositioning of |
| 35 // the content to account for iOS 6 and iOS 7+ layout differences. | 33 // the content to account for iOS 6 and iOS 7+ layout differences. |
| 36 @property(nonatomic, retain) UIView* contentView; | 34 @property(nonatomic, retain) UIView* contentView; |
| 37 @property(nonatomic, retain) BookmarkExtendedButton* backButton; | 35 @property(nonatomic, retain) BookmarkExtendedButton* backButton; |
| 38 @property(nonatomic, retain) BookmarkExtendedButton* editButton; | 36 @property(nonatomic, retain) BookmarkExtendedButton* editButton; |
| 39 @property(nonatomic, retain) BookmarkExtendedButton* menuButton; | 37 @property(nonatomic, retain) BookmarkExtendedButton* menuButton; |
| 40 @property(nonatomic, retain) UILabel* titleLabel; | 38 @property(nonatomic, retain) UILabel* titleLabel; |
| 41 @end | 39 @end |
| 42 | 40 |
| 43 @implementation BookmarkNavigationBar | 41 @implementation BookmarkNavigationBar |
| 44 @synthesize backButton = _backButton; | 42 @synthesize backButton = _backButton; |
| 45 @synthesize cancelButton = _cancelButton; | 43 @synthesize cancelButton = _cancelButton; |
| 46 @synthesize contentView = _contentView; | 44 @synthesize contentView = _contentView; |
| 47 @synthesize editButton = _editButton; | 45 @synthesize editButton = _editButton; |
| 48 @synthesize menuButton = _menuButton; | 46 @synthesize menuButton = _menuButton; |
| 49 @synthesize titleLabel = _titleLabel; | 47 @synthesize titleLabel = _titleLabel; |
| 50 | 48 |
| 51 - (id)initWithFrame:(CGRect)outerFrame { | 49 - (id)initWithFrame:(CGRect)outerFrame { |
| 52 self = [super initWithFrame:outerFrame]; | 50 self = [super initWithFrame:outerFrame]; |
| 53 if (self) { | 51 if (self) { |
| 54 _propertyReleaser_BookmarkNavigationBar.Init(self, | |
| 55 [BookmarkNavigationBar class]); | |
| 56 | |
| 57 self.backgroundColor = bookmark_utils_ios::mainBackgroundColor(); | 52 self.backgroundColor = bookmark_utils_ios::mainBackgroundColor(); |
| 58 self.autoresizingMask = UIViewAutoresizingFlexibleBottomMargin | | 53 self.autoresizingMask = UIViewAutoresizingFlexibleBottomMargin | |
| 59 UIViewAutoresizingFlexibleWidth; | 54 UIViewAutoresizingFlexibleWidth; |
| 60 | 55 |
| 61 // Position the content view at the bottom of |self|. | 56 // Position the content view at the bottom of |self|. |
| 62 CGFloat contentY = CGRectGetHeight(outerFrame) - kContentHeight; | 57 CGFloat contentY = CGRectGetHeight(outerFrame) - kContentHeight; |
| 63 self.contentView = base::scoped_nsobject<UIView>([[UIView alloc] | 58 self.contentView = base::scoped_nsobject<UIView>([[UIView alloc] |
| 64 initWithFrame:CGRectMake(0, contentY, CGRectGetWidth(outerFrame), | 59 initWithFrame:CGRectMake(0, contentY, CGRectGetWidth(outerFrame), |
| 65 kContentHeight)]); | 60 kContentHeight)]); |
| 66 [self addSubview:self.contentView]; | 61 [self addSubview:self.contentView]; |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 179 l10n_util::GetNSString(IDS_IOS_BOOKMARK_NEW_BACK_LABEL); | 174 l10n_util::GetNSString(IDS_IOS_BOOKMARK_NEW_BACK_LABEL); |
| 180 self.backButton.accessibilityIdentifier = @"Parent"; | 175 self.backButton.accessibilityIdentifier = @"Parent"; |
| 181 self.backButton.alpha = 0; | 176 self.backButton.alpha = 0; |
| 182 [self.contentView addSubview:self.backButton]; | 177 [self.contentView addSubview:self.backButton]; |
| 183 | 178 |
| 184 [self setNeedsLayout]; | 179 [self setNeedsLayout]; |
| 185 } | 180 } |
| 186 return self; | 181 return self; |
| 187 } | 182 } |
| 188 | 183 |
| 184 - (void)dealloc { |
| 185 base::mac::ReleaseProperties(self); |
| 186 [super dealloc]; |
| 187 } |
| 188 |
| 189 - (void)layoutSubviews { | 189 - (void)layoutSubviews { |
| 190 [super layoutSubviews]; | 190 [super layoutSubviews]; |
| 191 | 191 |
| 192 // When the alpha of the button is less than this amount, the title is | 192 // When the alpha of the button is less than this amount, the title is |
| 193 // allowed to overrun the button. Generally, layoutSubviews should only be | 193 // allowed to overrun the button. Generally, layoutSubviews should only be |
| 194 // called with buttons having an alpha of 0.0 or 1.0, so the value of this | 194 // called with buttons having an alpha of 0.0 or 1.0, so the value of this |
| 195 // constant doesn't matter too much. | 195 // constant doesn't matter too much. |
| 196 const CGFloat buttonAlphaForTitleOverrun = 0.1; | 196 const CGFloat buttonAlphaForTitleOverrun = 0.1; |
| 197 | 197 |
| 198 LayoutOffset labelTrailing = 0; | 198 LayoutOffset labelTrailing = 0; |
| (...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 351 self.backButton.alpha = 1.0; | 351 self.backButton.alpha = 1.0; |
| 352 } | 352 } |
| 353 completion:^(BOOL finished) { | 353 completion:^(BOOL finished) { |
| 354 if (finished) { | 354 if (finished) { |
| 355 [self setNeedsLayout]; | 355 [self setNeedsLayout]; |
| 356 } | 356 } |
| 357 }]; | 357 }]; |
| 358 } | 358 } |
| 359 | 359 |
| 360 @end | 360 @end |
| OLD | NEW |