Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(10)

Side by Side Diff: ios/chrome/browser/ui/omnibox/omnibox_popup_material_row.mm

Issue 2674543002: Remove logo from Physical Web omnibox suggestions (Closed)
Patch Set: Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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_property_releaser.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"
(...skipping 17 matching lines...) Expand all
28 // Set the append button normal and highlighted images. 28 // Set the append button normal and highlighted images.
29 - (void)updateAppendButtonImages; 29 - (void)updateAppendButtonImages;
30 30
31 @end 31 @end
32 32
33 @implementation OmniboxPopupMaterialRow 33 @implementation OmniboxPopupMaterialRow
34 34
35 @synthesize textTruncatingLabel = _textTruncatingLabel; 35 @synthesize textTruncatingLabel = _textTruncatingLabel;
36 @synthesize detailTruncatingLabel = _detailTruncatingLabel; 36 @synthesize detailTruncatingLabel = _detailTruncatingLabel;
37 @synthesize appendButton = _appendButton; 37 @synthesize appendButton = _appendButton;
38 @synthesize physicalWebButton = _physicalWebButton;
39 @synthesize answerImageView = _answerImageView; 38 @synthesize answerImageView = _answerImageView;
40 @synthesize imageView = _imageView; 39 @synthesize imageView = _imageView;
41 @synthesize rowHeight = _rowHeight; 40 @synthesize rowHeight = _rowHeight;
42 41
43 - (instancetype)initWithStyle:(UITableViewCellStyle)style 42 - (instancetype)initWithStyle:(UITableViewCellStyle)style
44 reuseIdentifier:(NSString*)reuseIdentifier { 43 reuseIdentifier:(NSString*)reuseIdentifier {
45 return [self initWithIncognito:NO]; 44 return [self initWithIncognito:NO];
46 } 45 }
47 46
48 - (instancetype)initWithIncognito:(BOOL)incognito { 47 - (instancetype)initWithIncognito:(BOOL)incognito {
(...skipping 18 matching lines...) Expand all
67 _detailTruncatingLabel.userInteractionEnabled = NO; 66 _detailTruncatingLabel.userInteractionEnabled = NO;
68 [self addSubview:_detailTruncatingLabel]; 67 [self addSubview:_detailTruncatingLabel];
69 68
70 _appendButton = [[UIButton buttonWithType:UIButtonTypeCustom] retain]; 69 _appendButton = [[UIButton buttonWithType:UIButtonTypeCustom] retain];
71 [_appendButton setContentMode:UIViewContentModeRight]; 70 [_appendButton setContentMode:UIViewContentModeRight];
72 [self updateAppendButtonImages]; 71 [self updateAppendButtonImages];
73 // TODO(justincohen): Consider using the UITableViewCell's accessory view. 72 // TODO(justincohen): Consider using the UITableViewCell's accessory view.
74 // The current implementation is from before using a UITableViewCell. 73 // The current implementation is from before using a UITableViewCell.
75 [self addSubview:_appendButton]; 74 [self addSubview:_appendButton];
76 75
77 _physicalWebButton = [[UIButton buttonWithType:UIButtonTypeCustom] retain];
78 [_physicalWebButton setContentMode:UIViewContentModeRight];
79 [self updatePhysicalWebImage];
80 [self addSubview:_physicalWebButton];
81
82 // Leading icon is only displayed on iPad. 76 // Leading icon is only displayed on iPad.
83 if (IsIPadIdiom()) { 77 if (IsIPadIdiom()) {
84 _imageView = [[UIImageView alloc] initWithFrame:CGRectZero]; 78 _imageView = [[UIImageView alloc] initWithFrame:CGRectZero];
85 _imageView.userInteractionEnabled = NO; 79 _imageView.userInteractionEnabled = NO;
86 _imageView.contentMode = UIViewContentModeCenter; 80 _imageView.contentMode = UIViewContentModeCenter;
87 81
88 // TODO(justincohen): Consider using the UITableViewCell's image view. 82 // TODO(justincohen): Consider using the UITableViewCell's image view.
89 // The current implementation is from before using a UITableViewCell. 83 // The current implementation is from before using a UITableViewCell.
90 [self addSubview:_imageView]; 84 [self addSubview:_imageView];
91 } 85 }
(...skipping 18 matching lines...) Expand all
110 floor((_rowHeight - kImageDimensionLength) / 2), kImageDimensionLength, 104 floor((_rowHeight - kImageDimensionLength) / 2), kImageDimensionLength,
111 kImageDimensionLength); 105 kImageDimensionLength);
112 _imageView.frame = LayoutRectGetRect(imageViewLayout); 106 _imageView.frame = LayoutRectGetRect(imageViewLayout);
113 107
114 LayoutRect trailingAccessoryLayout = LayoutRectMake( 108 LayoutRect trailingAccessoryLayout = LayoutRectMake(
115 CGRectGetWidth(self.bounds) - kAppendButtonSize - 109 CGRectGetWidth(self.bounds) - kAppendButtonSize -
116 kAppendButtonTrailingMargin, 110 kAppendButtonTrailingMargin,
117 CGRectGetWidth(self.bounds), floor((_rowHeight - kAppendButtonSize) / 2), 111 CGRectGetWidth(self.bounds), floor((_rowHeight - kAppendButtonSize) / 2),
118 kAppendButtonSize, kAppendButtonSize); 112 kAppendButtonSize, kAppendButtonSize);
119 _appendButton.frame = LayoutRectGetRect(trailingAccessoryLayout); 113 _appendButton.frame = LayoutRectGetRect(trailingAccessoryLayout);
120 _physicalWebButton.frame = LayoutRectGetRect(trailingAccessoryLayout);
121 } 114 }
122 115
123 - (void)updateLeadingImage:(int)imageID { 116 - (void)updateLeadingImage:(int)imageID {
124 _imageView.image = NativeImage(imageID); 117 _imageView.image = NativeImage(imageID);
125 118
126 // Adjust the vertical position based on the current size of the row. 119 // Adjust the vertical position based on the current size of the row.
127 CGRect frame = _imageView.frame; 120 CGRect frame = _imageView.frame;
128 frame.origin.y = floor((_rowHeight - kImageDimensionLength) / 2); 121 frame.origin.y = floor((_rowHeight - kImageDimensionLength) / 2);
129 _imageView.frame = frame; 122 _imageView.frame = frame;
130 } 123 }
(...skipping 28 matching lines...) Expand all
159 [_appendButton setImage:appendImage forState:UIControlStateNormal]; 152 [_appendButton setImage:appendImage forState:UIControlStateNormal];
160 int appendSelectedResourceID = 153 int appendSelectedResourceID =
161 _incognito ? IDR_IOS_OMNIBOX_KEYBOARD_VIEW_APPEND_INCOGNITO_HIGHLIGHTED 154 _incognito ? IDR_IOS_OMNIBOX_KEYBOARD_VIEW_APPEND_INCOGNITO_HIGHLIGHTED
162 : IDR_IOS_OMNIBOX_KEYBOARD_VIEW_APPEND_HIGHLIGHTED; 155 : IDR_IOS_OMNIBOX_KEYBOARD_VIEW_APPEND_HIGHLIGHTED;
163 UIImage* appendImageSelected = 156 UIImage* appendImageSelected =
164 NativeReversableImage(appendSelectedResourceID, YES); 157 NativeReversableImage(appendSelectedResourceID, YES);
165 [_appendButton setImage:appendImageSelected 158 [_appendButton setImage:appendImageSelected
166 forState:UIControlStateHighlighted]; 159 forState:UIControlStateHighlighted];
167 } 160 }
168 161
169 - (void)updatePhysicalWebImage {
170 UIImage* physicalWebImage = NativeImage(IDR_IOS_OMNIBOX_PHYSICAL_WEB);
rohitrao (ping after 24h) 2017/02/03 21:11:10 Are these two images used anywhere else? Can they
mattreynolds 2017/02/03 22:41:45 They're unused, I'll remove them.
171 [_physicalWebButton setImage:physicalWebImage forState:UIControlStateNormal];
172
173 UIImage* physicalWebImageSelected =
174 NativeImage(IDR_IOS_OMNIBOX_PHYSICAL_WEB_HIGHLIGHTED);
175 [_physicalWebButton setImage:physicalWebImageSelected
176 forState:UIControlStateHighlighted];
177 }
178
179 - (NSString*)accessibilityLabel { 162 - (NSString*)accessibilityLabel {
180 return _textTruncatingLabel.attributedText.string; 163 return _textTruncatingLabel.attributedText.string;
181 } 164 }
182 165
183 - (NSString*)accessibilityValue { 166 - (NSString*)accessibilityValue {
184 return _detailTruncatingLabel.attributedText.string; 167 return _detailTruncatingLabel.attributedText.string;
185 } 168 }
186 169
187 @end 170 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698