| 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_editing_bar.h" | 5 #import "ios/chrome/browser/ui/bookmarks/bars/bookmark_editing_bar.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/mac/objc_property_releaser.h" | 8 #include "base/mac/objc_release_properties.h" |
| 9 #include "base/mac/scoped_nsobject.h" | 9 #include "base/mac/scoped_nsobject.h" |
| 10 #include "base/strings/sys_string_conversions.h" | 10 #include "base/strings/sys_string_conversions.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/grit/ios_strings.h" | 14 #include "ios/chrome/grit/ios_strings.h" |
| 15 #import "ios/third_party/material_components_ios/src/components/Typography/src/M
aterialTypography.h" | 15 #import "ios/third_party/material_components_ios/src/components/Typography/src/M
aterialTypography.h" |
| 16 #include "ui/base/l10n/l10n_util.h" | 16 #include "ui/base/l10n/l10n_util.h" |
| 17 | 17 |
| 18 namespace { | 18 namespace { |
| 19 // The distance between buttons. | 19 // The distance between buttons. |
| 20 CGFloat kInterButtonMargin = 24; | 20 CGFloat kInterButtonMargin = 24; |
| 21 } // namespace | 21 } // namespace |
| 22 | 22 |
| 23 @interface BookmarkEditingBar () { | 23 @interface BookmarkEditingBar () |
| 24 base::mac::ObjCPropertyReleaser _propertyReleaser_BookmarkEditingBar; | |
| 25 } | |
| 26 @property(nonatomic, retain) BookmarkExtendedButton* cancelButton; | 24 @property(nonatomic, retain) BookmarkExtendedButton* cancelButton; |
| 27 // This label is slightly left off center, and reflects the number of bookmarks | 25 // This label is slightly left off center, and reflects the number of bookmarks |
| 28 // selected for editing. | 26 // selected for editing. |
| 29 @property(nonatomic, retain) UILabel* countLabel; | 27 @property(nonatomic, retain) UILabel* countLabel; |
| 30 @property(nonatomic, retain) BookmarkExtendedButton* deleteButton; | 28 @property(nonatomic, retain) BookmarkExtendedButton* deleteButton; |
| 31 @property(nonatomic, retain) UIView* dropShadow; | 29 @property(nonatomic, retain) UIView* dropShadow; |
| 32 @property(nonatomic, retain) BookmarkExtendedButton* editButton; | 30 @property(nonatomic, retain) BookmarkExtendedButton* editButton; |
| 33 @property(nonatomic, retain) BookmarkExtendedButton* moveButton; | 31 @property(nonatomic, retain) BookmarkExtendedButton* moveButton; |
| 34 @end | 32 @end |
| 35 | 33 |
| 36 @implementation BookmarkEditingBar | 34 @implementation BookmarkEditingBar |
| 37 @synthesize cancelButton = _cancelButton; | 35 @synthesize cancelButton = _cancelButton; |
| 38 @synthesize countLabel = _countLabel; | 36 @synthesize countLabel = _countLabel; |
| 39 @synthesize deleteButton = _deleteButton; | 37 @synthesize deleteButton = _deleteButton; |
| 40 @synthesize dropShadow = _dropShadow; | 38 @synthesize dropShadow = _dropShadow; |
| 41 @synthesize editButton = _editButton; | 39 @synthesize editButton = _editButton; |
| 42 @synthesize moveButton = _moveButton; | 40 @synthesize moveButton = _moveButton; |
| 43 | 41 |
| 44 - (id)initWithFrame:(CGRect)outerFrame { | 42 - (id)initWithFrame:(CGRect)outerFrame { |
| 45 self = [super initWithFrame:outerFrame]; | 43 self = [super initWithFrame:outerFrame]; |
| 46 if (self) { | 44 if (self) { |
| 47 _propertyReleaser_BookmarkEditingBar.Init(self, [BookmarkEditingBar class]); | |
| 48 self.backgroundColor = bookmark_utils_ios::blueColor(); | 45 self.backgroundColor = bookmark_utils_ios::blueColor(); |
| 49 | 46 |
| 50 CGRect bounds = self.contentView.bounds; | 47 CGRect bounds = self.contentView.bounds; |
| 51 | 48 |
| 52 // Add the cancel button to the leading side of the bar. | 49 // Add the cancel button to the leading side of the bar. |
| 53 CGFloat cancelButtonWidth = 24; | 50 CGFloat cancelButtonWidth = 24; |
| 54 CGFloat cancelButtonHeight = 24; | 51 CGFloat cancelButtonHeight = 24; |
| 55 CGFloat cancelButtonY = | 52 CGFloat cancelButtonY = |
| 56 floor((bounds.size.height - cancelButtonHeight) / 2); | 53 floor((bounds.size.height - cancelButtonHeight) / 2); |
| 57 CGFloat cancelButtonX = cancelButtonY; | 54 CGFloat cancelButtonX = cancelButtonY; |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 171 CGRectMake(0, CGRectGetHeight(self.bounds), | 168 CGRectMake(0, CGRectGetHeight(self.bounds), |
| 172 CGRectGetWidth(shadow.frame), CGRectGetHeight(shadow.frame)); | 169 CGRectGetWidth(shadow.frame), CGRectGetHeight(shadow.frame)); |
| 173 [self addSubview:shadow]; | 170 [self addSubview:shadow]; |
| 174 self.dropShadow = shadow; | 171 self.dropShadow = shadow; |
| 175 | 172 |
| 176 [self updateUIWithBookmarkCount:0 folderCount:0]; | 173 [self updateUIWithBookmarkCount:0 folderCount:0]; |
| 177 } | 174 } |
| 178 return self; | 175 return self; |
| 179 } | 176 } |
| 180 | 177 |
| 178 - (void)dealloc { |
| 179 base::mac::ReleaseProperties(self); |
| 180 [super dealloc]; |
| 181 } |
| 182 |
| 181 - (void)setCancelTarget:(id)target action:(SEL)action { | 183 - (void)setCancelTarget:(id)target action:(SEL)action { |
| 182 [self.cancelButton addTarget:target | 184 [self.cancelButton addTarget:target |
| 183 action:action | 185 action:action |
| 184 forControlEvents:UIControlEventTouchUpInside]; | 186 forControlEvents:UIControlEventTouchUpInside]; |
| 185 } | 187 } |
| 186 | 188 |
| 187 - (void)setEditTarget:(id)target action:(SEL)action { | 189 - (void)setEditTarget:(id)target action:(SEL)action { |
| 188 [self.editButton addTarget:target | 190 [self.editButton addTarget:target |
| 189 action:action | 191 action:action |
| 190 forControlEvents:UIControlEventTouchUpInside]; | 192 forControlEvents:UIControlEventTouchUpInside]; |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 243 self.editButton.hidden = YES; | 245 self.editButton.hidden = YES; |
| 244 self.moveButton.hidden = NO; | 246 self.moveButton.hidden = NO; |
| 245 self.deleteButton.hidden = NO; | 247 self.deleteButton.hidden = NO; |
| 246 } | 248 } |
| 247 | 249 |
| 248 - (void)showShadow:(BOOL)show { | 250 - (void)showShadow:(BOOL)show { |
| 249 self.dropShadow.hidden = !show; | 251 self.dropShadow.hidden = !show; |
| 250 } | 252 } |
| 251 | 253 |
| 252 @end | 254 @end |
| OLD | NEW |