Commit 952759a6 authored by Mike Pinkerton's avatar Mike Pinkerton Committed by Commit Bot

Add iPadOS pointer support to NTP tiles.

Add pointer support to the mostVisited and shortcut buttons
on the NTP.

BUG=1139054

Change-Id: I9486aca3c27871312df0051149f8ed1e6f1dea22
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2476957
Auto-Submit: Mike Pinkerton <pinkerton@chromium.org>
Reviewed-by: default avatarGauthier Ambard <gambard@chromium.org>
Commit-Queue: Mike Pinkerton <pinkerton@chromium.org>
Cr-Commit-Position: refs/heads/master@{#820328}
parent 34522fc0
...@@ -22,6 +22,7 @@ source_set("ntp_tile_views") { ...@@ -22,6 +22,7 @@ source_set("ntp_tile_views") {
"resources:ntp_readinglist_icon", "resources:ntp_readinglist_icon",
"resources:ntp_recent_icon", "resources:ntp_recent_icon",
"//base", "//base",
"//ios/chrome/browser/ui:feature_flags",
"//ios/chrome/browser/ui/util", "//ios/chrome/browser/ui/util",
"//ios/chrome/common/ui/colors", "//ios/chrome/common/ui/colors",
"//ios/chrome/common/ui/favicon", "//ios/chrome/common/ui/favicon",
......
...@@ -10,7 +10,11 @@ ...@@ -10,7 +10,11 @@
// A generic NTP tile view. Provides a title label and an image container on a // A generic NTP tile view. Provides a title label and an image container on a
// squircle-shaped background. Concrete subclasses of this are used to display // squircle-shaped background. Concrete subclasses of this are used to display
// most visited tiles and shortcut tiles on NTP and other places. // most visited tiles and shortcut tiles on NTP and other places.
#ifdef __IPHONE_13_4
@interface NTPTileView : UIView <UIPointerInteractionDelegate>
#else
@interface NTPTileView : UIView @interface NTPTileView : UIView
#endif
// Container for the image view. Used in subclasses. // Container for the image view. Used in subclasses.
@property(nonatomic, strong, readonly, nonnull) UIView* imageContainerView; @property(nonatomic, strong, readonly, nonnull) UIView* imageContainerView;
......
...@@ -4,6 +4,8 @@ ...@@ -4,6 +4,8 @@
#import "ios/chrome/browser/ui/ntp_tile_views/ntp_tile_view.h" #import "ios/chrome/browser/ui/ntp_tile_views/ntp_tile_view.h"
#include "base/feature_list.h"
#include "ios/chrome/browser/ui/ui_feature_flags.h"
#import "ios/chrome/browser/ui/util/dynamic_type_util.h" #import "ios/chrome/browser/ui/util/dynamic_type_util.h"
#import "ios/chrome/common/ui/colors/UIColor+cr_semantic_colors.h" #import "ios/chrome/common/ui/colors/UIColor+cr_semantic_colors.h"
#import "ios/chrome/common/ui/colors/semantic_color_names.h" #import "ios/chrome/common/ui/colors/semantic_color_names.h"
...@@ -68,6 +70,15 @@ const CGFloat kPreferredMaxWidth = 73; ...@@ -68,6 +70,15 @@ const CGFloat kPreferredMaxWidth = 73;
@{ @"space" : @(kSpaceIconTitle) }); @{ @"space" : @(kSpaceIconTitle) });
_imageBackgroundView = backgroundView; _imageBackgroundView = backgroundView;
#ifdef __IPHONE_13_4
if (@available(iOS 13.4, *)) {
if (base::FeatureList::IsEnabled(kPointerSupport)) {
[self addInteraction:[[UIPointerInteraction alloc]
initWithDelegate:self]];
}
}
#endif
} }
return self; return self;
} }
...@@ -90,4 +101,30 @@ const CGFloat kPreferredMaxWidth = 73; ...@@ -90,4 +101,30 @@ const CGFloat kPreferredMaxWidth = 73;
} }
} }
#pragma mark - UIPointerInteractionDelegate
#ifdef __IPHONE_13_4
- (UIPointerRegion*)pointerInteraction:(UIPointerInteraction*)interaction
regionForRequest:(UIPointerRegionRequest*)request
defaultRegion:(UIPointerRegion*)defaultRegion
API_AVAILABLE(ios(13.4)) {
return defaultRegion;
}
- (UIPointerStyle*)pointerInteraction:(UIPointerInteraction*)interaction
styleForRegion:(UIPointerRegion*)region
API_AVAILABLE(ios(13.4)) {
UITargetedPreview* preview =
[[UITargetedPreview alloc] initWithView:_imageContainerView];
UIPointerHighlightEffect* effect =
[UIPointerHighlightEffect effectWithPreview:preview];
UIPointerShape* shape =
[UIPointerShape shapeWithRoundedRect:_imageContainerView.frame
cornerRadius:8.0];
return [UIPointerStyle styleWithEffect:effect shape:shape];
}
#endif
@end @end
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