Commit ddbb487b authored by Roberto Moura's avatar Roberto Moura Committed by Commit Bot

Add a pan gesture in the tabstrip to reveal the thumb strip.

- Change the tabstrip's background to clear to allow the thumb
strip to be seen from behind it during enter/exit animation.
- Add a pan gesture recognizer to reveal/hide the thumb strip by
dragging down/up the tabstrip.

Bug: 1094335
Change-Id: I193d848f4ba2aaf07202c6d986496c2ed4b708a2
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2315884
Commit-Queue: Roberto Moura <mouraroberto@google.com>
Reviewed-by: default avataredchin <edchin@chromium.org>
Reviewed-by: default avatarMark Cogan <marq@chromium.org>
Cr-Commit-Position: refs/heads/master@{#799950}
parent 41695565
...@@ -50,6 +50,7 @@ source_set("tabs") { ...@@ -50,6 +50,7 @@ source_set("tabs") {
"//ios/chrome/browser/ui/elements", "//ios/chrome/browser/ui/elements",
"//ios/chrome/browser/ui/fullscreen", "//ios/chrome/browser/ui/fullscreen",
"//ios/chrome/browser/ui/fullscreen:feature_flags", "//ios/chrome/browser/ui/fullscreen:feature_flags",
"//ios/chrome/browser/ui/gestures",
"//ios/chrome/browser/ui/image_util", "//ios/chrome/browser/ui/image_util",
"//ios/chrome/browser/ui/ntp:util", "//ios/chrome/browser/ui/ntp:util",
"//ios/chrome/browser/ui/open_in", "//ios/chrome/browser/ui/open_in",
......
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
@protocol PopupMenuLongPressDelegate; @protocol PopupMenuLongPressDelegate;
@protocol TabStripPresentation; @protocol TabStripPresentation;
@class ViewRevealingVerticalPanHandler;
class Browser; class Browser;
// Controller class for the tabstrip. Manages displaying tabs and keeping the // Controller class for the tabstrip. Manages displaying tabs and keeping the
...@@ -32,6 +33,9 @@ class Browser; ...@@ -32,6 +33,9 @@ class Browser;
// Used to check if the tabstrip is visible before starting an animation. // Used to check if the tabstrip is visible before starting an animation.
@property(nonatomic, assign) id<TabStripPresentation> presentationProvider; @property(nonatomic, assign) id<TabStripPresentation> presentationProvider;
// Pan gesture handler for the tab strip.
@property(nonatomic, weak) ViewRevealingVerticalPanHandler* panGestureHandler;
// Designated initializer, |dispatcher| is not retained. // Designated initializer, |dispatcher| is not retained.
- (instancetype)initWithBrowser:(Browser*)browser - (instancetype)initWithBrowser:(Browser*)browser
style:(TabStripStyle)style NS_DESIGNATED_INITIALIZER; style:(TabStripStyle)style NS_DESIGNATED_INITIALIZER;
......
...@@ -35,6 +35,7 @@ ...@@ -35,6 +35,7 @@
#include "ios/chrome/browser/ui/fullscreen/fullscreen_controller.h" #include "ios/chrome/browser/ui/fullscreen/fullscreen_controller.h"
#import "ios/chrome/browser/ui/fullscreen/fullscreen_features.h" #import "ios/chrome/browser/ui/fullscreen/fullscreen_features.h"
#include "ios/chrome/browser/ui/fullscreen/scoped_fullscreen_disabler.h" #include "ios/chrome/browser/ui/fullscreen/scoped_fullscreen_disabler.h"
#import "ios/chrome/browser/ui/gestures/view_revealing_vertical_pan_handler.h"
#import "ios/chrome/browser/ui/ntp/ntp_util.h" #import "ios/chrome/browser/ui/ntp/ntp_util.h"
#import "ios/chrome/browser/ui/popup_menu/public/popup_menu_long_press_delegate.h" #import "ios/chrome/browser/ui/popup_menu/public/popup_menu_long_press_delegate.h"
#import "ios/chrome/browser/ui/tabs/requirements/tab_strip_constants.h" #import "ios/chrome/browser/ui/tabs/requirements/tab_strip_constants.h"
...@@ -120,6 +121,11 @@ const CGFloat kNewTabButtonBottomImageInset = -2.0; ...@@ -120,6 +121,11 @@ const CGFloat kNewTabButtonBottomImageInset = -2.0;
// Returns the background color. // Returns the background color.
UIColor* BackgroundColor() { UIColor* BackgroundColor() {
if (base::FeatureList::IsEnabled(kExpandedTabStrip)) {
// The background needs to be clear to allow the thumb strip to be seen
// from behind the tab strip during the enter/exit thumb strip animation.
return UIColor.clearColor;
}
return UIColor.blackColor; return UIColor.blackColor;
} }
...@@ -282,6 +288,9 @@ UIColor* BackgroundColor() { ...@@ -282,6 +288,9 @@ UIColor* BackgroundColor() {
// Handler for URL drop interactions. // Handler for URL drop interactions.
@property(nonatomic, strong) URLDragDropHandler* dragDropHandler; @property(nonatomic, strong) URLDragDropHandler* dragDropHandler;
// Pan gesture recognizer for the view revealing pan gesture handler.
@property(nonatomic, weak) UIPanGestureRecognizer* panGestureRecognizer;
// Initializes the tab array based on the the entries in the |_webStateList|'s. // Initializes the tab array based on the the entries in the |_webStateList|'s.
// Creates one TabView per Tab and adds it to the tabstrip. A later call to // Creates one TabView per Tab and adds it to the tabstrip. A later call to
// |-layoutTabs| is needed to properly place the tabs in the correct positions. // |-layoutTabs| is needed to properly place the tabs in the correct positions.
...@@ -423,6 +432,7 @@ UIColor* BackgroundColor() { ...@@ -423,6 +432,7 @@ UIColor* BackgroundColor() {
@synthesize longPressDelegate = _longPressDelegate; @synthesize longPressDelegate = _longPressDelegate;
@synthesize presentationProvider = _presentationProvider; @synthesize presentationProvider = _presentationProvider;
@synthesize animationWaitDuration = _animationWaitDuration; @synthesize animationWaitDuration = _animationWaitDuration;
@synthesize panGestureHandler = _panGestureHandler;
- (instancetype)initWithBrowser:(Browser*)browser style:(TabStripStyle)style { - (instancetype)initWithBrowser:(Browser*)browser style:(TabStripStyle)style {
if ((self = [super init])) { if ((self = [super init])) {
...@@ -569,6 +579,20 @@ UIColor* BackgroundColor() { ...@@ -569,6 +579,20 @@ UIColor* BackgroundColor() {
[self layoutTabStripSubviews]; [self layoutTabStripSubviews];
} }
- (void)setPanGestureHandler:
(ViewRevealingVerticalPanHandler*)panGestureHandler {
_panGestureHandler = panGestureHandler;
[self.view removeGestureRecognizer:self.panGestureRecognizer];
UIPanGestureRecognizer* panGestureRecognizer = [[UIPanGestureRecognizer alloc]
initWithTarget:panGestureHandler
action:@selector(handlePanGesture:)];
panGestureRecognizer.maximumNumberOfTouches = 1;
[self.view addGestureRecognizer:panGestureRecognizer];
self.panGestureRecognizer = panGestureRecognizer;
}
#pragma mark - Private #pragma mark - Private
- (void)initializeTabArray { - (void)initializeTabArray {
......
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
@protocol PopupMenuLongPressDelegate; @protocol PopupMenuLongPressDelegate;
@protocol TabStripPresentation; @protocol TabStripPresentation;
@class ViewRevealingVerticalPanHandler;
// A legacy coordinator that presents the public interface for the tablet tab // A legacy coordinator that presents the public interface for the tablet tab
// strip feature. // strip feature.
...@@ -28,6 +29,10 @@ ...@@ -28,6 +29,10 @@
// synchronize animations. // synchronize animations.
@property(nonatomic, assign) NSTimeInterval animationWaitDuration; @property(nonatomic, assign) NSTimeInterval animationWaitDuration;
// Sets the pan gesture handler for the tab strip controller.
- (void)setPanGestureHandler:
(ViewRevealingVerticalPanHandler*)panGestureHandler;
// Hides or shows the TabStrip. // Hides or shows the TabStrip.
- (void)hideTabStrip:(BOOL)hidden; - (void)hideTabStrip:(BOOL)hidden;
......
...@@ -57,6 +57,11 @@ ...@@ -57,6 +57,11 @@
[self.tabStripController tabStripSizeDidChange]; [self.tabStripController tabStripSizeDidChange];
} }
- (void)setPanGestureHandler:
(ViewRevealingVerticalPanHandler*)panGestureHandler {
self.tabStripController.panGestureHandler = panGestureHandler;
}
#pragma mark - ChromeCoordinator #pragma mark - ChromeCoordinator
- (void)start { - (void)start {
......
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