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

Unified Diff: ios/chrome/browser/ui/omnibox/omnibox_popup_material_row.mm

Issue 2602903002: Factor iOS native image loading into a utility function. (Closed)
Patch Set: Fixed BUILD files. Created 4 years 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 side-by-side diff with in-line comments
Download patch
Index: ios/chrome/browser/ui/omnibox/omnibox_popup_material_row.mm
diff --git a/ios/chrome/browser/ui/omnibox/omnibox_popup_material_row.mm b/ios/chrome/browser/ui/omnibox/omnibox_popup_material_row.mm
index 445950fcd22d49645a3264ecd338a131bde84e71..be53f8a65c412d7c29df56ea0128686327930a0a 100644
--- a/ios/chrome/browser/ui/omnibox/omnibox_popup_material_row.mm
+++ b/ios/chrome/browser/ui/omnibox/omnibox_popup_material_row.mm
@@ -11,7 +11,6 @@
#include "ios/chrome/browser/ui/ui_util.h"
#import "ios/chrome/browser/ui/uikit_ui_util.h"
#include "ios/chrome/grit/ios_theme_resources.h"
-#include "ui/base/resource/resource_bundle.h"
namespace {
const CGFloat kImageDimensionLength = 19.0;
@@ -28,9 +27,6 @@ const CGFloat kAppendButtonTrailingMargin = 4;
// Set the append button normal and highlighted images.
- (void)updateAppendButtonImages;
-// Set the Physical Web image view image.
-- (void)updatePhysicalWebImage;
-
@end
@implementation OmniboxPopupMaterialRow
@@ -80,7 +76,7 @@ const CGFloat kAppendButtonTrailingMargin = 4;
_physicalWebImageView = [[UIImageView alloc] initWithFrame:CGRectZero];
_physicalWebImageView.userInteractionEnabled = NO;
_physicalWebImageView.contentMode = UIViewContentModeCenter;
- [self updatePhysicalWebImage];
+ _physicalWebImageView.image = NativeImage(IDR_IOS_OMNIBOX_PHYSICAL_WEB);
[self addSubview:_physicalWebImageView];
// Left icon is only displayed on iPad.
@@ -127,11 +123,8 @@ const CGFloat kAppendButtonTrailingMargin = 4;
_physicalWebImageView.frame = LayoutRectGetRect(rightAccessoryLayout);
}
-- (void)updateLeftImage:(int)imageId {
- // Update the image.
- ResourceBundle& rb = ResourceBundle::GetSharedInstance();
- UIImage* image = rb.GetNativeImageNamed(imageId).ToUIImage();
- _imageView.image = image;
+- (void)updateLeftImage:(int)imageID {
+ _imageView.image = NativeImage(imageID);
// Adjust the vertical position based on the current size of the row.
CGRect frame = _imageView.frame;
@@ -161,32 +154,20 @@ const CGFloat kAppendButtonTrailingMargin = 4;
}
- (void)updateAppendButtonImages {
- ResourceBundle& rb = ResourceBundle::GetSharedInstance();
int appendResourceID = _incognito
? IDR_IOS_OMNIBOX_KEYBOARD_VIEW_APPEND_INCOGNITO
: IDR_IOS_OMNIBOX_KEYBOARD_VIEW_APPEND;
- UIImage* appendImage = rb.GetNativeImageNamed(appendResourceID).ToUIImage();
- if (UseRTLLayout()) {
- appendImage = [appendImage imageFlippedForRightToLeftLayoutDirection];
- }
+ UIImage* appendImage = NativeReversableImage(appendResourceID, YES);
[_appendButton setImage:appendImage forState:UIControlStateNormal];
int appendSelectedResourceID =
_incognito ? IDR_IOS_OMNIBOX_KEYBOARD_VIEW_APPEND_INCOGNITO_HIGHLIGHTED
: IDR_IOS_OMNIBOX_KEYBOARD_VIEW_APPEND_HIGHLIGHTED;
- UIImage* appendImageSelected =
- rb.GetNativeImageNamed(appendSelectedResourceID).ToUIImage();
+ UIImage* appendImageSelected = NativeImage(appendSelectedResourceID);
[_appendButton setImage:appendImageSelected
forState:UIControlStateHighlighted];
}
-- (void)updatePhysicalWebImage {
- ResourceBundle& rb = ResourceBundle::GetSharedInstance();
- UIImage* physicalWebImage =
- rb.GetNativeImageNamed(IDR_IOS_OMNIBOX_PHYSICAL_WEB).ToUIImage();
- _physicalWebImageView.image = physicalWebImage;
-}
-
- (NSString*)accessibilityLabel {
return _textTruncatingLabel.attributedText.string;
}

Powered by Google App Engine
This is Rietveld 408576698