Commit 4d42436e authored by Gauthier Ambard's avatar Gauthier Ambard Committed by Commit Bot

Add blur effect to the toolbar

This CL adds a blur effect to the toolbar's background, to see the
content of the page below.

Screenshot: https://drive.google.com/file/d/1MB5lyrozQ3OkEenWtXi3MWfOy0e2hwxx/view

Bug: 805846
Cq-Include-Trybots: master.tryserver.chromium.mac:ios-simulator-cronet;master.tryserver.chromium.mac:ios-simulator-full-configs
Change-Id: Ib12dd0396fbfef9868d352e92a9ec0981aa091df
Reviewed-on: https://chromium-review.googlesource.com/897323
Commit-Queue: Gauthier Ambard <gambard@chromium.org>
Reviewed-by: default avatarLouis Romero <lpromero@chromium.org>
Cr-Commit-Position: refs/heads/master@{#533645}
parent e6e5740d
...@@ -104,10 +104,9 @@ ...@@ -104,10 +104,9 @@
} }
DCHECK(self.buttonFactory); DCHECK(self.buttonFactory);
self.backgroundColor =
self.buttonFactory.toolbarConfiguration.backgroundColor;
self.translatesAutoresizingMaskIntoConstraints = NO; self.translatesAutoresizingMaskIntoConstraints = NO;
[self setUpBlurredBackground];
[self setUpLocationBar]; [self setUpLocationBar];
[self setUpLeadingStackView]; [self setUpLeadingStackView];
[self setUpTrailingStackView]; [self setUpTrailingStackView];
...@@ -124,11 +123,22 @@ ...@@ -124,11 +123,22 @@
#pragma mark - Setup #pragma mark - Setup
// Sets the blur effect on the toolbar background.
- (void)setUpBlurredBackground {
UIBlurEffect* blurEffect = self.buttonFactory.toolbarConfiguration.blurEffect;
UIVisualEffectView* blur =
[[UIVisualEffectView alloc] initWithEffect:blurEffect];
[self addSubview:blur];
blur.translatesAutoresizingMaskIntoConstraints = NO;
AddSameConstraints(blur, self);
}
// Sets the location bar container and its view if present. // Sets the location bar container and its view if present.
- (void)setUpLocationBar { - (void)setUpLocationBar {
self.locationBarContainer = [[UIView alloc] init]; self.locationBarContainer = [[UIView alloc] init];
self.locationBarContainer.backgroundColor = self.locationBarContainer.backgroundColor =
self.buttonFactory.toolbarConfiguration.omniboxBackgroundColor; [self.buttonFactory.toolbarConfiguration
locationBarBackgroundColorWithVisibility:1];
self.locationBarContainer.layer.cornerRadius = self.locationBarContainer.layer.cornerRadius =
kAdaptiveLocationBarCornerRadius; kAdaptiveLocationBarCornerRadius;
[self.locationBarContainer [self.locationBarContainer
......
...@@ -59,8 +59,7 @@ ...@@ -59,8 +59,7 @@
- (void)resetAfterSideSwipeSnapshot { - (void)resetAfterSideSwipeSnapshot {
[super resetAfterSideSwipeSnapshot]; [super resetAfterSideSwipeSnapshot];
self.view.backgroundColor = self.view.backgroundColor = nil;
self.buttonFactory.toolbarConfiguration.backgroundColor;
self.view.locationBarContainer.hidden = NO; self.view.locationBarContainer.hidden = NO;
} }
...@@ -137,8 +136,8 @@ ...@@ -137,8 +136,8 @@
(kToolbarHeight - kToolbarHeightFullscreen) * progress - (kToolbarHeight - kToolbarHeightFullscreen) * progress -
2 * kLocationBarVerticalMargin); 2 * kLocationBarVerticalMargin);
self.view.locationBarContainer.backgroundColor = self.view.locationBarContainer.backgroundColor =
[self.buttonFactory.toolbarConfiguration.omniboxBackgroundColor [self.buttonFactory.toolbarConfiguration
colorWithAlphaComponent:alphaValue]; locationBarBackgroundColorWithVisibility:alphaValue];
} }
- (void)updateForFullscreenEnabled:(BOOL)enabled { - (void)updateForFullscreenEnabled:(BOOL)enabled {
......
...@@ -71,10 +71,15 @@ ...@@ -71,10 +71,15 @@
} }
DCHECK(self.buttonFactory); DCHECK(self.buttonFactory);
self.backgroundColor =
self.buttonFactory.toolbarConfiguration.backgroundColor;
self.translatesAutoresizingMaskIntoConstraints = NO; self.translatesAutoresizingMaskIntoConstraints = NO;
UIBlurEffect* blurEffect = self.buttonFactory.toolbarConfiguration.blurEffect;
UIVisualEffectView* blur =
[[UIVisualEffectView alloc] initWithEffect:blurEffect];
[self addSubview:blur];
blur.translatesAutoresizingMaskIntoConstraints = NO;
AddSameConstraints(blur, self);
self.tabGridButton = [self.buttonFactory tabGridButton]; self.tabGridButton = [self.buttonFactory tabGridButton];
self.shareButton = [self.buttonFactory shareButton]; self.shareButton = [self.buttonFactory shareButton];
self.omniboxButton = [self.buttonFactory omniboxButton]; self.omniboxButton = [self.buttonFactory omniboxButton];
......
...@@ -19,17 +19,23 @@ ...@@ -19,17 +19,23 @@
// Style of this configuration. // Style of this configuration.
@property(nonatomic, assign) ToolbarStyle style; @property(nonatomic, assign) ToolbarStyle style;
// Blur effect for the toolbar background.
@property(nonatomic, readonly) UIBlurEffect* blurEffect;
// Background color of the NTP. Used to do as if the toolbar was transparent and // Background color of the NTP. Used to do as if the toolbar was transparent and
// the NTP is visible behind it. // the NTP is visible behind it.
@property(nonatomic, readonly) UIColor* NTPBackgroundColor; @property(nonatomic, readonly) UIColor* NTPBackgroundColor;
// Background color of the toolbar. // Background color of the toolbar.
// TODO(crbug.com/800266): Remove this property.
@property(nonatomic, readonly) UIColor* backgroundColor; @property(nonatomic, readonly) UIColor* backgroundColor;
// Background color of the omnibox. // Background color of the omnibox.
// TODO(crbug.com/800266): Remove this property.
@property(nonatomic, readonly) UIColor* omniboxBackgroundColor; @property(nonatomic, readonly) UIColor* omniboxBackgroundColor;
// Border color of the omnibox. // Border color of the omnibox.
// TODO(crbug.com/800266): Remove this property.
@property(nonatomic, readonly) UIColor* omniboxBorderColor; @property(nonatomic, readonly) UIColor* omniboxBorderColor;
// Color of the title of the buttons for the normal state. // Color of the title of the buttons for the normal state.
...@@ -38,6 +44,12 @@ ...@@ -38,6 +44,12 @@
// Color of the title of the buttons for the highlighted state. // Color of the title of the buttons for the highlighted state.
@property(nonatomic, readonly) UIColor* buttonTitleHighlightedColor; @property(nonatomic, readonly) UIColor* buttonTitleHighlightedColor;
// Returns the background color of the location bar, with a |visibilityFactor|.
// The |visibilityFactor| is here to alter the alpha value of the background
// color. Even with a |visibilityFactor| of 1, the final color could is
// translucent.
- (UIColor*)locationBarBackgroundColorWithVisibility:(CGFloat)visibilityFactor;
@end @end
#endif // IOS_CHROME_BROWSER_UI_TOOLBAR_CLEAN_TOOLBAR_CONFIGURATION_H_ #endif // IOS_CHROME_BROWSER_UI_TOOLBAR_CLEAN_TOOLBAR_CONFIGURATION_H_
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
#import "ios/chrome/browser/ui/toolbar/clean/toolbar_configuration.h" #import "ios/chrome/browser/ui/toolbar/clean/toolbar_configuration.h"
#import "base/logging.h"
#import "ios/chrome/browser/ui/toolbar/clean/toolbar_constants.h" #import "ios/chrome/browser/ui/toolbar/clean/toolbar_constants.h"
#import "ios/chrome/browser/ui/toolbar/public/web_toolbar_controller_constants.h" #import "ios/chrome/browser/ui/toolbar/public/web_toolbar_controller_constants.h"
#include "ios/chrome/browser/ui/ui_util.h" #include "ios/chrome/browser/ui/ui_util.h"
...@@ -25,6 +26,15 @@ ...@@ -25,6 +26,15 @@
return self; return self;
} }
- (UIBlurEffect*)blurEffect {
switch (self.style) {
case NORMAL:
return [UIBlurEffect effectWithStyle:UIBlurEffectStyleProminent];
case INCOGNITO:
return [UIBlurEffect effectWithStyle:UIBlurEffectStyleDark];
}
}
- (UIColor*)NTPBackgroundColor { - (UIColor*)NTPBackgroundColor {
switch (self.style) { switch (self.style) {
case NORMAL: case NORMAL:
...@@ -37,12 +47,8 @@ ...@@ -37,12 +47,8 @@
- (UIColor*)backgroundColor { - (UIColor*)backgroundColor {
if (IsUIRefreshPhase1Enabled()) { if (IsUIRefreshPhase1Enabled()) {
switch (self.style) { NOTREACHED();
case NORMAL: return nil;
return UIColorFromRGB(kAdaptiveToolbarBackgroundColor);
case INCOGNITO:
return UIColorFromRGB(kIncognitoToolbarBackgroundColor);
}
} else { } else {
switch (self.style) { switch (self.style) {
case NORMAL: case NORMAL:
...@@ -55,12 +61,8 @@ ...@@ -55,12 +61,8 @@
- (UIColor*)omniboxBackgroundColor { - (UIColor*)omniboxBackgroundColor {
if (IsUIRefreshPhase1Enabled()) { if (IsUIRefreshPhase1Enabled()) {
switch (self.style) { NOTREACHED();
case NORMAL: return nil;
return UIColorFromRGB(kAdaptiveLocationBackgroundColor);
case INCOGNITO:
return UIColorFromRGB(kIcongnitoAdaptiveLocationBackgroundColor);
}
} else { } else {
switch (self.style) { switch (self.style) {
case NORMAL: case NORMAL:
...@@ -72,11 +74,16 @@ ...@@ -72,11 +74,16 @@
} }
- (UIColor*)omniboxBorderColor { - (UIColor*)omniboxBorderColor {
switch (self.style) { if (IsUIRefreshPhase1Enabled()) {
case NORMAL: NOTREACHED();
return UIColorFromRGB(kLocationBarBorderColor); return nil;
case INCOGNITO: } else {
return UIColorFromRGB(kIncognitoLocationBarBorderColor); switch (self.style) {
case NORMAL:
return UIColorFromRGB(kLocationBarBorderColor);
case INCOGNITO:
return UIColorFromRGB(kIncognitoLocationBarBorderColor);
}
} }
} }
...@@ -98,4 +105,17 @@ ...@@ -98,4 +105,17 @@
} }
} }
- (UIColor*)locationBarBackgroundColorWithVisibility:(CGFloat)visibilityFactor {
switch (self.style) {
case NORMAL:
return [UIColor colorWithWhite:0
alpha:kAdaptiveLocationBarBackgroundAlpha *
visibilityFactor];
case INCOGNITO:
return [UIColor colorWithWhite:1
alpha:kAdaptiveLocationBarBackgroundAlpha *
visibilityFactor];
}
}
@end @end
...@@ -56,12 +56,9 @@ extern const NSInteger kShowTabStripButtonMaxTabCount; ...@@ -56,12 +56,9 @@ extern const NSInteger kShowTabStripButtonMaxTabCount;
// Animation constants. // Animation constants.
extern const LayoutOffset kToolbarButtonAnimationOffset; extern const LayoutOffset kToolbarButtonAnimationOffset;
// Adaptive Toolbar styling.
extern const CGFloat kAdaptiveToolbarBackgroundColor;
// Adaptive Location bar constants. // Adaptive Location bar constants.
extern const CGFloat kAdaptiveLocationBarCornerRadius; extern const CGFloat kAdaptiveLocationBarCornerRadius;
extern const CGFloat kAdaptiveLocationBackgroundColor;
extern const CGFloat kIcongnitoAdaptiveLocationBackgroundColor; extern const CGFloat kIcongnitoAdaptiveLocationBackgroundColor;
extern const CGFloat kAdaptiveLocationBarBackgroundAlpha;
#endif // IOS_CHROME_BROWSER_UI_TOOLBAR_CLEAN_TOOLBAR_CONSTANTS_H_ #endif // IOS_CHROME_BROWSER_UI_TOOLBAR_CLEAN_TOOLBAR_CONSTANTS_H_
...@@ -43,7 +43,6 @@ const NSInteger kShowTabStripButtonMaxTabCount = 99; ...@@ -43,7 +43,6 @@ const NSInteger kShowTabStripButtonMaxTabCount = 99;
const LayoutOffset kToolbarButtonAnimationOffset = -10.0; const LayoutOffset kToolbarButtonAnimationOffset = -10.0;
const CGFloat kAdaptiveToolbarBackgroundColor = 0xE4E4E4; const CGFloat kAdaptiveLocationBarCornerRadius = 11;
const CGFloat kAdaptiveLocationBarCornerRadius = 12;
const CGFloat kAdaptiveLocationBackgroundColor = 0xCCCCCC;
const CGFloat kIcongnitoAdaptiveLocationBackgroundColor = 0x6A6A6A; const CGFloat kIcongnitoAdaptiveLocationBackgroundColor = 0x6A6A6A;
const CGFloat kAdaptiveLocationBarBackgroundAlpha = 0.12;
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