Commit 273c468d authored by Gauthier Ambard's avatar Gauthier Ambard Committed by Commit Bot

[iOS] Cleanup names for TabGrid animations

This CL updates the names of the object providing animations
information from GridTransitionStateProviding to
GridTransitionAnimationLayoutProviding and its methods.
Hopefully, it should increase the readability of the responsibilities
of the object.

It also removes the context parameter as it wasn't used and I plan to
use this class without a context in a future CL.

Bug: 1038034
Change-Id: I9b125cdd6603c7441dfd0cb9f1c256b3d60e37b4
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2050317Reviewed-by: default avatarMark Cogan <marq@chromium.org>
Commit-Queue: Gauthier Ambard <gambard@chromium.org>
Auto-Submit: Gauthier Ambard <gambard@chromium.org>
Cr-Commit-Position: refs/heads/master@{#740327}
parent 61d76753
......@@ -7,12 +7,12 @@
#import <UIKit/UIKit.h>
@protocol GridTransitionStateProviding;
@protocol GridTransitionAnimationLayoutProviding;
@interface TabGridTransitionHandler
: NSObject<UIViewControllerTransitioningDelegate>
@property(nonatomic, weak) id<GridTransitionStateProviding> provider;
@property(nonatomic, weak) id<GridTransitionAnimationLayoutProviding> provider;
@end
......
......@@ -5,7 +5,7 @@
#import "ios/chrome/browser/ui/tab_grid/tab_grid_transition_handler.h"
#import "ios/chrome/browser/ui/tab_grid/transitions/grid_to_visible_tab_animator.h"
#import "ios/chrome/browser/ui/tab_grid/transitions/grid_transition_state_providing.h"
#import "ios/chrome/browser/ui/tab_grid/transitions/grid_transition_animation_layout_providing.h"
#import "ios/chrome/browser/ui/tab_grid/transitions/reduced_motion_animator.h"
#import "ios/chrome/browser/ui/tab_grid/transitions/tab_to_grid_animator.h"
......@@ -23,8 +23,8 @@ animationControllerForPresentedController:(UIViewController*)presented
sourceController:(UIViewController*)source {
if (!UIAccessibilityIsReduceMotionEnabled() &&
self.provider.selectedCellVisible) {
return
[[GridToVisibleTabAnimator alloc] initWithStateProvider:self.provider];
return [[GridToVisibleTabAnimator alloc]
initWithAnimationLayoutProvider:self.provider];
}
ReducedMotionAnimator* simpleAnimator = [[ReducedMotionAnimator alloc] init];
simpleAnimator.presenting = YES;
......@@ -34,7 +34,8 @@ animationControllerForPresentedController:(UIViewController*)presented
- (id<UIViewControllerAnimatedTransitioning>)
animationControllerForDismissedController:(UIViewController*)dismissed {
if (!UIAccessibilityIsReduceMotionEnabled()) {
return [[TabToGridAnimator alloc] initWithStateProvider:self.provider];
return [[TabToGridAnimator alloc]
initWithAnimationLayoutProvider:self.provider];
}
ReducedMotionAnimator* simpleAnimator = [[ReducedMotionAnimator alloc] init];
simpleAnimator.presenting = NO;
......
......@@ -8,7 +8,7 @@
#import <UIKit/UIKit.h>
#import "ios/chrome/browser/ui/tab_grid/tab_grid_paging.h"
#import "ios/chrome/browser/ui/tab_grid/transitions/grid_transition_state_providing.h"
#import "ios/chrome/browser/ui/tab_grid/transitions/grid_transition_animation_layout_providing.h"
@protocol ApplicationCommands;
@protocol GridConsumer;
......@@ -28,7 +28,7 @@
// View controller representing a tab switcher. The tab switcher has an
// incognito tab grid, regular tab grid, and remote tabs.
@interface TabGridViewController
: UIViewController<TabGridPaging, GridTransitionStateProviding>
: UIViewController <TabGridPaging, GridTransitionAnimationLayoutProviding>
@property(nonatomic, weak) id<ApplicationCommands> dispatcher;
......
......@@ -312,7 +312,7 @@ NSUInteger GetPageIndexFromPage(TabGridPage page) {
return l10n_util::GetNSString(stringID);
}
#pragma mark - GridTransitionStateProviding properties
#pragma mark - GridTransitionAnimationLayoutProviding properties
- (BOOL)isSelectedCellVisible {
if (self.activePage != self.currentPage)
......@@ -323,8 +323,7 @@ NSUInteger GetPageIndexFromPage(TabGridPage page) {
: gridViewController.selectedCellVisible;
}
- (GridTransitionLayout*)layoutForTransitionContext:
(id<UIViewControllerContextTransitioning>)context {
- (GridTransitionLayout*)transitionLayout {
GridViewController* gridViewController =
[self gridViewControllerForPage:self.activePage];
if (!gridViewController)
......@@ -335,13 +334,11 @@ NSUInteger GetPageIndexFromPage(TabGridPage page) {
return layout;
}
- (UIView*)proxyContainerForTransitionContext:
(id<UIViewControllerContextTransitioning>)context {
- (UIView*)animationViewsContainer {
return self.view;
}
- (UIView*)proxyPositionForTransitionContext:
(id<UIViewControllerContextTransitioning>)context {
- (UIView*)animationViewsContainerBottomView {
return self.scrollView;
}
......
......@@ -11,9 +11,9 @@ source_set("transitions") {
"grid_to_visible_tab_animator.mm",
"grid_transition_animation.h",
"grid_transition_animation.mm",
"grid_transition_animation_layout_providing.h",
"grid_transition_layout.h",
"grid_transition_layout.mm",
"grid_transition_state_providing.h",
"reduced_motion_animator.h",
"reduced_motion_animator.mm",
"tab_to_grid_animator.h",
......
......@@ -7,17 +7,17 @@
#import <UIKit/UIKit.h>
@protocol GridTransitionStateProviding;
@protocol GridTransitionAnimationLayoutProviding;
// Animator object for transitioning from a collection view of square-ish items
// (the "grid") into a fullscreen view controller (the "tab").
@interface GridToVisibleTabAnimator
: NSObject<UIViewControllerAnimatedTransitioning>
// Initialize an animator object with |stateProvider| to provide state
// information for the transition.
- (instancetype)initWithStateProvider:
(id<GridTransitionStateProviding>)stateProvider;
// Initialize an animator object with |animationLayoutProvider| to provide
// layout information for the transition.
- (instancetype)initWithAnimationLayoutProvider:
(id<GridTransitionAnimationLayoutProviding>)animationLayoutProvider;
@end
......
......@@ -6,8 +6,8 @@
#include "ios/chrome/browser/crash_report/breakpad_helper.h"
#import "ios/chrome/browser/ui/tab_grid/transitions/grid_transition_animation.h"
#import "ios/chrome/browser/ui/tab_grid/transitions/grid_transition_animation_layout_providing.h"
#import "ios/chrome/browser/ui/tab_grid/transitions/grid_transition_layout.h"
#import "ios/chrome/browser/ui/tab_grid/transitions/grid_transition_state_providing.h"
#import "ios/chrome/browser/ui/util/layout_guide_names.h"
#import "ios/chrome/browser/ui/util/named_guide.h"
#import "ios/chrome/browser/ui/util/property_animator_group.h"
......@@ -17,7 +17,8 @@
#endif
@interface GridToVisibleTabAnimator ()
@property(nonatomic, weak) id<GridTransitionStateProviding> stateProvider;
@property(nonatomic, weak) id<GridTransitionAnimationLayoutProviding>
animationLayoutProvider;
// Animation object for this transition.
@property(nonatomic, strong) GridTransitionAnimation* animation;
// Transition context passed into this object when the animation is started.
......@@ -26,14 +27,11 @@
@end
@implementation GridToVisibleTabAnimator
@synthesize stateProvider = _stateProvider;
@synthesize animation = _animation;
@synthesize transitionContext = _transitionContext;
- (instancetype)initWithStateProvider:
(id<GridTransitionStateProviding>)stateProvider {
- (instancetype)initWithAnimationLayoutProvider:
(id<GridTransitionAnimationLayoutProviding>)animationLayoutProvider {
if ((self = [super init])) {
_stateProvider = stateProvider;
_animationLayoutProvider = animationLayoutProvider;
}
return self;
}
......@@ -65,11 +63,11 @@
// Get the layout of the grid for the transition.
GridTransitionLayout* layout =
[self.stateProvider layoutForTransitionContext:transitionContext];
[self.animationLayoutProvider transitionLayout];
// Ask the state provider for the views to use when inserting the animation.
UIView* proxyContainer =
[self.stateProvider proxyContainerForTransitionContext:transitionContext];
UIView* animationContainer =
[self.animationLayoutProvider animationViewsContainer];
// Find the rect for the animating tab by getting the content area layout
// guide.
......@@ -89,8 +87,9 @@
[layout.activeItem populateWithSnapshotsFromView:viewWithNamedGuides
middleRect:finalRect];
layout.expandedRect = [proxyContainer convertRect:viewWithNamedGuides.frame
fromView:presentedView];
layout.expandedRect =
[animationContainer convertRect:viewWithNamedGuides.frame
fromView:presentedView];
NSTimeInterval duration = [self transitionDuration:transitionContext];
// Create the animation view and insert it.
......@@ -99,9 +98,10 @@
duration:duration
direction:GridAnimationDirectionExpanding];
UIView* viewBehindProxies =
[self.stateProvider proxyPositionForTransitionContext:transitionContext];
[proxyContainer insertSubview:self.animation aboveSubview:viewBehindProxies];
UIView* bottomViewForAnimations =
[self.animationLayoutProvider animationViewsContainerBottomView];
[animationContainer insertSubview:self.animation
aboveSubview:bottomViewForAnimations];
// Reparent the active cell view so that it can animate above the presenting
// view while the rest of the animation is embedded inside it.
......
......@@ -2,38 +2,34 @@
// 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_TRANSITION_STATE_PROVIDING_H_
#define IOS_CHROME_BROWSER_UI_TAB_GRID_TRANSITIONS_GRID_TRANSITION_STATE_PROVIDING_H_
#ifndef IOS_CHROME_BROWSER_UI_TAB_GRID_TRANSITIONS_GRID_TRANSITION_ANIMATION_LAYOUT_PROVIDING_H_
#define IOS_CHROME_BROWSER_UI_TAB_GRID_TRANSITIONS_GRID_TRANSITION_ANIMATION_LAYOUT_PROVIDING_H_
#import <Foundation/Foundation.h>
@class GridTransitionLayout;
// Objects conforming to this protocol can provide state information to
// transition delegates and animators for a grid.
@protocol GridTransitionStateProviding
// Objects conforming to this protocol can provide information for the
// animation of the transitions from and to a grid.
@protocol GridTransitionAnimationLayoutProviding
// YES if the currently selected cell is visible in the grid.
@property(nonatomic, readonly, getter=isSelectedCellVisible)
BOOL selectedCellVisible;
// Asks the provider for an aray of layout items that provide objects for use
// in building an animated transition.
- (GridTransitionLayout*)layoutForTransitionContext:
(id<UIViewControllerContextTransitioning>)context;
// Asks the provider for the information on the layout of the grid of cells,
// used in transition animations.
- (GridTransitionLayout*)transitionLayout;
// Asks the provider for the view to add proxy views to when building an
// animated transition.
- (UIView*)proxyContainerForTransitionContext:
(id<UIViewControllerContextTransitioning>)context;
// Asks the provider for the view to which the animation views should be added.
- (UIView*)animationViewsContainer;
// Asks the provider for the view (if any) that proxy views should be added
// Asks the provider for the view (if any) that animation views should be added
// in front of when building an animated transition. It's an error if this
// view is not nil and isn't an immediate subview of the view returned by
// |-proxyContainerForTransitionContext:|
- (UIView*)proxyPositionForTransitionContext:
(id<UIViewControllerContextTransitioning>)context;
// |-animationViewsContainer|
- (UIView*)animationViewsContainerBottomView;
@end
#endif // IOS_CHROME_BROWSER_UI_TAB_GRID_TRANSITIONS_TAB_GRID_TRANSITION_STATE_PROVIDING_H_
#endif // IOS_CHROME_BROWSER_UI_TAB_GRID_TRANSITIONS_GRID_TRANSITION_ANIMATION_LAYOUT_PROVIDING_H_
......@@ -7,16 +7,16 @@
#import <UIKit/UIKit.h>
@protocol GridTransitionStateProviding;
@protocol GridTransitionAnimationLayoutProviding;
// Animator object for transitioning from a fullscreen view controller (the
// "tab") into a collection view of square-ish items (the "grid").
@interface TabToGridAnimator : NSObject<UIViewControllerAnimatedTransitioning>
// Initialize an animator object with |stateProvider| to provide state
// information for the transition.
- (instancetype)initWithStateProvider:
(id<GridTransitionStateProviding>)stateProvider;
// Initialize an animator object with |animationLayoutProvider| to provide
// layout information for the transition.
- (instancetype)initWithAnimationLayoutProvider:
(id<GridTransitionAnimationLayoutProviding>)animationLayoutProvider;
@end
......
......@@ -5,8 +5,8 @@
#import "ios/chrome/browser/ui/tab_grid/transitions/tab_to_grid_animator.h"
#import "ios/chrome/browser/ui/tab_grid/transitions/grid_transition_animation.h"
#import "ios/chrome/browser/ui/tab_grid/transitions/grid_transition_animation_layout_providing.h"
#import "ios/chrome/browser/ui/tab_grid/transitions/grid_transition_layout.h"
#import "ios/chrome/browser/ui/tab_grid/transitions/grid_transition_state_providing.h"
#import "ios/chrome/browser/ui/util/layout_guide_names.h"
#import "ios/chrome/browser/ui/util/named_guide.h"
#import "ios/chrome/browser/ui/util/property_animator_group.h"
......@@ -16,7 +16,8 @@
#endif
@interface TabToGridAnimator ()
@property(nonatomic, weak) id<GridTransitionStateProviding> stateProvider;
@property(nonatomic, weak) id<GridTransitionAnimationLayoutProviding>
animationLayoutProvider;
// Animation object for this transition.
@property(nonatomic, strong) GridTransitionAnimation* animation;
// Transition context passed into this object when the animation is started.
......@@ -25,14 +26,11 @@
@end
@implementation TabToGridAnimator
@synthesize stateProvider = _stateProvider;
@synthesize animation = _animation;
@synthesize transitionContext = _transitionContext;
- (instancetype)initWithStateProvider:
(id<GridTransitionStateProviding>)stateProvider {
- (instancetype)initWithAnimationLayoutProvider:
(id<GridTransitionAnimationLayoutProviding>)animationLayoutProvider {
if ((self = [super init])) {
_stateProvider = stateProvider;
_animationLayoutProvider = animationLayoutProvider;
}
return self;
}
......@@ -71,12 +69,12 @@
[gridView layoutIfNeeded];
// Ask the state provider for the views to use when inserting the animation.
UIView* proxyContainer =
[self.stateProvider proxyContainerForTransitionContext:transitionContext];
UIView* animationContainer =
[self.animationLayoutProvider animationViewsContainer];
// Get the layout of the grid for the transition.
GridTransitionLayout* layout =
[self.stateProvider layoutForTransitionContext:transitionContext];
[self.animationLayoutProvider transitionLayout];
// Get the initial rect for the snapshotted content of the active tab.
// Conceptually this transition is dismissing a tab (a BVC). However,
......@@ -95,8 +93,9 @@
[layout.activeItem populateWithSnapshotsFromView:viewWithNamedGuides
middleRect:initialRect];
layout.expandedRect = [proxyContainer convertRect:viewWithNamedGuides.frame
fromView:dismissingView];
layout.expandedRect =
[animationContainer convertRect:viewWithNamedGuides.frame
fromView:dismissingView];
NSTimeInterval duration = [self transitionDuration:transitionContext];
// Create the animation view and insert it.
......@@ -105,9 +104,10 @@
duration:duration
direction:GridAnimationDirectionContracting];
UIView* viewBehindProxies =
[self.stateProvider proxyPositionForTransitionContext:transitionContext];
[proxyContainer insertSubview:self.animation aboveSubview:viewBehindProxies];
UIView* bottomViewForAnimations =
[self.animationLayoutProvider animationViewsContainerBottomView];
[animationContainer insertSubview:self.animation
aboveSubview:bottomViewForAnimations];
[self.animation.animator addCompletion:^(UIViewAnimatingPosition position) {
BOOL finished = (position == UIViewAnimatingPositionEnd);
......
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