Commit f7e02c7a authored by Mark Cogan's avatar Mark Cogan Committed by Commit Bot

[iOS] Set up stub transition animators for Tab Grid.

This CL sets up stub implementations for the Tabb Grid transition
animators and helper objects/protocols.

Bug: 804537
Cq-Include-Trybots: master.tryserver.chromium.mac:ios-simulator-cronet;master.tryserver.chromium.mac:ios-simulator-full-configs
Change-Id: Ie030f3222a93774e9da6a90b02cd865350f2dd37
Reviewed-on: https://chromium-review.googlesource.com/924756
Commit-Queue: Mark Cogan <marq@chromium.org>
Reviewed-by: default avataredchin <edchin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#537537}
parent 0b05c5ec
......@@ -39,6 +39,9 @@ source_set("tab_grid_ui") {
"tab_grid_bottom_toolbar.mm",
"tab_grid_top_toolbar.h",
"tab_grid_top_toolbar.mm",
"tab_grid_transition_handler.h",
"tab_grid_transition_handler.mm",
"tab_grid_transition_state_provider.h",
"tab_grid_view_controller.h",
"tab_grid_view_controller.mm",
]
......@@ -47,6 +50,7 @@ source_set("tab_grid_ui") {
deps = [
"//base",
"//ios/chrome/browser/ui/tab_grid/transitions",
"//ios/chrome/browser/ui/util:constraints_ui",
]
}
......
......@@ -8,20 +8,23 @@
#import "ios/chrome/browser/ui/main/bvc_container_view_controller.h"
#import "ios/chrome/browser/ui/tab_grid/tab_grid_adaptor.h"
#import "ios/chrome/browser/ui/tab_grid/tab_grid_mediator.h"
#import "ios/chrome/browser/ui/tab_grid/tab_grid_transition_handler.h"
#import "ios/chrome/browser/ui/tab_grid/tab_grid_view_controller.h"
#if !defined(__has_feature) || !__has_feature(objc_arc)
#error "This file requires ARC support."
#endif
@interface TabGridCoordinator ()<UIViewControllerTransitioningDelegate>
// Object that internally backs the public TabSwitcher
@interface TabGridCoordinator ()
// Object that internally backs the public TabSwitcher
@property(nonatomic, strong) TabGridAdaptor* adaptor;
// Container view controller for the BVC to live in; this class's view
// controller will present this.
@property(nonatomic, strong) BVCContainerViewController* bvcContainer;
// Mediates between the model layer and the tab grid UI layer.
@property(nonatomic, strong) TabGridMediator* mediator;
// Transitioning delegate for the view controller.
@property(nonatomic, strong) TabGridTransitionHandler* transitionHandler;
@end
@implementation TabGridCoordinator
......@@ -35,6 +38,7 @@
@synthesize adaptor = _adaptor;
@synthesize bvcContainer = _bvcContainer;
@synthesize mediator = _mediator;
@synthesize transitionHandler = _transitionHandler;
#pragma mark - Public properties
......@@ -51,8 +55,11 @@
#pragma mark - ChromeCoordinator
- (void)start {
UIViewController* mainViewController = [[TabGridViewController alloc] init];
mainViewController.transitioningDelegate = self;
TabGridViewController* mainViewController =
[[TabGridViewController alloc] init];
self.transitionHandler = [[TabGridTransitionHandler alloc] init];
self.transitionHandler.provider = mainViewController;
mainViewController.transitioningDelegate = self.transitionHandler;
_mainViewController = mainViewController;
self.window.rootViewController = self.mainViewController;
self.adaptor = [[TabGridAdaptor alloc] init];
......@@ -63,22 +70,6 @@
self.mediator.incognitoTabModel = self.incognitoTabModel;
}
#pragma mark - UIViewControllerTransitioningDelegate
- (id<UIViewControllerAnimatedTransitioning>)
animationControllerForPresentedController:(UIViewController*)presented
presentingController:(UIViewController*)presenting
sourceController:(UIViewController*)source {
return nil;
}
- (id<UIViewControllerAnimatedTransitioning>)
animationControllerForDismissedController:(UIViewController*)dismissed {
// Verify that the presenting and dismissed view controllers are of the
// expected types.
return nil;
}
#pragma mark - ViewControllerSwapping
- (UIViewController*)activeViewController {
......@@ -105,7 +96,7 @@ animationControllerForDismissedController:(UIViewController*)dismissed {
// If a BVC is currently being presented, dismiss it. This will trigger any
// necessary animations.
if (self.bvcContainer) {
self.bvcContainer.transitioningDelegate = self;
self.bvcContainer.transitioningDelegate = self.transitionHandler;
self.bvcContainer = nil;
BOOL animated = !self.animationsDisabledForTesting;
[self.mainViewController dismissViewControllerAnimated:animated
......@@ -133,7 +124,7 @@ animationControllerForDismissedController:(UIViewController*)dismissed {
self.bvcContainer = [[BVCContainerViewController alloc] init];
self.bvcContainer.currentBVC = viewController;
self.bvcContainer.transitioningDelegate = self;
self.bvcContainer.transitioningDelegate = self.transitionHandler;
BOOL animated = !self.animationsDisabledForTesting;
[self.mainViewController presentViewController:self.bvcContainer
animated:animated
......
// Copyright 2018 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_TAB_GRID_TAB_GRID_TRANSITION_HANDLER_H_
#define IOS_CHROME_BROWSER_UI_TAB_GRID_TAB_GRID_TRANSITION_HANDLER_H_
#import <UIKit/UIKit.h>
@protocol TabGridTransitionStateProvider;
@interface TabGridTransitionHandler
: NSObject<UIViewControllerTransitioningDelegate>
@property(nonatomic, weak) id<TabGridTransitionStateProvider> provider;
@end
#endif // IOS_CHROME_BROWSER_UI_TAB_GRID_TAB_GRID_TRANSITION_HANDLER_H_
// Copyright 2018 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 "ios/chrome/browser/ui/tab_grid/tab_grid_transition_handler.h"
#import "ios/chrome/browser/ui/tab_grid/tab_grid_transition_state_provider.h"
#import "ios/chrome/browser/ui/tab_grid/transitions/grid_to_hidden_tab_animator.h"
#import "ios/chrome/browser/ui/tab_grid/transitions/grid_to_visible_tab_animator.h"
#import "ios/chrome/browser/ui/tab_grid/transitions/tab_to_grid_animator.h"
#if !defined(__has_feature) || !__has_feature(objc_arc)
#error "This file requires ARC support."
#endif
@implementation TabGridTransitionHandler
@synthesize provider = _provider;
#pragma mark - UIViewControllerTransitioningDelegate
- (id<UIViewControllerAnimatedTransitioning>)
animationControllerForPresentedController:(UIViewController*)presented
presentingController:(UIViewController*)presenting
sourceController:(UIViewController*)source {
id<UIViewControllerAnimatedTransitioning> animator;
if (self.provider.selectedTabVisible) {
// This will be a GridToVisibleTabAnimator eventually.
animator = nil;
} else {
// This will be a GridToHiddenTabAnimator eventually.
animator = nil;
}
return animator;
}
- (id<UIViewControllerAnimatedTransitioning>)
animationControllerForDismissedController:(UIViewController*)dismissed {
// This will be a TabToGridAnimator eventually.
return nil;
}
@end
// Copyright 2018 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_TAB_GRID_TAB_GRID_TRANSITION_STATE_PROVIDER_H_
#define IOS_CHROME_BROWSER_UI_TAB_GRID_TAB_GRID_TRANSITION_STATE_PROVIDER_H_
#import <Foundation/Foundation.h>
// Objects conforming to this protocol can provide state information to
// transition delegates and animators for the tab grid.
@protocol TabGridTransitionStateProvider
// YES if the currently selected tab is visible in the tab grid.
@property(nonatomic, readonly) BOOL selectedTabVisible;
@end
#endif // IOS_CHROME_BROWSER_UI_TAB_GRID_TAB_GRID_TRANSITION_STATE_PROVIDER_H_
......@@ -8,12 +8,16 @@
#import <UIKit/UIKit.h>
#import "ios/chrome/browser/ui/tab_grid/grid_consumer.h"
#import "ios/chrome/browser/ui/tab_grid/tab_grid_transition_state_provider.h"
// View controller representing a tab switcher. The tab switcher has an
// View controller representing a tab switcher. The tab switcher has an
// incognito tab grid, regular tab grid, and remote tabs.
@interface TabGridViewController : UIViewController
@interface TabGridViewController
: UIViewController<TabGridTransitionStateProvider>
@property(nonatomic, readonly) id<GridConsumer> regularTabsConsumer;
@property(nonatomic, readonly) id<GridConsumer> incognitoTabsConsumer;
@end
#endif // IOS_CHROME_BROWSER_UI_TAB_GRID_TAB_GRID_VIEW_CONTROLLER_H_
......@@ -93,7 +93,7 @@
constraintEqualToAnchor:self.view.trailingAnchor],
nil];
if (@available(iOS 11, *)) {
// SafeArea is only available in iOS 11+.
// SafeArea is only available in iOS 11+.
[constraints addObjectsFromArray:@[
[topToolbar.bottomAnchor
constraintEqualToAnchor:self.view.safeAreaLayoutGuide.topAnchor
......@@ -122,4 +122,10 @@
bottomToolbar.intrinsicContentSize.height, 0);
}
#pragma mark - TabGridTransitionStateProvider properties
- (BOOL)selectedTabVisible {
return NO;
}
@end
# Copyright 2018 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("//ios/public/provider/chrome/browser/build_config.gni")
source_set("transitions") {
sources = [
"grid_to_hidden_tab_animator.h",
"grid_to_hidden_tab_animator.mm",
"grid_to_visible_tab_animator.h",
"grid_to_visible_tab_animator.mm",
"tab_to_grid_animator.h",
"tab_to_grid_animator.mm",
]
configs += [ "//build/config/compiler:enable_arc" ]
deps = [
"//base",
]
}
// Copyright 2018 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_TAB_GRID_TRANSITIONS_GRID_TO_HIDDEN_TAB_ANIMATOR_H_
#define IOS_CHROME_BROWSER_UI_TAB_GRID_TRANSITIONS_GRID_TO_HIDDEN_TAB_ANIMATOR_H_
#import <UIKit/UIKit.h>
@interface GridToHiddenTabAnimator
: NSObject<UIViewControllerAnimatedTransitioning>
@end
#endif // IOS_CHROME_BROWSER_UI_TAB_GRID_TRANSITIONS_GRID_TO_HIDDEN_TAB_ANIMATOR_H_
// Copyright 2018 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 "ios/chrome/browser/ui/tab_grid/transitions/grid_to_hidden_tab_animator.h"
#if !defined(__has_feature) || !__has_feature(objc_arc)
#error "This file requires ARC support."
#endif
@implementation GridToHiddenTabAnimator
- (NSTimeInterval)transitionDuration:
(id<UIViewControllerContextTransitioning>)transitionContext {
return 0.25;
}
- (void)animateTransition:
(id<UIViewControllerContextTransitioning>)transitionContext {
}
@end
// Copyright 2018 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_TAB_GRID_TRANSITIONS_GRID_TO_VISIBLE_TAB_ANIMATOR_H_
#define IOS_CHROME_BROWSER_UI_TAB_GRID_TRANSITIONS_GRID_TO_VISIBLE_TAB_ANIMATOR_H_
#import <UIKit/UIKit.h>
@interface GridToVisibleTabAnimator
: NSObject<UIViewControllerAnimatedTransitioning>
@end
#endif // IOS_CHROME_BROWSER_UI_TAB_GRID_TRANSITIONS_GRID_TO_VISIBLE_TAB_ANIMATOR_H_
// Copyright 2018 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 "ios/chrome/browser/ui/tab_grid/transitions/grid_to_visible_tab_animator.h"
#if !defined(__has_feature) || !__has_feature(objc_arc)
#error "This file requires ARC support."
#endif
@implementation GridToVisibleTabAnimator
- (NSTimeInterval)transitionDuration:
(id<UIViewControllerContextTransitioning>)transitionContext {
return 0.25;
}
- (void)animateTransition:
(id<UIViewControllerContextTransitioning>)transitionContext {
}
@end
// Copyright 2018 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_TAB_GRID_TRANSITIONS_TAB_TO_GRID_ANIMATOR_H_
#define IOS_CHROME_BROWSER_UI_TAB_GRID_TRANSITIONS_TAB_TO_GRID_ANIMATOR_H_
#import <UIKit/UIKit.h>
@interface TabToGridAnimator : NSObject<UIViewControllerAnimatedTransitioning>
@end
#endif // IOS_CHROME_BROWSER_UI_TAB_GRID_TRANSITIONS_TAB_TO_GRID_ANIMATOR_H_
// Copyright 2018 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 "ios/chrome/browser/ui/tab_grid/transitions/tab_to_grid_animator.h"
#if !defined(__has_feature) || !__has_feature(objc_arc)
#error "This file requires ARC support."
#endif
@implementation TabToGridAnimator
- (NSTimeInterval)transitionDuration:
(id<UIViewControllerContextTransitioning>)transitionContext {
return 0.25;
}
- (void)animateTransition:
(id<UIViewControllerContextTransitioning>)transitionContext {
}
@end
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