Commit 0a28f9d1 authored by Gauthier Ambard's avatar Gauthier Ambard Committed by Commit Bot

Add the shadow below the toolbar

The toolbar has a shadown below it.

Bug: 791469
Cq-Include-Trybots: master.tryserver.chromium.mac:ios-simulator-cronet;master.tryserver.chromium.mac:ios-simulator-full-configs
Change-Id: Iaf6ee9fe5190d2c4d5b6243bca3282d01ecba7ca
Reviewed-on: https://chromium-review.googlesource.com/806175
Commit-Queue: Gauthier Ambard <gambard@chromium.org>
Reviewed-by: default avatarSergio Collazos <sczs@chromium.org>
Cr-Commit-Position: refs/heads/master@{#521654}
parent 844e4a30
...@@ -62,6 +62,7 @@ source_set("toolbar_ui") { ...@@ -62,6 +62,7 @@ source_set("toolbar_ui") {
deps = [ deps = [
":toolbar_components_ui", ":toolbar_components_ui",
"//base", "//base",
"//ios/chrome/app/theme",
"//ios/chrome/browser/ui", "//ios/chrome/browser/ui",
"//ios/chrome/browser/ui/activity_services/requirements", "//ios/chrome/browser/ui/activity_services/requirements",
"//ios/chrome/browser/ui/bubble", "//ios/chrome/browser/ui/bubble",
......
...@@ -22,6 +22,7 @@ ...@@ -22,6 +22,7 @@
#import "ios/chrome/browser/ui/toolbar/public/web_toolbar_controller_constants.h" #import "ios/chrome/browser/ui/toolbar/public/web_toolbar_controller_constants.h"
#import "ios/chrome/browser/ui/uikit_ui_util.h" #import "ios/chrome/browser/ui/uikit_ui_util.h"
#import "ios/chrome/browser/ui/util/constraints_ui_util.h" #import "ios/chrome/browser/ui/util/constraints_ui_util.h"
#include "ios/chrome/grit/ios_theme_resources.h"
#import "ios/third_party/material_components_ios/src/components/ProgressView/src/MaterialProgressView.h" #import "ios/third_party/material_components_ios/src/components/ProgressView/src/MaterialProgressView.h"
#if !defined(__has_feature) || !__has_feature(objc_arc) #if !defined(__has_feature) || !__has_feature(objc_arc)
...@@ -46,6 +47,8 @@ ...@@ -46,6 +47,8 @@
@property(nonatomic, assign) BOOL voiceSearchEnabled; @property(nonatomic, assign) BOOL voiceSearchEnabled;
@property(nonatomic, strong) MDCProgressView* progressBar; @property(nonatomic, strong) MDCProgressView* progressBar;
@property(nonatomic, strong) UIStackView* locationBarContainerStackView; @property(nonatomic, strong) UIStackView* locationBarContainerStackView;
// The shadow below the toolbar. Lazily instantiated.
@property(nonatomic, strong) UIImageView* shadowView;
// Background view, used to display the incognito NTP background color on the // Background view, used to display the incognito NTP background color on the
// toolbar. // toolbar.
@property(nonatomic, strong) UIView* backgroundView; @property(nonatomic, strong) UIView* backgroundView;
...@@ -87,25 +90,11 @@ ...@@ -87,25 +90,11 @@
@synthesize voiceSearchEnabled = _voiceSearchEnabled; @synthesize voiceSearchEnabled = _voiceSearchEnabled;
@synthesize progressBar = _progressBar; @synthesize progressBar = _progressBar;
@synthesize locationBarContainerStackView = _locationBarContainerStackView; @synthesize locationBarContainerStackView = _locationBarContainerStackView;
@synthesize shadowView = _shadowView;
@synthesize expandedToolbarConstraints = _expandedToolbarConstraints; @synthesize expandedToolbarConstraints = _expandedToolbarConstraints;
@synthesize topSafeAnchor = _topSafeAnchor; @synthesize topSafeAnchor = _topSafeAnchor;
@synthesize regularToolbarConstraints = _regularToolbarConstraints; @synthesize regularToolbarConstraints = _regularToolbarConstraints;
#pragma mark - Properties accessor
- (UIView*)backgroundView {
if (!_backgroundView) {
_backgroundView = [[UIView alloc] initWithFrame:CGRectZero];
_backgroundView.translatesAutoresizingMaskIntoConstraints = NO;
_backgroundView.backgroundColor =
[UIColor colorWithWhite:kNTPBackgroundColorBrightnessIncognito
alpha:1.0];
[self.view insertSubview:_backgroundView atIndex:0];
AddSameConstraints(self.view, _backgroundView);
}
return _backgroundView;
}
#pragma mark - Public #pragma mark - Public
- (instancetype)initWithDispatcher: - (instancetype)initWithDispatcher:
...@@ -192,6 +181,7 @@ ...@@ -192,6 +181,7 @@
[self setUpToolbarStackView]; [self setUpToolbarStackView];
[self setUpLocationBarContainerView]; [self setUpLocationBarContainerView];
[self.view addSubview:self.stackView]; [self.view addSubview:self.stackView];
[self.view addSubview:self.shadowView];
[self.view addSubview:self.progressBar]; [self.view addSubview:self.progressBar];
[self setConstraints]; [self setConstraints];
} }
...@@ -257,6 +247,17 @@ ...@@ -257,6 +247,17 @@
]; ];
[NSLayoutConstraint activateConstraints:progressBarConstraints]; [NSLayoutConstraint activateConstraints:progressBarConstraints];
// Shadow constraints.
[NSLayoutConstraint activateConstraints:@[
[self.shadowView.topAnchor constraintEqualToAnchor:self.view.bottomAnchor],
[self.shadowView.leadingAnchor
constraintEqualToAnchor:self.view.leadingAnchor],
[self.shadowView.trailingAnchor
constraintEqualToAnchor:self.view.trailingAnchor],
[self.shadowView.heightAnchor
constraintEqualToConstant:kToolbarShadowHeight],
]];
// StackView constraints. The main Toolbar StackView. // StackView constraints. The main Toolbar StackView.
NSArray* stackViewConstraints = @[ NSArray* stackViewConstraints = @[
[self.stackView.heightAnchor [self.stackView.heightAnchor
...@@ -613,6 +614,19 @@ ...@@ -613,6 +614,19 @@
#pragma mark - Setters & Getters. #pragma mark - Setters & Getters.
- (UIView*)backgroundView {
if (!_backgroundView) {
_backgroundView = [[UIView alloc] initWithFrame:CGRectZero];
_backgroundView.translatesAutoresizingMaskIntoConstraints = NO;
_backgroundView.backgroundColor =
[UIColor colorWithWhite:kNTPBackgroundColorBrightnessIncognito
alpha:1.0];
[self.view insertSubview:_backgroundView atIndex:0];
AddSameConstraints(self.view, _backgroundView);
}
return _backgroundView;
}
- (NSLayoutYAxisAnchor*)topSafeAnchor { - (NSLayoutYAxisAnchor*)topSafeAnchor {
if (!_topSafeAnchor) { if (!_topSafeAnchor) {
if (@available(iOS 11, *)) { if (@available(iOS 11, *)) {
...@@ -671,6 +685,16 @@ ...@@ -671,6 +685,16 @@
_locationBarView = view; _locationBarView = view;
} }
- (UIImageView*)shadowView {
if (!_shadowView) {
_shadowView = [[UIImageView alloc] init];
_shadowView.translatesAutoresizingMaskIntoConstraints = NO;
_shadowView.userInteractionEnabled = NO;
_shadowView.image = NativeImage(IDR_IOS_TOOLBAR_SHADOW);
}
return _shadowView;
}
#pragma mark - Private #pragma mark - Private
// Sets the progress of the progressBar to 1 then hides it. // Sets the progress of the progressBar to 1 then hides it.
......
...@@ -67,6 +67,9 @@ extern const LayoutOffset kButtonFadeOutXOffset; ...@@ -67,6 +67,9 @@ extern const LayoutOffset kButtonFadeOutXOffset;
// a popover anchored to it. // a popover anchored to it.
extern const CGFloat kPopoverAnchorHorizontalPadding; extern const CGFloat kPopoverAnchorHorizontalPadding;
// Height of the shadow displayed below the toolbar.
extern const CGFloat kToolbarShadowHeight;
// Toolbar style. Determines which button images are used. // Toolbar style. Determines which button images are used.
enum ToolbarControllerStyle { enum ToolbarControllerStyle {
ToolbarControllerStyleLightMode = 0, ToolbarControllerStyleLightMode = 0,
......
...@@ -28,6 +28,8 @@ const NSInteger kFontSizeTenTabsOrMore = 9; ...@@ -28,6 +28,8 @@ const NSInteger kFontSizeTenTabsOrMore = 9;
const NSUInteger kTransitionLayerCapacity = 11; const NSUInteger kTransitionLayerCapacity = 11;
const CGFloat kToolbarShadowHeight = 2;
// Macros for creating CGRects of height H, origin (0,0), with the portrait // Macros for creating CGRects of height H, origin (0,0), with the portrait
// width of phone/pad devices. // width of phone/pad devices.
// clang-format off // clang-format off
......
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