Commit 4715999c authored by Robbie Gibson's avatar Robbie Gibson Committed by Commit Bot

[iOS] Fix Thumb Strip gradients and transforms in RTL

The TabStrip uses a CGAffineTransform to implement RTL. Because of this,
when we display the snapshot for the thumb strip transition, the
CGAffineTransform for the transition also needs to take the RTL behavior
into account.

Bug: 1094335
Change-Id: I736a2b2b74781407f8b685bfb21bef81ab8c0ef1
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2536444
Commit-Queue: Robbie Gibson <rkgibson@google.com>
Reviewed-by: default avataredchin <edchin@chromium.org>
Reviewed-by: default avatarGauthier Ambard <gambard@chromium.org>
Cr-Commit-Position: refs/heads/master@{#827757}
parent c84e17c5
......@@ -2861,13 +2861,17 @@ NSString* const kBrowserViewControllerSnackbarCategory =
// parent is hidden but the view itself is not, the snapshot will not be a
// blank view.
self.tabStripSnapshot = [self.tabStripView screenshotForAnimation];
self.tabStripSnapshot.translatesAutoresizingMaskIntoConstraints = NO;
self.tabStripSnapshot.transform =
currentViewRevealState == ViewRevealState::Hidden
? CGAffineTransformIdentity
: CGAffineTransformMakeTranslation(
0, self.tabStripView.frame.size.height);
? [self.tabStripView adjustTransformForRTL:CGAffineTransformIdentity]
: [self.tabStripView
adjustTransformForRTL:CGAffineTransformMakeTranslation(
0,
self.tabStripView.frame.size.height)];
self.tabStripView.hidden = YES;
[self.contentArea addSubview:self.tabStripSnapshot];
AddSameConstraints(self.tabStripSnapshot, self.tabStripView);
// Remove the fake status bar to allow the thumb strip animations to appear.
[_fakeStatusBarView removeFromSuperview];
......@@ -2902,23 +2906,26 @@ NSString* const kBrowserViewControllerSnackbarCategory =
case ViewRevealState::Hidden:
self.view.superview.transform = CGAffineTransformIdentity;
self.view.transform = CGAffineTransformIdentity;
self.tabStripSnapshot.transform = CGAffineTransformIdentity;
self.tabStripSnapshot.transform =
[self.tabStripView adjustTransformForRTL:CGAffineTransformIdentity];
break;
case ViewRevealState::Peeked:
self.view.superview.transform = CGAffineTransformMakeTranslation(
0, self.thumbStripPanHandler.peekedHeight);
self.view.transform = CGAffineTransformMakeTranslation(
0, -self.tabStripView.frame.size.height - self.headerOffset);
self.tabStripSnapshot.transform = CGAffineTransformMakeTranslation(
0, self.tabStripView.frame.size.height);
self.tabStripSnapshot.transform = [self.tabStripView
adjustTransformForRTL:CGAffineTransformMakeTranslation(
0, self.tabStripView.frame.size.height)];
break;
case ViewRevealState::Revealed:
self.view.superview.transform = CGAffineTransformMakeTranslation(
0, self.thumbStripPanHandler.revealedHeight);
self.view.transform = CGAffineTransformMakeTranslation(
0, -self.tabStripView.frame.size.height - self.headerOffset);
self.tabStripSnapshot.transform = CGAffineTransformMakeTranslation(
0, self.tabStripView.frame.size.height);
self.tabStripSnapshot.transform = [self.tabStripView
adjustTransformForRTL:CGAffineTransformMakeTranslation(
0, self.tabStripView.frame.size.height)];
break;
}
}
......
......@@ -27,6 +27,7 @@
#import "ios/chrome/browser/ui/tab_switcher/tab_grid/transitions/grid_transition_layout.h"
#import "ios/chrome/browser/ui/thumb_strip/thumb_strip_feature.h"
#include "ios/chrome/browser/ui/ui_feature_flags.h"
#include "ios/chrome/browser/ui/util/rtl_geometry.h"
#import "ios/chrome/browser/ui/util/uikit_ui_util.h"
#import "ios/chrome/common/ui/util/constraints_ui_util.h"
......@@ -817,9 +818,13 @@ NSIndexPath* CreateIndexPath(NSInteger index) {
- (CGFloat)offsetPastEndOfScrollView {
CGFloat offset;
if (self.currentLayout == self.horizontalLayout) {
offset = self.collectionView.contentOffset.x +
self.collectionView.frame.size.width -
self.collectionView.contentSize.width;
if (UseRTLLayout()) {
offset = -self.collectionView.contentOffset.x;
} else {
offset = self.collectionView.contentOffset.x +
self.collectionView.frame.size.width -
self.collectionView.contentSize.width;
}
} else {
DCHECK_EQ(self.gridLayout, self.currentLayout);
offset = self.collectionView.contentOffset.y +
......
......@@ -32,6 +32,7 @@
#import "ios/chrome/browser/ui/thumb_strip/thumb_strip_feature.h"
#include "ios/chrome/browser/ui/ui_feature_flags.h"
#import "ios/chrome/browser/ui/util/rtl_geometry.h"
#include "ios/chrome/browser/ui/util/rtl_geometry.h"
#import "ios/chrome/browser/ui/util/uikit_ui_util.h"
#import "ios/chrome/common/ui/colors/semantic_color_names.h"
#import "ios/chrome/common/ui/util/constraints_ui_util.h"
......@@ -520,8 +521,11 @@ NSUInteger GetPageIndexFromPage(TabGridPage page) {
// Hides the thumb strip's plus sign button by translating it away and making it
// transparent.
- (void)hidePlusSignButton {
self.plusSignButton.transform = CGAffineTransformMakeTranslation(
kThumbStripPlusSignButtonSlideOutDistance, 0);
CGFloat xDistance = UseRTLLayout()
? -kThumbStripPlusSignButtonSlideOutDistance
: kThumbStripPlusSignButtonSlideOutDistance;
self.plusSignButton.transform =
CGAffineTransformMakeTranslation(xDistance, 0);
self.plusSignButton.alpha = 0;
}
......
......@@ -5,6 +5,7 @@
#import "ios/chrome/browser/ui/tab_switcher/tab_grid/thumb_strip_plus_sign_button.h"
#import "ios/chrome/browser/ui/tab_switcher/tab_grid/grid/grid_constants.h"
#include "ios/chrome/browser/ui/util/rtl_geometry.h"
#if !defined(__has_feature) || !__has_feature(objc_arc)
#error "This file requires ARC support."
......@@ -56,6 +57,9 @@
gradient.startPoint = CGPointMake(0.0, 0.5);
gradient.endPoint = CGPointMake(1.0, 0.5);
gradient.locations = @[ @0, @0.5 ];
if (UseRTLLayout()) {
gradient.affineTransform = CGAffineTransformMakeScale(-1, 1);
}
[self.layer insertSublayer:gradient atIndex:0];
}
......
......@@ -5,6 +5,7 @@
#import "ios/chrome/browser/ui/tabs/tab_strip_container_view.h"
#import "ios/chrome/browser/ui/tabs/tab_strip_view.h"
#include "ios/chrome/browser/ui/util/rtl_geometry.h"
#if !defined(__has_feature) || !__has_feature(objc_arc)
#error "This file requires ARC support."
......@@ -15,8 +16,16 @@
- (UIView*)screenshotForAnimation {
UIView* tabStripSnapshot =
[self.tabStripView snapshotViewAfterScreenUpdates:YES];
tabStripSnapshot.frame = self.frame;
tabStripSnapshot.transform =
[self adjustTransformForRTL:tabStripSnapshot.transform];
return tabStripSnapshot;
}
- (CGAffineTransform)adjustTransformForRTL:(CGAffineTransform)transform {
if (!UseRTLLayout()) {
return transform;
}
return CGAffineTransformConcat(transform, CGAffineTransformMakeScale(-1, 1));
}
@end
......@@ -11,6 +11,9 @@
// Returns a snapshot of the Tab Strip view.
- (UIView*)screenshotForAnimation;
// Adjusts |transform| to take the current RTL mode into account.
- (CGAffineTransform)adjustTransformForRTL:(CGAffineTransform)transform;
@end
#endif // IOS_CHROME_BROWSER_UI_TABS_TAB_STRIP_CONTAINING_H_
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