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

Implement the view revealing animatee protocol in the toolbar.

- Implement the view revealing animatee methods: when revealing the
thumb strip view, the toolbar's top right and top left corners will
become rounded.
- Add a pan gesture recognizer to reveal/hide the thumb strip by
dragging down/up the toolbar.

Bug: 1094335
Change-Id: Ib024cc033e2bf4f270c006330a3f972624b495eb
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2315346
Commit-Queue: 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@{#800059}
parent 64b19d1b
...@@ -45,6 +45,7 @@ source_set("toolbar") { ...@@ -45,6 +45,7 @@ source_set("toolbar") {
"//ios/chrome/browser/ui/coordinators:chrome_coordinators", "//ios/chrome/browser/ui/coordinators:chrome_coordinators",
"//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/location_bar", "//ios/chrome/browser/ui/location_bar",
"//ios/chrome/browser/ui/ntp", "//ios/chrome/browser/ui/ntp",
"//ios/chrome/browser/ui/ntp:util", "//ios/chrome/browser/ui/ntp:util",
...@@ -94,6 +95,7 @@ source_set("toolbar_ui") { ...@@ -94,6 +95,7 @@ source_set("toolbar_ui") {
"//ios/chrome/browser/ui/activity_services/requirements", "//ios/chrome/browser/ui/activity_services/requirements",
"//ios/chrome/browser/ui/commands", "//ios/chrome/browser/ui/commands",
"//ios/chrome/browser/ui/fullscreen:ui", "//ios/chrome/browser/ui/fullscreen:ui",
"//ios/chrome/browser/ui/gestures",
"//ios/chrome/browser/ui/ntp:ntp", "//ios/chrome/browser/ui/ntp:ntp",
"//ios/chrome/browser/ui/orchestrator", "//ios/chrome/browser/ui/orchestrator",
"//ios/chrome/browser/ui/popup_menu/public", "//ios/chrome/browser/ui/popup_menu/public",
......
...@@ -11,6 +11,8 @@ ...@@ -11,6 +11,8 @@
@protocol ActivityServicePositioner; @protocol ActivityServicePositioner;
@protocol OmniboxPopupPresenterDelegate; @protocol OmniboxPopupPresenterDelegate;
@protocol ToolbarCoordinatorDelegate; @protocol ToolbarCoordinatorDelegate;
@class ViewRevealingVerticalPanHandler;
@protocol ViewRevealingAnimatee;
// Coordinator for the primary part, the one containing the omnibox, of the // Coordinator for the primary part, the one containing the omnibox, of the
// adaptive toolbar. // adaptive toolbar.
...@@ -25,6 +27,10 @@ ...@@ -25,6 +27,10 @@
@property(nonatomic, weak) id<OmniboxPopupPresenterDelegate> @property(nonatomic, weak) id<OmniboxPopupPresenterDelegate>
popupPresenterDelegate; popupPresenterDelegate;
// A reference to the view controller that implements the view revealing
// vertical pan handler delegate methods.
@property(nonatomic, weak, readonly) id<ViewRevealingAnimatee> animatee;
// Positioner for activity services attached to the toolbar // Positioner for activity services attached to the toolbar
- (id<ActivityServicePositioner>)activityServicePositioner; - (id<ActivityServicePositioner>)activityServicePositioner;
...@@ -39,6 +45,10 @@ ...@@ -39,6 +45,10 @@
// transition to the expanded location bar state of the view controller. // transition to the expanded location bar state of the view controller.
- (void)transitionToLocationBarFocusedState:(BOOL)focused; - (void)transitionToLocationBarFocusedState:(BOOL)focused;
// Sets the pan gesture handler for the toolbar controller.
- (void)setPanGestureHandler:
(ViewRevealingVerticalPanHandler*)panGestureHandler;
@end @end
#endif // IOS_CHROME_BROWSER_UI_TOOLBAR_PRIMARY_TOOLBAR_COORDINATOR_H_ #endif // IOS_CHROME_BROWSER_UI_TOOLBAR_PRIMARY_TOOLBAR_COORDINATOR_H_
...@@ -148,6 +148,15 @@ ...@@ -148,6 +148,15 @@
animated:self.enableAnimationsForOmniboxFocus]; animated:self.enableAnimationsForOmniboxFocus];
} }
- (id<ViewRevealingAnimatee>)animatee {
return self.viewController;
}
- (void)setPanGestureHandler:
(ViewRevealingVerticalPanHandler*)panGestureHandler {
self.viewController.panGestureHandler = panGestureHandler;
}
#pragma mark - PrimaryToolbarViewControllerDelegate #pragma mark - PrimaryToolbarViewControllerDelegate
- (void)viewControllerTraitCollectionDidChange: - (void)viewControllerTraitCollectionDidChange:
......
...@@ -67,6 +67,10 @@ ...@@ -67,6 +67,10 @@
@property(nonatomic, strong, readwrite) @property(nonatomic, strong, readwrite)
NSLayoutConstraint* locationBarBottomConstraint; NSLayoutConstraint* locationBarBottomConstraint;
// Whether the top-left and top-right corners of the toolbar are rounded or
// square.
@property(nonatomic, assign) BOOL topCornersRounded;
// Sets all the subviews and constraints of the view. The |topSafeAnchor| needs // Sets all the subviews and constraints of the view. The |topSafeAnchor| needs
// to be set before calling this. // to be set before calling this.
- (void)setUp; - (void)setUp;
......
...@@ -169,6 +169,11 @@ ...@@ -169,6 +169,11 @@
self.fakeOmniboxTarget = nil; self.fakeOmniboxTarget = nil;
} }
- (void)setTopCornersRounded:(BOOL)rounded {
_topCornersRounded = rounded;
self.layer.cornerRadius = rounded ? kTopCornerRadius : 0;
}
#pragma mark - UIView #pragma mark - UIView
- (CGSize)intrinsicContentSize { - (CGSize)intrinsicContentSize {
...@@ -195,6 +200,9 @@ ...@@ -195,6 +200,9 @@
- (void)setUpToolbarBackground { - (void)setUpToolbarBackground {
self.backgroundColor = self.backgroundColor =
self.buttonFactory.toolbarConfiguration.backgroundColor; self.buttonFactory.toolbarConfiguration.backgroundColor;
if (base::FeatureList::IsEnabled(kExpandedTabStrip)) {
self.layer.maskedCorners = kCALayerMinXMinYCorner | kCALayerMaxXMinYCorner;
}
self.contentView = self; self.contentView = self;
} }
......
...@@ -7,23 +7,29 @@ ...@@ -7,23 +7,29 @@
#import "ios/chrome/browser/ui/activity_services/requirements/activity_service_positioner.h" #import "ios/chrome/browser/ui/activity_services/requirements/activity_service_positioner.h"
#import "ios/chrome/browser/ui/fullscreen/fullscreen_ui_element.h" #import "ios/chrome/browser/ui/fullscreen/fullscreen_ui_element.h"
#import "ios/chrome/browser/ui/gestures/view_revealing_animatee.h"
#import "ios/chrome/browser/ui/orchestrator/toolbar_animatee.h" #import "ios/chrome/browser/ui/orchestrator/toolbar_animatee.h"
#import "ios/chrome/browser/ui/toolbar/adaptive_toolbar_view_controller.h" #import "ios/chrome/browser/ui/toolbar/adaptive_toolbar_view_controller.h"
@protocol PrimaryToolbarViewControllerDelegate; @protocol PrimaryToolbarViewControllerDelegate;
@class ViewRevealingVerticalPanHandler;
// ViewController for the primary toobar part of the adaptive toolbar. It is the // ViewController for the primary toobar part of the adaptive toolbar. It is the
// part always displayed and containing the location bar. // part always displayed and containing the location bar.
@interface PrimaryToolbarViewController @interface PrimaryToolbarViewController
: AdaptiveToolbarViewController<ActivityServicePositioner, : AdaptiveToolbarViewController <ActivityServicePositioner,
FullscreenUIElement, FullscreenUIElement,
ToolbarAnimatee> ToolbarAnimatee,
ViewRevealingAnimatee>
@property(nonatomic, weak) id<PrimaryToolbarViewControllerDelegate> delegate; @property(nonatomic, weak) id<PrimaryToolbarViewControllerDelegate> delegate;
// Whether the omnibox should be hidden on NTP. // Whether the omnibox should be hidden on NTP.
@property(nonatomic, assign) BOOL shouldHideOmniboxOnNTP; @property(nonatomic, assign) BOOL shouldHideOmniboxOnNTP;
// Pan gesture handler for the toolbar.
@property(nonatomic, weak) ViewRevealingVerticalPanHandler* panGestureHandler;
// Sets the location bar view controller, containing the omnibox. // Sets the location bar view controller, containing the omnibox.
- (void)setLocationBarViewController:(UIViewController*)locationBarView; - (void)setLocationBarViewController:(UIViewController*)locationBarView;
......
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
#import "ios/chrome/browser/ui/commands/browser_commands.h" #import "ios/chrome/browser/ui/commands/browser_commands.h"
#import "ios/chrome/browser/ui/commands/omnibox_commands.h" #import "ios/chrome/browser/ui/commands/omnibox_commands.h"
#import "ios/chrome/browser/ui/fullscreen/fullscreen_animator.h" #import "ios/chrome/browser/ui/fullscreen/fullscreen_animator.h"
#import "ios/chrome/browser/ui/gestures/view_revealing_vertical_pan_handler.h"
#import "ios/chrome/browser/ui/toolbar/adaptive_toolbar_view_controller+subclassing.h" #import "ios/chrome/browser/ui/toolbar/adaptive_toolbar_view_controller+subclassing.h"
#import "ios/chrome/browser/ui/toolbar/buttons/toolbar_button.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_button_factory.h"
...@@ -34,6 +35,8 @@ ...@@ -34,6 +35,8 @@
@property(nonatomic, assign) BOOL isNTP; @property(nonatomic, assign) BOOL isNTP;
// The last fullscreen progress registered. // The last fullscreen progress registered.
@property(nonatomic, assign) CGFloat previousFullscreenProgress; @property(nonatomic, assign) CGFloat previousFullscreenProgress;
// Pan Gesture Recognizer for the view revealing pan gesture handler.
@property(nonatomic, weak) UIPanGestureRecognizer* panGestureRecognizer;
@end @end
@implementation PrimaryToolbarViewController @implementation PrimaryToolbarViewController
...@@ -55,6 +58,26 @@ ...@@ -55,6 +58,26 @@
}]; }];
} }
- (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 - viewRevealingAnimatee
- (void)animateViewReveal:(BOOL)viewRevealed {
self.view.topCornersRounded = !viewRevealed;
}
#pragma mark - AdaptiveToolbarViewController #pragma mark - AdaptiveToolbarViewController
- (void)updateForSideSwipeSnapshotOnNTP:(BOOL)onNTP { - (void)updateForSideSwipeSnapshotOnNTP:(BOOL)onNTP {
......
...@@ -98,6 +98,10 @@ extern NSString* const kToolbarNewTabButtonIdentifier; ...@@ -98,6 +98,10 @@ extern NSString* const kToolbarNewTabButtonIdentifier;
// Accessibility identifier of the cancel omnibox edit button. // Accessibility identifier of the cancel omnibox edit button.
extern NSString* const kToolbarCancelOmniboxEditButtonIdentifier; extern NSString* const kToolbarCancelOmniboxEditButtonIdentifier;
// Round corner radius for top-left and top-right corners when thumb strip is
// visible.
extern const CGFloat kTopCornerRadius;
// Font size for the TabGrid button containing the tab count. // Font size for the TabGrid button containing the tab count.
extern const NSInteger kTabGridButtonFontSize; extern const NSInteger kTabGridButtonFontSize;
......
...@@ -58,6 +58,8 @@ const CGFloat kNonDynamicToolbarHeight = 14; ...@@ -58,6 +58,8 @@ const CGFloat kNonDynamicToolbarHeight = 14;
const CGFloat kToolbarHeightFullscreen = 20; const CGFloat kToolbarHeightFullscreen = 20;
const CGFloat kNonDynamicToolbarHeightFullscreen = 3; const CGFloat kNonDynamicToolbarHeightFullscreen = 3;
const CGFloat kTopCornerRadius = 10;
NSString* const kToolbarToolsMenuButtonIdentifier = NSString* const kToolbarToolsMenuButtonIdentifier =
@"kToolbarToolsMenuButtonIdentifier"; @"kToolbarToolsMenuButtonIdentifier";
NSString* const kToolbarStackButtonIdentifier = NSString* const kToolbarStackButtonIdentifier =
......
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