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

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

Issue 2749543002: Add a footer item for the Content Suggestions (Closed)
Patch Set: Created 3 years, 9 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #import "ios/chrome/browser/ui/content_suggestions/content_suggestions_footer_it em.h"
6
7 #import "ios/chrome/browser/ui/uikit_ui_util.h"
8
9 #if !defined(__has_feature) || !__has_feature(objc_arc)
10 #error "This file requires ARC support."
11 #endif
12
13 #pragma mark - ContentSuggestionsFooterItem
14
15 @interface ContentSuggestionsFooterItem ()
16
17 @property(nonatomic, copy) NSString* title;
18 @property(nonatomic, copy) void (^action)();
19
20 - (void)executeAction;
21
22 @end
23
24 @implementation ContentSuggestionsFooterItem
25
26 @synthesize title = _title;
27 @synthesize action = _action;
28 @synthesize suggestionIdentifier = _suggestionIdentifier;
29
30 - (instancetype)initWithType:(NSInteger)type
31 title:(NSString*)title
32 action:(void (^)())action {
33 self = [super initWithType:type];
34 if (self) {
35 self.cellClass = [ContentSuggestionsFooterCell class];
36 _title = [title copy];
37 _action = [action copy];
38 }
39 return self;
40 }
41
42 - (void)configureCell:(ContentSuggestionsFooterCell*)cell {
43 [super configureCell:cell];
44 [cell.actionButton setTitle:self.title forState:UIControlStateNormal];
45 [cell.actionButton addTarget:self
46 action:@selector(executeAction)
47 forControlEvents:UIControlEventTouchUpInside];
48 }
49
50 #pragma mark - Private
51
52 - (void)executeAction {
53 if (self.action) {
54 self.action();
55 }
56 }
57
58 @end
59
60 #pragma mark - ContentSuggestionsFooterCell
61
62 @implementation ContentSuggestionsFooterCell
63
64 @synthesize actionButton = _actionButton;
65
66 - (instancetype)initWithFrame:(CGRect)frame {
67 self = [super initWithFrame:frame];
68 if (self) {
69 _actionButton = [UIButton buttonWithType:UIButtonTypeSystem];
lpromero 2017/03/13 14:45:14 No other styling? Will it be an MDCButton?
gambard 2017/03/14 10:02:42 For now I have no design for it so I go for the ea
70 _actionButton.translatesAutoresizingMaskIntoConstraints = NO;
71 [self.contentView addSubview:_actionButton];
72 AddSameSizeConstraint(self.contentView, _actionButton);
73 }
74 return self;
75 }
76
77 - (void)prepareForReuse {
78 [self.actionButton removeTarget:nil
79 action:NULL
80 forControlEvents:UIControlEventAllEvents];
81 }
82
83 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698