Commit 5c8b1704 authored by Gauthier Ambard's avatar Gauthier Ambard Committed by Commit Bot

Update the LocationBar container during fullscreen

This CL updates the location bar container, updating its background
color and its height to follow the fullscreen progress.
It also updates BVC so the location bar is always displayed.

Bug: 804731
Cq-Include-Trybots: master.tryserver.chromium.mac:ios-simulator-cronet;master.tryserver.chromium.mac:ios-simulator-full-configs
Change-Id: I6f5b2a750cf1593c8d4c7f12163a9db90dc34090
Reviewed-on: https://chromium-review.googlesource.com/883283Reviewed-by: default avatarKurt Horimoto <kkhorimoto@chromium.org>
Reviewed-by: default avatarLouis Romero <lpromero@chromium.org>
Commit-Queue: Gauthier Ambard <gambard@chromium.org>
Cr-Commit-Position: refs/heads/master@{#533247}
parent 9a9120ea
...@@ -4023,7 +4023,12 @@ bubblePresenterForFeature:(const base::Feature&)feature ...@@ -4023,7 +4023,12 @@ bubblePresenterForFeature:(const base::Feature&)feature
// progress of 1.0 fully shows the headers and a progress of 0.0 fully hides // progress of 1.0 fully shows the headers and a progress of 0.0 fully hides
// them. // them.
- (void)updateHeadersForFullscreenProgress:(CGFloat)progress { - (void)updateHeadersForFullscreenProgress:(CGFloat)progress {
CGFloat offset = AlignValueToPixel((1.0 - progress) * [self toolbarHeight]); CGFloat toolbarHeightFullscreen = 0;
if (IsUIRefreshPhase1Enabled()) {
toolbarHeightFullscreen = kToolbarHeightFullscreen;
}
CGFloat offset = AlignValueToPixel(
(1.0 - progress) * ([self toolbarHeight] - toolbarHeightFullscreen));
[self setFramesForHeaders:[self headerViews] atOffset:offset]; [self setFramesForHeaders:[self headerViews] atOffset:offset];
} }
......
...@@ -24,15 +24,13 @@ ...@@ -24,15 +24,13 @@
- (instancetype)initWithCoder:(NSCoder*)aDecoder NS_UNAVAILABLE; - (instancetype)initWithCoder:(NSCoder*)aDecoder NS_UNAVAILABLE;
- (instancetype)init NS_UNAVAILABLE; - (instancetype)init NS_UNAVAILABLE;
// Top anchor at the bottom of the safeAreaLayoutGuide. Used so views don't
// overlap with the Status Bar.
@property(nonatomic, strong) NSLayoutYAxisAnchor* topSafeAnchor;
// The location bar view, containing the omnibox. // The location bar view, containing the omnibox.
@property(nonatomic, strong) UIView* locationBarView; @property(nonatomic, strong) UIView* locationBarView;
// Container for the location bar. // Container for the location bar.
@property(nonatomic, strong, readonly) UIView* locationBarContainer; @property(nonatomic, strong, readonly) UIView* locationBarContainer;
// The height of the container for the location bar.
@property(nonatomic, strong, readonly) NSLayoutConstraint* locationBarHeight;
// StackView containing the leading buttons (relative to the location bar). // StackView containing the leading buttons (relative to the location bar).
// It should only contain ToolbarButtons. // It should only contain ToolbarButtons.
......
...@@ -24,6 +24,8 @@ ...@@ -24,6 +24,8 @@
// 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.
@property(nonatomic, strong, readwrite) NSLayoutConstraint* locationBarHeight;
// StackView containing the leading buttons (relative to the location bar). It // StackView containing the leading buttons (relative to the location bar). It
// should only contain ToolbarButtons. Redefined as readwrite. // should only contain ToolbarButtons. Redefined as readwrite.
...@@ -66,7 +68,7 @@ ...@@ -66,7 +68,7 @@
@implementation PrimaryToolbarView @implementation PrimaryToolbarView
@synthesize locationBarView = _locationBarView; @synthesize locationBarView = _locationBarView;
@synthesize topSafeAnchor = _topSafeAnchor; @synthesize locationBarHeight = _locationBarHeight;
@synthesize buttonFactory = _buttonFactory; @synthesize buttonFactory = _buttonFactory;
@synthesize allButtons = _allButtons; @synthesize allButtons = _allButtons;
@synthesize progressBar = _progressBar; @synthesize progressBar = _progressBar;
...@@ -101,7 +103,6 @@ ...@@ -101,7 +103,6 @@
return; return;
} }
DCHECK(self.buttonFactory); DCHECK(self.buttonFactory);
DCHECK(self.topSafeAnchor);
self.backgroundColor = self.backgroundColor =
self.buttonFactory.toolbarConfiguration.backgroundColor; self.buttonFactory.toolbarConfiguration.backgroundColor;
...@@ -115,6 +116,12 @@ ...@@ -115,6 +116,12 @@
[self setUpConstraints]; [self setUpConstraints];
} }
#pragma mark - UIView
- (CGSize)intrinsicContentSize {
return CGSizeMake(UIViewNoIntrinsicMetric, kToolbarHeight);
}
#pragma mark - Setup #pragma mark - Setup
// Sets the location bar container and its view if present. // Sets the location bar container and its view if present.
...@@ -189,11 +196,14 @@ ...@@ -189,11 +196,14 @@
constraintEqualToAnchor:safeArea.leadingAnchor], constraintEqualToAnchor:safeArea.leadingAnchor],
[self.leadingStackView.bottomAnchor [self.leadingStackView.bottomAnchor
constraintEqualToAnchor:safeArea.bottomAnchor], constraintEqualToAnchor:safeArea.bottomAnchor],
[self.leadingStackView.topAnchor [self.leadingStackView.heightAnchor
constraintEqualToAnchor:self.topSafeAnchor], constraintEqualToConstant:kToolbarHeight],
]]; ]];
// LocationBar constraints. // LocationBar constraints.
self.locationBarHeight = [self.locationBarContainer.heightAnchor
constraintEqualToConstant:kToolbarHeight -
2 * kLocationBarVerticalMargin];
[NSLayoutConstraint activateConstraints:@[ [NSLayoutConstraint activateConstraints:@[
[self.locationBarContainer.leadingAnchor [self.locationBarContainer.leadingAnchor
constraintEqualToAnchor:self.leadingStackView.trailingAnchor], constraintEqualToAnchor:self.leadingStackView.trailingAnchor],
...@@ -202,12 +212,7 @@ ...@@ -202,12 +212,7 @@
[self.locationBarContainer.bottomAnchor [self.locationBarContainer.bottomAnchor
constraintEqualToAnchor:self.bottomAnchor constraintEqualToAnchor:self.bottomAnchor
constant:-kLocationBarVerticalMargin], constant:-kLocationBarVerticalMargin],
[self.locationBarContainer.topAnchor self.locationBarHeight,
constraintEqualToAnchor:self.topSafeAnchor
constant:kLocationBarVerticalMargin],
[self.locationBarContainer.heightAnchor
constraintEqualToConstant:kToolbarHeight -
2 * kLocationBarVerticalMargin],
]]; ]];
// Trailing StackView constraints. // Trailing StackView constraints.
...@@ -216,8 +221,8 @@ ...@@ -216,8 +221,8 @@
constraintEqualToAnchor:safeArea.trailingAnchor], constraintEqualToAnchor:safeArea.trailingAnchor],
[self.trailingStackView.bottomAnchor [self.trailingStackView.bottomAnchor
constraintEqualToAnchor:safeArea.bottomAnchor], constraintEqualToAnchor:safeArea.bottomAnchor],
[self.trailingStackView.topAnchor [self.trailingStackView.heightAnchor
constraintEqualToAnchor:self.topSafeAnchor], constraintEqualToConstant:kToolbarHeight],
]]; ]];
// locationBarView constraints, if present. // locationBarView constraints, if present.
......
...@@ -13,6 +13,8 @@ ...@@ -13,6 +13,8 @@
#import "ios/chrome/browser/ui/toolbar/adaptive/adaptive_toolbar_view_controller+subclassing.h" #import "ios/chrome/browser/ui/toolbar/adaptive/adaptive_toolbar_view_controller+subclassing.h"
#import "ios/chrome/browser/ui/toolbar/adaptive/primary_toolbar_view.h" #import "ios/chrome/browser/ui/toolbar/adaptive/primary_toolbar_view.h"
#import "ios/chrome/browser/ui/toolbar/clean/toolbar_button.h" #import "ios/chrome/browser/ui/toolbar/clean/toolbar_button.h"
#import "ios/chrome/browser/ui/toolbar/clean/toolbar_button_factory.h"
#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/clean/toolbar_constants.h"
#import "ios/chrome/browser/ui/toolbar/clean/toolbar_tools_menu_button.h" #import "ios/chrome/browser/ui/toolbar/clean/toolbar_tools_menu_button.h"
#import "ios/chrome/browser/ui/util/named_guide.h" #import "ios/chrome/browser/ui/util/named_guide.h"
...@@ -66,12 +68,6 @@ ...@@ -66,12 +68,6 @@
self.view = self.view =
[[PrimaryToolbarView alloc] initWithButtonFactory:self.buttonFactory]; [[PrimaryToolbarView alloc] initWithButtonFactory:self.buttonFactory];
if (@available(iOS 11, *)) {
self.view.topSafeAnchor = self.view.safeAreaLayoutGuide.topAnchor;
} else {
self.view.topSafeAnchor = self.topLayoutGuide.bottomAnchor;
}
// This method cannot be called from the init as the topSafeAnchor can only be // This method cannot be called from the init as the topSafeAnchor can only be
// set to topLayoutGuide after the view creation on iOS 10. // set to topLayoutGuide after the view creation on iOS 10.
[self.view setUp]; [self.view setUp];
...@@ -129,9 +125,16 @@ ...@@ -129,9 +125,16 @@
#pragma mark - FullscreenUIElement #pragma mark - FullscreenUIElement
- (void)updateForFullscreenProgress:(CGFloat)progress { - (void)updateForFullscreenProgress:(CGFloat)progress {
self.view.leadingStackView.alpha = progress; CGFloat alphaValue = fmax(progress * 2 - 1, 0);
self.view.trailingStackView.alpha = progress; self.view.leadingStackView.alpha = alphaValue;
// TODO(crbug.com/804731): Update the location bar constraints. self.view.trailingStackView.alpha = alphaValue;
self.view.locationBarHeight.constant =
AlignValueToPixel(kToolbarHeightFullscreen +
(kToolbarHeight - kToolbarHeightFullscreen) * progress -
2 * kLocationBarVerticalMargin);
self.view.locationBarContainer.backgroundColor =
[self.buttonFactory.toolbarConfiguration.omniboxBackgroundColor
colorWithAlphaComponent:alphaValue];
} }
- (void)updateForFullscreenEnabled:(BOOL)enabled { - (void)updateForFullscreenEnabled:(BOOL)enabled {
......
...@@ -13,6 +13,8 @@ ...@@ -13,6 +13,8 @@
// Height of the toolbar. // Height of the toolbar.
extern const CGFloat kToolbarHeight; extern const CGFloat kToolbarHeight;
// Height of the toolbar when in fullscreen.
extern const CGFloat kToolbarHeightFullscreen;
// The time delay before non-initial button images are loaded. // The time delay before non-initial button images are loaded.
extern const int64_t kNonInitialImageAdditionDelayNanosec; extern const int64_t kNonInitialImageAdditionDelayNanosec;
......
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
#endif #endif
const CGFloat kToolbarHeight = 56; const CGFloat kToolbarHeight = 56;
const CGFloat kToolbarHeightFullscreen = 35;
const int64_t kNonInitialImageAdditionDelayNanosec = 500000LL; const int64_t kNonInitialImageAdditionDelayNanosec = 500000LL;
......
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