Commit 3724a2a9 authored by Gauthier Ambard's avatar Gauthier Ambard Committed by Commit Bot

Add orchestrator for the omnibox focus animation

This CL adds an orchestrator for the animation triggered when the
omnibox is focused. This orchestrator is responsible for coordinating
the animation occuring in multiple stages and through multiple object.

Having one central object ensure all animations are occuring with the
same timing.

Bug: 804748
Cq-Include-Trybots: master.tryserver.chromium.mac:ios-simulator-cronet;master.tryserver.chromium.mac:ios-simulator-full-configs
Change-Id: I07583f0fabde6b2fea8c0f9b2a7830fbb7e3cbc8
Reviewed-on: https://chromium-review.googlesource.com/895443
Commit-Queue: Gauthier Ambard <gambard@chromium.org>
Reviewed-by: default avatarStepan Khapugin <stkhapugin@chromium.org>
Reviewed-by: default avatarMark Cogan <marq@chromium.org>
Cr-Commit-Position: refs/heads/master@{#533686}
parent a7f11d6a
# 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.
source_set("orchestrator") {
configs += [ "//build/config/compiler:enable_arc" ]
sources = [
"omnibox_focus_orchestrator.h",
"omnibox_focus_orchestrator.mm",
"toolbar_animatee.h",
]
deps = [
"//ios/chrome/common:timing",
]
libs = [ "UIKit.framework" ]
}
gambard@chromium.org
stkhapugin@chromium.org
# TEAM: ios-directory-owners@chromium.org
# OS: iOS
// 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_ORCHESTRATOR_OMNIBOX_FOCUS_ORCHESTRATOR_H_
#define IOS_CHROME_BROWSER_UI_ORCHESTRATOR_OMNIBOX_FOCUS_ORCHESTRATOR_H_
#import <UIKit/UIKit.h>
@protocol ToolbarAnimatee;
// Orchestrator for the animation occuring when the omnibox is
// focused/unfocused.
@interface OmniboxFocusOrchestrator : NSObject
// Toolbar animatee, orchestrated by this object.
@property(nonatomic, weak) id<ToolbarAnimatee> toolbarAnimatee;
// Updates the UI elements orchestrated by this object to reflect the omnibox
// |focused| state, |animated| or not.
- (void)transitionToStateFocused:(BOOL)focused animated:(BOOL)animated;
@end
#endif // IOS_CHROME_BROWSER_UI_ORCHESTRATOR_OMNIBOX_FOCUS_ORCHESTRATOR_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/orchestrator/omnibox_focus_orchestrator.h"
#import "ios/chrome/browser/ui/orchestrator/toolbar_animatee.h"
#import "ios/chrome/common/material_timing.h"
#if !defined(__has_feature) || !__has_feature(objc_arc)
#error "This file requires ARC support."
#endif
@implementation OmniboxFocusOrchestrator
@synthesize toolbarAnimatee = _toolbarAnimatee;
- (void)transitionToStateFocused:(BOOL)focused animated:(BOOL)animated {
if (focused) {
[self focusOmniboxAnimated:animated];
} else {
[self unfocusOmniboxAnimated:animated];
}
}
#pragma mark - Private
// Updates the UI elements reflect the omnibox focused state, |animated| or not.
- (void)focusOmniboxAnimated:(BOOL)animated {
void (^expansion)() = ^{
[self.toolbarAnimatee expandLocationBar];
[self.toolbarAnimatee showCancelButton];
};
void (^hideControls)() = ^{
[self.toolbarAnimatee hideControlButtons];
};
if (animated) {
UIViewPropertyAnimator* slowAnimator = [[UIViewPropertyAnimator alloc]
initWithDuration:ios::material::kDuration2
curve:UIViewAnimationCurveEaseInOut
animations:^{
expansion();
}];
UIViewPropertyAnimator* fastAnimator = [[UIViewPropertyAnimator alloc]
initWithDuration:ios::material::kDuration1
curve:UIViewAnimationCurveEaseInOut
animations:^{
hideControls();
}];
[slowAnimator startAnimation];
[fastAnimator startAnimation];
} else {
expansion();
hideControls();
}
}
// Updates the UI elements reflect the omnibox unfocused state, |animated| or
// not.
- (void)unfocusOmniboxAnimated:(BOOL)animated {
// TODO(crbug.com/801082): Implement that.
}
@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_ORCHESTRATOR_TOOLBAR_ANIMATEE_H_
#define IOS_CHROME_BROWSER_UI_ORCHESTRATOR_TOOLBAR_ANIMATEE_H_
// Protocol defining an interface to trigger changes on the toolbar. Calling
// those methods should not start any animation.
@protocol ToolbarAnimatee<NSObject>
// Changes related to the Location Bar container.
- (void)expandLocationBar;
- (void)contractLocationBar;
// Changes related to the cancel button.
- (void)showCancelButton;
- (void)hideCancelButton;
// Changes related to the buttons displayed when the omnibox is not focused.
- (void)showControlButtons;
- (void)hideControlButtons;
@end
#endif // IOS_CHROME_BROWSER_UI_ORCHESTRATOR_TOOLBAR_ANIMATEE_H_
......@@ -31,6 +31,7 @@ source_set("adaptive") {
"//ios/chrome/browser/ui/ntp:util",
"//ios/chrome/browser/ui/omnibox",
"//ios/chrome/browser/ui/omnibox/popup",
"//ios/chrome/browser/ui/orchestrator",
"//ios/chrome/browser/ui/toolbar",
"//ios/chrome/browser/ui/toolbar/clean:toolbar",
"//ios/chrome/browser/ui/toolbar/clean:toolbar_components_ui",
......@@ -65,6 +66,7 @@ source_set("adaptive_ui") {
"//ios/chrome/browser/ui/commands",
"//ios/chrome/browser/ui/fullscreen:new_fullscreen_ui",
"//ios/chrome/browser/ui/history_popup/requirements",
"//ios/chrome/browser/ui/orchestrator",
"//ios/chrome/browser/ui/toolbar/clean:toolbar_components_ui",
"//ios/chrome/browser/ui/toolbar/clean:toolbar_ui",
"//ios/chrome/browser/ui/toolbar/public",
......
......@@ -18,6 +18,7 @@
#import "ios/chrome/browser/ui/ntp/ntp_util.h"
#import "ios/chrome/browser/ui/omnibox/omnibox_popup_positioner.h"
#import "ios/chrome/browser/ui/omnibox/omnibox_text_field_ios.h"
#import "ios/chrome/browser/ui/orchestrator/omnibox_focus_orchestrator.h"
#import "ios/chrome/browser/ui/toolbar/adaptive/adaptive_toolbar_coordinator+subclassing.h"
#import "ios/chrome/browser/ui/toolbar/adaptive/primary_toolbar_view_controller.h"
#import "ios/chrome/browser/ui/toolbar/clean/toolbar_coordinator_delegate.h"
......@@ -40,14 +41,17 @@
@property(nonatomic, strong) PrimaryToolbarViewController* viewController;
// The coordinator for the location bar in the toolbar.
@property(nonatomic, strong) LocationBarCoordinator* locationBarCoordinator;
// Orchestrator for the expansion animation.
@property(nonatomic, strong) OmniboxFocusOrchestrator* orchestrator;
@end
@implementation PrimaryToolbarCoordinator
@dynamic viewController;
@synthesize locationBarCoordinator = _locationBarCoordinator;
@synthesize delegate = _delegate;
@synthesize locationBarCoordinator = _locationBarCoordinator;
@synthesize orchestrator = _orchestrator;
@synthesize URLLoader = _URLLoader;
#pragma mark - ChromeCoordinator
......@@ -57,6 +61,9 @@
self.viewController.buttonFactory = [self buttonFactoryWithType:PRIMARY];
self.viewController.dispatcher = self.dispatcher;
self.orchestrator = [[OmniboxFocusOrchestrator alloc] init];
self.orchestrator.toolbarAnimatee = self.viewController;
[self setUpLocationBar];
self.viewController.locationBarView = self.locationBarCoordinator.view;
[super start];
......@@ -103,7 +110,7 @@
}
- (void)transitionToLocationBarFocusedState:(BOOL)focused {
// TODO(crbug.com/801082): implement this.
[self.orchestrator transitionToStateFocused:focused animated:YES];
}
#pragma mark - FakeboxFocuser
......
......@@ -8,6 +8,7 @@
#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/history_popup/requirements/tab_history_ui_updater.h"
#import "ios/chrome/browser/ui/orchestrator/toolbar_animatee.h"
#import "ios/chrome/browser/ui/toolbar/adaptive/adaptive_toolbar_view_controller.h"
// ViewController for the primary toobar part of the adaptive toolbar. It is the
......@@ -15,7 +16,8 @@
@interface PrimaryToolbarViewController
: AdaptiveToolbarViewController<ActivityServicePositioner,
FullscreenUIElement,
TabHistoryUIUpdater>
TabHistoryUIUpdater,
ToolbarAnimatee>
// Sets the location bar view, containing the omnibox.
- (void)setLocationBarView:(UIView*)locationBarView;
......
......@@ -169,6 +169,32 @@
}];
}
#pragma mark - ToolbarAnimatee
- (void)expandLocationBar {
// TODO(crbug.com/804749): Implement this.
}
- (void)contractLocationBar {
// TODO(crbug.com/804749): Implement this.
}
- (void)showCancelButton {
// TODO(crbug.com/804750): Implement this.
}
- (void)hideCancelButton {
// TODO(crbug.com/804750): Implement this.
}
- (void)showControlButtons {
// TODO(crbug.com/804751): Implement this.
}
- (void)hideControlButtons {
// TODO(crbug.com/804751): Implement this.
}
#pragma mark - Private
// Adds a LongPressGesture to the |view|, with target on -|handleLongPress:|.
......
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