OLD | NEW |
(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 <UIKit/UIKit.h> |
| 6 |
| 7 #include "base/ios/ios_util.h" |
| 8 #include "ios/chrome/today_extension/ui_util.h" |
| 9 |
| 10 namespace { |
| 11 const CGFloat kVeryLowOpacity = 0.25; |
| 12 const CGFloat kLowOpacity = 0.3; |
| 13 const CGFloat kMediumOpacity = 0.54; |
| 14 const CGFloat kHighOpacity = 0.8; |
| 15 const CGFloat kVeryHighOpacity = 0.87; |
| 16 const CGFloat kFooterFontOpacity = 0.4; |
| 17 const CGFloat kBackgroundOpacity = 0.75; |
| 18 } |
| 19 |
| 20 namespace ui_util { |
| 21 |
| 22 const CGFloat kFirstLineHeight = 60; |
| 23 const CGFloat kFirstLineButtonMargin = 8; |
| 24 const CGFloat kSecondLineHeight = 56; |
| 25 const CGFloat kSecondLineVerticalPadding = 10; |
| 26 const CGFloat kUIButtonSeparator = 28; |
| 27 const CGFloat kUIButtonFrontShift = 8; |
| 28 const CGFloat kUIButtonCornerRadius = 4; |
| 29 |
| 30 const CGFloat kFooterVerticalMargin = 18; |
| 31 const CGFloat kFooterHorizontalMargin = 16; |
| 32 const CGFloat kTitleFontSize = 16; |
| 33 |
| 34 const CGFloat kEmptyLabelYOffset = -16; |
| 35 |
| 36 // These five constants have been empirically determined to align paste URL |
| 37 // button with chrome header icon and text. |
| 38 const CGFloat kiPadTextOffset = 10; |
| 39 const CGFloat kiPhoneTextOffset = 6; |
| 40 const CGFloat kiPadIconOffset = -31; |
| 41 const CGFloat kiPhoneIconOffset = -26; |
| 42 const CGFloat kDefaultLeadingMarginInset = 48; |
| 43 |
| 44 UIColor* InkColor() { |
| 45 return [UIColor colorWithWhite:0.5 alpha:0.4]; |
| 46 } |
| 47 |
| 48 UIColor* BaseColorWithAlpha(CGFloat alpha) { |
| 49 if (base::ios::IsRunningOnIOS10OrLater()) { |
| 50 return [UIColor colorWithWhite:0.3 alpha:alpha]; |
| 51 } else { |
| 52 return [UIColor colorWithWhite:1 alpha:alpha]; |
| 53 } |
| 54 } |
| 55 |
| 56 UIColor* TitleColor() { |
| 57 return BaseColorWithAlpha(kVeryHighOpacity); |
| 58 } |
| 59 |
| 60 UIColor* BorderColor() { |
| 61 return BaseColorWithAlpha(kLowOpacity); |
| 62 } |
| 63 |
| 64 UIColor* TextColor() { |
| 65 return BaseColorWithAlpha(kMediumOpacity); |
| 66 } |
| 67 |
| 68 UIColor* BackgroundColor() { |
| 69 return BaseColorWithAlpha(kBackgroundOpacity); |
| 70 } |
| 71 |
| 72 UIColor* FooterTextColor() { |
| 73 return BaseColorWithAlpha(kFooterFontOpacity); |
| 74 } |
| 75 |
| 76 UIColor* NormalTintColor() { |
| 77 if (base::ios::IsRunningOnIOS10OrLater()) { |
| 78 return [UIColor colorWithWhite:0 alpha:kHighOpacity]; |
| 79 } else { |
| 80 return BaseColorWithAlpha(kVeryLowOpacity); |
| 81 } |
| 82 } |
| 83 |
| 84 UIColor* ActiveTintColor() { |
| 85 if (base::ios::IsRunningOnIOS10OrLater()) { |
| 86 return [UIColor colorWithWhite:0 alpha:kHighOpacity]; |
| 87 } else { |
| 88 return BaseColorWithAlpha(kVeryHighOpacity); |
| 89 } |
| 90 } |
| 91 |
| 92 UIColor* emptyLabelColor() { |
| 93 return [[UIColor blackColor] colorWithAlphaComponent:kFooterFontOpacity]; |
| 94 } |
| 95 |
| 96 bool IsIPadIdiom() { |
| 97 UIUserInterfaceIdiom idiom = [[UIDevice currentDevice] userInterfaceIdiom]; |
| 98 return idiom == UIUserInterfaceIdiomPad; |
| 99 } |
| 100 |
| 101 bool IsRTL() { |
| 102 NSString* locale = [NSLocale currentLocale].localeIdentifier; |
| 103 return [NSLocale characterDirectionForLanguage:locale] == |
| 104 NSLocaleLanguageDirectionRightToLeft; |
| 105 } |
| 106 |
| 107 CGFloat ChromeIconOffset() { |
| 108 return ui_util::IsIPadIdiom() ? kiPadIconOffset : kiPhoneIconOffset; |
| 109 } |
| 110 |
| 111 CGFloat ChromeTextOffset() { |
| 112 return ui_util::IsIPadIdiom() ? kiPadTextOffset : kiPhoneTextOffset; |
| 113 } |
| 114 |
| 115 void ConstrainAllSidesOfViewToView(UIView* container, UIView* filler) { |
| 116 [NSLayoutConstraint activateConstraints:@[ |
| 117 [filler.leadingAnchor constraintEqualToAnchor:container.leadingAnchor], |
| 118 [filler.trailingAnchor constraintEqualToAnchor:container.trailingAnchor], |
| 119 [filler.topAnchor constraintEqualToAnchor:container.topAnchor], |
| 120 [filler.bottomAnchor constraintEqualToAnchor:container.bottomAnchor], |
| 121 ]]; |
| 122 } |
| 123 |
| 124 } // namespace ui_util |
OLD | NEW |