Commit 49b3ffb2 authored by Eugene But's avatar Eugene But Committed by Commit Bot

Correct Download Manager presentation with UI Refresh flag enabled.

This CL presents Download Manager from _browserContainerViewController,
which means that UI shows up between Web Content and Secondary Toolbar
on z-axe. This is only done if UI Refresh flag is enabled.

Also extended Download Manager coordinator and view controller to support
bottomMarginHeightAnchor property. This property allows adding bottom
margin to download manager UI in order to present Download Manager
UI above Secondary Toolbar on y-axe.

Bug: 818264
Cq-Include-Trybots: master.tryserver.chromium.mac:ios-simulator-cronet;master.tryserver.chromium.mac:ios-simulator-full-configs
Change-Id: I373ecb6e9892bdc20ba720742d653471ff0a9bad
Reviewed-on: https://chromium-review.googlesource.com/1024641Reviewed-by: default avatarKurt Horimoto <kkhorimoto@chromium.org>
Reviewed-by: default avatarGauthier Ambard <gambard@chromium.org>
Commit-Queue: Eugene But <eugenebut@chromium.org>
Cr-Commit-Position: refs/heads/master@{#560672}
parent 0579ec8f
...@@ -1026,8 +1026,15 @@ applicationCommandEndpoint:(id<ApplicationCommands>)applicationCommandEndpoint { ...@@ -1026,8 +1026,15 @@ applicationCommandEndpoint:(id<ApplicationCommands>)applicationCommandEndpoint {
// DownloadManagerCoordinator must be created before // DownloadManagerCoordinator must be created before
// DownloadManagerTabHelper. // DownloadManagerTabHelper.
_downloadManagerCoordinator = _browserContainerCoordinator = [[BrowserContainerCoordinator alloc]
[[DownloadManagerCoordinator alloc] initWithBaseViewController:self]; initWithBaseViewController:self
browserState:browserState];
[_browserContainerCoordinator start];
_downloadManagerCoordinator = [[DownloadManagerCoordinator alloc]
initWithBaseViewController:IsUIRefreshPhase1Enabled()
? _browserContainerCoordinator
.viewController
: self];
_downloadManagerCoordinator.presenter = _downloadManagerCoordinator.presenter =
[[VerticalAnimationContainer alloc] init]; [[VerticalAnimationContainer alloc] init];
...@@ -1632,10 +1639,6 @@ applicationCommandEndpoint:(id<ApplicationCommands>)applicationCommandEndpoint { ...@@ -1632,10 +1639,6 @@ applicationCommandEndpoint:(id<ApplicationCommands>)applicationCommandEndpoint {
// The WebView is overflowing its bounds to be displayed below the toolbars. // The WebView is overflowing its bounds to be displayed below the toolbars.
self.view.clipsToBounds = YES; self.view.clipsToBounds = YES;
_browserContainerCoordinator = [[BrowserContainerCoordinator alloc]
initWithBaseViewController:self
browserState:self.browserState];
[_browserContainerCoordinator start];
UIViewController* containerViewController = UIViewController* containerViewController =
_browserContainerCoordinator.viewController; _browserContainerCoordinator.viewController;
[self addChildViewController:containerViewController]; [self addChildViewController:containerViewController];
...@@ -2290,6 +2293,8 @@ applicationCommandEndpoint:(id<ApplicationCommands>)applicationCommandEndpoint { ...@@ -2290,6 +2293,8 @@ applicationCommandEndpoint:(id<ApplicationCommands>)applicationCommandEndpoint {
// DownloadManagerCoordinator is already created. // DownloadManagerCoordinator is already created.
DCHECK(_downloadManagerCoordinator); DCHECK(_downloadManagerCoordinator);
_downloadManagerCoordinator.webStateList = [_model webStateList]; _downloadManagerCoordinator.webStateList = [_model webStateList];
_downloadManagerCoordinator.bottomMarginHeightAnchor =
[NamedGuide guideWithName:kSecondaryToolbar view:self.view].heightAnchor;
if (IsUIRefreshPhase1Enabled()) { if (IsUIRefreshPhase1Enabled()) {
self.popupMenuCoordinator = [[PopupMenuCoordinator alloc] self.popupMenuCoordinator = [[PopupMenuCoordinator alloc]
......
...@@ -32,6 +32,9 @@ class WebStateList; ...@@ -32,6 +32,9 @@ class WebStateList;
// Needed to observe web state closing. Set to null when stop method is called. // Needed to observe web state closing. Set to null when stop method is called.
@property(nonatomic) WebStateList* webStateList; @property(nonatomic) WebStateList* webStateList;
// Controls the height of the bottom margin.
@property(nonatomic) NSLayoutDimension* bottomMarginHeightAnchor;
// Underlying UIViewController presented by this coordinator. // Underlying UIViewController presented by this coordinator.
@property(nonatomic, readonly) UIViewController* viewController; @property(nonatomic, readonly) UIViewController* viewController;
......
...@@ -145,6 +145,7 @@ class UnopenedDownloadsTracker : public web::DownloadTaskObserver, ...@@ -145,6 +145,7 @@ class UnopenedDownloadsTracker : public web::DownloadTaskObserver,
@synthesize animatesPresentation = _animatesPresentation; @synthesize animatesPresentation = _animatesPresentation;
@synthesize downloadTask = _downloadTask; @synthesize downloadTask = _downloadTask;
@synthesize webStateList = _webStateList; @synthesize webStateList = _webStateList;
@synthesize bottomMarginHeightAnchor = _bottomMarginHeightAnchor;
- (void)dealloc { - (void)dealloc {
[[InstallationNotifier sharedInstance] unregisterForNotifications:self]; [[InstallationNotifier sharedInstance] unregisterForNotifications:self];
...@@ -155,6 +156,7 @@ class UnopenedDownloadsTracker : public web::DownloadTaskObserver, ...@@ -155,6 +156,7 @@ class UnopenedDownloadsTracker : public web::DownloadTaskObserver,
_viewController = [[DownloadManagerViewController alloc] init]; _viewController = [[DownloadManagerViewController alloc] init];
_viewController.delegate = self; _viewController.delegate = self;
_viewController.bottomMarginHeightAnchor = self.bottomMarginHeightAnchor;
_mediator.SetDownloadTask(_downloadTask); _mediator.SetDownloadTask(_downloadTask);
_mediator.SetConsumer(_viewController); _mediator.SetConsumer(_viewController);
......
...@@ -41,6 +41,9 @@ ...@@ -41,6 +41,9 @@
@property(nonatomic, weak) id<DownloadManagerViewControllerDelegate> delegate; @property(nonatomic, weak) id<DownloadManagerViewControllerDelegate> delegate;
// Controls the height of the bottom margin.
@property(nonatomic) NSLayoutDimension* bottomMarginHeightAnchor;
@end @end
// All UI elements presend in view controller's view. // All UI elements presend in view controller's view.
......
...@@ -77,11 +77,11 @@ NSString* GetSizeString(long long size_in_bytes) { ...@@ -77,11 +77,11 @@ NSString* GetSizeString(long long size_in_bytes) {
// Grey line which separates downloadControlsRow and installDriveControlsRow. // Grey line which separates downloadControlsRow and installDriveControlsRow.
@property(nonatomic, readonly) UIView* horizontalLine; @property(nonatomic, readonly) UIView* horizontalLine;
// Represents constraint for self.view.bottomAnchor, which can either be // Represents constraint for kBottomMarginGuide's topAnchor, which can either be
// constrained to installDriveControlsRow's bottomAnchor or to // constrained to installDriveControlsRow's bottomAnchor or to
// downloadControlsRow's bottomAnchor. Stored in a property to allow // downloadControlsRow's bottomAnchor. Stored in a property to allow
// deactivating the old constraint. // deactivating the old constraint.
@property(nonatomic) NSLayoutConstraint* bottomConstraint; @property(nonatomic) NSLayoutConstraint* bottomMarginGuideTopConstraint;
// Represents constraint for self.view.widthAnchor, which is anchored to // Represents constraint for self.view.widthAnchor, which is anchored to
// superview with different multipliers depending on size class. Stored in a // superview with different multipliers depending on size class. Stored in a
...@@ -103,16 +103,20 @@ NSString* GetSizeString(long long size_in_bytes) { ...@@ -103,16 +103,20 @@ NSString* GetSizeString(long long size_in_bytes) {
// UILayoutGuide for action button. Used in delegate callbacks. // UILayoutGuide for action button. Used in delegate callbacks.
@property(nonatomic) UILayoutGuide* actionButtonGuide; @property(nonatomic) UILayoutGuide* actionButtonGuide;
// UILayoutGuide for adding bottom margin to Download Manager view.
@property(nonatomic) UILayoutGuide* bottomMarginGuide;
@end @end
@implementation DownloadManagerViewController @implementation DownloadManagerViewController
@synthesize delegate = _delegate; @synthesize delegate = _delegate;
@synthesize bottomMarginHeightAnchor = _bottomMarginHeightAnchor;
@synthesize background = _background; @synthesize background = _background;
@synthesize downloadControlsRow = _downloadControlsRow; @synthesize downloadControlsRow = _downloadControlsRow;
@synthesize installDriveControlsRow = _installDriveControlsRow; @synthesize installDriveControlsRow = _installDriveControlsRow;
@synthesize horizontalLine = _horizontalLine; @synthesize horizontalLine = _horizontalLine;
@synthesize bottomConstraint = _bottomConstraint; @synthesize bottomMarginGuideTopConstraint = _bottomMarginGuideTopConstraint;
@synthesize viewWidthConstraint = _viewWidthConstraint; @synthesize viewWidthConstraint = _viewWidthConstraint;
@synthesize downloadControlsRowLeadingConstraint = @synthesize downloadControlsRowLeadingConstraint =
_downloadControlsRowLeadingConstraint; _downloadControlsRowLeadingConstraint;
...@@ -124,6 +128,7 @@ NSString* GetSizeString(long long size_in_bytes) { ...@@ -124,6 +128,7 @@ NSString* GetSizeString(long long size_in_bytes) {
_installDriveControlsRowTrailingConstraint; _installDriveControlsRowTrailingConstraint;
@synthesize statusLabelTrailingConstraint = _statusLabelTrailingConstraint; @synthesize statusLabelTrailingConstraint = _statusLabelTrailingConstraint;
@synthesize actionButtonGuide = _actionButtonGuide; @synthesize actionButtonGuide = _actionButtonGuide;
@synthesize bottomMarginGuide = _bottomMarginGuide;
#pragma mark - UIViewController overrides #pragma mark - UIViewController overrides
...@@ -145,6 +150,8 @@ NSString* GetSizeString(long long size_in_bytes) { ...@@ -145,6 +150,8 @@ NSString* GetSizeString(long long size_in_bytes) {
self.actionButtonGuide = [[UILayoutGuide alloc] init]; self.actionButtonGuide = [[UILayoutGuide alloc] init];
[self.view addLayoutGuide:self.actionButtonGuide]; [self.view addLayoutGuide:self.actionButtonGuide];
self.bottomMarginGuide = [[UILayoutGuide alloc] init];
[self.view addLayoutGuide:self.bottomMarginGuide];
} }
- (void)updateViewConstraints { - (void)updateViewConstraints {
...@@ -155,7 +162,11 @@ NSString* GetSizeString(long long size_in_bytes) { ...@@ -155,7 +162,11 @@ NSString* GetSizeString(long long size_in_bytes) {
// self.view constraints. // self.view constraints.
UIView* view = self.view; UIView* view = self.view;
[self updateBottomConstraints]; UILayoutGuide* bottomMarginGuide = self.bottomMarginGuide;
[NSLayoutConstraint activateConstraints:@[
[view.bottomAnchor constraintEqualToAnchor:bottomMarginGuide.bottomAnchor],
]];
[self updateBottomMarginGuideTopConstraint];
// background constraints. // background constraints.
UIView* background = self.background; UIView* background = self.background;
...@@ -198,6 +209,18 @@ NSString* GetSizeString(long long size_in_bytes) { ...@@ -198,6 +209,18 @@ NSString* GetSizeString(long long size_in_bytes) {
[installDriveRow.heightAnchor constraintEqualToConstant:kRowHeight], [installDriveRow.heightAnchor constraintEqualToConstant:kRowHeight],
]]; ]];
// bottom margin row constraints.
if (_bottomMarginHeightAnchor) {
[NSLayoutConstraint activateConstraints:@[
[bottomMarginGuide.heightAnchor
constraintEqualToAnchor:_bottomMarginHeightAnchor],
]];
} else {
[NSLayoutConstraint activateConstraints:@[
[bottomMarginGuide.heightAnchor constraintEqualToConstant:0],
]];
}
// close button constraints. // close button constraints.
[NSLayoutConstraint activateConstraints:@[ [NSLayoutConstraint activateConstraints:@[
[closeButton.centerYAnchor [closeButton.centerYAnchor
...@@ -356,7 +379,7 @@ NSString* GetSizeString(long long size_in_bytes) { ...@@ -356,7 +379,7 @@ NSString* GetSizeString(long long size_in_bytes) {
animations:^{ animations:^{
DownloadManagerViewController* strongSelf = weakSelf; DownloadManagerViewController* strongSelf = weakSelf;
[strongSelf updateInstallDriveControlsRow]; [strongSelf updateInstallDriveControlsRow];
[strongSelf updateBottomConstraints]; [strongSelf updateBottomMarginGuideTopConstraint];
[strongSelf.view.superview layoutIfNeeded]; [strongSelf.view.superview layoutIfNeeded];
}]; }];
} }
...@@ -564,22 +587,26 @@ NSString* GetSizeString(long long size_in_bytes) { ...@@ -564,22 +587,26 @@ NSString* GetSizeString(long long size_in_bytes) {
#pragma mark - UI Updates #pragma mark - UI Updates
// Updates and activates self.bottomConstraint. self.bottomConstraint // Updates and activates self.bottomMarginGuideTopConstraint.
// constraints self.view.bottomAnchor to installDriveControlsRow's bottom // self.bottomMarginGuideTopConstraint constraints kBottomMarginGuide's
// if |_installDriveButtonVisible| is set to YES, otherwise // topAnchor to installDriveControlsRow's bottom if |_installDriveButtonVisible|
// self.view.bottomAnchor is constrained to downloadControlsRow's botttom. This // is set to YES, otherwise self.view.bottomAnchor is constrained to
// resizes self.view to show or hide installDriveControlsRow view. // downloadControlsRow's bottom. This resizes self.view to show or hide
- (void)updateBottomConstraints { // installDriveControlsRow view.
self.bottomConstraint.active = NO; - (void)updateBottomMarginGuideTopConstraint {
if (!self.viewLoaded) {
NSLayoutYAxisAnchor* firstAnchor = self.view.layoutMarginsGuide.bottomAnchor; // This method will be called again when the view is loaded.
return;
}
self.bottomMarginGuideTopConstraint.active = NO;
NSLayoutYAxisAnchor* secondAnchor = NSLayoutYAxisAnchor* secondAnchor =
_installDriveButtonVisible ? self.installDriveControlsRow.bottomAnchor _installDriveButtonVisible ? self.installDriveControlsRow.bottomAnchor
: self.downloadControlsRow.bottomAnchor; : self.downloadControlsRow.bottomAnchor;
self.bottomConstraint = [firstAnchor constraintEqualToAnchor:secondAnchor]; self.bottomMarginGuideTopConstraint =
[self.bottomMarginGuide.topAnchor constraintEqualToAnchor:secondAnchor];
self.bottomConstraint.active = YES; self.bottomMarginGuideTopConstraint.active = YES;
} }
// Updates background image for the given UITraitCollection. // Updates background image for the given UITraitCollection.
......
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