Commit 30567e9c authored by Gauthier Ambard's avatar Gauthier Ambard Committed by Commit Bot

Add side swipe support for Clean Toolbar

The toolbar needs to update its UI when a snapshot for the side swipe
is taken.

Bug: 785756
Cq-Include-Trybots: master.tryserver.chromium.mac:ios-simulator-cronet;master.tryserver.chromium.mac:ios-simulator-full-configs
Change-Id: If1735fe80b575608ed625dda3525a51b1689ee49
Reviewed-on: https://chromium-review.googlesource.com/809155Reviewed-by: default avatarStepan Khapugin <stkhapugin@chromium.org>
Commit-Queue: Gauthier Ambard <gambard@chromium.org>
Cr-Commit-Position: refs/heads/master@{#522452}
parent c3a3f000
......@@ -19,6 +19,10 @@
// Style of this configuration.
@property(nonatomic, assign) ToolbarStyle style;
// Background color of the NTP. Used to do as if the toolbar was transparent and
// the NTP is visible behind it.
@property(nonatomic, readonly) UIColor* NTPBackgroundColor;
// Background color of the toolbar.
@property(nonatomic, readonly) UIColor* backgroundColor;
......
......@@ -5,6 +5,7 @@
#import "ios/chrome/browser/ui/toolbar/clean/toolbar_configuration.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/uikit_ui_util.h"
#if !defined(__has_feature) || !__has_feature(objc_arc)
......@@ -23,6 +24,16 @@
return self;
}
- (UIColor*)NTPBackgroundColor {
switch (self.style) {
case NORMAL:
return [UIColor whiteColor];
case INCOGNITO:
return [UIColor colorWithWhite:kNTPBackgroundColorBrightnessIncognito
alpha:1.0];
}
}
- (UIColor*)backgroundColor {
switch (self.style) {
case NORMAL:
......
......@@ -230,7 +230,7 @@
web::NavigationItem* item =
webState->GetNavigationManager()->GetVisibleItem();
GURL URL = item ? item->GetURL().GetOrigin() : GURL::EmptyGURL();
BOOL isNTP = URL == GURL(kChromeUINewTabURL);
BOOL isNTP = (URL == GURL(kChromeUINewTabURL));
// Don't do anything for a live non-ntp tab.
if (webState == [self getWebState] && !isNTP) {
......
......@@ -159,11 +159,19 @@
}
- (void)updateForSideSwipeSnapshotOnNTP:(BOOL)onNTP {
// TODO(crbug.com/785756): Implement this.
self.progressBar.hidden = YES;
if (onNTP) {
self.backgroundView.alpha = 1;
self.locationBarContainer.hidden = YES;
// The back button is visible only if the forward button is enabled.
self.backButton.hiddenInCurrentState = !self.forwardButton.enabled;
}
}
- (void)resetAfterSideSwipeSnapshot {
// TODO(crbug.com/785756): Implement this.
self.backgroundView.alpha = 0;
self.locationBarContainer.hidden = NO;
self.backButton.hiddenInCurrentState = NO;
}
- (void)setBackgroundToIncognitoNTPColorWithAlpha:(CGFloat)alpha {
......@@ -686,8 +694,7 @@
_backgroundView = [[UIView alloc] initWithFrame:CGRectZero];
_backgroundView.translatesAutoresizingMaskIntoConstraints = NO;
_backgroundView.backgroundColor =
[UIColor colorWithWhite:kNTPBackgroundColorBrightnessIncognito
alpha:1.0];
self.buttonFactory.toolbarConfiguration.NTPBackgroundColor;
[self.view insertSubview:_backgroundView atIndex:0];
AddSameConstraints(self.view, _backgroundView);
}
......
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