OLD | NEW |
(Empty) | |
| 1 // Copyright 2014 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/ntp/recent_tabs/views/spacers_view.h" |
| 6 |
| 7 #include "base/logging.h" |
| 8 #import "ios/chrome/browser/ui/ntp/recent_tabs/views/views_utils.h" |
| 9 #include "ios/chrome/browser/ui/ui_util.h" |
| 10 #import "ios/chrome/browser/ui/uikit_ui_util.h" |
| 11 |
| 12 #if !defined(__has_feature) || !__has_feature(objc_arc) |
| 13 #error "This file requires ARC support." |
| 14 #endif |
| 15 |
| 16 namespace { |
| 17 |
| 18 // Desired height of the view. |
| 19 const CGFloat kHeaderDesiredHeightIPhone = 8; |
| 20 const CGFloat kHeaderDesiredHeightIPad = 48; |
| 21 const CGFloat kFooterDesiredHeight = 17; |
| 22 |
| 23 // Text color. |
| 24 const int kSeparatorColor = 0x5a5a5a; |
| 25 const CGFloat kSeparatorAlpha = 0.1; |
| 26 |
| 27 } // namespace |
| 28 |
| 29 @implementation RecentlyTabsTopSpacingHeader |
| 30 |
| 31 + (CGFloat)desiredHeightInUITableViewCell { |
| 32 if (IsIPadIdiom()) { |
| 33 return kHeaderDesiredHeightIPad; |
| 34 } else { |
| 35 return kHeaderDesiredHeightIPhone; |
| 36 } |
| 37 } |
| 38 |
| 39 @end |
| 40 |
| 41 @implementation RecentlyClosedSectionFooter |
| 42 |
| 43 - (instancetype)initWithFrame:(CGRect)aRect { |
| 44 self = [super initWithFrame:CGRectZero]; |
| 45 if (self) { |
| 46 // Create and add separator. |
| 47 UIView* separator = [[UIView alloc] init]; |
| 48 [separator setTranslatesAutoresizingMaskIntoConstraints:NO]; |
| 49 UIColor* separatorColor = UIColorFromRGB(kSeparatorColor, kSeparatorAlpha); |
| 50 [separator setBackgroundColor:separatorColor]; |
| 51 [self addSubview:separator]; |
| 52 |
| 53 // Set constraints on separator. |
| 54 NSDictionary* viewsDictionary = @{ @"separator" : separator }; |
| 55 // This set of constraints should match the constraints set on the |
| 56 // RecentTabsTableViewController. |
| 57 // clang-format off |
| 58 NSArray* constraints = @[ |
| 59 @"V:|-(8)-[separator(==1)]", |
| 60 @"H:|-(16)-[separator(<=516)]-(16)-|", |
| 61 @"H:[separator(==516@500)]" |
| 62 ]; |
| 63 // clang-format on |
| 64 [self addConstraint:[NSLayoutConstraint |
| 65 constraintWithItem:separator |
| 66 attribute:NSLayoutAttributeCenterX |
| 67 relatedBy:NSLayoutRelationEqual |
| 68 toItem:self |
| 69 attribute:NSLayoutAttributeCenterX |
| 70 multiplier:1 |
| 71 constant:0]]; |
| 72 ApplyVisualConstraints(constraints, viewsDictionary, self); |
| 73 } |
| 74 return self; |
| 75 } |
| 76 |
| 77 + (CGFloat)desiredHeightInUITableViewCell { |
| 78 return kFooterDesiredHeight; |
| 79 } |
| 80 |
| 81 @end |
OLD | NEW |