Commit 45a38907 authored by adamta's avatar adamta Committed by Chromium LUCI CQ

[iOS] Creates DiscoverFeedVC for NTP

Creates view controller to wrap Discover feed returned by Mulder. Will
be used as the primary NTP scroll view so that feed scroll actions could
be detected and to expose certain properties.

Bug: 1114792
Change-Id: I8ee9160b70234c1e25e9a5ea721d8982b84b5f30
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2576416
Commit-Queue: Adam Trudeau-Arcaro <adamta@google.com>
Reviewed-by: default avatarSergio Collazos <sczs@chromium.org>
Cr-Commit-Position: refs/heads/master@{#834266}
parent d866af57
......@@ -51,6 +51,8 @@ source_set("util") {
source_set("ntp_internal") {
configs += [ "//build/config/compiler:enable_arc" ]
sources = [
"discover_feed_view_controller.h",
"discover_feed_view_controller.mm",
"incognito_view.h",
"incognito_view.mm",
"incognito_view_controller.h",
......
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef IOS_CHROME_BROWSER_UI_NTP_DISCOVER_FEED_VIEW_CONTROLLER_H_
#define IOS_CHROME_BROWSER_UI_NTP_DISCOVER_FEED_VIEW_CONTROLLER_H_
#import <UIKit/UIKit.h>
// View controller wrapping a Discover feed view controller originating
// elsewhere.
@interface DiscoverFeedViewController : UIViewController
// Collection view subview that contains the feed articles.
@property(nonatomic, weak, readonly) UICollectionView* feedCollectionView;
// Initializes view controller with the browser object.
- (instancetype)initWithDiscoverFeedViewController:
(UIViewController*)discoverFeed NS_DESIGNATED_INITIALIZER;
- (instancetype)initWithNibName:(NSString*)nibNameOrNil
bundle:(NSBundle*)nibBundleOrNil NS_UNAVAILABLE;
- (instancetype)initWithCoder:(NSCoder*)aDecoder NS_UNAVAILABLE;
@end
#endif // IOS_CHROME_BROWSER_UI_NTP_DISCOVER_FEED_VIEW_CONTROLLER_H_
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#import <UIKit/UIKit.h>
#import "ios/chrome/browser/ui/ntp/discover_feed_view_controller.h"
#import "ios/chrome/common/ui/util/constraints_ui_util.h"
#if !defined(__has_feature) || !__has_feature(objc_arc)
#error "This file requires ARC support."
#endif
@interface DiscoverFeedViewController ()
// Feed view controller being contained by this view controller.
@property(nonatomic, strong) UIViewController* discoverFeed;
@end
@implementation DiscoverFeedViewController
- (instancetype)initWithDiscoverFeedViewController:
(UIViewController*)discoverFeed {
self = [super initWithNibName:nil bundle:nil];
if (self) {
// TODO(crbug.com/1114792): Handle case where feed is disabled, replacing it
// with a regular scroll view.
_discoverFeed = discoverFeed;
}
return self;
}
- (void)viewDidLoad {
[super viewDidLoad];
UIView* discoverView = self.discoverFeed.view;
// Iterates through subviews to find collection view containing feed articles.
// TODO(crbug.com/1085419): Once the CollectionView is cleanly exposed, remove
// this loop.
for (UIView* view in discoverView.subviews) {
if ([view isKindOfClass:[UICollectionView class]]) {
_feedCollectionView = static_cast<UICollectionView*>(view);
}
}
[self.discoverFeed willMoveToParentViewController:self];
[self addChildViewController:self.discoverFeed];
[self.view addSubview:discoverView];
[self.discoverFeed didMoveToParentViewController:self];
discoverView.translatesAutoresizingMaskIntoConstraints = NO;
AddSameConstraints(discoverView, self.view);
}
@end
......@@ -33,6 +33,7 @@
- (void)viewDidLoad {
[super viewDidLoad];
[self.contentSuggestionsViewController willMoveToParentViewController:self];
[self addChildViewController:self.contentSuggestionsViewController];
[self.view addSubview:self.contentSuggestionsViewController.view];
[self.contentSuggestionsViewController didMoveToParentViewController:self];
......
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