Commit 364f6cc6 authored by gambard's avatar gambard Committed by Commit Bot

Fix Most Visited alignment on device rotation

When the device is rotated, the layout should be invalidated in order
to have the Most Visited tiles to have the "correct" alignment, i.e.
4 tiles per row.
It also prevent the omnibox from being unfocused on rotation.

Bug: 751237
Change-Id: I305eff881d226ea692b8f8767dfb52557ce61f82
Reviewed-on: https://chromium-review.googlesource.com/597629Reviewed-by: default avatarOlivier Robin <olivierrobin@chromium.org>
Commit-Queue: Gauthier Ambard <gambard@chromium.org>
Cr-Commit-Position: refs/heads/master@{#491385}
parent f55c6b19
......@@ -151,13 +151,14 @@ initWithCollectionController:
#pragma mark - ContentSuggestionsHeaderSynchronizing
- (void)updateFakeOmniboxForScrollView:(UIScrollView*)scrollView {
// Unfocus the omnibox when the scroll view is scrolled below the pinned
// offset.
- (void)unfocusOmniboxOnCollectionScroll {
// Unfocus the omnibox when the scroll view is scrolled.
if ([self.headerController isOmniboxFocused] && !self.shouldAnimateHeader) {
[self.headerController unfocusOmnibox];
}
}
- (void)updateFakeOmniboxForScrollView:(UIScrollView*)scrollView {
if (IsIPadIdiom()) {
return;
}
......
......@@ -11,6 +11,9 @@
// synchronize with the header, containing the fake omnibox and the logo.
@protocol ContentSuggestionsHeaderSynchronizing
// Handles the scroll of the collection and unfocus the omnibox if needed.
- (void)unfocusOmniboxOnCollectionScroll;
// Updates the fake omnibox to adapt to the current scrolling.
- (void)updateFakeOmniboxForScrollView:(nonnull UIScrollView*)scrollView;
......
......@@ -30,7 +30,7 @@
namespace {
using CSCollectionViewItem = CollectionViewItem<SuggestedContent>;
const CGFloat kMaxCardWidth = 432;
const CGFloat kMaxCardWidth = 416;
// Returns whether the cells should be displayed using the full width.
BOOL ShouldCellsBeFullWidth(UITraitCollection* collection) {
......@@ -213,6 +213,7 @@ BOOL ShouldCellsBeFullWidth(UITraitCollection* collection) {
^(id<UIViewControllerTransitionCoordinatorContext> context) {
[self.headerCommandHandler
updateFakeOmniboxForScrollView:self.collectionView];
[self.collectionView.collectionViewLayout invalidateLayout];
};
[coordinator animateAlongsideTransition:alongsideBlock completion:nil];
}
......@@ -423,6 +424,7 @@ BOOL ShouldCellsBeFullWidth(UITraitCollection* collection) {
[super scrollViewDidScroll:scrollView];
[self.audience contentSuggestionsDidScroll];
[self.overscrollActionsController scrollViewDidScroll:scrollView];
[self.headerCommandHandler unfocusOmniboxOnCollectionScroll];
[self.headerCommandHandler updateFakeOmniboxForScrollView:scrollView];
self.scrolledToTop =
scrollView.contentOffset.y >= [self.suggestionsDelegate pinnedOffsetY];
......
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