Commit 3db72cdf authored by sczs's avatar sczs Committed by Commit Bot

[ios] Fixes Discover header alignment for Max/Plus devices.

Bug: 1127014, 1085419
Change-Id: Ia87c235ca32e60396e721f1821eafc78f44c9ce1
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2404958Reviewed-by: default avatarGanggui Tang <gogerald@chromium.org>
Commit-Queue: Sergio Collazos <sczs@chromium.org>
Cr-Commit-Position: refs/heads/master@{#806269}
parent 0809a16e
...@@ -31,8 +31,8 @@ const CGFloat kHeaderMenuButtonInsetTopAndBottom = 2; ...@@ -31,8 +31,8 @@ const CGFloat kHeaderMenuButtonInsetTopAndBottom = 2;
const CGFloat kHeaderMenuButtonInsetSides = 2; const CGFloat kHeaderMenuButtonInsetSides = 2;
// Duration for the header animation when Discover feed visibility changes. // Duration for the header animation when Discover feed visibility changes.
const CGFloat kHeaderChangeAnimationDuration = 0.3; const CGFloat kHeaderChangeAnimationDuration = 0.3;
// Max width for cards in iPhone, this is used to align the header to the card // Max width for cards in non Max/Plus iPhones, this is used to align the header
// margins. This is currently hard coded by Discover. // to the card margins. This is currently hard coded by Discover.
const CGFloat kFeedCardIPhoneWidth = 375; const CGFloat kFeedCardIPhoneWidth = 375;
} }
...@@ -132,20 +132,24 @@ const CGFloat kFeedCardIPhoneWidth = 375; ...@@ -132,20 +132,24 @@ const CGFloat kFeedCardIPhoneWidth = 375;
]]; ]];
// TODO(b/167703449): Once the card width and padding is exposed we should // TODO(b/167703449): Once the card width and padding is exposed we should
// stop hardcodnig this for iPhone and use those values instead. // stop hardcoding this for some iPhones (the ones with a portrait width of
if (IsIPadIdiom()) { // kFeedCardIPhoneWidth) and use those values instead.
BOOL shouldFixWidth = IsPortrait()
? (CurrentScreenWidth() == kFeedCardIPhoneWidth)
: (CurrentScreenHeight() == kFeedCardIPhoneWidth);
if (shouldFixWidth) {
[constraintsArray addObjectsFromArray:@[
[container.centerXAnchor
constraintEqualToAnchor:self.contentView.centerXAnchor],
[container.widthAnchor constraintEqualToConstant:kFeedCardIPhoneWidth],
]];
} else {
[constraintsArray addObjectsFromArray:@[ [constraintsArray addObjectsFromArray:@[
[container.leadingAnchor [container.leadingAnchor
constraintEqualToAnchor:self.contentView.leadingAnchor], constraintEqualToAnchor:self.contentView.leadingAnchor],
[container.trailingAnchor [container.trailingAnchor
constraintEqualToAnchor:self.contentView.trailingAnchor], constraintEqualToAnchor:self.contentView.trailingAnchor],
]]; ]];
} else {
[constraintsArray addObjectsFromArray:@[
[container.centerXAnchor
constraintEqualToAnchor:self.contentView.centerXAnchor],
[container.widthAnchor constraintEqualToConstant:kFeedCardIPhoneWidth],
]];
} }
[NSLayoutConstraint activateConstraints:constraintsArray]; [NSLayoutConstraint activateConstraints:constraintsArray];
......
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