Commit 0155c20e authored by gambard's avatar gambard Committed by Commit Bot

Fix ContentSuggestions view after QRCode scan

When the QRCode scanner is shown, the current view is removed from the
view hierarchy. As ContentSuggestions is using the topLayoutGuide as
part of its constraints, the constraint was removed.
So when the QRCode scanner is dismissed, the collection has no
constraint for its top anchor.
This CL fixes it by setting the constraint relative to its superview
instead of the top layout guide.
It also implements a delegate for the header controller.

Bug: 750648
Change-Id: Iccee2279db686ce2e6f3060ed505defbdc038a0b
Reviewed-on: https://chromium-review.googlesource.com/595652Reviewed-by: default avatarJean-François Geyelin <jif@chromium.org>
Commit-Queue: Gauthier Ambard <gambard@chromium.org>
Cr-Commit-Position: refs/heads/master@{#490987}
parent 653ff53a
......@@ -68,6 +68,7 @@ const char kNTPHelpURL[] = "https://support.google.com/chrome/?p=new_tab";
ContentSuggestionsCommands,
ContentSuggestionsGestureCommands,
ContentSuggestionsHeaderViewControllerCommandHandler,
ContentSuggestionsHeaderViewControllerDelegate,
ContentSuggestionsViewControllerAudience,
ContentSuggestionsViewControllerDelegate,
OverscrollActionsControllerDelegate>
......@@ -120,6 +121,7 @@ const char kNTPHelpURL[] = "https://support.google.com/chrome/?p=new_tab";
self.headerController = [[ContentSuggestionsHeaderViewController alloc] init];
self.headerController.dispatcher = self.dispatcher;
self.headerController.delegate = self;
self.headerController.readingListModel =
ReadingListModelFactory::GetForBrowserState(self.browserState);
self.googleLandingMediator =
......@@ -324,6 +326,16 @@ const char kNTPHelpURL[] = "https://support.google.com/chrome/?p=new_tab";
[self showMostVisitedUndoForURL:item.URL];
}
#pragma mark - ContentSuggestionsHeaderViewControllerDelegate
- (BOOL)isContextMenuVisible {
return self.alertCoordinator.isVisible;
}
- (BOOL)isScrolledToTop {
return self.suggestionsViewController.scrolledToTop;
}
#pragma mark - ContentSuggestionsViewControllerDelegate
- (CGFloat)pinnedOffsetY {
......
......@@ -7,10 +7,13 @@
#import <UIKit/UIKit.h>
// TODO(crbug.com/700375): Implement this protocol somewhere.
// Delegate for the ContentSuggestionsHeaderViewController.
@protocol ContentSuggestionsHeaderViewControllerDelegate
// Returns whether a context menu is visible.
- (BOOL)isContextMenuVisible;
// Returns whether the collection is scrolled to its top.
- (BOOL)isScrolledToTop;
@end
......
......@@ -183,10 +183,8 @@ BOOL ShouldCellsBeFullWidth(UITraitCollection* collection) {
}
self.automaticallyAdjustsScrollViewInsets = NO;
self.collectionView.translatesAutoresizingMaskIntoConstraints = NO;
ApplyVisualConstraints(
@[ @"V:[top][collection]|", @"H:|[collection]|" ],
@{ @"collection" : self.collectionView,
@"top" : self.topLayoutGuide });
ApplyVisualConstraints(@[ @"V:|[collection]|", @"H:|[collection]|" ],
@{@"collection" : self.collectionView});
UILongPressGestureRecognizer* longPressRecognizer =
[[UILongPressGestureRecognizer alloc]
......
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