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

Unified Diff: ios/chrome/today_extension/ui_util.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
« no previous file with comments | « ios/chrome/today_extension/ui_util.h ('k') | ios/chrome/today_extension/url_table_cell.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ios/chrome/today_extension/ui_util.mm
diff --git a/ios/chrome/today_extension/ui_util.mm b/ios/chrome/today_extension/ui_util.mm
new file mode 100644
index 0000000000000000000000000000000000000000..9367ca7f7aa289380ce02563e95f69aef0c629f6
--- /dev/null
+++ b/ios/chrome/today_extension/ui_util.mm
@@ -0,0 +1,124 @@
+// 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 <UIKit/UIKit.h>
+
+#include "base/ios/ios_util.h"
+#include "ios/chrome/today_extension/ui_util.h"
+
+namespace {
+const CGFloat kVeryLowOpacity = 0.25;
+const CGFloat kLowOpacity = 0.3;
+const CGFloat kMediumOpacity = 0.54;
+const CGFloat kHighOpacity = 0.8;
+const CGFloat kVeryHighOpacity = 0.87;
+const CGFloat kFooterFontOpacity = 0.4;
+const CGFloat kBackgroundOpacity = 0.75;
+}
+
+namespace ui_util {
+
+const CGFloat kFirstLineHeight = 60;
+const CGFloat kFirstLineButtonMargin = 8;
+const CGFloat kSecondLineHeight = 56;
+const CGFloat kSecondLineVerticalPadding = 10;
+const CGFloat kUIButtonSeparator = 28;
+const CGFloat kUIButtonFrontShift = 8;
+const CGFloat kUIButtonCornerRadius = 4;
+
+const CGFloat kFooterVerticalMargin = 18;
+const CGFloat kFooterHorizontalMargin = 16;
+const CGFloat kTitleFontSize = 16;
+
+const CGFloat kEmptyLabelYOffset = -16;
+
+// These five constants have been empirically determined to align paste URL
+// button with chrome header icon and text.
+const CGFloat kiPadTextOffset = 10;
+const CGFloat kiPhoneTextOffset = 6;
+const CGFloat kiPadIconOffset = -31;
+const CGFloat kiPhoneIconOffset = -26;
+const CGFloat kDefaultLeadingMarginInset = 48;
+
+UIColor* InkColor() {
+ return [UIColor colorWithWhite:0.5 alpha:0.4];
+}
+
+UIColor* BaseColorWithAlpha(CGFloat alpha) {
+ if (base::ios::IsRunningOnIOS10OrLater()) {
+ return [UIColor colorWithWhite:0.3 alpha:alpha];
+ } else {
+ return [UIColor colorWithWhite:1 alpha:alpha];
+ }
+}
+
+UIColor* TitleColor() {
+ return BaseColorWithAlpha(kVeryHighOpacity);
+}
+
+UIColor* BorderColor() {
+ return BaseColorWithAlpha(kLowOpacity);
+}
+
+UIColor* TextColor() {
+ return BaseColorWithAlpha(kMediumOpacity);
+}
+
+UIColor* BackgroundColor() {
+ return BaseColorWithAlpha(kBackgroundOpacity);
+}
+
+UIColor* FooterTextColor() {
+ return BaseColorWithAlpha(kFooterFontOpacity);
+}
+
+UIColor* NormalTintColor() {
+ if (base::ios::IsRunningOnIOS10OrLater()) {
+ return [UIColor colorWithWhite:0 alpha:kHighOpacity];
+ } else {
+ return BaseColorWithAlpha(kVeryLowOpacity);
+ }
+}
+
+UIColor* ActiveTintColor() {
+ if (base::ios::IsRunningOnIOS10OrLater()) {
+ return [UIColor colorWithWhite:0 alpha:kHighOpacity];
+ } else {
+ return BaseColorWithAlpha(kVeryHighOpacity);
+ }
+}
+
+UIColor* emptyLabelColor() {
+ return [[UIColor blackColor] colorWithAlphaComponent:kFooterFontOpacity];
+}
+
+bool IsIPadIdiom() {
+ UIUserInterfaceIdiom idiom = [[UIDevice currentDevice] userInterfaceIdiom];
+ return idiom == UIUserInterfaceIdiomPad;
+}
+
+bool IsRTL() {
+ NSString* locale = [NSLocale currentLocale].localeIdentifier;
+ return [NSLocale characterDirectionForLanguage:locale] ==
+ NSLocaleLanguageDirectionRightToLeft;
+}
+
+CGFloat ChromeIconOffset() {
+ return ui_util::IsIPadIdiom() ? kiPadIconOffset : kiPhoneIconOffset;
+}
+
+CGFloat ChromeTextOffset() {
+ return ui_util::IsIPadIdiom() ? kiPadTextOffset : kiPhoneTextOffset;
+}
+
+void ConstrainAllSidesOfViewToView(UIView* container, UIView* filler) {
+ [NSLayoutConstraint activateConstraints:@[
+ [filler.leadingAnchor constraintEqualToAnchor:container.leadingAnchor],
+ [filler.trailingAnchor constraintEqualToAnchor:container.trailingAnchor],
+ [filler.topAnchor constraintEqualToAnchor:container.topAnchor],
+ [filler.bottomAnchor constraintEqualToAnchor:container.bottomAnchor],
+ ]];
+}
+
+} // namespace ui_util
« no previous file with comments | « ios/chrome/today_extension/ui_util.h ('k') | ios/chrome/today_extension/url_table_cell.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698