| OLD | NEW |
| 1 // Copyright (c) 2014 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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/omnibox/omnibox_popup_material_row.h" | 5 #import "ios/chrome/browser/ui/omnibox/omnibox_popup_material_row.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 #import "ios/chrome/browser/ui/omnibox/truncating_attributed_label.h" | 9 #import "ios/chrome/browser/ui/omnibox/truncating_attributed_label.h" |
| 10 #include "ios/chrome/browser/ui/rtl_geometry.h" | 10 #include "ios/chrome/browser/ui/rtl_geometry.h" |
| 11 #include "ios/chrome/browser/ui/ui_util.h" | 11 #include "ios/chrome/browser/ui/ui_util.h" |
| 12 #import "ios/chrome/browser/ui/uikit_ui_util.h" | 12 #import "ios/chrome/browser/ui/uikit_ui_util.h" |
| 13 #include "ios/chrome/grit/ios_theme_resources.h" | 13 #include "ios/chrome/grit/ios_theme_resources.h" |
| 14 | 14 |
| 15 namespace { | 15 namespace { |
| 16 const CGFloat kImageDimensionLength = 19.0; | 16 const CGFloat kImageDimensionLength = 19.0; |
| 17 const CGFloat kLeadingPaddingIpad = 164; | 17 const CGFloat kLeadingPaddingIpad = 164; |
| 18 const CGFloat kLeadingPaddingIpadCompact = 71; | 18 const CGFloat kLeadingPaddingIpadCompact = 71; |
| 19 const CGFloat kAppendButtonTrailingMargin = 4; | 19 const CGFloat kAppendButtonTrailingMargin = 4; |
| 20 const CGFloat kAppendButtonSize = 48.0; | 20 const CGFloat kAppendButtonSize = 48.0; |
| 21 } | 21 } |
| 22 | 22 |
| 23 @interface OmniboxPopupMaterialRow () { | 23 @interface OmniboxPopupMaterialRow () { |
| 24 BOOL _incognito; | 24 BOOL _incognito; |
| 25 base::mac::ObjCPropertyReleaser _propertyReleaser_OmniboxPopupMaterialRow; | |
| 26 } | 25 } |
| 27 | 26 |
| 28 // Set the append button normal and highlighted images. | 27 // Set the append button normal and highlighted images. |
| 29 - (void)updateAppendButtonImages; | 28 - (void)updateAppendButtonImages; |
| 30 | 29 |
| 31 @end | 30 @end |
| 32 | 31 |
| 33 @implementation OmniboxPopupMaterialRow | 32 @implementation OmniboxPopupMaterialRow |
| 34 | 33 |
| 35 @synthesize textTruncatingLabel = _textTruncatingLabel; | 34 @synthesize textTruncatingLabel = _textTruncatingLabel; |
| 36 @synthesize detailTruncatingLabel = _detailTruncatingLabel; | 35 @synthesize detailTruncatingLabel = _detailTruncatingLabel; |
| 37 @synthesize appendButton = _appendButton; | 36 @synthesize appendButton = _appendButton; |
| 38 @synthesize answerImageView = _answerImageView; | 37 @synthesize answerImageView = _answerImageView; |
| 39 @synthesize imageView = _imageView; | 38 @synthesize imageView = _imageView; |
| 40 @synthesize rowHeight = _rowHeight; | 39 @synthesize rowHeight = _rowHeight; |
| 41 | 40 |
| 42 - (instancetype)initWithStyle:(UITableViewCellStyle)style | 41 - (instancetype)initWithStyle:(UITableViewCellStyle)style |
| 43 reuseIdentifier:(NSString*)reuseIdentifier { | 42 reuseIdentifier:(NSString*)reuseIdentifier { |
| 44 return [self initWithIncognito:NO]; | 43 return [self initWithIncognito:NO]; |
| 45 } | 44 } |
| 46 | 45 |
| 47 - (instancetype)initWithIncognito:(BOOL)incognito { | 46 - (instancetype)initWithIncognito:(BOOL)incognito { |
| 48 self = [super initWithStyle:UITableViewCellStyleDefault | 47 self = [super initWithStyle:UITableViewCellStyleDefault |
| 49 reuseIdentifier:@"OmniboxPopupMaterialRow"]; | 48 reuseIdentifier:@"OmniboxPopupMaterialRow"]; |
| 50 if (self) { | 49 if (self) { |
| 51 self.isAccessibilityElement = YES; | 50 self.isAccessibilityElement = YES; |
| 52 self.backgroundColor = [UIColor clearColor]; | 51 self.backgroundColor = [UIColor clearColor]; |
| 53 _incognito = incognito; | 52 _incognito = incognito; |
| 54 _propertyReleaser_OmniboxPopupMaterialRow.Init( | |
| 55 self, [OmniboxPopupMaterialRow class]); | |
| 56 | |
| 57 _textTruncatingLabel = | 53 _textTruncatingLabel = |
| 58 [[OmniboxPopupTruncatingLabel alloc] initWithFrame:CGRectZero]; | 54 [[OmniboxPopupTruncatingLabel alloc] initWithFrame:CGRectZero]; |
| 59 _textTruncatingLabel.autoresizingMask = UIViewAutoresizingFlexibleWidth; | 55 _textTruncatingLabel.autoresizingMask = UIViewAutoresizingFlexibleWidth; |
| 60 _textTruncatingLabel.userInteractionEnabled = NO; | 56 _textTruncatingLabel.userInteractionEnabled = NO; |
| 61 [self addSubview:_textTruncatingLabel]; | 57 [self addSubview:_textTruncatingLabel]; |
| 62 | 58 |
| 63 _detailTruncatingLabel = | 59 _detailTruncatingLabel = |
| 64 [[OmniboxPopupTruncatingLabel alloc] initWithFrame:CGRectZero]; | 60 [[OmniboxPopupTruncatingLabel alloc] initWithFrame:CGRectZero]; |
| 65 _detailTruncatingLabel.autoresizingMask = UIViewAutoresizingFlexibleWidth; | 61 _detailTruncatingLabel.autoresizingMask = UIViewAutoresizingFlexibleWidth; |
| 66 _detailTruncatingLabel.userInteractionEnabled = NO; | 62 _detailTruncatingLabel.userInteractionEnabled = NO; |
| (...skipping 18 matching lines...) Expand all Loading... |
| 85 } | 81 } |
| 86 | 82 |
| 87 _answerImageView = [[UIImageView alloc] initWithFrame:CGRectZero]; | 83 _answerImageView = [[UIImageView alloc] initWithFrame:CGRectZero]; |
| 88 _answerImageView.userInteractionEnabled = NO; | 84 _answerImageView.userInteractionEnabled = NO; |
| 89 _answerImageView.contentMode = UIViewContentModeScaleAspectFit; | 85 _answerImageView.contentMode = UIViewContentModeScaleAspectFit; |
| 90 [self addSubview:_answerImageView]; | 86 [self addSubview:_answerImageView]; |
| 91 } | 87 } |
| 92 return self; | 88 return self; |
| 93 } | 89 } |
| 94 | 90 |
| 91 - (void)dealloc { |
| 92 base::mac::ReleaseProperties(self); |
| 93 [super dealloc]; |
| 94 } |
| 95 |
| 95 - (void)layoutSubviews { | 96 - (void)layoutSubviews { |
| 96 [super layoutSubviews]; | 97 [super layoutSubviews]; |
| 97 [self layoutAccessoryViews]; | 98 [self layoutAccessoryViews]; |
| 98 } | 99 } |
| 99 | 100 |
| 100 - (void)layoutAccessoryViews { | 101 - (void)layoutAccessoryViews { |
| 101 LayoutRect imageViewLayout = LayoutRectMake( | 102 LayoutRect imageViewLayout = LayoutRectMake( |
| 102 IsCompactTablet() ? kLeadingPaddingIpadCompact : kLeadingPaddingIpad, | 103 IsCompactTablet() ? kLeadingPaddingIpadCompact : kLeadingPaddingIpad, |
| 103 CGRectGetWidth(self.bounds), | 104 CGRectGetWidth(self.bounds), |
| 104 floor((_rowHeight - kImageDimensionLength) / 2), kImageDimensionLength, | 105 floor((_rowHeight - kImageDimensionLength) / 2), kImageDimensionLength, |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 161 | 162 |
| 162 - (NSString*)accessibilityLabel { | 163 - (NSString*)accessibilityLabel { |
| 163 return _textTruncatingLabel.attributedText.string; | 164 return _textTruncatingLabel.attributedText.string; |
| 164 } | 165 } |
| 165 | 166 |
| 166 - (NSString*)accessibilityValue { | 167 - (NSString*)accessibilityValue { |
| 167 return _detailTruncatingLabel.attributedText.string; | 168 return _detailTruncatingLabel.attributedText.string; |
| 168 } | 169 } |
| 169 | 170 |
| 170 @end | 171 @end |
| OLD | NEW |