Commit 2a94be7a authored by Robbie Gibson's avatar Robbie Gibson Committed by Commit Bot

[iOS] Remove transparency on toolbars

Bug: 976643
Change-Id: I13e7f454112ddfa9eed2779290fefd8dcaeee8a3
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1691920Reviewed-by: default avatarGauthier Ambard <gambard@chromium.org>
Reviewed-by: default avatarRohit Rao <rohitrao@chromium.org>
Reviewed-by: default avatarJavier Ernesto Flores Robles <javierrobles@chromium.org>
Commit-Queue: Robbie Gibson <rkgibson@google.com>
Cr-Commit-Position: refs/heads/master@{#676893}
parent 377104d0
...@@ -130,25 +130,14 @@ CGFloat IdentityDiscToolbarOffset(id<UITraitEnvironment> environment) { ...@@ -130,25 +130,14 @@ CGFloat IdentityDiscToolbarOffset(id<UITraitEnvironment> environment) {
// Fake Toolbar. // Fake Toolbar.
ToolbarButtonFactory* buttonFactory = ToolbarButtonFactory* buttonFactory =
[[ToolbarButtonFactory alloc] initWithStyle:NORMAL]; [[ToolbarButtonFactory alloc] initWithStyle:NORMAL];
UIBlurEffect* blurEffect = buttonFactory.toolbarConfiguration.blurEffect; UIView* fakeToolbar = [[UIView alloc] init];
UIView* fakeToolbar = nil;
UIView* fakeToolbarContentView;
if (blurEffect) {
UIVisualEffectView* visualEffectView =
[[UIVisualEffectView alloc] initWithEffect:blurEffect];
fakeToolbar = visualEffectView;
fakeToolbarContentView = visualEffectView.contentView;
} else {
fakeToolbar = [[UIView alloc] init];
fakeToolbarContentView = fakeToolbar;
}
fakeToolbar.backgroundColor = fakeToolbar.backgroundColor =
buttonFactory.toolbarConfiguration.blurBackgroundColor; buttonFactory.toolbarConfiguration.backgroundColor;
[searchField insertSubview:fakeToolbar atIndex:0]; [searchField insertSubview:fakeToolbar atIndex:0];
fakeToolbar.translatesAutoresizingMaskIntoConstraints = NO; fakeToolbar.translatesAutoresizingMaskIntoConstraints = NO;
// Fake location bar. // Fake location bar.
[fakeToolbarContentView addSubview:self.fakeLocationBar]; [fakeToolbar addSubview:self.fakeLocationBar];
// Omnibox, used for animations. // Omnibox, used for animations.
// TODO(crbug.com/936811): See if it is possible to share some initialization // TODO(crbug.com/936811): See if it is possible to share some initialization
...@@ -335,7 +324,7 @@ CGFloat IdentityDiscToolbarOffset(id<UITraitEnvironment> environment) { ...@@ -335,7 +324,7 @@ CGFloat IdentityDiscToolbarOffset(id<UITraitEnvironment> environment) {
self.separator.alpha = percent; self.separator.alpha = percent;
} }
// Grow the blur to cover the safeArea top. // Grow the background to cover the safeArea top.
self.fakeToolbarTopConstraint.constant = -safeAreaInsets.top * percent; self.fakeToolbarTopConstraint.constant = -safeAreaInsets.top * percent;
CGFloat toolbarExpandedHeight = ToolbarHeight(); CGFloat toolbarExpandedHeight = ToolbarHeight();
......
...@@ -45,20 +45,10 @@ const CGFloat kVerticalOffset = 6; ...@@ -45,20 +45,10 @@ const CGFloat kVerticalOffset = 6;
ToolbarConfiguration* configuration = [[ToolbarConfiguration alloc] ToolbarConfiguration* configuration = [[ToolbarConfiguration alloc]
initWithStyle:incognito ? INCOGNITO : NORMAL]; initWithStyle:incognito ? INCOGNITO : NORMAL];
UIBlurEffect* effect = [configuration blurEffect]; UIView* containerView = [[UIView alloc] init];
[containerView addSubview:viewController.view];
if (effect) { _popupContainerView = containerView;
UIVisualEffectView* effectView = _popupContainerView.backgroundColor = [configuration backgroundColor];
[[UIVisualEffectView alloc] initWithEffect:effect];
[effectView.contentView addSubview:viewController.view];
_popupContainerView = effectView;
} else {
UIView* containerView = [[UIView alloc] init];
[containerView addSubview:viewController.view];
_popupContainerView = containerView;
}
_popupContainerView.backgroundColor = [configuration blurBackgroundColor];
_popupContainerView.translatesAutoresizingMaskIntoConstraints = NO; _popupContainerView.translatesAutoresizingMaskIntoConstraints = NO;
viewController.view.translatesAutoresizingMaskIntoConstraints = NO; viewController.view.translatesAutoresizingMaskIntoConstraints = NO;
AddSameConstraints(viewController.view, _popupContainerView); AddSameConstraints(viewController.view, _popupContainerView);
......
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
#include "base/mac/foundation_util.h" #include "base/mac/foundation_util.h"
#import "ios/chrome/browser/ui/table_view/chrome_table_view_controller.h" #import "ios/chrome/browser/ui/table_view/chrome_table_view_controller.h"
#import "ios/chrome/browser/ui/table_view/chrome_table_view_styler.h" #import "ios/chrome/browser/ui/table_view/chrome_table_view_styler.h"
#import "ios/chrome/common/colors/UIColor+cr_semantic_colors.h"
#if !defined(__has_feature) || !__has_feature(objc_arc) #if !defined(__has_feature) || !__has_feature(objc_arc)
#error "This file requires ARC support." #error "This file requires ARC support."
...@@ -30,20 +31,12 @@ ...@@ -30,20 +31,12 @@
- (void)viewDidLoad { - (void)viewDidLoad {
[super viewDidLoad]; [super viewDidLoad];
UIVisualEffectView* visualEffectView = [[UIVisualEffectView alloc] self.navigationBar.translucent = NO;
initWithEffect:[UIBlurEffect self.navigationBar.barTintColor = UIColor.cr_systemBackgroundColor;
effectWithStyle:UIBlurEffectStyleExtraLight]]; self.view.backgroundColor = UIColor.cr_systemBackgroundColor;
self.navigationBar.translucent = YES;
self.navigationController.navigationBar.backgroundColor =
[UIColor clearColor];
[self.navigationController.navigationBar addSubview:visualEffectView];
self.navigationBar.prefersLargeTitles = YES; self.navigationBar.prefersLargeTitles = YES;
[self.toolbar setShadowImage:[UIImage new] self.toolbar.translucent = NO;
forToolbarPosition:UIBarPositionAny];
self.toolbar.translucent = YES;
[self.toolbar addSubview:visualEffectView];
} }
@end @end
...@@ -21,10 +21,6 @@ ...@@ -21,10 +21,6 @@
// 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) UIView* 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.
......
...@@ -59,15 +59,10 @@ const CGFloat kTabGridAnimationsTotalDuration = 0.5; ...@@ -59,15 +59,10 @@ const CGFloat kTabGridAnimationsTotalDuration = 0.5;
- (void)updateForSideSwipeSnapshotOnNTP:(BOOL)onNTP { - (void)updateForSideSwipeSnapshotOnNTP:(BOOL)onNTP {
self.view.progressBar.hidden = YES; self.view.progressBar.hidden = YES;
self.view.progressBar.alpha = 0; self.view.progressBar.alpha = 0;
self.view.blur.hidden = YES;
self.view.backgroundColor =
self.buttonFactory.toolbarConfiguration.backgroundColor;
} }
- (void)resetAfterSideSwipeSnapshot { - (void)resetAfterSideSwipeSnapshot {
self.view.progressBar.alpha = 1; self.view.progressBar.alpha = 1;
self.view.blur.hidden = NO;
self.view.backgroundColor = [UIColor clearColor];
} }
#pragma mark - UIViewController #pragma mark - UIViewController
......
...@@ -19,12 +19,6 @@ ...@@ -19,12 +19,6 @@
// 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 blur effect.
@property(nonatomic, readonly) UIColor* blurBackgroundColor;
// 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;
...@@ -51,10 +45,6 @@ ...@@ -51,10 +45,6 @@
// translucent. // translucent.
- (UIColor*)locationBarBackgroundColorWithVisibility:(CGFloat)visibilityFactor; - (UIColor*)locationBarBackgroundColorWithVisibility:(CGFloat)visibilityFactor;
// Vibrancy effect for the toolbar elements, based on the |blurEffect|. Returns
// nil of no vibrancy effect should be applied.
- (UIVisualEffect*)vibrancyEffectForBlurEffect:(UIBlurEffect*)blurEffect;
@end @end
#endif // IOS_CHROME_BROWSER_UI_TOOLBAR_BUTTONS_TOOLBAR_CONFIGURATION_H_ #endif // IOS_CHROME_BROWSER_UI_TOOLBAR_BUTTONS_TOOLBAR_CONFIGURATION_H_
...@@ -26,32 +26,6 @@ ...@@ -26,32 +26,6 @@
return self; return self;
} }
- (UIBlurEffect*)blurEffect {
if (UIAccessibilityIsReduceTransparencyEnabled())
return nil;
switch (self.style) {
case NORMAL:
return [UIBlurEffect effectWithStyle:UIBlurEffectStyleExtraLight];
case INCOGNITO:
return [UIBlurEffect effectWithStyle:UIBlurEffectStyleDark];
}
}
- (UIColor*)blurBackgroundColor {
if (UIAccessibilityIsReduceTransparencyEnabled()) {
switch (self.style) {
case NORMAL:
return
[UIColor colorWithWhite:kBlurBackgroundGrayscaleComponent alpha:1];
case INCOGNITO:
return UIColorFromRGB(kIncognitoToolbarBackgroundColor);
}
}
return [UIColor colorWithWhite:kBlurBackgroundGrayscaleComponent
alpha:kBlurBackgroundAlpha];
}
- (UIColor*)NTPBackgroundColor { - (UIColor*)NTPBackgroundColor {
switch (self.style) { switch (self.style) {
case NORMAL: case NORMAL:
...@@ -130,16 +104,4 @@ ...@@ -130,16 +104,4 @@
} }
} }
- (UIVisualEffect*)vibrancyEffectForBlurEffect:(UIBlurEffect*)blurEffect {
if (!blurEffect)
return nil;
switch (self.style) {
case NORMAL:
return [UIVibrancyEffect effectForBlurEffect:blurEffect];
case INCOGNITO:
return nil;
}
}
@end @end
...@@ -31,9 +31,6 @@ ...@@ -31,9 +31,6 @@
// ContentView of the vibrancy effect if there is one, self otherwise. // ContentView of the vibrancy effect if there is one, self otherwise.
@property(nonatomic, strong) UIView* contentView; @property(nonatomic, strong) UIView* contentView;
// The blur visual effect view, redefined as readwrite.
@property(nonatomic, strong, readwrite) UIView* 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.
...@@ -125,7 +122,6 @@ ...@@ -125,7 +122,6 @@
@synthesize expandedConstraints = _expandedConstraints; @synthesize expandedConstraints = _expandedConstraints;
@synthesize contractedConstraints = _contractedConstraints; @synthesize contractedConstraints = _contractedConstraints;
@synthesize contractedNoMarginConstraints = _contractedNoMarginConstraints; @synthesize contractedNoMarginConstraints = _contractedNoMarginConstraints;
@synthesize blur = _blur;
@synthesize contentView = _contentView; @synthesize contentView = _contentView;
#pragma mark - Public #pragma mark - Public
...@@ -147,7 +143,7 @@ ...@@ -147,7 +143,7 @@
self.translatesAutoresizingMaskIntoConstraints = NO; self.translatesAutoresizingMaskIntoConstraints = NO;
[self setUpBlurredBackground]; [self setUpToolbarBackground];
[self setUpLeadingStackView]; [self setUpLeadingStackView];
[self setUpTrailingStackView]; [self setUpTrailingStackView];
[self setUpCancelButton]; [self setUpCancelButton];
...@@ -157,11 +153,6 @@ ...@@ -157,11 +153,6 @@
[self setUpSeparator]; [self setUpSeparator];
[self setUpConstraints]; [self setUpConstraints];
// Make sure that the trait collection is taken into account.
if (@available(iOS 13, *)) {
[self updateLayoutForPreviousTraitCollection:nil];
}
} }
- (void)addFakeOmniboxTarget { - (void)addFakeOmniboxTarget {
...@@ -184,39 +175,14 @@ ...@@ -184,39 +175,14 @@
ToolbarExpandedHeight(self.traitCollection.preferredContentSizeCategory)); ToolbarExpandedHeight(self.traitCollection.preferredContentSizeCategory));
} }
- (void)traitCollectionDidChange:(UITraitCollection*)previousTraitCollection {
[super traitCollectionDidChange:previousTraitCollection];
[self updateLayoutForPreviousTraitCollection:previousTraitCollection];
}
#pragma mark - Setup #pragma mark - Setup
// Sets the blur effect on the toolbar background. // Sets up the toolbar background.
- (void)setUpBlurredBackground { - (void)setUpToolbarBackground {
UIBlurEffect* blurEffect = self.buttonFactory.toolbarConfiguration.blurEffect; self.backgroundColor =
if (blurEffect) { self.buttonFactory.toolbarConfiguration.backgroundColor;
self.blur = [[UIVisualEffectView alloc] initWithEffect:blurEffect];
} else {
self.blur = [[UIView alloc] init];
}
self.blur.backgroundColor =
self.buttonFactory.toolbarConfiguration.blurBackgroundColor;
[self addSubview:self.blur];
self.contentView = self; self.contentView = self;
if (UIVisualEffect* vibrancy = [self.buttonFactory.toolbarConfiguration
vibrancyEffectForBlurEffect:blurEffect]) {
UIVisualEffectView* vibrancyView =
[[UIVisualEffectView alloc] initWithEffect:vibrancy];
self.contentView = vibrancyView.contentView;
[self addSubview:vibrancyView];
vibrancyView.translatesAutoresizingMaskIntoConstraints = NO;
AddSameConstraints(self, vibrancyView);
}
self.blur.translatesAutoresizingMaskIntoConstraints = NO;
AddSameConstraints(self.blur, self);
} }
// Sets the cancel button to stop editing the location bar. // Sets the cancel button to stop editing the location bar.
...@@ -470,19 +436,4 @@ ...@@ -470,19 +436,4 @@
- (ToolbarButton*)searchButton { - (ToolbarButton*)searchButton {
return nil; return nil;
} }
#pragma mark - Private
- (void)updateLayoutForPreviousTraitCollection:
(UITraitCollection*)previousTraitCollection {
if (IsRegularXRegularSizeClass(self)) {
self.backgroundColor =
self.buttonFactory.toolbarConfiguration.backgroundColor;
self.blur.alpha = 0;
} else {
self.backgroundColor = [UIColor clearColor];
self.blur.alpha = 1;
}
}
@end @end
...@@ -31,9 +31,6 @@ const CGFloat kToolsMenuOffset = -7; ...@@ -31,9 +31,6 @@ const CGFloat kToolsMenuOffset = -7;
// 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) UIView* blur;
// Separator above the toolbar, redefined as readwrite. // Separator above the toolbar, redefined as readwrite.
@property(nonatomic, strong, readwrite) UIView* separator; @property(nonatomic, strong, readwrite) UIView* separator;
...@@ -63,7 +60,6 @@ const CGFloat kToolsMenuOffset = -7; ...@@ -63,7 +60,6 @@ const CGFloat kToolsMenuOffset = -7;
@synthesize toolsMenuButton = _toolsMenuButton; @synthesize toolsMenuButton = _toolsMenuButton;
@synthesize searchButton = _searchButton; @synthesize searchButton = _searchButton;
@synthesize tabGridButton = _tabGridButton; @synthesize tabGridButton = _tabGridButton;
@synthesize blur = _blur;
#pragma mark - Public #pragma mark - Public
...@@ -106,30 +102,10 @@ const CGFloat kToolsMenuOffset = -7; ...@@ -106,30 +102,10 @@ const CGFloat kToolsMenuOffset = -7;
self.translatesAutoresizingMaskIntoConstraints = NO; self.translatesAutoresizingMaskIntoConstraints = NO;
UIBlurEffect* blurEffect = self.buttonFactory.toolbarConfiguration.blurEffect; self.backgroundColor =
if (blurEffect) { self.buttonFactory.toolbarConfiguration.backgroundColor;
self.blur = [[UIVisualEffectView alloc] initWithEffect:blurEffect];
} else {
self.blur = [[UIView alloc] init];
}
self.blur.backgroundColor =
self.buttonFactory.toolbarConfiguration.blurBackgroundColor;
[self addSubview:self.blur];
self.blur.translatesAutoresizingMaskIntoConstraints = NO;
AddSameConstraints(self.blur, self);
UIView* contentView = self; UIView* contentView = self;
UIVisualEffect* vibrancy = [self.buttonFactory.toolbarConfiguration
vibrancyEffectForBlurEffect:blurEffect];
if (vibrancy && IconForSearchButton() != ToolbarSearchButtonIconColorful) {
// Add vibrancy only if we have a vibrancy effect.
UIVisualEffectView* vibrancyView =
[[UIVisualEffectView alloc] initWithEffect:vibrancy];
[self addSubview:vibrancyView];
vibrancyView.translatesAutoresizingMaskIntoConstraints = NO;
AddSameConstraints(self, vibrancyView);
contentView = vibrancyView.contentView;
}
self.backButton = [self.buttonFactory backButton]; self.backButton = [self.buttonFactory backButton];
self.forwardButton = [self.buttonFactory forwardButton]; self.forwardButton = [self.buttonFactory forwardButton];
......
...@@ -81,18 +81,9 @@ CGFloat kFakeTextBoxWidth = 240; ...@@ -81,18 +81,9 @@ CGFloat kFakeTextBoxWidth = 240;
ToolbarConfiguration* configuration = ToolbarConfiguration* configuration =
[[ToolbarConfiguration alloc] initWithStyle:NORMAL]; [[ToolbarConfiguration alloc] initWithStyle:NORMAL];
UIBlurEffect* effect = [configuration blurEffect]; UIView* containerView = [[UIView alloc] init];
UIView* containerView; [containerView addSubview:self.popupViewController.view];
if (effect) { containerView.backgroundColor = [configuration backgroundColor];
UIVisualEffectView* effectView =
[[UIVisualEffectView alloc] initWithEffect:effect];
[effectView.contentView addSubview:self.popupViewController.view];
containerView = effectView;
} else {
containerView = [[UIView alloc] init];
[containerView addSubview:self.popupViewController.view];
}
containerView.backgroundColor = [configuration blurBackgroundColor];
containerView.translatesAutoresizingMaskIntoConstraints = NO; containerView.translatesAutoresizingMaskIntoConstraints = NO;
self.popupViewController.view.translatesAutoresizingMaskIntoConstraints = NO; self.popupViewController.view.translatesAutoresizingMaskIntoConstraints = NO;
AddSameConstraints(self.popupViewController.view, containerView); AddSameConstraints(self.popupViewController.view, containerView);
......
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