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

Side by Side Diff: ios/chrome/browser/ui/settings/cells/passphrase_error_item.mm

Issue 2589583003: Upstream Chrome on iOS source code [7/11]. (Closed)
Patch Set: 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 unified diff | Download patch
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #import "ios/chrome/browser/ui/settings/cells/passphrase_error_item.h"
6
7 #import <UIKit/UIKit.h>
8
9 #import "ios/chrome/browser/ui/colors/MDCPalette+CrAdditions.h"
10 #import "ios/third_party/material_components_ios/src/components/Palettes/src/Mat erialPalettes.h"
11 #import "ios/third_party/material_roboto_font_loader_ios/src/src/MaterialRobotoF ontLoader.h"
12
13 #if !defined(__has_feature) || !__has_feature(objc_arc)
14 #error "This file requires ARC support."
15 #endif
16
17 namespace {
18 // Padding used on the leading and trailing edges of the cell.
19 const CGFloat kHorizontalPadding = 16;
20 } // namespace
21
22 @implementation PassphraseErrorItem
23
24 @synthesize text = _text;
25
26 - (instancetype)initWithType:(NSInteger)type {
27 self = [super initWithType:type];
28 if (self) {
29 self.cellClass = [PassphraseErrorCell class];
30 }
31 return self;
32 }
33
34 - (void)configureCell:(PassphraseErrorCell*)cell {
35 [super configureCell:cell];
36 cell.textLabel.text = self.text;
37 }
38
39 @end
40
41 @interface PassphraseErrorCell ()
42 @property(nonatomic, readonly, strong) UIImageView* errorImageView;
43 @end
44
45 @implementation PassphraseErrorCell
46
47 @synthesize textLabel = _textLabel;
48 @synthesize errorImageView = _errorImageView;
49
50 - (instancetype)initWithFrame:(CGRect)frame {
51 self = [super initWithFrame:frame];
52 if (self) {
53 UIView* contentView = self.contentView;
54
55 _textLabel = [[UILabel alloc] init];
56 _textLabel.translatesAutoresizingMaskIntoConstraints = NO;
57 _textLabel.font =
58 [[MDFRobotoFontLoader sharedInstance] mediumFontOfSize:14];
59 _textLabel.textColor = [[MDCPalette cr_redPalette] tint500];
60 [contentView addSubview:_textLabel];
61
62 _errorImageView = [[UIImageView alloc] init];
63 _errorImageView.translatesAutoresizingMaskIntoConstraints = NO;
64 _errorImageView.image = [UIImage imageNamed:@"encryption_error"];
65 [contentView addSubview:_errorImageView];
66
67 // Set up the constraints.
68 [NSLayoutConstraint activateConstraints:@[
69 [_errorImageView.leadingAnchor
70 constraintEqualToAnchor:contentView.leadingAnchor
71 constant:kHorizontalPadding],
72 [_textLabel.leadingAnchor
73 constraintEqualToAnchor:_errorImageView.trailingAnchor
74 constant:kHorizontalPadding],
75 [_textLabel.trailingAnchor
76 constraintEqualToAnchor:contentView.trailingAnchor
77 constant:-kHorizontalPadding],
78 [_errorImageView.centerYAnchor
79 constraintEqualToAnchor:contentView.centerYAnchor],
80 [_textLabel.centerYAnchor
81 constraintEqualToAnchor:contentView.centerYAnchor],
82 ]];
83
84 [_errorImageView
85 setContentHuggingPriority:UILayoutPriorityRequired
86 forAxis:UILayoutConstraintAxisHorizontal];
87 }
88 return self;
89 }
90
91 - (void)prepareForReuse {
92 [super prepareForReuse];
93 self.textLabel.text = nil;
94 }
95
96 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698