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

Side by Side Diff: ios/chrome/browser/ui/autofill/cells/status_item.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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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/autofill/cells/status_item.h" 5 #import "ios/chrome/browser/ui/autofill/cells/status_item.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #import "ios/chrome/browser/ui/colors/MDCPalette+CrAdditions.h" 8 #import "ios/chrome/browser/ui/colors/MDCPalette+CrAdditions.h"
9 #import "ios/chrome/browser/ui/uikit_ui_util.h"
9 #include "ios/chrome/grit/ios_theme_resources.h" 10 #include "ios/chrome/grit/ios_theme_resources.h"
10 #import "ios/third_party/material_components_ios/src/components/ActivityIndicato r/src/MaterialActivityIndicator.h" 11 #import "ios/third_party/material_components_ios/src/components/ActivityIndicato r/src/MaterialActivityIndicator.h"
11 #import "ios/third_party/material_components_ios/src/components/Palettes/src/Mat erialPalettes.h" 12 #import "ios/third_party/material_components_ios/src/components/Palettes/src/Mat erialPalettes.h"
12 #import "ios/third_party/material_roboto_font_loader_ios/src/src/MaterialRobotoF ontLoader.h" 13 #import "ios/third_party/material_roboto_font_loader_ios/src/src/MaterialRobotoF ontLoader.h"
13 #include "ui/base/resource/resource_bundle.h"
14 14
15 #if !defined(__has_feature) || !__has_feature(objc_arc) 15 #if !defined(__has_feature) || !__has_feature(objc_arc)
16 #error "This file requires ARC support." 16 #error "This file requires ARC support."
17 #endif 17 #endif
18 18
19 namespace { 19 namespace {
20 // Padding used on the leading and trailing edges of the cell. 20 // Padding used on the leading and trailing edges of the cell.
21 const CGFloat kHorizontalPadding = 16; 21 const CGFloat kHorizontalPadding = 16;
22 } // namespace 22 } // namespace
23 23
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 UIView* verticalCenteringView = [[UIView alloc] init]; 64 UIView* verticalCenteringView = [[UIView alloc] init];
65 verticalCenteringView.translatesAutoresizingMaskIntoConstraints = NO; 65 verticalCenteringView.translatesAutoresizingMaskIntoConstraints = NO;
66 [contentView addSubview:verticalCenteringView]; 66 [contentView addSubview:verticalCenteringView];
67 67
68 _activityIndicator = [[MDCActivityIndicator alloc] init]; 68 _activityIndicator = [[MDCActivityIndicator alloc] init];
69 _activityIndicator.cycleColors = @[ [[MDCPalette cr_bluePalette] tint500] ]; 69 _activityIndicator.cycleColors = @[ [[MDCPalette cr_bluePalette] tint500] ];
70 [_activityIndicator setRadius:10]; 70 [_activityIndicator setRadius:10];
71 _activityIndicator.translatesAutoresizingMaskIntoConstraints = NO; 71 _activityIndicator.translatesAutoresizingMaskIntoConstraints = NO;
72 [verticalCenteringView addSubview:_activityIndicator]; 72 [verticalCenteringView addSubview:_activityIndicator];
73 73
74 _verifiedImageView = [[UIImageView alloc] init];
75 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
76 // TODO(crbug.com/508925): Get rid of IDR_IOS_CHECKMARK, use a vector icon 74 // TODO(crbug.com/508925): Get rid of IDR_IOS_CHECKMARK, use a vector icon
77 // instead. 75 // instead.
78 _verifiedImageView.image = 76 _verifiedImageView =
79 rb.GetNativeImageNamed(IDR_IOS_CHECKMARK).ToUIImage(); 77 [[UIImageView alloc] initWithImage:NativeImage(IDR_IOS_CHECKMARK)];
80 _verifiedImageView.contentMode = UIViewContentModeScaleAspectFit; 78 _verifiedImageView.contentMode = UIViewContentModeScaleAspectFit;
81 _verifiedImageView.hidden = YES; 79 _verifiedImageView.hidden = YES;
82 _verifiedImageView.translatesAutoresizingMaskIntoConstraints = NO; 80 _verifiedImageView.translatesAutoresizingMaskIntoConstraints = NO;
83 [verticalCenteringView addSubview:_verifiedImageView]; 81 [verticalCenteringView addSubview:_verifiedImageView];
84 82
85 _errorImageView = [[UIImageView alloc] init]; 83 _errorImageView =
86 _errorImageView.image = rb.GetNativeImageNamed(IDR_IOS_ERROR).ToUIImage(); 84 [[UIImageView alloc] initWithImage:NativeImage(IDR_IOS_ERROR)];
87 _errorImageView.contentMode = UIViewContentModeScaleAspectFit; 85 _errorImageView.contentMode = UIViewContentModeScaleAspectFit;
88 _errorImageView.hidden = YES; 86 _errorImageView.hidden = YES;
89 _errorImageView.translatesAutoresizingMaskIntoConstraints = NO; 87 _errorImageView.translatesAutoresizingMaskIntoConstraints = NO;
90 [verticalCenteringView addSubview:_errorImageView]; 88 [verticalCenteringView addSubview:_errorImageView];
91 89
92 _textLabel = [[UILabel alloc] init]; 90 _textLabel = [[UILabel alloc] init];
93 _textLabel.font = 91 _textLabel.font =
94 [[MDFRobotoFontLoader sharedInstance] mediumFontOfSize:16]; 92 [[MDFRobotoFontLoader sharedInstance] mediumFontOfSize:16];
95 _textLabel.numberOfLines = 0; 93 _textLabel.numberOfLines = 0;
96 _textLabel.lineBreakMode = NSLineBreakByWordWrapping; 94 _textLabel.lineBreakMode = NSLineBreakByWordWrapping;
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 self.textLabel.textColor = [[MDCPalette cr_redPalette] tint500]; 187 self.textLabel.textColor = [[MDCPalette cr_redPalette] tint500];
190 [self.activityIndicator stopAnimating]; 188 [self.activityIndicator stopAnimating];
191 self.activityIndicator.hidden = YES; 189 self.activityIndicator.hidden = YES;
192 self.verifiedImageView.hidden = YES; 190 self.verifiedImageView.hidden = YES;
193 self.errorImageView.hidden = NO; 191 self.errorImageView.hidden = NO;
194 break; 192 break;
195 } 193 }
196 } 194 }
197 195
198 @end 196 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698