Commit 86496528 authored by Gauthier Ambard's avatar Gauthier Ambard Committed by Commit Bot

Add blur effect to the popup menu

This CL adds a blur effect for the popup of the popup menu.

Bug: 821765
Cq-Include-Trybots: master.tryserver.chromium.mac:ios-simulator-cronet;master.tryserver.chromium.mac:ios-simulator-full-configs
Change-Id: Ie562e101ef8d43f8721d92aa070260ccdb957a72
Reviewed-on: https://chromium-review.googlesource.com/980312Reviewed-by: default avatarOlivier Robin <olivierrobin@chromium.org>
Commit-Queue: Gauthier Ambard <gambard@chromium.org>
Cr-Commit-Position: refs/heads/master@{#546052}
parent bae41164
......@@ -53,6 +53,7 @@ source_set("popup_menu_ui") {
"//ios/chrome/browser/ui/popup_menu/cells",
"//ios/chrome/browser/ui/presenters",
"//ios/chrome/browser/ui/table_view",
"//ios/chrome/browser/ui/table_view:styler",
"//ios/chrome/browser/ui/util",
"//ios/chrome/common",
"//ui/base",
......
......@@ -10,6 +10,7 @@
#import "ios/chrome/browser/ui/commands/browser_commands.h"
#import "ios/chrome/browser/ui/commands/open_new_tab_command.h"
#import "ios/chrome/browser/ui/popup_menu/cells/popup_menu_item.h"
#import "ios/chrome/browser/ui/table_view/chrome_table_view_styler.h"
#if !defined(__has_feature) || !__has_feature(objc_arc)
#error "This file requires ARC support."
......@@ -26,6 +27,7 @@ using base::UserMetricsAction;
#pragma mark - UIViewController
- (void)viewDidLoad {
self.styler.tableViewBackgroundColor = nil;
[super viewDidLoad];
self.tableView.rowHeight = UITableViewAutomaticDimension;
self.tableView.sectionHeaderHeight = 0;
......
......@@ -16,6 +16,8 @@ const CGFloat kCornerRadius = 15;
const CGFloat kShadowRadius = 10;
const CGFloat kShadowOpacity = 0.3;
const CGFloat kContentMargin = 8;
const CGFloat kBlurBackgroundGreyScale = 0.98;
const CGFloat kBlurBackgroundAlpha = 0.75;
} // namespace
@interface PopupMenuViewController ()<UIGestureRecognizerDelegate>
......@@ -56,14 +58,33 @@ const CGFloat kContentMargin = 8;
// Sets the content container view up.
- (void)setUpContentContainer {
_contentContainer = [[UIView alloc] init];
_contentContainer.backgroundColor = [UIColor whiteColor];
if (UIAccessibilityIsReduceTransparencyEnabled()) {
_contentContainer.backgroundColor =
[UIColor colorWithWhite:kBlurBackgroundGreyScale alpha:1];
} else {
_contentContainer.backgroundColor = [UIColor clearColor];
UIBlurEffect* blurEffect =
[UIBlurEffect effectWithStyle:UIBlurEffectStyleLight];
UIVisualEffectView* blur =
[[UIVisualEffectView alloc] initWithEffect:blurEffect];
blur.contentView.backgroundColor =
[UIColor colorWithWhite:kBlurBackgroundGreyScale
alpha:kBlurBackgroundAlpha];
[_contentContainer addSubview:blur];
blur.translatesAutoresizingMaskIntoConstraints = NO;
blur.layer.cornerRadius = kCornerRadius;
blur.layer.masksToBounds = YES;
AddSameConstraints(blur, _contentContainer);
}
_contentContainer.layer.cornerRadius = kCornerRadius;
_contentContainer.layer.shadowRadius = kShadowRadius;
_contentContainer.layer.shadowOpacity = kShadowOpacity;
_contentContainer.translatesAutoresizingMaskIntoConstraints = NO;
_contentContainer.layoutMargins = UIEdgeInsetsMake(
kContentMargin, kContentMargin, kContentMargin, kContentMargin);
// TODO(crbug.com/821765): Add blur effect and update the shadow.
// TODO(crbug.com/821765): Add update the shadow.
[self.view addSubview:_contentContainer];
}
......
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