Commit 6f1b99ce authored by Gauthier Ambard's avatar Gauthier Ambard Committed by Commit Bot

Change toolbar background color during side swipe

During side swipe, the snapshot of the toolbar cannot have the blur
effect. This CL adds a solid grey background on the toolbar during the
side swipe.

Bug: 807988
Cq-Include-Trybots: master.tryserver.chromium.mac:ios-simulator-cronet;master.tryserver.chromium.mac:ios-simulator-full-configs
Change-Id: I6301068a453e70cc1da005858657dd0fdd2f8ea1
Reviewed-on: https://chromium-review.googlesource.com/955422
Commit-Queue: Gauthier Ambard <gambard@chromium.org>
Reviewed-by: default avatarJustin Cohen <justincohen@chromium.org>
Cr-Commit-Position: refs/heads/master@{#542122}
parent ff99524d
...@@ -120,9 +120,7 @@ ...@@ -120,9 +120,7 @@
BOOL isNTP = IsVisibleUrlNewTabPage(webState); BOOL isNTP = IsVisibleUrlNewTabPage(webState);
[self.mediator updateConsumerForWebState:webState]; [self.mediator updateConsumerForWebState:webState];
if (webState != self.webStateList->GetActiveWebState() || isNTP) {
[self.viewController updateForSideSwipeSnapshotOnNTP:isNTP]; [self.viewController updateForSideSwipeSnapshotOnNTP:isNTP];
}
} }
- (void)resetToolbarAfterSideSwipeSnapshot { - (void)resetToolbarAfterSideSwipeSnapshot {
......
...@@ -22,6 +22,9 @@ ...@@ -22,6 +22,9 @@
// Progress bar displayed below the toolbar. // Progress bar displayed below the toolbar.
@property(nonatomic, strong, readonly) MDCProgressView* progressBar; @property(nonatomic, strong, readonly) MDCProgressView* progressBar;
// The blur visual effect view.
@property(nonatomic, strong, readonly) UIVisualEffectView* blur;
// Button to navigate back. // Button to navigate back.
@property(nonatomic, strong, readonly) ToolbarButton* backButton; @property(nonatomic, strong, readonly) ToolbarButton* backButton;
// Buttons to navigate forward. // Buttons to navigate forward.
......
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
#import "ios/chrome/browser/ui/toolbar/adaptive/adaptive_toolbar_view.h" #import "ios/chrome/browser/ui/toolbar/adaptive/adaptive_toolbar_view.h"
#import "ios/chrome/browser/ui/toolbar/buttons/toolbar_button.h" #import "ios/chrome/browser/ui/toolbar/buttons/toolbar_button.h"
#import "ios/chrome/browser/ui/toolbar/buttons/toolbar_button_factory.h" #import "ios/chrome/browser/ui/toolbar/buttons/toolbar_button_factory.h"
#import "ios/chrome/browser/ui/toolbar/buttons/toolbar_configuration.h"
#import "ios/chrome/browser/ui/toolbar/buttons/toolbar_constants.h" #import "ios/chrome/browser/ui/toolbar/buttons/toolbar_constants.h"
#import "ios/chrome/browser/ui/toolbar/buttons/toolbar_tab_grid_button.h" #import "ios/chrome/browser/ui/toolbar/buttons/toolbar_tab_grid_button.h"
#import "ios/chrome/browser/ui/toolbar/buttons/toolbar_tools_menu_button.h" #import "ios/chrome/browser/ui/toolbar/buttons/toolbar_tools_menu_button.h"
...@@ -40,11 +41,16 @@ ...@@ -40,11 +41,16 @@
- (void)updateForSideSwipeSnapshotOnNTP:(BOOL)onNTP { - (void)updateForSideSwipeSnapshotOnNTP:(BOOL)onNTP {
self.view.progressBar.hidden = YES; self.view.progressBar.hidden = YES;
self.view.blur.hidden = YES;
self.view.backgroundColor =
self.buttonFactory.toolbarConfiguration.backgroundColor;
// TODO(crbug.com/804850): Have the correct background color for incognito // TODO(crbug.com/804850): Have the correct background color for incognito
// NTP. // NTP.
} }
- (void)resetAfterSideSwipeSnapshot { - (void)resetAfterSideSwipeSnapshot {
self.view.blur.hidden = NO;
self.view.backgroundColor = [UIColor clearColor];
} }
#pragma mark - UIViewController #pragma mark - UIViewController
......
...@@ -30,9 +30,6 @@ ...@@ -30,9 +30,6 @@
// Container for the location bar. // Container for the location bar.
@property(nonatomic, strong, readonly) UIView* locationBarContainer; @property(nonatomic, strong, readonly) UIView* locationBarContainer;
// The blur visual effect view.
@property(nonatomic, strong, readwrite) UIVisualEffectView* blur;
// The height of the container for the location bar. // The height of the container for the location bar.
@property(nonatomic, strong, readonly) NSLayoutConstraint* locationBarHeight; @property(nonatomic, strong, readonly) NSLayoutConstraint* locationBarHeight;
......
...@@ -22,10 +22,12 @@ ...@@ -22,10 +22,12 @@
// Factory used to create the buttons. // Factory used to create the buttons.
@property(nonatomic, strong) ToolbarButtonFactory* buttonFactory; @property(nonatomic, strong) ToolbarButtonFactory* buttonFactory;
// Content view in which the view that might have vibrancy effect should be // ContentView of the vibrancy effect if there is one, self otherwise.
// added.
@property(nonatomic, strong) UIView* contentView; @property(nonatomic, strong) UIView* contentView;
// The blur visual effect view, redefined as readwrite.
@property(nonatomic, strong, readwrite) UIVisualEffectView* blur;
// Container for the location bar, redefined as readwrite. // Container for the location bar, redefined as readwrite.
@property(nonatomic, strong, readwrite) UIView* locationBarContainer; @property(nonatomic, strong, readwrite) UIView* locationBarContainer;
// The height of the container for the location bar, redefined as readwrite. // The height of the container for the location bar, redefined as readwrite.
...@@ -149,6 +151,7 @@ ...@@ -149,6 +151,7 @@
self.blur = [[UIVisualEffectView alloc] initWithEffect:blurEffect]; self.blur = [[UIVisualEffectView alloc] initWithEffect:blurEffect];
self.blur.contentView.backgroundColor = self.blur.contentView.backgroundColor =
self.buttonFactory.toolbarConfiguration.blurEffectBackgroundColor; self.buttonFactory.toolbarConfiguration.blurEffectBackgroundColor;
[self addSubview:self.blur];
self.contentView = self; self.contentView = self;
...@@ -157,12 +160,11 @@ ...@@ -157,12 +160,11 @@
UIVisualEffectView* vibrancyView = UIVisualEffectView* vibrancyView =
[[UIVisualEffectView alloc] initWithEffect:vibrancy]; [[UIVisualEffectView alloc] initWithEffect:vibrancy];
self.contentView = vibrancyView.contentView; self.contentView = vibrancyView.contentView;
[self.blur.contentView addSubview:vibrancyView]; [self addSubview:vibrancyView];
vibrancyView.translatesAutoresizingMaskIntoConstraints = NO; vibrancyView.translatesAutoresizingMaskIntoConstraints = NO;
AddSameConstraints(self.blur, vibrancyView); AddSameConstraints(self, vibrancyView);
} }
[self addSubview:self.blur];
self.blur.translatesAutoresizingMaskIntoConstraints = NO; self.blur.translatesAutoresizingMaskIntoConstraints = NO;
AddSameConstraints(self.blur, self); AddSameConstraints(self.blur, self);
......
...@@ -23,6 +23,9 @@ ...@@ -23,6 +23,9 @@
// Redefined as readwrite // Redefined as readwrite
@property(nonatomic, strong, readwrite) NSArray<ToolbarButton*>* allButtons; @property(nonatomic, strong, readwrite) NSArray<ToolbarButton*>* allButtons;
// The blur visual effect view, redefined as readwrite.
@property(nonatomic, strong, readwrite) UIVisualEffectView* blur;
// The stack view containing the buttons. // The stack view containing the buttons.
@property(nonatomic, strong) UIStackView* stackView; @property(nonatomic, strong) UIStackView* stackView;
...@@ -49,6 +52,7 @@ ...@@ -49,6 +52,7 @@
@synthesize toolsMenuButton = _toolsMenuButton; @synthesize toolsMenuButton = _toolsMenuButton;
@synthesize omniboxButton = _omniboxButton; @synthesize omniboxButton = _omniboxButton;
@synthesize tabGridButton = _tabGridButton; @synthesize tabGridButton = _tabGridButton;
@synthesize blur = _blur;
#pragma mark - Public #pragma mark - Public
...@@ -80,14 +84,13 @@ ...@@ -80,14 +84,13 @@
self.translatesAutoresizingMaskIntoConstraints = NO; self.translatesAutoresizingMaskIntoConstraints = NO;
UIBlurEffect* blurEffect = self.buttonFactory.toolbarConfiguration.blurEffect; UIBlurEffect* blurEffect = self.buttonFactory.toolbarConfiguration.blurEffect;
UIVisualEffectView* blur = self.blur = [[UIVisualEffectView alloc] initWithEffect:blurEffect];
[[UIVisualEffectView alloc] initWithEffect:blurEffect]; self.blur.contentView.backgroundColor =
blur.contentView.backgroundColor =
self.buttonFactory.toolbarConfiguration.blurEffectBackgroundColor; self.buttonFactory.toolbarConfiguration.blurEffectBackgroundColor;
[self addSubview:blur]; [self addSubview:self.blur];
blur.translatesAutoresizingMaskIntoConstraints = NO; self.blur.translatesAutoresizingMaskIntoConstraints = NO;
AddSameConstraints(blur, self); AddSameConstraints(self.blur, self);
UIView* contentView = self; UIView* contentView = self;
if (UIVisualEffect* vibrancy = [self.buttonFactory.toolbarConfiguration if (UIVisualEffect* vibrancy = [self.buttonFactory.toolbarConfiguration
......
...@@ -30,7 +30,6 @@ ...@@ -30,7 +30,6 @@
@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.
......
...@@ -57,8 +57,13 @@ ...@@ -57,8 +57,13 @@
- (UIColor*)backgroundColor { - (UIColor*)backgroundColor {
if (IsUIRefreshPhase1Enabled()) { if (IsUIRefreshPhase1Enabled()) {
NOTREACHED(); switch (self.style) {
return nil; case NORMAL:
return
[UIColor colorWithWhite:kBlurBackgroundGrayscaleComponent alpha:1];
case INCOGNITO:
return UIColorFromRGB(kIncognitoToolbarBackgroundColor);
}
} else { } else {
switch (self.style) { switch (self.style) {
case NORMAL: case NORMAL:
......
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