Commit 59802d40 authored by Mark Cogan's avatar Mark Cogan Committed by Commit Bot

[iOS] Round corners on reduced motion tab transition.

This CL adds corner roundedness matching for the reduced motion tab
grid transition animation (which is also used when exiting the tab grid
from a tab that isn't visible).

The free function that exposes the device's (approximate) corner radius
is facored into a ui_utils method.

Bug: 870659
Cq-Include-Trybots: luci.chromium.try:ios-simulator-full-configs;master.tryserver.chromium.mac:ios-simulator-cronet
Change-Id: I5abdd190140f2a4a4fd3b0b18f0d300a6d0dd5ea
Reviewed-on: https://chromium-review.googlesource.com/1177606Reviewed-by: default avataredchin <edchin@chromium.org>
Commit-Queue: Mark Cogan <marq@chromium.org>
Cr-Commit-Position: refs/heads/master@{#584014}
parent fcc23e2e
...@@ -19,9 +19,6 @@ namespace { ...@@ -19,9 +19,6 @@ namespace {
// Scale factor for inactive items when a tab is expanded. // Scale factor for inactive items when a tab is expanded.
const CGFloat kInactiveItemScale = 0.95; const CGFloat kInactiveItemScale = 0.95;
CGFloat DeviceCornerRadius() {
return IsIPhoneX() ? 40.0 : 0.0;
}
} }
@interface GridTransitionAnimation () @interface GridTransitionAnimation ()
......
...@@ -4,6 +4,8 @@ ...@@ -4,6 +4,8 @@
#import "ios/chrome/browser/ui/tab_grid/transitions/reduced_motion_animator.h" #import "ios/chrome/browser/ui/tab_grid/transitions/reduced_motion_animator.h"
#include "ios/chrome/browser/ui/ui_util.h"
#if !defined(__has_feature) || !__has_feature(objc_arc) #if !defined(__has_feature) || !__has_feature(objc_arc)
#error "This file requires ARC support." #error "This file requires ARC support."
#endif #endif
...@@ -60,7 +62,7 @@ ...@@ -60,7 +62,7 @@
finalAnimatingViewTransform = animatingView.transform; finalAnimatingViewTransform = animatingView.transform;
animatingView.transform = animatingView.transform =
CGAffineTransformScale(finalAnimatingViewTransform, 0.75, 0.75); CGAffineTransformScale(finalAnimatingViewTransform, 0.75, 0.75);
finalAnimatingCornerRadius = 0; finalAnimatingCornerRadius = DeviceCornerRadius();
animatingView.layer.cornerRadius = 26.0; animatingView.layer.cornerRadius = 26.0;
} else { } else {
// If dismissing, the disappearing view (the tab view) animates out // If dismissing, the disappearing view (the tab view) animates out
...@@ -69,6 +71,7 @@ ...@@ -69,6 +71,7 @@
finalAnimatingViewAlpha = 0; finalAnimatingViewAlpha = 0;
finalAnimatingViewTransform = finalAnimatingViewTransform =
CGAffineTransformScale(animatingView.transform, 0.75, 0.75); CGAffineTransformScale(animatingView.transform, 0.75, 0.75);
animatingView.layer.cornerRadius = DeviceCornerRadius();
finalAnimatingCornerRadius = 26.0; finalAnimatingCornerRadius = 26.0;
} }
......
...@@ -54,6 +54,9 @@ bool IsUIRefreshPhase1Enabled(); ...@@ -54,6 +54,9 @@ bool IsUIRefreshPhase1Enabled();
// Returns the height of the status bar, accounting for orientation. // Returns the height of the status bar, accounting for orientation.
CGFloat StatusBarHeight(); CGFloat StatusBarHeight();
// Returns the approximate corner radius of the current device.
CGFloat DeviceCornerRadius();
// Returns the closest pixel-aligned value less than |value|, taking the scale // Returns the closest pixel-aligned value less than |value|, taking the scale
// factor into account. At a scale of 1, equivalent to floor(). // factor into account. At a scale of 1, equivalent to floor().
CGFloat AlignValueToPixel(CGFloat value); CGFloat AlignValueToPixel(CGFloat value);
......
...@@ -99,6 +99,10 @@ CGFloat StatusBarHeight() { ...@@ -99,6 +99,10 @@ CGFloat StatusBarHeight() {
return isCompactHeight ? 0 : 20; return isCompactHeight ? 0 : 20;
} }
CGFloat DeviceCornerRadius() {
return IsIPhoneX() ? 40.0 : 0.0;
}
CGFloat AlignValueToPixel(CGFloat value) { CGFloat AlignValueToPixel(CGFloat value) {
static CGFloat scale = [[UIScreen mainScreen] scale]; static CGFloat scale = [[UIScreen mainScreen] scale];
return floor(value * scale) / scale; return floor(value * scale) / scale;
......
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