| 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/bookmark_menu_cell.h" | 5 #import "ios/chrome/browser/ui/bookmarks/bookmark_menu_cell.h" |
| 6 | 6 |
| 7 #include "base/mac/objc_property_releaser.h" | 7 #include "base/mac/objc_release_properties.h" |
| 8 #include "base/mac/scoped_nsobject.h" | 8 #include "base/mac/scoped_nsobject.h" |
| 9 #import "ios/chrome/browser/ui/bookmarks/bookmark_menu_item.h" | 9 #import "ios/chrome/browser/ui/bookmarks/bookmark_menu_item.h" |
| 10 #import "ios/chrome/browser/ui/bookmarks/bookmark_utils_ios.h" | 10 #import "ios/chrome/browser/ui/bookmarks/bookmark_utils_ios.h" |
| 11 #include "ios/chrome/browser/ui/rtl_geometry.h" | 11 #include "ios/chrome/browser/ui/rtl_geometry.h" |
| 12 #include "ios/chrome/browser/ui/ui_util.h" | 12 #include "ios/chrome/browser/ui/ui_util.h" |
| 13 #import "ios/chrome/browser/ui/uikit_ui_util.h" | 13 #import "ios/chrome/browser/ui/uikit_ui_util.h" |
| 14 #import "ios/third_party/material_components_ios/src/components/Ink/src/Material
Ink.h" | 14 #import "ios/third_party/material_components_ios/src/components/Ink/src/Material
Ink.h" |
| 15 #import "ios/third_party/material_components_ios/src/components/Palettes/src/Mat
erialPalettes.h" | 15 #import "ios/third_party/material_components_ios/src/components/Palettes/src/Mat
erialPalettes.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 | 17 |
| 18 namespace { | 18 namespace { |
| 19 CGFloat kTrailingMargin = 16.0; | 19 CGFloat kTrailingMargin = 16.0; |
| 20 } // namespace | 20 } // namespace |
| 21 | 21 |
| 22 @interface BookmarkMenuCell () { | 22 @interface BookmarkMenuCell () |
| 23 base::mac::ObjCPropertyReleaser _propertyReleaser_BookmarkMenuCell; | |
| 24 } | |
| 25 // Set to YES if the cell can be selected. | 23 // Set to YES if the cell can be selected. |
| 26 @property(nonatomic, assign) BOOL isSelectable; | 24 @property(nonatomic, assign) BOOL isSelectable; |
| 27 // Set to YES if the cell should animate on selection. | 25 // Set to YES if the cell should animate on selection. |
| 28 @property(nonatomic, assign) BOOL shouldAnimateHighlight; | 26 @property(nonatomic, assign) BOOL shouldAnimateHighlight; |
| 29 // Icon view. | 27 // Icon view. |
| 30 @property(nonatomic, assign) UIImageView* iconView; | 28 @property(nonatomic, assign) UIImageView* iconView; |
| 31 // Text label. | 29 // Text label. |
| 32 @property(nonatomic, assign) UILabel* itemLabel; | 30 @property(nonatomic, assign) UILabel* itemLabel; |
| 33 // Separator view. Displayed at 1 pixel height on top for some cells. | 31 // Separator view. Displayed at 1 pixel height on top for some cells. |
| 34 @property(nonatomic, assign) UIView* separatorView; | 32 @property(nonatomic, assign) UIView* separatorView; |
| 35 @end | 33 @end |
| 36 | 34 |
| 37 @implementation BookmarkMenuCell | 35 @implementation BookmarkMenuCell |
| 38 @synthesize isSelectable = _isSelectable; | 36 @synthesize isSelectable = _isSelectable; |
| 39 @synthesize shouldAnimateHighlight = _shouldAnimateHighlight; | 37 @synthesize shouldAnimateHighlight = _shouldAnimateHighlight; |
| 40 @synthesize iconView = _iconView; | 38 @synthesize iconView = _iconView; |
| 41 @synthesize itemLabel = _itemLabel; | 39 @synthesize itemLabel = _itemLabel; |
| 42 @synthesize separatorView = _separatorView; | 40 @synthesize separatorView = _separatorView; |
| 43 @synthesize inkView = _inkView; | 41 @synthesize inkView = _inkView; |
| 44 | 42 |
| 45 - (instancetype)initWithStyle:(UITableViewCellStyle)style | 43 - (instancetype)initWithStyle:(UITableViewCellStyle)style |
| 46 reuseIdentifier:(NSString*)reuseIdentifier { | 44 reuseIdentifier:(NSString*)reuseIdentifier { |
| 47 self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]; | 45 self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]; |
| 48 if (self) { | 46 if (self) { |
| 49 _propertyReleaser_BookmarkMenuCell.Init(self, [BookmarkMenuCell class]); | |
| 50 | |
| 51 // Create icon view. | 47 // Create icon view. |
| 52 base::scoped_nsobject<UIImageView> iconView([[UIImageView alloc] init]); | 48 base::scoped_nsobject<UIImageView> iconView([[UIImageView alloc] init]); |
| 53 _iconView = iconView; | 49 _iconView = iconView; |
| 54 | 50 |
| 55 // Create item label. | 51 // Create item label. |
| 56 base::scoped_nsobject<UILabel> itemLabel([[UILabel alloc] init]); | 52 base::scoped_nsobject<UILabel> itemLabel([[UILabel alloc] init]); |
| 57 _itemLabel = itemLabel; | 53 _itemLabel = itemLabel; |
| 58 | 54 |
| 59 self.contentView.layoutMargins = UIEdgeInsetsMakeDirected( | 55 self.contentView.layoutMargins = UIEdgeInsetsMakeDirected( |
| 60 0, bookmark_utils_ios::menuMargin, 0, kTrailingMargin); | 56 0, bookmark_utils_ios::menuMargin, 0, kTrailingMargin); |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 102 ]]; | 98 ]]; |
| 103 _separatorView.translatesAutoresizingMaskIntoConstraints = NO; | 99 _separatorView.translatesAutoresizingMaskIntoConstraints = NO; |
| 104 | 100 |
| 105 // Configure background colors. | 101 // Configure background colors. |
| 106 _separatorView.backgroundColor = [UIColor colorWithWhite:0.0 alpha:.12]; | 102 _separatorView.backgroundColor = [UIColor colorWithWhite:0.0 alpha:.12]; |
| 107 self.backgroundColor = [UIColor clearColor]; | 103 self.backgroundColor = [UIColor clearColor]; |
| 108 } | 104 } |
| 109 return self; | 105 return self; |
| 110 } | 106 } |
| 111 | 107 |
| 108 - (void)dealloc { |
| 109 base::mac::ReleaseProperties(self); |
| 110 [super dealloc]; |
| 111 } |
| 112 |
| 112 - (void)prepareForReuse { | 113 - (void)prepareForReuse { |
| 113 self.shouldAnimateHighlight = NO; | 114 self.shouldAnimateHighlight = NO; |
| 114 self.isSelectable = NO; | 115 self.isSelectable = NO; |
| 115 [self.inkView cancelAllAnimationsAnimated:NO]; | 116 [self.inkView cancelAllAnimationsAnimated:NO]; |
| 116 [super prepareForReuse]; | 117 [super prepareForReuse]; |
| 117 } | 118 } |
| 118 | 119 |
| 119 - (void)setSelected:(BOOL)selected animated:(BOOL)animated { | 120 - (void)setSelected:(BOOL)selected animated:(BOOL)animated { |
| 120 [super setSelected:selected animated:animated]; | 121 [super setSelected:selected animated:animated]; |
| 121 if (IsIPadIdiom()) | 122 if (IsIPadIdiom()) |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 168 // If there is no icon, hide the icon image view so that stack view redraws | 169 // If there is no icon, hide the icon image view so that stack view redraws |
| 169 // without the icon, and vice versa. | 170 // without the icon, and vice versa. |
| 170 self.iconView.hidden = (self.iconView.image == nil); | 171 self.iconView.hidden = (self.iconView.image == nil); |
| 171 } | 172 } |
| 172 | 173 |
| 173 + (NSString*)reuseIdentifier { | 174 + (NSString*)reuseIdentifier { |
| 174 return @"BookmarkMenuCell"; | 175 return @"BookmarkMenuCell"; |
| 175 } | 176 } |
| 176 | 177 |
| 177 @end | 178 @end |
| OLD | NEW |