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

[iOS] Style the UI Refresh popup.

Styles the popup per spec:
* removes shadows
* makes background match the toolbar background

Bug: 821817
Cq-Include-Trybots: luci.chromium.try:ios-simulator-full-configs;master.tryserver.chromium.mac:ios-simulator-cronet
Change-Id: I9073e78aa6a83b00ab97d45abf590b01ce90886e
Reviewed-on: https://chromium-review.googlesource.com/1108210Reviewed-by: default avatarGauthier Ambard <gambard@chromium.org>
Commit-Queue: Stepan Khapugin <stkhapugin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#569566}
parent 0f9a9c53
...@@ -34,6 +34,7 @@ source_set("popup") { ...@@ -34,6 +34,7 @@ source_set("popup") {
"//ios/chrome/browser/ui/commands", "//ios/chrome/browser/ui/commands",
"//ios/chrome/browser/ui/omnibox:omnibox_popup_shared", "//ios/chrome/browser/ui/omnibox:omnibox_popup_shared",
"//ios/chrome/browser/ui/omnibox:omnibox_util", "//ios/chrome/browser/ui/omnibox:omnibox_util",
"//ios/chrome/browser/ui/toolbar/buttons",
"//ios/chrome/browser/ui/toolbar/public:feature_flags", "//ios/chrome/browser/ui/toolbar/public:feature_flags",
"//ios/chrome/browser/ui/toolbar/public:public", "//ios/chrome/browser/ui/toolbar/public:public",
"//ios/chrome/browser/ui/util:util", "//ios/chrome/browser/ui/util:util",
......
...@@ -59,12 +59,14 @@ ...@@ -59,12 +59,14 @@
self.popupViewController = [[OmniboxPopupViewController alloc] init]; self.popupViewController = [[OmniboxPopupViewController alloc] init];
self.popupViewController.incognito = self.browserState->IsOffTheRecord(); self.popupViewController.incognito = self.browserState->IsOffTheRecord();
self.mediator.incognito = self.browserState->IsOffTheRecord(); BOOL isIncognito = self.browserState->IsOffTheRecord();
self.mediator.incognito = isIncognito;
self.mediator.consumer = self.popupViewController; self.mediator.consumer = self.popupViewController;
if (IsUIRefreshPhase1Enabled()) { if (IsUIRefreshPhase1Enabled()) {
self.mediator.presenter = [[OmniboxPopupPresenter alloc] self.mediator.presenter = [[OmniboxPopupPresenter alloc]
initWithPopupPositioner:self.positioner initWithPopupPositioner:self.positioner
popupViewController:self.popupViewController]; popupViewController:self.popupViewController
incognito:isIncognito];
} else { } else {
self.mediator.presenter = [[OmniboxPopupLegacyPresenter alloc] self.mediator.presenter = [[OmniboxPopupLegacyPresenter alloc]
initWithPopupPositioner:self.positioner initWithPopupPositioner:self.positioner
......
...@@ -11,7 +11,8 @@ ...@@ -11,7 +11,8 @@
@interface OmniboxPopupPresenter : NSObject<OmniboxPopupGenericPresenter> @interface OmniboxPopupPresenter : NSObject<OmniboxPopupGenericPresenter>
- (instancetype)initWithPopupPositioner:(id<OmniboxPopupPositioner>)positioner - (instancetype)initWithPopupPositioner:(id<OmniboxPopupPositioner>)positioner
popupViewController:(UIViewController*)viewController; popupViewController:(UIViewController*)viewController
incognito:(BOOL)incognito;
@end @end
......
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
#import "ios/chrome/browser/ui/omnibox/popup/omnibox_popup_presenter.h" #import "ios/chrome/browser/ui/omnibox/popup/omnibox_popup_presenter.h"
#import "ios/chrome/browser/ui/omnibox/popup/omnibox_popup_positioner.h" #import "ios/chrome/browser/ui/omnibox/popup/omnibox_popup_positioner.h"
#import "ios/chrome/browser/ui/toolbar/buttons/toolbar_configuration.h"
#import "ios/chrome/browser/ui/toolbar/public/features.h" #import "ios/chrome/browser/ui/toolbar/public/features.h"
#include "ios/chrome/browser/ui/ui_util.h" #include "ios/chrome/browser/ui/ui_util.h"
#import "ios/chrome/browser/ui/uikit_ui_util.h" #import "ios/chrome/browser/ui/uikit_ui_util.h"
...@@ -19,11 +20,7 @@ ...@@ -19,11 +20,7 @@
namespace { namespace {
const CGFloat kExpandAnimationDuration = 0.1; const CGFloat kExpandAnimationDuration = 0.1;
const CGFloat kCollapseAnimationDuration = 0.05; const CGFloat kCollapseAnimationDuration = 0.05;
const CGFloat kShadowHeight = 10;
const CGFloat kVerticalOffset = 6; const CGFloat kVerticalOffset = 6;
NS_INLINE CGFloat BottomPadding() {
return IsIPadIdiom() ? kShadowHeight : 0;
}
} // namespace } // namespace
@interface OmniboxPopupPresenter () @interface OmniboxPopupPresenter ()
...@@ -42,42 +39,35 @@ NS_INLINE CGFloat BottomPadding() { ...@@ -42,42 +39,35 @@ NS_INLINE CGFloat BottomPadding() {
@synthesize bottomConstraint = _bottomConstraint; @synthesize bottomConstraint = _bottomConstraint;
- (instancetype)initWithPopupPositioner:(id<OmniboxPopupPositioner>)positioner - (instancetype)initWithPopupPositioner:(id<OmniboxPopupPositioner>)positioner
popupViewController:(UIViewController*)viewController { popupViewController:(UIViewController*)viewController
incognito:(BOOL)incognito {
self = [super init]; self = [super init];
if (self) { if (self) {
_positioner = positioner; _positioner = positioner;
_viewController = viewController; _viewController = viewController;
// Set up a container for presentation. // Popup uses same colors as the toolbar, so the ToolbarConfiguration is
UIView* popupContainer = [[UIView alloc] init]; // used to get the style.
_popupContainerView = popupContainer; ToolbarConfiguration* configuration = [[ToolbarConfiguration alloc]
popupContainer.translatesAutoresizingMaskIntoConstraints = NO; initWithStyle:incognito ? INCOGNITO : NORMAL];
popupContainer.layoutMargins = UIEdgeInsetsMake(0, 0, BottomPadding(), 0);
UIBlurEffect* effect = [configuration blurEffect];
// Add the view controller's view to the container.
[popupContainer addSubview:viewController.view]; if (effect) {
UIVisualEffectView* effectView =
[[UIVisualEffectView alloc] initWithEffect:effect];
[effectView.contentView addSubview:viewController.view];
_popupContainerView = effectView;
} else {
UIView* containerView = [[UIView alloc] init];
[containerView addSubview:viewController.view];
_popupContainerView = containerView;
}
_popupContainerView.backgroundColor = [configuration blurBackgroundColor];
_popupContainerView.translatesAutoresizingMaskIntoConstraints = NO;
viewController.view.translatesAutoresizingMaskIntoConstraints = NO; viewController.view.translatesAutoresizingMaskIntoConstraints = NO;
AddSameConstraintsToSidesWithInsets( AddSameConstraints(viewController.view, _popupContainerView);
viewController.view, popupContainer,
LayoutSides::kLeading | LayoutSides::kTrailing | LayoutSides::kBottom |
LayoutSides::kTop,
ChromeDirectionalEdgeInsetsMake(0, 0, BottomPadding(), 0));
// Add a shadow.
UIImageView* shadowView = [[UIImageView alloc]
initWithImage:NativeImage(IDR_IOS_TOOLBAR_SHADOW_FULL_BLEED)];
[shadowView setUserInteractionEnabled:NO];
[shadowView setTranslatesAutoresizingMaskIntoConstraints:NO];
[popupContainer addSubview:shadowView];
// On iPhone, the shadow is on the top of the popup, as if it's cast by
// the omnibox; on iPad, the shadow is cast by the popup instead, so it's
// below the popup.
AddSameConstraintsToSides(shadowView, popupContainer,
LayoutSides::kLeading | LayoutSides::kTrailing);
AddSameConstraintsToSides(
shadowView, popupContainer,
IsIPadIdiom() ? LayoutSides::kBottom : LayoutSides::kTop);
} }
return self; return self;
} }
......
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
#import "ios/chrome/browser/ui/omnibox/popup/self_sizing_table_view.h" #import "ios/chrome/browser/ui/omnibox/popup/self_sizing_table_view.h"
#import "ios/chrome/browser/ui/omnibox/truncating_attributed_label.h" #import "ios/chrome/browser/ui/omnibox/truncating_attributed_label.h"
#include "ios/chrome/browser/ui/rtl_geometry.h" #include "ios/chrome/browser/ui/rtl_geometry.h"
#import "ios/chrome/browser/ui/toolbar/buttons/toolbar_configuration.h"
#include "ios/chrome/browser/ui/ui_util.h" #include "ios/chrome/browser/ui/ui_util.h"
#import "ios/chrome/browser/ui/uikit_ui_util.h" #import "ios/chrome/browser/ui/uikit_ui_util.h"
#include "ios/chrome/grit/ios_theme_resources.h" #include "ios/chrome/grit/ios_theme_resources.h"
...@@ -127,6 +128,7 @@ UIColor* BackgroundColorIncognito() { ...@@ -127,6 +128,7 @@ UIColor* BackgroundColorIncognito() {
self.view.backgroundColor = self.view.backgroundColor =
IsIPadIdiom() ? BackgroundColorTablet() : BackgroundColorPhone(); IsIPadIdiom() ? BackgroundColorTablet() : BackgroundColorPhone();
} }
[self.view setAutoresizingMask:(UIViewAutoresizingFlexibleWidth | [self.view setAutoresizingMask:(UIViewAutoresizingFlexibleWidth |
UIViewAutoresizingFlexibleHeight)]; UIViewAutoresizingFlexibleHeight)];
...@@ -168,7 +170,21 @@ UIColor* BackgroundColorIncognito() { ...@@ -168,7 +170,21 @@ UIColor* BackgroundColorIncognito() {
} }
- (void)traitCollectionDidChange:(UITraitCollection*)previousTraitCollection { - (void)traitCollectionDidChange:(UITraitCollection*)previousTraitCollection {
[super traitCollectionDidChange:previousTraitCollection];
[self layoutRows]; [self layoutRows];
if (!IsUIRefreshPhase1Enabled()) {
return;
}
ToolbarConfiguration* configuration = [[ToolbarConfiguration alloc]
initWithStyle:self.incognito ? INCOGNITO : NORMAL];
if (IsRegularXRegularSizeClass(self)) {
self.view.backgroundColor = configuration.backgroundColor;
} else {
self.view.backgroundColor = [UIColor clearColor];
}
} }
- (void)viewWillTransitionToSize:(CGSize)size - (void)viewWillTransitionToSize:(CGSize)size
......
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