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 @@ ...@@ -10,7 +10,7 @@
#include "ios/chrome/browser/ui/download/download_manager_animation_constants.h" #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/download_manager_state_view.h"
#import "ios/chrome/browser/ui/download/radial_progress_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/chrome/grit/ios_strings.h"
#include "ios/public/provider/chrome/browser/chrome_browser_provider.h" #include "ios/public/provider/chrome/browser/chrome_browser_provider.h"
#import "ios/public/provider/chrome/browser/images/branded_image_provider.h" #import "ios/public/provider/chrome/browser/images/branded_image_provider.h"
...@@ -23,8 +23,6 @@ ...@@ -23,8 +23,6 @@
#endif #endif
namespace { namespace {
// Layout Guide name for action button UILayoutGuide.
GuideName* const kActionButtonGuide = @"kDownloadManagerActionButtonGuide";
// Additional left margin for close button. // Additional left margin for close button.
const CGFloat kCloseButtonLeftMargin = 17; const CGFloat kCloseButtonLeftMargin = 17;
...@@ -102,6 +100,9 @@ NSString* GetSizeString(long long size_in_bytes) { ...@@ -102,6 +100,9 @@ NSString* GetSizeString(long long size_in_bytes) {
// self.closeButton or to self.actionButton (when visible). // self.closeButton or to self.actionButton (when visible).
@property(nonatomic) NSLayoutConstraint* statusLabelTrailingConstraint; @property(nonatomic) NSLayoutConstraint* statusLabelTrailingConstraint;
// UILayoutGuide for action button. Used in delegate callbacks.
@property(nonatomic) UILayoutGuide* actionButtonGuide;
@end @end
@implementation DownloadManagerViewController @implementation DownloadManagerViewController
...@@ -122,6 +123,7 @@ NSString* GetSizeString(long long size_in_bytes) { ...@@ -122,6 +123,7 @@ NSString* GetSizeString(long long size_in_bytes) {
@synthesize installDriveControlsRowTrailingConstraint = @synthesize installDriveControlsRowTrailingConstraint =
_installDriveControlsRowTrailingConstraint; _installDriveControlsRowTrailingConstraint;
@synthesize statusLabelTrailingConstraint = _statusLabelTrailingConstraint; @synthesize statusLabelTrailingConstraint = _statusLabelTrailingConstraint;
@synthesize actionButtonGuide = _actionButtonGuide;
#pragma mark - UIViewController overrides #pragma mark - UIViewController overrides
...@@ -141,10 +143,8 @@ NSString* GetSizeString(long long size_in_bytes) { ...@@ -141,10 +143,8 @@ NSString* GetSizeString(long long size_in_bytes) {
[self.installDriveControlsRow addSubview:self.installDriveLabel]; [self.installDriveControlsRow addSubview:self.installDriveLabel];
[self.installDriveControlsRow addSubview:self.horizontalLine]; [self.installDriveControlsRow addSubview:self.horizontalLine];
NamedGuide* actionButtonGuide = self.actionButtonGuide = [[UILayoutGuide alloc] init];
[[NamedGuide alloc] initWithName:kActionButtonGuide]; [self.view addLayoutGuide:self.actionButtonGuide];
[self.view addLayoutGuide:actionButtonGuide];
actionButtonGuide.constrainedView = self.actionButton;
} }
- (void)updateViewConstraints { - (void)updateViewConstraints {
...@@ -286,6 +286,9 @@ NSString* GetSizeString(long long size_in_bytes) { ...@@ -286,6 +286,9 @@ NSString* GetSizeString(long long size_in_bytes) {
constraintEqualToAnchor:installDriveRow.trailingAnchor], constraintEqualToAnchor:installDriveRow.trailingAnchor],
]]; ]];
// constraint actionButtonGuide to action button.
AddSameConstraints(self.actionButtonGuide, actionButton);
[self updateConstraintsForTraitCollection:self.traitCollection]; [self updateConstraintsForTraitCollection:self.traitCollection];
_addedConstraints = YES; _addedConstraints = YES;
...@@ -537,10 +540,8 @@ NSString* GetSizeString(long long size_in_bytes) { ...@@ -537,10 +540,8 @@ NSString* GetSizeString(long long size_in_bytes) {
SEL selector = @selector SEL selector = @selector
(downloadManagerViewController:presentOpenInMenuWithLayoutGuide:); (downloadManagerViewController:presentOpenInMenuWithLayoutGuide:);
if ([_delegate respondsToSelector:selector]) { if ([_delegate respondsToSelector:selector]) {
UILayoutGuide* guide =
[NamedGuide guideWithName:kActionButtonGuide view:self.view];
[_delegate downloadManagerViewController:self [_delegate downloadManagerViewController:self
presentOpenInMenuWithLayoutGuide:guide]; presentOpenInMenuWithLayoutGuide:self.actionButtonGuide];
} }
break; 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