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

Side by Side Diff: ios/chrome/browser/ui/bookmarks/bookmark_collection_cells.mm

Issue 2602903002: Factor iOS native image loading into a utility function. (Closed)
Patch Set: Fixed BUILD files. Created 3 years, 11 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 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_collection_cells.h" 5 #import "ios/chrome/browser/ui/bookmarks/bookmark_collection_cells.h"
6 6
7 #import <QuartzCore/QuartzCore.h> 7 #import <QuartzCore/QuartzCore.h>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/mac/objc_property_releaser.h" 10 #include "base/mac/objc_property_releaser.h"
11 #include "base/mac/scoped_nsobject.h" 11 #include "base/mac/scoped_nsobject.h"
12 #import "ios/chrome/browser/ui/bookmarks/bookmark_extended_button.h" 12 #import "ios/chrome/browser/ui/bookmarks/bookmark_extended_button.h"
13 #import "ios/chrome/browser/ui/bookmarks/bookmark_home_view_controller.h" 13 #import "ios/chrome/browser/ui/bookmarks/bookmark_home_view_controller.h"
14 #import "ios/chrome/browser/ui/bookmarks/bookmark_utils_ios.h" 14 #import "ios/chrome/browser/ui/bookmarks/bookmark_utils_ios.h"
15 #import "ios/chrome/browser/ui/rtl_geometry.h" 15 #import "ios/chrome/browser/ui/rtl_geometry.h"
16 #import "ios/chrome/browser/ui/uikit_ui_util.h" 16 #import "ios/chrome/browser/ui/uikit_ui_util.h"
17 #include "ios/chrome/grit/ios_strings.h" 17 #include "ios/chrome/grit/ios_strings.h"
18 #include "ios/chrome/grit/ios_theme_resources.h" 18 #include "ios/chrome/grit/ios_theme_resources.h"
19 #import "ios/third_party/material_components_ios/src/components/Ink/src/Material Ink.h" 19 #import "ios/third_party/material_components_ios/src/components/Ink/src/Material Ink.h"
20 #import "ios/third_party/material_components_ios/src/components/Typography/src/M aterialTypography.h" 20 #import "ios/third_party/material_components_ios/src/components/Typography/src/M aterialTypography.h"
21 #include "ui/base/l10n/l10n_util_mac.h" 21 #include "ui/base/l10n/l10n_util_mac.h"
22 #include "ui/base/resource/resource_bundle.h"
23 #import "ui/gfx/ios/NSString+CrStringDrawing.h" 22 #import "ui/gfx/ios/NSString+CrStringDrawing.h"
24 #include "url/gurl.h" 23 #include "url/gurl.h"
25 24
26 namespace { 25 namespace {
27 const CGFloat kBookmarkItemCellDefaultImageSize = 40.0; 26 const CGFloat kBookmarkItemCellDefaultImageSize = 40.0;
28 const CGFloat kBookmarkFolderCellDefaultImageSize = 24.0; 27 const CGFloat kBookmarkFolderCellDefaultImageSize = 24.0;
29 } // namespace 28 } // namespace
30 29
31 @interface BookmarkCell () { 30 @interface BookmarkCell () {
32 @protected 31 @protected
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after
279 } 278 }
280 279
281 - (void)showButtonOfType:(bookmark_cell::ButtonType)buttonType 280 - (void)showButtonOfType:(bookmark_cell::ButtonType)buttonType
282 animated:(BOOL)animated { 281 animated:(BOOL)animated {
283 switch (buttonType) { 282 switch (buttonType) {
284 case bookmark_cell::ButtonNone: 283 case bookmark_cell::ButtonNone:
285 [self removeButtonAnimated:animated]; 284 [self removeButtonAnimated:animated];
286 break; 285 break;
287 286
288 case bookmark_cell::ButtonMenu: { 287 case bookmark_cell::ButtonMenu: {
289 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); 288 [self addButtonWithImage:NativeImage(IDR_IOS_TOOLBAR_LIGHT_TOOLS)
290 UIImage* bgImage = 289 animated:animated];
291 rb.GetNativeImageNamed(IDR_IOS_TOOLBAR_LIGHT_TOOLS).ToUIImage();
292 [self addButtonWithImage:bgImage animated:animated];
293 break; 290 break;
294 } 291 }
295 } 292 }
296 } 293 }
297 294
298 - (void)addButtonWithImage:(UIImage*)image animated:(BOOL)animated { 295 - (void)addButtonWithImage:(UIImage*)image animated:(BOOL)animated {
299 // Set the image. 296 // Set the image.
300 [self.button setImage:image forState:UIControlStateNormal]; 297 [self.button setImage:image forState:UIControlStateNormal];
301 298
302 // Animates the button in. 299 // Animates the button in.
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after
541 return self; 538 return self;
542 } 539 }
543 540
544 - (void)layoutSubviews { 541 - (void)layoutSubviews {
545 CGFloat lineHeight = 1; 542 CGFloat lineHeight = 1;
546 CGFloat lineY = self.bounds.size.height - lineHeight - 8; 543 CGFloat lineY = self.bounds.size.height - lineHeight - 8;
547 _lineView.frame = CGRectMake(0, lineY, self.bounds.size.width, lineHeight); 544 _lineView.frame = CGRectMake(0, lineY, self.bounds.size.width, lineHeight);
548 } 545 }
549 546
550 @end 547 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698