Commit 11b87f51 authored by Eugene But's avatar Eugene But Committed by Commit Bot

Store Download Manager action button UILayoutGuide in ivar.

Previously Download Manager used NamedGuide instead of ivar. Named
guides suppose to be used to pass the guide across the different layers
of UI. In this case storing UILayoutGuide in ivar is sufficient.

Bug: None
Cq-Include-Trybots: master.tryserver.chromium.mac:ios-simulator-cronet;master.tryserver.chromium.mac:ios-simulator-full-configs
Change-Id: I8937900fdfcbbbe906a586cf206fd2c42317c70e
Reviewed-on: https://chromium-review.googlesource.com/1040266
Commit-Queue: Eugene But <eugenebut@chromium.org>
Reviewed-by: default avatarKurt Horimoto <kkhorimoto@chromium.org>
Cr-Commit-Position: refs/heads/master@{#556098}
parent 58923711
......@@ -10,7 +10,7 @@
#include "ios/chrome/browser/ui/download/download_manager_animation_constants.h"
#import "ios/chrome/browser/ui/download/download_manager_state_view.h"
#import "ios/chrome/browser/ui/download/radial_progress_view.h"
#import "ios/chrome/browser/ui/util/named_guide.h"
#import "ios/chrome/browser/ui/util/constraints_ui_util.h"
#include "ios/chrome/grit/ios_strings.h"
#include "ios/public/provider/chrome/browser/chrome_browser_provider.h"
#import "ios/public/provider/chrome/browser/images/branded_image_provider.h"
......@@ -23,8 +23,6 @@
#endif
namespace {
// Layout Guide name for action button UILayoutGuide.
GuideName* const kActionButtonGuide = @"kDownloadManagerActionButtonGuide";
// Additional left margin for close button.
const CGFloat kCloseButtonLeftMargin = 17;
......@@ -102,6 +100,9 @@ NSString* GetSizeString(long long size_in_bytes) {
// self.closeButton or to self.actionButton (when visible).
@property(nonatomic) NSLayoutConstraint* statusLabelTrailingConstraint;
// UILayoutGuide for action button. Used in delegate callbacks.
@property(nonatomic) UILayoutGuide* actionButtonGuide;
@end
@implementation DownloadManagerViewController
......@@ -122,6 +123,7 @@ NSString* GetSizeString(long long size_in_bytes) {
@synthesize installDriveControlsRowTrailingConstraint =
_installDriveControlsRowTrailingConstraint;
@synthesize statusLabelTrailingConstraint = _statusLabelTrailingConstraint;
@synthesize actionButtonGuide = _actionButtonGuide;
#pragma mark - UIViewController overrides
......@@ -141,10 +143,8 @@ NSString* GetSizeString(long long size_in_bytes) {
[self.installDriveControlsRow addSubview:self.installDriveLabel];
[self.installDriveControlsRow addSubview:self.horizontalLine];
NamedGuide* actionButtonGuide =
[[NamedGuide alloc] initWithName:kActionButtonGuide];
[self.view addLayoutGuide:actionButtonGuide];
actionButtonGuide.constrainedView = self.actionButton;
self.actionButtonGuide = [[UILayoutGuide alloc] init];
[self.view addLayoutGuide:self.actionButtonGuide];
}
- (void)updateViewConstraints {
......@@ -286,6 +286,9 @@ NSString* GetSizeString(long long size_in_bytes) {
constraintEqualToAnchor:installDriveRow.trailingAnchor],
]];
// constraint actionButtonGuide to action button.
AddSameConstraints(self.actionButtonGuide, actionButton);
[self updateConstraintsForTraitCollection:self.traitCollection];
_addedConstraints = YES;
......@@ -537,10 +540,8 @@ NSString* GetSizeString(long long size_in_bytes) {
SEL selector = @selector
(downloadManagerViewController:presentOpenInMenuWithLayoutGuide:);
if ([_delegate respondsToSelector:selector]) {
UILayoutGuide* guide =
[NamedGuide guideWithName:kActionButtonGuide view:self.view];
[_delegate downloadManagerViewController:self
presentOpenInMenuWithLayoutGuide:guide];
presentOpenInMenuWithLayoutGuide:self.actionButtonGuide];
}
break;
}
......
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