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 @@
BOOL isNTP = IsVisibleUrlNewTabPage(webState);
[self.mediator updateConsumerForWebState:webState];
if (webState != self.webStateList->GetActiveWebState() || isNTP) {
[self.viewController updateForSideSwipeSnapshotOnNTP:isNTP];
}
[self.viewController updateForSideSwipeSnapshotOnNTP:isNTP];
}
- (void)resetToolbarAfterSideSwipeSnapshot {
......
......@@ -22,6 +22,9 @@
// Progress bar displayed below the toolbar.
@property(nonatomic, strong, readonly) MDCProgressView* progressBar;
// The blur visual effect view.
@property(nonatomic, strong, readonly) UIVisualEffectView* blur;
// Button to navigate back.
@property(nonatomic, strong, readonly) ToolbarButton* backButton;
// Buttons to navigate forward.
......
......@@ -9,6 +9,7 @@
#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_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_tab_grid_button.h"
#import "ios/chrome/browser/ui/toolbar/buttons/toolbar_tools_menu_button.h"
......@@ -40,11 +41,16 @@
- (void)updateForSideSwipeSnapshotOnNTP:(BOOL)onNTP {
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
// NTP.
}
- (void)resetAfterSideSwipeSnapshot {
self.view.blur.hidden = NO;
self.view.backgroundColor = [UIColor clearColor];
}
#pragma mark - UIViewController
......
......@@ -30,9 +30,6 @@
// Container for the location bar.
@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.
@property(nonatomic, strong, readonly) NSLayoutConstraint* locationBarHeight;
......
......@@ -22,10 +22,12 @@
// Factory used to create the buttons.
@property(nonatomic, strong) ToolbarButtonFactory* buttonFactory;
// Content view in which the view that might have vibrancy effect should be
// added.
// ContentView of the vibrancy effect if there is one, self otherwise.
@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.
@property(nonatomic, strong, readwrite) UIView* locationBarContainer;
// The height of the container for the location bar, redefined as readwrite.
......@@ -149,6 +151,7 @@
self.blur = [[UIVisualEffectView alloc] initWithEffect:blurEffect];
self.blur.contentView.backgroundColor =
self.buttonFactory.toolbarConfiguration.blurEffectBackgroundColor;
[self addSubview:self.blur];
self.contentView = self;
......@@ -157,12 +160,11 @@
UIVisualEffectView* vibrancyView =
[[UIVisualEffectView alloc] initWithEffect:vibrancy];
self.contentView = vibrancyView.contentView;
[self.blur.contentView addSubview:vibrancyView];
[self addSubview:vibrancyView];
vibrancyView.translatesAutoresizingMaskIntoConstraints = NO;
AddSameConstraints(self.blur, vibrancyView);
AddSameConstraints(self, vibrancyView);
}
[self addSubview:self.blur];
self.blur.translatesAutoresizingMaskIntoConstraints = NO;
AddSameConstraints(self.blur, self);
......
......@@ -23,6 +23,9 @@
// Redefined as readwrite
@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.
@property(nonatomic, strong) UIStackView* stackView;
......@@ -49,6 +52,7 @@
@synthesize toolsMenuButton = _toolsMenuButton;
@synthesize omniboxButton = _omniboxButton;
@synthesize tabGridButton = _tabGridButton;
@synthesize blur = _blur;
#pragma mark - Public
......@@ -80,14 +84,13 @@
self.translatesAutoresizingMaskIntoConstraints = NO;
UIBlurEffect* blurEffect = self.buttonFactory.toolbarConfiguration.blurEffect;
UIVisualEffectView* blur =
[[UIVisualEffectView alloc] initWithEffect:blurEffect];
blur.contentView.backgroundColor =
self.blur = [[UIVisualEffectView alloc] initWithEffect:blurEffect];
self.blur.contentView.backgroundColor =
self.buttonFactory.toolbarConfiguration.blurEffectBackgroundColor;
[self addSubview:blur];
blur.translatesAutoresizingMaskIntoConstraints = NO;
AddSameConstraints(blur, self);
[self addSubview:self.blur];
self.blur.translatesAutoresizingMaskIntoConstraints = NO;
AddSameConstraints(self.blur, self);
UIView* contentView = self;
if (UIVisualEffect* vibrancy = [self.buttonFactory.toolbarConfiguration
......
......@@ -30,7 +30,6 @@
@property(nonatomic, readonly) UIColor* NTPBackgroundColor;
// Background color of the toolbar.
// TODO(crbug.com/800266): Remove this property.
@property(nonatomic, readonly) UIColor* backgroundColor;
// Background color of the omnibox.
......
......@@ -57,8 +57,13 @@
- (UIColor*)backgroundColor {
if (IsUIRefreshPhase1Enabled()) {
NOTREACHED();
return nil;
switch (self.style) {
case NORMAL:
return
[UIColor colorWithWhite:kBlurBackgroundGrayscaleComponent alpha:1];
case INCOGNITO:
return UIColorFromRGB(kIncognitoToolbarBackgroundColor);
}
} else {
switch (self.style) {
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