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") {
"//ios/chrome/browser/ui/commands",
"//ios/chrome/browser/ui/omnibox:omnibox_popup_shared",
"//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:public",
"//ios/chrome/browser/ui/util:util",
......
......@@ -59,12 +59,14 @@
self.popupViewController = [[OmniboxPopupViewController alloc] init];
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;
if (IsUIRefreshPhase1Enabled()) {
self.mediator.presenter = [[OmniboxPopupPresenter alloc]
initWithPopupPositioner:self.positioner
popupViewController:self.popupViewController];
popupViewController:self.popupViewController
incognito:isIncognito];
} else {
self.mediator.presenter = [[OmniboxPopupLegacyPresenter alloc]
initWithPopupPositioner:self.positioner
......
......@@ -11,7 +11,8 @@
@interface OmniboxPopupPresenter : NSObject<OmniboxPopupGenericPresenter>
- (instancetype)initWithPopupPositioner:(id<OmniboxPopupPositioner>)positioner
popupViewController:(UIViewController*)viewController;
popupViewController:(UIViewController*)viewController
incognito:(BOOL)incognito;
@end
......
......@@ -5,6 +5,7 @@
#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/toolbar/buttons/toolbar_configuration.h"
#import "ios/chrome/browser/ui/toolbar/public/features.h"
#include "ios/chrome/browser/ui/ui_util.h"
#import "ios/chrome/browser/ui/uikit_ui_util.h"
......@@ -19,11 +20,7 @@
namespace {
const CGFloat kExpandAnimationDuration = 0.1;
const CGFloat kCollapseAnimationDuration = 0.05;
const CGFloat kShadowHeight = 10;
const CGFloat kVerticalOffset = 6;
NS_INLINE CGFloat BottomPadding() {
return IsIPadIdiom() ? kShadowHeight : 0;
}
} // namespace
@interface OmniboxPopupPresenter ()
......@@ -42,42 +39,35 @@ NS_INLINE CGFloat BottomPadding() {
@synthesize bottomConstraint = _bottomConstraint;
- (instancetype)initWithPopupPositioner:(id<OmniboxPopupPositioner>)positioner
popupViewController:(UIViewController*)viewController {
popupViewController:(UIViewController*)viewController
incognito:(BOOL)incognito {
self = [super init];
if (self) {
_positioner = positioner;
_viewController = viewController;
// Set up a container for presentation.
UIView* popupContainer = [[UIView alloc] init];
_popupContainerView = popupContainer;
popupContainer.translatesAutoresizingMaskIntoConstraints = NO;
popupContainer.layoutMargins = UIEdgeInsetsMake(0, 0, BottomPadding(), 0);
// Add the view controller's view to the container.
[popupContainer addSubview:viewController.view];
// Popup uses same colors as the toolbar, so the ToolbarConfiguration is
// used to get the style.
ToolbarConfiguration* configuration = [[ToolbarConfiguration alloc]
initWithStyle:incognito ? INCOGNITO : NORMAL];
UIBlurEffect* effect = [configuration blurEffect];
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;
AddSameConstraintsToSidesWithInsets(
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);
AddSameConstraints(viewController.view, _popupContainerView);
}
return self;
}
......
......@@ -14,6 +14,7 @@
#import "ios/chrome/browser/ui/omnibox/popup/self_sizing_table_view.h"
#import "ios/chrome/browser/ui/omnibox/truncating_attributed_label.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"
#import "ios/chrome/browser/ui/uikit_ui_util.h"
#include "ios/chrome/grit/ios_theme_resources.h"
......@@ -127,6 +128,7 @@ UIColor* BackgroundColorIncognito() {
self.view.backgroundColor =
IsIPadIdiom() ? BackgroundColorTablet() : BackgroundColorPhone();
}
[self.view setAutoresizingMask:(UIViewAutoresizingFlexibleWidth |
UIViewAutoresizingFlexibleHeight)];
......@@ -168,7 +170,21 @@ UIColor* BackgroundColorIncognito() {
}
- (void)traitCollectionDidChange:(UITraitCollection*)previousTraitCollection {
[super traitCollectionDidChange:previousTraitCollection];
[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
......
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