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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: ios/chrome/today_extension/notification_center_button.mm
diff --git a/ios/chrome/today_extension/notification_center_button.mm b/ios/chrome/today_extension/notification_center_button.mm
new file mode 100644
index 0000000000000000000000000000000000000000..caf4fa8bebb35018a6bba9bd9258d4357de66bea
--- /dev/null
+++ b/ios/chrome/today_extension/notification_center_button.mm
@@ -0,0 +1,69 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#import <NotificationCenter/NotificationCenter.h>
+#import <QuartzCore/QuartzCore.h>
+
+#import "ios/chrome/today_extension/notification_center_button.h"
+
+#import "base/mac/scoped_nsobject.h"
+#include "ios/chrome/today_extension/ui_util.h"
+
+@implementation NotificationCenterButton {
+ CGFloat _horizontalPadding;
+ CGFloat _verticalPadding;
+ CGSize _imageSize;
+ CGFloat _imageTextSeparator;
+ // Shift the centered content to the front (left in LTR, right in RTL).
+ CGFloat _frontShift;
+}
+
+- (instancetype)initWithTitle:(NSString*)title
+ icon:(NSString*)icon
+ target:(id)target
+ action:(SEL)action
+ backgroundColor:(UIColor*)backgroundColor
+ inkColor:(UIColor*)inkColor
+ titleColor:(UIColor*)titleColor {
+ self = [super initWithFrame:CGRectZero];
+ if (self) {
+ [self setInkColor:inkColor];
+ if ([icon length]) {
+ UIImage* iconImage = [UIImage imageNamed:icon];
+ [self setImage:iconImage forState:UIControlStateNormal];
+ _imageSize = [iconImage size];
+ } else {
+ _imageSize = CGSizeZero;
+ }
+ [self bringSubviewToFront:[self imageView]];
+
+ [self addTarget:target
+ action:action
+ forControlEvents:UIControlEventTouchUpInside];
+ [self setExclusiveTouch:YES];
+
+ UIFont* titleFont =
+ [UIFont fontWithName:@"Helvetica" size:ui_util::kTitleFontSize];
+ [super setTitle:title forState:UIControlStateNormal];
+ [self setBackgroundColor:backgroundColor];
+ [self titleLabel].font = titleFont;
+ [self titleLabel].lineBreakMode = NSLineBreakByTruncatingTail;
+ [self setTitleColor:titleColor forState:UIControlStateNormal];
+ [self setTitleColor:[titleColor colorWithAlphaComponent:1]
+ forState:UIControlStateHighlighted];
+ }
+ return self;
+}
+
+- (void)setButtonSpacesSeparator:(const CGFloat)separator
+ frontShift:(const CGFloat)frontShift
+ horizontalPadding:(const CGFloat)horizontalPadding
+ verticalPadding:(const CGFloat)verticalPadding {
+ _horizontalPadding = horizontalPadding;
+ _verticalPadding = verticalPadding;
+ _imageTextSeparator = separator;
+ _frontShift = frontShift;
+}
+
+@end
« 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