Commit 93431873 authored by Gauthier Ambard's avatar Gauthier Ambard Committed by Commit Bot

Fix History bottom toolbar on iPhone X

On iPhone X, the safe area is cutting the bottom and sides of the
device. The bottom toolbar needs to take it into account to be
correctly displayed on iPhone X.

Before: https://drive.google.com/file/d/0By4O1f2IQqQ_aE9PcnJoblpocTQ/view
After: https://drive.google.com/open?id=0B21N-0pPGAuJVG9YMkU2ZDdONVE

Bug: 765397
Change-Id: I20eea4ab32089cb5fb2850166b04c19425ba04de
Reviewed-on: https://chromium-review.googlesource.com/668578
Commit-Queue: Gauthier Ambard <gambard@chromium.org>
Reviewed-by: default avatarSergio Collazos <sczs@chromium.org>
Cr-Commit-Position: refs/heads/master@{#502582}
parent 14bfbd13
......@@ -8,6 +8,7 @@
#include "components/strings/grit/components_strings.h"
#include "ios/chrome/browser/ui/rtl_geometry.h"
#import "ios/chrome/browser/ui/uikit_ui_util.h"
#import "ios/chrome/browser/ui/util/constraints_ui_util.h"
#import "ios/third_party/material_components_ios/src/components/Palettes/src/MaterialPalettes.h"
#import "ios/third_party/material_components_ios/src/components/Typography/src/MaterialTypography.h"
#include "ui/base/l10n/l10n_util_mac.h"
......@@ -21,6 +22,8 @@ namespace {
CGFloat kShadowOpacity = 0.2f;
// Horizontal margin for the contents of ClearBrowsingBar.
CGFloat kHorizontalMargin = 8.0f;
// Height of the part of the toolbar containing content.
const CGFloat kToolbarHeight = 48.0f;
// Enum to specify button position in the clear browsing bar.
typedef NS_ENUM(BOOL, ButtonPlacement) { Leading, Trailing };
} // namespace
......@@ -91,17 +94,27 @@ typedef NS_ENUM(BOOL, ButtonPlacement) { Leading, Trailing };
[self addSubview:_stackView];
_stackView.translatesAutoresizingMaskIntoConstraints = NO;
if (@available(iOS 11.0, *)) {
[NSLayoutConstraint activateConstraints:@[
[self.safeAreaLayoutGuide.topAnchor
constraintEqualToAnchor:_stackView.topAnchor],
[self.safeAreaLayoutGuide.leadingAnchor
constraintEqualToAnchor:_stackView.leadingAnchor],
[self.safeAreaLayoutGuide.trailingAnchor
constraintEqualToAnchor:_stackView.trailingAnchor],
[self.safeAreaLayoutGuide.bottomAnchor
constraintEqualToAnchor:_stackView.bottomAnchor],
]];
} else {
AddSameConstraints(_stackView, self);
}
[_stackView.heightAnchor constraintEqualToConstant:kToolbarHeight].active =
YES;
_stackView.layoutMarginsRelativeArrangement = YES;
[NSLayoutConstraint activateConstraints:@[
[_stackView.layoutMarginsGuide.leadingAnchor
constraintEqualToAnchor:self.leadingAnchor
constant:kHorizontalMargin],
[_stackView.layoutMarginsGuide.trailingAnchor
constraintEqualToAnchor:self.trailingAnchor
constant:-kHorizontalMargin],
[_stackView.topAnchor constraintEqualToAnchor:self.topAnchor],
[_stackView.bottomAnchor constraintEqualToAnchor:self.bottomAnchor],
]];
_stackView.layoutMargins =
UIEdgeInsetsMake(0, kHorizontalMargin, 0, kHorizontalMargin);
[self setBackgroundColor:[UIColor whiteColor]];
[[self layer] setShadowOpacity:kShadowOpacity];
......
......@@ -173,7 +173,7 @@ CGFloat kShadowOpacity = 0.2f;
@"clearBrowsingBar" : _clearBrowsingBar,
};
NSArray* constraints = @[
@"V:|[collectionView][clearBrowsingBar(==48)]|", @"H:|[collectionView]|",
@"V:|[collectionView][clearBrowsingBar]|", @"H:|[collectionView]|",
@"H:|[clearBrowsingBar]|"
];
ApplyVisualConstraints(constraints, views);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment