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

Side by Side Diff: ios/chrome/today_extension/notification_center_button.mm

Issue 2586713002: Upstream code and resources for Chrome on iOS extensions. (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 2015 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 <NotificationCenter/NotificationCenter.h>
6 #import <QuartzCore/QuartzCore.h>
7
8 #import "ios/chrome/today_extension/notification_center_button.h"
9
10 #import "base/mac/scoped_nsobject.h"
11 #include "ios/chrome/today_extension/ui_util.h"
12
13 @implementation NotificationCenterButton {
14 CGFloat _horizontalPadding;
15 CGFloat _verticalPadding;
16 CGSize _imageSize;
17 CGFloat _imageTextSeparator;
18 // Shift the centered content to the front (left in LTR, right in RTL).
19 CGFloat _frontShift;
20 }
21
22 - (instancetype)initWithTitle:(NSString*)title
23 icon:(NSString*)icon
24 target:(id)target
25 action:(SEL)action
26 backgroundColor:(UIColor*)backgroundColor
27 inkColor:(UIColor*)inkColor
28 titleColor:(UIColor*)titleColor {
29 self = [super initWithFrame:CGRectZero];
30 if (self) {
31 [self setInkColor:inkColor];
32 if ([icon length]) {
33 UIImage* iconImage = [UIImage imageNamed:icon];
34 [self setImage:iconImage forState:UIControlStateNormal];
35 _imageSize = [iconImage size];
36 } else {
37 _imageSize = CGSizeZero;
38 }
39 [self bringSubviewToFront:[self imageView]];
40
41 [self addTarget:target
42 action:action
43 forControlEvents:UIControlEventTouchUpInside];
44 [self setExclusiveTouch:YES];
45
46 UIFont* titleFont =
47 [UIFont fontWithName:@"Helvetica" size:ui_util::kTitleFontSize];
48 [super setTitle:title forState:UIControlStateNormal];
49 [self setBackgroundColor:backgroundColor];
50 [self titleLabel].font = titleFont;
51 [self titleLabel].lineBreakMode = NSLineBreakByTruncatingTail;
52 [self setTitleColor:titleColor forState:UIControlStateNormal];
53 [self setTitleColor:[titleColor colorWithAlphaComponent:1]
54 forState:UIControlStateHighlighted];
55 }
56 return self;
57 }
58
59 - (void)setButtonSpacesSeparator:(const CGFloat)separator
60 frontShift:(const CGFloat)frontShift
61 horizontalPadding:(const CGFloat)horizontalPadding
62 verticalPadding:(const CGFloat)verticalPadding {
63 _horizontalPadding = horizontalPadding;
64 _verticalPadding = verticalPadding;
65 _imageTextSeparator = separator;
66 _frontShift = frontShift;
67 }
68
69 @end
OLDNEW
« no previous file with comments | « ios/chrome/today_extension/notification_center_button.h ('k') | ios/chrome/today_extension/notification_center_url_button.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698