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

Side by Side Diff: ios/chrome/browser/ui/content_suggestions/content_suggestions_expandable_item.mm

Issue 2644123003: Move ios/ui/suggestions to ios/ui/content_suggestions (Closed)
Patch Set: Rebase 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 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 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/suggestions/suggestions_expandable_item.h" 5 #import "ios/chrome/browser/ui/content_suggestions/content_suggestions_expandabl e_item.h"
6 6
7 #import "ios/chrome/browser/ui/uikit_ui_util.h" 7 #import "ios/chrome/browser/ui/uikit_ui_util.h"
8 #include "ui/base/l10n/l10n_util_mac.h" 8 #include "ui/base/l10n/l10n_util_mac.h"
9 9
10 #if !defined(__has_feature) || !__has_feature(objc_arc) 10 #if !defined(__has_feature) || !__has_feature(objc_arc)
11 #error "This file requires ARC support." 11 #error "This file requires ARC support."
12 #endif 12 #endif
13 13
14 namespace { 14 namespace {
15 const CGFloat kImageSize = 80; 15 const CGFloat kImageSize = 80;
(...skipping 12 matching lines...) Expand all
28 @synthesize delegate = _delegate; 28 @synthesize delegate = _delegate;
29 @synthesize expanded = _expanded; 29 @synthesize expanded = _expanded;
30 30
31 - (instancetype)initWithType:(NSInteger)type 31 - (instancetype)initWithType:(NSInteger)type
32 title:(NSString*)title 32 title:(NSString*)title
33 subtitle:(NSString*)subtitle 33 subtitle:(NSString*)subtitle
34 image:(UIImage*)image 34 image:(UIImage*)image
35 detailText:(NSString*)detail { 35 detailText:(NSString*)detail {
36 self = [super initWithType:type]; 36 self = [super initWithType:type];
37 if (self) { 37 if (self) {
38 self.cellClass = [SuggestionsExpandableCell class]; 38 self.cellClass = [ContentSuggestionsExpandableCell class];
39 _title = [title copy]; 39 _title = [title copy];
40 _subtitle = [subtitle copy]; 40 _subtitle = [subtitle copy];
41 _image = image; 41 _image = image;
42 _detail = [detail copy]; 42 _detail = [detail copy];
43 } 43 }
44 return self; 44 return self;
45 } 45 }
46 46
47 #pragma mark - CollectionViewItem 47 #pragma mark - CollectionViewItem
48 48
49 - (void)configureCell:(SuggestionsExpandableCell*)cell { 49 - (void)configureCell:(ContentSuggestionsExpandableCell*)cell {
50 [super configureCell:cell]; 50 [super configureCell:cell];
51 cell.delegate = self.delegate; 51 cell.delegate = self.delegate;
52 cell.titleLabel.text = _title; 52 cell.titleLabel.text = _title;
53 cell.subtitleLabel.text = _subtitle; 53 cell.subtitleLabel.text = _subtitle;
54 cell.imageView.image = _image; 54 cell.imageView.image = _image;
55 cell.detailLabel.text = _detail; 55 cell.detailLabel.text = _detail;
56 if (self.expanded) 56 if (self.expanded)
57 [cell expand]; 57 [cell expand];
58 else 58 else
59 [cell collapse]; 59 [cell collapse];
60 } 60 }
61 61
62 @end 62 @end
63 63
64 #pragma mark - SuggestionsExpandableCell 64 #pragma mark - ContentSuggestionsExpandableCell
65 65
66 @interface SuggestionsExpandableCell () { 66 @interface ContentSuggestionsExpandableCell () {
67 UIView* _articleContainer; 67 UIView* _articleContainer;
68 UIButton* _interactionButton; 68 UIButton* _interactionButton;
69 UIButton* _expandButton; 69 UIButton* _expandButton;
70 BOOL _expanded; 70 BOOL _expanded;
71 NSArray<NSLayoutConstraint*>* _expandedConstraints; 71 NSArray<NSLayoutConstraint*>* _expandedConstraints;
72 NSArray<NSLayoutConstraint*>* _collapsedConstraints; 72 NSArray<NSLayoutConstraint*>* _collapsedConstraints;
73 } 73 }
74 74
75 // Callback for the UI action showing the details. 75 // Callback for the UI action showing the details.
76 - (void)expand:(id)sender; 76 - (void)expand:(id)sender;
77 // Callback for the UI action hiding the details. 77 // Callback for the UI action hiding the details.
78 - (void)collapse:(id)sender; 78 - (void)collapse:(id)sender;
79 79
80 @end 80 @end
81 81
82 @implementation SuggestionsExpandableCell 82 @implementation ContentSuggestionsExpandableCell
83 83
84 @synthesize titleLabel = _titleLabel; 84 @synthesize titleLabel = _titleLabel;
85 @synthesize subtitleLabel = _subtitleLabel; 85 @synthesize subtitleLabel = _subtitleLabel;
86 @synthesize detailLabel = _detailLabel; 86 @synthesize detailLabel = _detailLabel;
87 @synthesize imageView = _imageView; 87 @synthesize imageView = _imageView;
88 @synthesize delegate = _delegate; 88 @synthesize delegate = _delegate;
89 89
90 - (instancetype)initWithFrame:(CGRect)frame { 90 - (instancetype)initWithFrame:(CGRect)frame {
91 self = [super initWithFrame:frame]; 91 self = [super initWithFrame:frame];
92 if (self) { 92 if (self) {
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
228 CGFloat parentWidth = CGRectGetWidth(self.contentView.bounds); 228 CGFloat parentWidth = CGRectGetWidth(self.contentView.bounds);
229 _subtitleLabel.preferredMaxLayoutWidth = parentWidth - kImageSize - 3 * 8; 229 _subtitleLabel.preferredMaxLayoutWidth = parentWidth - kImageSize - 3 * 8;
230 _detailLabel.preferredMaxLayoutWidth = parentWidth; 230 _detailLabel.preferredMaxLayoutWidth = parentWidth;
231 231
232 // Re-layout with the new preferred width to allow the label to adjust its 232 // Re-layout with the new preferred width to allow the label to adjust its
233 // height. 233 // height.
234 [super layoutSubviews]; 234 [super layoutSubviews];
235 } 235 }
236 236
237 @end 237 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698