Commit 47d79058 authored by Roberto Moura's avatar Roberto Moura Committed by Commit Bot

Add thumb strip to the browser.

- Add the thumb strip coordinator to the browser coordinator.
- Add a reference to the thumb strip pan handler inside the BVC so that
the BVC can add the tab strip and the toolbar as animatees of the view
revealing vertical pan handler.
- Implement the view revealing animatee protocol: when revealing the
view, the tab strip should be translated down to be hidden behind
the toolbar.
- Set the BVC's background colour to clear and remove the fake status
bar so that the thumb strip can be visible from behind those.
- Add a pan gesture recognizer to the toolbar and tab strip, the first
set of entry points to the thumb strip.
- Set the tab strip to be below the toolbar in the view hierarchy so that
it can slide behind the toolbar during thumb strip transitions.

Bug: 1094335
Change-Id: Ic749236f70f5c3a589ae70e5b6a9442e85acf517
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2315029
Commit-Queue: Roberto Moura <mouraroberto@google.com>
Auto-Submit: Roberto Moura <mouraroberto@google.com>
Reviewed-by: default avatarMark Cogan <marq@chromium.org>
Reviewed-by: default avataredchin <edchin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#803160}
parent e7bc6aae
......@@ -95,6 +95,8 @@
[self removeOldContentView];
_contentView = contentView;
_contentView.clipsToBounds = YES;
if (contentView)
[self.view insertSubview:contentView atIndex:0];
}
......
......@@ -98,6 +98,7 @@ source_set("browser_view") {
"//ios/chrome/browser/ui/fullscreen",
"//ios/chrome/browser/ui/fullscreen:feature_flags",
"//ios/chrome/browser/ui/fullscreen:ui",
"//ios/chrome/browser/ui/gestures",
"//ios/chrome/browser/ui/history",
"//ios/chrome/browser/ui/image_util:web",
"//ios/chrome/browser/ui/infobars",
......@@ -140,6 +141,8 @@ source_set("browser_view") {
"//ios/chrome/browser/ui/tabs/requirements",
"//ios/chrome/browser/ui/text_zoom",
"//ios/chrome/browser/ui/text_zoom:text_zoom_ui",
"//ios/chrome/browser/ui/thumb_strip",
"//ios/chrome/browser/ui/thumb_strip:feature_flags",
"//ios/chrome/browser/ui/toolbar",
"//ios/chrome/browser/ui/toolbar:toolbar_ui",
"//ios/chrome/browser/ui/toolbar/accessory",
......
......@@ -61,6 +61,8 @@
#import "ios/chrome/browser/ui/sharing/sharing_coordinator.h"
#import "ios/chrome/browser/ui/snackbar/snackbar_coordinator.h"
#import "ios/chrome/browser/ui/text_zoom/text_zoom_coordinator.h"
#import "ios/chrome/browser/ui/thumb_strip/thumb_strip_coordinator.h"
#import "ios/chrome/browser/ui/thumb_strip/thumb_strip_feature.h"
#import "ios/chrome/browser/ui/toolbar/accessory/toolbar_accessory_coordinator_delegate.h"
#import "ios/chrome/browser/ui/toolbar/accessory/toolbar_accessory_presenter.h"
#import "ios/chrome/browser/ui/translate/legacy_translate_infobar_coordinator.h"
......@@ -184,6 +186,9 @@
@property(nonatomic, strong)
OverlayContainerCoordinator* infobarModalOverlayContainerCoordinator;
// Coordinator for the thumb strip.
@property(nonatomic, strong) ThumbStripCoordinator* thumbStripCoordinator;
@end
@implementation BrowserCoordinator {
......@@ -403,6 +408,15 @@
self.viewController.infobarModalOverlayContainerViewController =
self.infobarModalOverlayContainerCoordinator.viewController;
}
if (IsThumbStripEnabled()) {
self.thumbStripCoordinator = [[ThumbStripCoordinator alloc]
initWithBaseViewController:self.viewController
browser:self.browser];
[self.thumbStripCoordinator start];
self.viewController.thumbStripPanHandler =
self.thumbStripCoordinator.panHandler;
}
}
// Stops child coordinators.
......@@ -462,6 +476,9 @@
[self.infobarModalOverlayContainerCoordinator stop];
self.infobarModalOverlayContainerCoordinator = nil;
[self.thumbStripCoordinator stop];
self.thumbStripCoordinator = nil;
}
#pragma mark - ActivityServiceCommands
......
......@@ -9,6 +9,7 @@
#import "base/ios/block_types.h"
#import "ios/chrome/browser/ui/find_bar/find_bar_coordinator.h"
#import "ios/chrome/browser/ui/gestures/view_revealing_vertical_pan_handler.h"
#import "ios/chrome/browser/ui/page_info/requirements/page_info_presentation.h"
#import "ios/chrome/browser/ui/settings/sync/utils/sync_presenter.h"
#import "ios/chrome/browser/ui/toolbar/toolbar_coordinator_delegate.h"
......@@ -65,6 +66,10 @@ class Browser;
@property(nonatomic, readonly) id<ActivityServicePositioner>
activityServicePositioner;
// The thumb strip's pan gesture handler.
@property(nonatomic, weak)
ViewRevealingVerticalPanHandler* thumbStripPanHandler;
// Whether the receiver is currently the primary BVC.
- (void)setPrimary:(BOOL)primary;
......
......@@ -89,6 +89,7 @@
#import "ios/chrome/browser/ui/fullscreen/fullscreen_features.h"
#import "ios/chrome/browser/ui/fullscreen/fullscreen_ui_element.h"
#import "ios/chrome/browser/ui/fullscreen/fullscreen_ui_updater.h"
#import "ios/chrome/browser/ui/gestures/view_revealing_animatee.h"
#import "ios/chrome/browser/ui/image_util/image_copier.h"
#import "ios/chrome/browser/ui/image_util/image_saver.h"
#import "ios/chrome/browser/ui/infobars/infobar_container_coordinator.h"
......@@ -117,6 +118,7 @@
#import "ios/chrome/browser/ui/tabs/requirements/tab_strip_presentation.h"
#import "ios/chrome/browser/ui/tabs/switch_to_tab_animation_view.h"
#import "ios/chrome/browser/ui/tabs/tab_strip_legacy_coordinator.h"
#import "ios/chrome/browser/ui/thumb_strip/thumb_strip_feature.h"
#import "ios/chrome/browser/ui/toolbar/accessory/toolbar_accessory_presenter.h"
#import "ios/chrome/browser/ui/toolbar/adaptive_toolbar_coordinator.h"
#import "ios/chrome/browser/ui/toolbar/adaptive_toolbar_view_controller.h"
......@@ -329,6 +331,7 @@ NSString* const kBrowserViewControllerSnackbarCategory =
CaptivePortalDetectorTabHelperDelegate,
CRWWebStateDelegate,
CRWWebStateObserver,
FindBarPresentationDelegate,
FullscreenUIElement,
InfobarPositioner,
KeyCommandsPlumbing,
......@@ -345,11 +348,11 @@ NSString* const kBrowserViewControllerSnackbarCategory =
SigninPresenter,
SnapshotGeneratorDelegate,
TabStripPresentation,
FindBarPresentationDelegate,
ToolbarHeightProviderForFullscreen,
WebStateListObserving,
UIGestureRecognizerDelegate,
URLLoadingObserver> {
URLLoadingObserver,
ViewRevealingAnimatee,
WebStateListObserving> {
// The dependency factory passed on initialization. Used to vend objects used
// by the BVC.
BrowserViewControllerDependencyFactory* _dependencyFactory;
......@@ -619,6 +622,8 @@ NSString* const kBrowserViewControllerSnackbarCategory =
- (void)displayWebState:(web::WebState*)webState;
// Initializes the bookmark interaction controller if not already initialized.
- (void)initializeBookmarkInteractionController;
// Sets up the thumb strip.
- (void)setUpThumbStrip;
// UI Configuration, update and Layout
// -----------------------------------
......@@ -1430,6 +1435,10 @@ NSString* const kBrowserViewControllerSnackbarCategory =
[tapRecognizer setDelegate:self];
[tapRecognizer setCancelsTouchesInView:NO];
[self.contentArea addGestureRecognizer:tapRecognizer];
if (IsThumbStripEnabled()) {
[self setUpThumbStrip];
}
}
- (void)viewSafeAreaInsetsDidChange {
......@@ -1832,6 +1841,13 @@ NSString* const kBrowserViewControllerSnackbarCategory =
}
- (void)installFakeStatusBar {
if (IsThumbStripEnabled()) {
// A fake status bar on the browser view is not necessary when the thumb
// strip feature is enabled because the view behind the browser view already
// has a dark background. Adding a fake status bar would block the
// visibility of the thumb strip thumbnails when moving the browser view.
return;
}
CGRect statusBarFrame = CGRectMake(0, 0, CGRectGetWidth(self.view.bounds), 0);
_fakeStatusBarView = [[UIView alloc] initWithFrame:statusBarFrame];
[_fakeStatusBarView setAutoresizingMask:UIViewAutoresizingFlexibleWidth];
......@@ -1931,6 +1947,16 @@ NSString* const kBrowserViewControllerSnackbarCategory =
}
}
// Sets up the thumb strip pan gesture handler.
- (void)setUpThumbStrip {
[self.thumbStripPanHandler
addAnimatee:self.primaryToolbarCoordinator.animatee];
[self.thumbStripPanHandler addAnimatee:self];
self.primaryToolbarCoordinator.panGestureHandler = self.thumbStripPanHandler;
self.tabStripCoordinator.panGestureHandler = self.thumbStripPanHandler;
}
// Called by NSNotificationCenter when the view's window becomes key to account
// for topLayoutGuide length updates.
- (void)updateToolbarHeightForKeyWindow {
......@@ -2173,12 +2199,13 @@ NSString* const kBrowserViewControllerSnackbarCategory =
}
}
// Add the primary toolbar. On iPad, it should be behind the tab strip.
// Add the primary toolbar. On iPad, it should be in front of the tab strip
// because the tab strip slides behind it when showing the thumb strip.
UIView* primaryToolbarView =
self.primaryToolbarCoordinator.viewController.view;
if (IsIPadIdiom()) {
[self.view insertSubview:primaryToolbarView
belowSubview:self.tabStripView];
aboveSubview:self.tabStripView];
} else {
[self.view addSubview:primaryToolbarView];
}
......@@ -2695,6 +2722,12 @@ NSString* const kBrowserViewControllerSnackbarCategory =
#pragma mark - ** Protocol Implementations and Helpers **
#pragma mark - ViewRevealingAnimatee
- (void)animateViewReveal:(BOOL)viewRevealed {
[self slideTabStripDown:!viewRevealed];
}
#pragma mark - BubblePresenterDelegate
- (web::WebState*)currentWebStateForBubblePresenter:
......@@ -4601,7 +4634,17 @@ NSString* const kBrowserViewControllerSnackbarCategory =
tabStripFrame.origin.y = self.headerOffset;
tabStripFrame.size.width = CGRectGetWidth([self view].bounds);
[self.tabStripView setFrame:tabStripFrame];
[[self view] addSubview:tabStripView];
// The tab strip should be behind the toolbar, because it slides behind the
// toolbar during the transition to the thumb strip.
[self.view insertSubview:tabStripView
belowSubview:self.primaryToolbarCoordinator.viewController.view];
}
- (void)slideTabStripDown:(BOOL)slide {
self.tabStripView.transform =
slide ? CGAffineTransformMakeTranslation(
0, self.tabStripView.frame.size.height)
: CGAffineTransformIdentity;
}
#pragma mark - FindBarPresentationDelegate
......
......@@ -162,6 +162,7 @@ source_set("main") {
"//ios/chrome/browser/ui/recent_tabs",
"//ios/chrome/browser/ui/settings/sync",
"//ios/chrome/browser/ui/snackbar",
"//ios/chrome/browser/ui/thumb_strip:feature_flags",
"//ios/chrome/browser/ui/translate:legacy_translate",
"//ios/chrome/browser/ui/util:multiwindow_util",
"//ios/chrome/browser/url_loading",
......
......@@ -3,6 +3,7 @@
// found in the LICENSE file.
#import "ios/chrome/browser/ui/main/bvc_container_view_controller.h"
#import "ios/chrome/browser/ui/thumb_strip/thumb_strip_feature.h"
#include <ostream>
......@@ -46,6 +47,12 @@
// be made.
[self setNeedsStatusBarAppearanceUpdate];
if (IsThumbStripEnabled()) {
// The background needs to be clear to allow the thumb strip to be seen
// during the enter/exit thumb strip animation.
self.currentBVC.view.backgroundColor = [UIColor clearColor];
}
DCHECK(self.currentBVC == bvc);
}
......
......@@ -10,11 +10,16 @@
@protocol TabStripPresentation
// Returns YES if the tab strip is fully visible. Returns NO if it is partially
// visible or not visible.
// visible or not visible. Sliding down the tab strip does not affect the return
// value.
- (BOOL)isTabStripFullyVisible;
// Asks the implementer to show the given |tabStripView|.
- (void)showTabStripView:(UIView*)tabStripView;
// Translate the tab strip down by a distance equal to its height if slide is
// set to YES.
- (void)slideTabStripDown:(BOOL)slide;
@end
#endif // IOS_CHROME_BROWSER_UI_TABS_REQUIREMENTS_TAB_STRIP_PRESENTATION_H_
......@@ -16,3 +16,16 @@ source_set("thumb_strip") {
]
configs += [ "//build/config/compiler:enable_arc" ]
}
source_set("feature_flags") {
sources = [
"thumb_strip_feature.h",
"thumb_strip_feature.mm",
]
deps = [
"//base",
"//ios/chrome/browser/ui:feature_flags",
"//ios/chrome/browser/ui/util",
]
configs += [ "//build/config/compiler:enable_arc" ]
}
// 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_THUMB_STRIP_THUMB_STRIP_FEATURE_H_
#define IOS_CHROME_BROWSER_UI_THUMB_STRIP_THUMB_STRIP_FEATURE_H_
// Returns true if the Thumb Strip feature is enabled and the device is an iPad.
bool IsThumbStripEnabled();
#endif // IOS_CHROME_BROWSER_UI_THUMB_STRIP_THUMB_STRIP_FEATURE_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 "ios/chrome/browser/ui/thumb_strip/thumb_strip_feature.h"
#import "ios/chrome/browser/ui/ui_feature_flags.h"
#import "ios/chrome/browser/ui/util/ui_util.h"
#if !defined(__has_feature) || !__has_feature(objc_arc)
#error "This file requires ARC support."
#endif
bool IsThumbStripEnabled() {
return IsIPadIdiom() && base::FeatureList::IsEnabled(kExpandedTabStrip);
}
......@@ -99,6 +99,7 @@ source_set("toolbar_ui") {
"//ios/chrome/browser/ui/ntp:ntp",
"//ios/chrome/browser/ui/orchestrator",
"//ios/chrome/browser/ui/popup_menu/public",
"//ios/chrome/browser/ui/thumb_strip:feature_flags",
"//ios/chrome/browser/ui/toolbar/buttons",
"//ios/chrome/browser/ui/toolbar/public",
"//ios/chrome/browser/ui/toolbar/public:feature_flags",
......
......@@ -6,6 +6,7 @@
#include "base/check.h"
#import "base/ios/ios_util.h"
#import "ios/chrome/browser/ui/thumb_strip/thumb_strip_feature.h"
#import "ios/chrome/browser/ui/toolbar/buttons/toolbar_button.h"
#import "ios/chrome/browser/ui/toolbar/buttons/toolbar_button_factory.h"
#import "ios/chrome/browser/ui/toolbar/buttons/toolbar_configuration.h"
......@@ -150,7 +151,7 @@
[self setUpProgressBar];
[self setUpCollapsedToolbarButton];
[self setUpSeparator];
if (IsIPadIdiom() && base::FeatureList::IsEnabled(kExpandedTabStrip)) {
if (IsThumbStripEnabled()) {
[self setUpHandleBar];
}
......
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