Commit 479b677b authored by edchin's avatar edchin Committed by Commit Bot

[ios] Move SadTab placement using NamedGuide out of BVC

The goal of this CL is to reduce SadTabCoordinator code in BVC so that
SadTabCoordinator can eventually be moved to BrowserCoordinator.

NamedGuides decouple placement of views from BVC. This CL moves SadTab
view placement out of BVC and next to the presentation code so that
presentation and placement are adjacent to one another. This helps to
reduce the SadTabCoordinator footprint in BVC.

Bug: 905524
Change-Id: Ib6744e145380441b3b43c783a12162a9bc0f7f1b
Reviewed-on: https://chromium-review.googlesource.com/c/1426176
Commit-Queue: edchin <edchin@chromium.org>
Reviewed-by: default avataredchin <edchin@chromium.org>
Reviewed-by: default avatarKurt Horimoto <kkhorimoto@chromium.org>
Cr-Commit-Position: refs/heads/master@{#626450}
parent df83a6f9
......@@ -365,7 +365,6 @@ NSString* const kBrowserViewControllerSnackbarCategory =
OverscrollActionsControllerDelegate,
PasswordControllerDelegate,
PreloadControllerDelegate,
SadTabCoordinatorDelegate,
SideSwipeControllerDelegate,
SnapshotGeneratorDelegate,
TabDialogDelegate,
......@@ -2182,7 +2181,6 @@ NSString* const kBrowserViewControllerSnackbarCategory =
initWithBaseViewController:self.browserContainerViewController
browserState:_browserState];
sadTabCoordinator.dispatcher = self.dispatcher;
sadTabCoordinator.delegate = self;
sadTabCoordinator.overscrollDelegate = self;
_sadTabCoordinator = sadTabCoordinator;
} else {
......@@ -4651,15 +4649,6 @@ NSString* const kBrowserViewControllerSnackbarCategory =
return self.contentArea;
}
#pragma mark - SadTabCoordinatorDelegate
- (void)sadTabCoordinatorDidStart:(SadTabCoordinator*)sadTabCoordinator {
UIView* sadTabView = sadTabCoordinator.viewController.view;
sadTabView.translatesAutoresizingMaskIntoConstraints = NO;
AddSameConstraints(
[NamedGuide guideWithName:kContentAreaGuide view:self.view], sadTabView);
}
#pragma mark - UIGestureRecognizerDelegate
// Always return yes, as this tap should work with various recognizers,
......
......@@ -11,20 +11,12 @@
@protocol ApplicationCommands;
@protocol BrowserCommands;
@protocol OverscrollActionsControllerDelegate;
@class SadTabCoordinator;
@protocol SadTabCoordinatorDelegate
// Called from -[SadTabCoordinator start].
- (void)sadTabCoordinatorDidStart:(SadTabCoordinator*)sadTabCoordinator;
@end
// Coordinator that displays a SadTab view.
@interface SadTabCoordinator : ChromeCoordinator<SadTabTabHelperDelegate>
@property(nonatomic, weak) id<ApplicationCommands, BrowserCommands> dispatcher;
@property(nonatomic, weak) id<SadTabCoordinatorDelegate> delegate;
// Required to support Overscroll Actions UI, which is displayed when Sad Tab is
// pulled down.
@property(nonatomic, weak) id<OverscrollActionsControllerDelegate>
......
......@@ -10,6 +10,8 @@
#import "ios/chrome/browser/ui/commands/open_new_tab_command.h"
#import "ios/chrome/browser/ui/overscroll_actions/overscroll_actions_controller.h"
#import "ios/chrome/browser/ui/sad_tab/sad_tab_view_controller.h"
#import "ios/chrome/browser/ui/util/layout_guide_names.h"
#import "ios/chrome/browser/ui/util/named_guide.h"
#import "ios/chrome/browser/web/sad_tab_tab_helper.h"
#import "ios/chrome/common/ui_util/constraints_ui_util.h"
#import "ios/web/public/web_state/web_state.h"
......@@ -24,11 +26,6 @@
@end
@implementation SadTabCoordinator
@synthesize dispatcher = _dispatcher;
@synthesize delegate = _delegate;
@synthesize overscrollDelegate = _overscrollDelegate;
@synthesize viewController = _viewController;
@synthesize repeatedFailure = _repeatedFailure;
- (void)start {
if (_viewController)
......@@ -44,7 +41,10 @@
[self.baseViewController.view addSubview:_viewController.view];
[_viewController didMoveToParentViewController:self.baseViewController];
[self.delegate sadTabCoordinatorDidStart:self];
_viewController.view.translatesAutoresizingMaskIntoConstraints = NO;
AddSameConstraints([NamedGuide guideWithName:kContentAreaGuide
view:self.baseViewController.view],
_viewController.view);
}
- (void)stop {
......
......@@ -55,21 +55,6 @@ TEST_F(SadTabCoordinatorTest, Start) {
EXPECT_FALSE(view_controller.repeatedFailure);
}
// Tests |sadTabCoordinatorDidStart:| delegate call.
TEST_F(SadTabCoordinatorTest, Delegate) {
SadTabCoordinator* coordinator = [[SadTabCoordinator alloc]
initWithBaseViewController:base_view_controller_
browserState:browser_state_.get()];
id delegate = OCMStrictProtocolMock(@protocol(SadTabCoordinatorDelegate));
coordinator.delegate = delegate;
OCMExpect([delegate sadTabCoordinatorDidStart:coordinator]);
[coordinator start];
EXPECT_OCMOCK_VERIFY(delegate);
}
// Tests stopping coordinator.
TEST_F(SadTabCoordinatorTest, Stop) {
SadTabCoordinator* coordinator = [[SadTabCoordinator 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