Commit cdf8699e authored by stkhapugin@chromium.org's avatar stkhapugin@chromium.org Committed by Commit Bot

[iOS] Improvements of the focusing animation.

Fades the leading icon and the clear button to avoid overlapping with
the toolbar elements.

Bug: 867406
Cq-Include-Trybots: luci.chromium.try:ios-simulator-full-configs;master.tryserver.chromium.mac:ios-simulator-cronet
Change-Id: Ib60719fe1adee84032bbd59588609fd63cfa06ed
Reviewed-on: https://chromium-review.googlesource.com/1152919
Commit-Queue: Stepan Khapugin <stkhapugin@chromium.org>
Reviewed-by: default avatarRohit Rao <rohitrao@chromium.org>
Reviewed-by: default avatarGauthier Ambard <gambard@chromium.org>
Cr-Commit-Position: refs/heads/master@{#579767}
parent af4f6fe3
...@@ -176,6 +176,10 @@ const int kLocationAuthorizationStatusCount = 4; ...@@ -176,6 +176,10 @@ const int kLocationAuthorizationStatusCount = 4;
return self.viewController; return self.viewController;
} }
- (id<EditViewAnimatee>)editViewAnimatee {
return self.omniboxCoordinator.animatee;
}
#pragma mark - LoadQueryCommands #pragma mark - LoadQueryCommands
- (void)loadQuery:(NSString*)query immediately:(BOOL)immediately { - (void)loadQuery:(NSString*)query immediately:(BOOL)immediately {
......
...@@ -18,6 +18,7 @@ class WebStateList; ...@@ -18,6 +18,7 @@ class WebStateList;
@class CommandDispatcher; @class CommandDispatcher;
@protocol ApplicationCommands; @protocol ApplicationCommands;
@protocol BrowserCommands; @protocol BrowserCommands;
@protocol EditViewAnimatee;
@protocol LocationBarAnimatee; @protocol LocationBarAnimatee;
@protocol OmniboxPopupPositioner; @protocol OmniboxPopupPositioner;
@protocol ToolbarCoordinatorDelegate; @protocol ToolbarCoordinatorDelegate;
...@@ -63,9 +64,12 @@ class WebStateList; ...@@ -63,9 +64,12 @@ class WebStateList;
// @optional label and matching respondsToSelector: calls. // @optional label and matching respondsToSelector: calls.
@optional @optional
// Returns the animatee. // Returns the location bar animatee.
- (id<LocationBarAnimatee>)locationBarAnimatee; - (id<LocationBarAnimatee>)locationBarAnimatee;
// Returns the edit view animatee.
- (id<EditViewAnimatee>)editViewAnimatee;
@end @end
#endif // IOS_CHROME_BROWSER_UI_LOCATION_BAR_LOCATION_BAR_GENERIC_COORDINATOR_H_ #endif // IOS_CHROME_BROWSER_UI_LOCATION_BAR_LOCATION_BAR_GENERIC_COORDINATOR_H_
...@@ -39,6 +39,9 @@ ...@@ -39,6 +39,9 @@
// Shows or hides the leading button. // Shows or hides the leading button.
- (void)setLeadingImageHidden:(BOOL)hidden; - (void)setLeadingImageHidden:(BOOL)hidden;
// Sets the alpha level of the leading image view.
- (void)setLeadingImageAlpha:(CGFloat)alpha;
@end @end
#endif // IOS_CHROME_BROWSER_UI_OMNIBOX_OMNIBOX_CONTAINER_VIEW_H_ #endif // IOS_CHROME_BROWSER_UI_OMNIBOX_OMNIBOX_CONTAINER_VIEW_H_
...@@ -132,6 +132,10 @@ const CGFloat kTextFieldClearButtonTrailingOffset = 4; ...@@ -132,6 +132,10 @@ const CGFloat kTextFieldClearButtonTrailingOffset = 4;
self.textField.incognito = incognito; self.textField.incognito = incognito;
} }
- (void)setLeadingImageAlpha:(CGFloat)alpha {
self.leadingImageView.alpha = alpha;
}
#pragma mark - private #pragma mark - private
- (void)createLeadingImageView { - (void)createLeadingImageView {
......
...@@ -12,6 +12,7 @@ class ChromeBrowserState; ...@@ -12,6 +12,7 @@ class ChromeBrowserState;
} }
class WebOmniboxEditController; class WebOmniboxEditController;
@class CommandDispatcher; @class CommandDispatcher;
@protocol EditViewAnimatee;
@class OmniboxPopupCoordinator; @class OmniboxPopupCoordinator;
@class OmniboxTextFieldIOS; @class OmniboxTextFieldIOS;
@protocol LocationBarOffsetProvider; @protocol LocationBarOffsetProvider;
...@@ -26,6 +27,8 @@ class WebOmniboxEditController; ...@@ -26,6 +27,8 @@ class WebOmniboxEditController;
@property(nonatomic, assign) ios::ChromeBrowserState* browserState; @property(nonatomic, assign) ios::ChromeBrowserState* browserState;
// The dispatcher for this view controller. // The dispatcher for this view controller.
@property(nonatomic, weak) CommandDispatcher* dispatcher; @property(nonatomic, weak) CommandDispatcher* dispatcher;
// Returns the animatee for the omnibox focus orchestrator.
@property(nonatomic, strong, readonly) id<EditViewAnimatee> animatee;
// The view controller managed by this coordinator. The parent of this // The view controller managed by this coordinator. The parent of this
// coordinator is expected to add it to the responder chain. // coordinator is expected to add it to the responder chain.
......
...@@ -51,6 +51,8 @@ ...@@ -51,6 +51,8 @@
@synthesize viewController = _viewController; @synthesize viewController = _viewController;
@synthesize mediator = _mediator; @synthesize mediator = _mediator;
#pragma mark - public
- (void)start { - (void)start {
BOOL isIncognito = self.browserState->IsOffTheRecord(); BOOL isIncognito = self.browserState->IsOffTheRecord();
...@@ -155,6 +157,10 @@ ...@@ -155,6 +157,10 @@
return self.viewController; return self.viewController;
} }
- (id<EditViewAnimatee>)animatee {
return self.viewController;
}
#pragma mark - private #pragma mark - private
// Convenience accessor. // Convenience accessor.
......
...@@ -9,14 +9,16 @@ ...@@ -9,14 +9,16 @@
#import "ios/chrome/browser/ui/omnibox/omnibox_consumer.h" #import "ios/chrome/browser/ui/omnibox/omnibox_consumer.h"
#import "ios/chrome/browser/ui/omnibox/omnibox_text_field_ios.h" #import "ios/chrome/browser/ui/omnibox/omnibox_text_field_ios.h"
#import "ios/chrome/browser/ui/orchestrator/edit_view_animatee.h"
#import "ios/chrome/browser/ui/orchestrator/location_bar_offset_provider.h" #import "ios/chrome/browser/ui/orchestrator/location_bar_offset_provider.h"
@protocol LoadQueryCommands; @protocol LoadQueryCommands;
@protocol OmniboxFocuser; @protocol OmniboxFocuser;
// The view controller managing the omnibox textfield and its container view. // The view controller managing the omnibox textfield and its container view.
@interface OmniboxViewController @interface OmniboxViewController : UIViewController<EditViewAnimatee,
: UIViewController<LocationBarOffsetProvider, OmniboxConsumer> LocationBarOffsetProvider,
OmniboxConsumer>
// The textfield used by this view controller. // The textfield used by this view controller.
@property(nonatomic, readonly, strong) OmniboxTextFieldIOS* textField; @property(nonatomic, readonly, strong) OmniboxTextFieldIOS* textField;
......
...@@ -118,6 +118,16 @@ const CGFloat kClearButtonSize = 28.0f; ...@@ -118,6 +118,16 @@ const CGFloat kClearButtonSize = 28.0f;
[self.view setLeadingImage:icon]; [self.view setLeadingImage:icon];
} }
#pragma mark - EditViewAnimatee
- (void)setLeadingIconFaded:(BOOL)faded {
[self.view setLeadingImageAlpha:faded ? 0 : 1];
}
- (void)setClearButtonFaded:(BOOL)faded {
self.textField.rightView.alpha = faded ? 0 : 1;
}
#pragma mark - LocationBarOffsetProvider #pragma mark - LocationBarOffsetProvider
- (CGFloat)xOffsetForString:(NSString*)string { - (CGFloat)xOffsetForString:(NSString*)string {
......
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
source_set("orchestrator") { source_set("orchestrator") {
configs += [ "//build/config/compiler:enable_arc" ] configs += [ "//build/config/compiler:enable_arc" ]
sources = [ sources = [
"edit_view_animatee.h",
"location_bar_animatee.h", "location_bar_animatee.h",
"location_bar_offset_provider.h", "location_bar_offset_provider.h",
"omnibox_focus_orchestrator.h", "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.
#ifndef IOS_CHROME_BROWSER_UI_ORCHESTRATOR_EDIT_VIEW_ANIMATEE_H_
#define IOS_CHROME_BROWSER_UI_ORCHESTRATOR_EDIT_VIEW_ANIMATEE_H_
#import <UIKit/UIKit.h>
// An object that represents the edit state location bar for focusing animation.
@protocol EditViewAnimatee<NSObject>
// Toggles the visibility of the leading icon.
- (void)setLeadingIconFaded:(BOOL)faded;
// Toggles the visibility of the clear button.
- (void)setClearButtonFaded:(BOOL)faded;
@end
#endif // IOS_CHROME_BROWSER_UI_ORCHESTRATOR_EDIT_VIEW_ANIMATEE_H_
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
#import <UIKit/UIKit.h> #import <UIKit/UIKit.h>
@protocol EditViewAnimatee;
@protocol LocationBarAnimatee; @protocol LocationBarAnimatee;
@protocol ToolbarAnimatee; @protocol ToolbarAnimatee;
...@@ -19,6 +20,8 @@ ...@@ -19,6 +20,8 @@
@property(nonatomic, weak) id<LocationBarAnimatee> locationBarAnimatee; @property(nonatomic, weak) id<LocationBarAnimatee> locationBarAnimatee;
@property(nonatomic, weak) id<EditViewAnimatee> editViewAnimatee;
// Updates the UI elements orchestrated by this object to reflect the // Updates the UI elements orchestrated by this object to reflect the
// |omniboxFocused| state, and the |toolbarExpanded| state, |animated| or not. // |omniboxFocused| state, and the |toolbarExpanded| state, |animated| or not.
- (void)transitionToStateOmniboxFocused:(BOOL)omniboxFocused - (void)transitionToStateOmniboxFocused:(BOOL)omniboxFocused
......
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
#import "ios/chrome/browser/ui/orchestrator/omnibox_focus_orchestrator.h" #import "ios/chrome/browser/ui/orchestrator/omnibox_focus_orchestrator.h"
#import "ios/chrome/browser/ui/orchestrator/edit_view_animatee.h"
#import "ios/chrome/browser/ui/orchestrator/location_bar_animatee.h" #import "ios/chrome/browser/ui/orchestrator/location_bar_animatee.h"
#import "ios/chrome/browser/ui/orchestrator/toolbar_animatee.h" #import "ios/chrome/browser/ui/orchestrator/toolbar_animatee.h"
#import "ios/chrome/common/material_timing.h" #import "ios/chrome/common/material_timing.h"
...@@ -22,6 +23,7 @@ ...@@ -22,6 +23,7 @@
@synthesize toolbarAnimatee = _toolbarAnimatee; @synthesize toolbarAnimatee = _toolbarAnimatee;
@synthesize locationBarAnimatee = _locationBarAnimatee; @synthesize locationBarAnimatee = _locationBarAnimatee;
@synthesize editViewAnimatee = _editViewAnimatee;
@synthesize isAnimating = _isAnimating; @synthesize isAnimating = _isAnimating;
- (void)transitionToStateOmniboxFocused:(BOOL)omniboxFocused - (void)transitionToStateOmniboxFocused:(BOOL)omniboxFocused
...@@ -70,6 +72,8 @@ ...@@ -70,6 +72,8 @@
[self.locationBarAnimatee resetTransforms]; [self.locationBarAnimatee resetTransforms];
[self.locationBarAnimatee setSteadyViewFaded:NO]; [self.locationBarAnimatee setSteadyViewFaded:NO];
[self.locationBarAnimatee setEditViewFaded:NO]; [self.locationBarAnimatee setEditViewFaded:NO];
[self.editViewAnimatee setLeadingIconFaded:NO];
[self.editViewAnimatee setClearButtonFaded:NO];
self.isAnimating = NO; self.isAnimating = NO;
}; };
...@@ -79,6 +83,8 @@ ...@@ -79,6 +83,8 @@
// Make edit view transparent, but not hidden. // Make edit view transparent, but not hidden.
[self.locationBarAnimatee setEditViewHidden:NO]; [self.locationBarAnimatee setEditViewHidden:NO];
[self.locationBarAnimatee setEditViewFaded:YES]; [self.locationBarAnimatee setEditViewFaded:YES];
[self.editViewAnimatee setLeadingIconFaded:YES];
[self.editViewAnimatee setClearButtonFaded:YES];
CGFloat duration = ios::material::kDuration1; CGFloat duration = ios::material::kDuration1;
...@@ -112,6 +118,14 @@ ...@@ -112,6 +118,14 @@
[self.locationBarAnimatee setEditViewFaded:NO]; [self.locationBarAnimatee setEditViewFaded:NO];
} }
completion:nil]; completion:nil];
[UIView animateWithDuration:duration * 0.2
delay:duration * 0.8
options:UIViewAnimationCurveLinear
animations:^{
[self.editViewAnimatee setLeadingIconFaded:NO];
[self.editViewAnimatee setClearButtonFaded:NO];
}
completion:nil];
} else { } else {
cleanup(YES); cleanup(YES);
} }
...@@ -127,7 +141,8 @@ ...@@ -127,7 +141,8 @@
[self.locationBarAnimatee resetTransforms]; [self.locationBarAnimatee resetTransforms];
self.isAnimating = NO; self.isAnimating = NO;
[self.locationBarAnimatee setSteadyViewFaded:NO]; [self.locationBarAnimatee setSteadyViewFaded:NO];
[self.locationBarAnimatee setEditViewFaded:NO]; [self.editViewAnimatee setLeadingIconFaded:NO];
[self.editViewAnimatee setClearButtonFaded:NO];
}; };
if (animated) { if (animated) {
...@@ -136,6 +151,8 @@ ...@@ -136,6 +151,8 @@
// Make steady view transparent, but not hidden. // Make steady view transparent, but not hidden.
[self.locationBarAnimatee setSteadyViewHidden:NO]; [self.locationBarAnimatee setSteadyViewHidden:NO];
[self.locationBarAnimatee setSteadyViewFaded:YES]; [self.locationBarAnimatee setSteadyViewFaded:YES];
[self.editViewAnimatee setLeadingIconFaded:NO];
[self.editViewAnimatee setClearButtonFaded:NO];
CGFloat duration = ios::material::kDuration1; CGFloat duration = ios::material::kDuration1;
...@@ -150,6 +167,12 @@ ...@@ -150,6 +167,12 @@
// These timings are explained in a comment in // These timings are explained in a comment in
// focusOmniboxAnimated:shouldExpand:. // focusOmniboxAnimated:shouldExpand:.
[UIView animateWithDuration:0.2 * duration
animations:^{
[self.editViewAnimatee setLeadingIconFaded:YES];
[self.editViewAnimatee setClearButtonFaded:YES];
}];
[UIView animateWithDuration:duration * 0.8 [UIView animateWithDuration:duration * 0.8
delay:duration * 0.1 delay:duration * 0.1
options:UIViewAnimationCurveEaseInOut options:UIViewAnimationCurveEaseInOut
......
...@@ -84,6 +84,13 @@ ...@@ -84,6 +84,13 @@
self.orchestrator.locationBarAnimatee = self.orchestrator.locationBarAnimatee =
[self.locationBarCoordinator locationBarAnimatee]; [self.locationBarCoordinator locationBarAnimatee];
} }
if ([self.locationBarCoordinator
respondsToSelector:@selector(editViewAnimatee)]) {
self.orchestrator.editViewAnimatee =
[self.locationBarCoordinator editViewAnimatee];
}
[super start]; [super start];
_fullscreenObserver = _fullscreenObserver =
......
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