Commit 08c967e8 authored by lod's avatar lod Committed by Commit bot

Revert of [tab_grid] Hack-in border for active tab. (patchset #5 id:80001 of...

Revert of [tab_grid] Hack-in border for active tab. (patchset #5 id:80001 of https://codereview.chromium.org/2709563002/ )

Reason for revert:
Test "testLaunchAndTappingCell" in ios_showcase_egtests is broken by this CL. https://build.chromium.org/p/chromium.fyi/builders/EarlGreyiOS/builds/24682

Original issue's description:
> [tab_grid] Hack-in border for active tab.
>
> Screenshot:
> https://drive.google.com/open?id=0BwS6YyQeisH5WmpVS0tHcl9tN0E
>
> BUG=686770
>
> Review-Url: https://codereview.chromium.org/2709563002
> Cr-Commit-Position: refs/heads/master@{#452796}
> Committed: https://chromium.googlesource.com/chromium/src/+/a10c1ff3e00da36f1532264aa1866433aedaaae5

TBR=sczs@chromium.org,jif@chromium.org,marq@chromium.org,lpromero@chromium.org,edchin@chromium.org
# Skipping CQ checks because original CL landed less than 1 days ago.
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
BUG=686770

Review-Url: https://codereview.chromium.org/2714763003
Cr-Commit-Position: refs/heads/master@{#452813}
parent a7d8979e
...@@ -94,10 +94,6 @@ ...@@ -94,10 +94,6 @@
return urlText; return urlText;
} }
- (NSInteger)indexOfActiveTab {
return static_cast<NSInteger>(_activeWebStateIndex);
}
#pragma mark - TabCommands #pragma mark - TabCommands
- (void)showTabAtIndexPath:(NSIndexPath*)indexPath { - (void)showTabAtIndexPath:(NSIndexPath*)indexPath {
......
...@@ -11,13 +11,12 @@ ...@@ -11,13 +11,12 @@
#import <UIKit/UIKit.h> #import <UIKit/UIKit.h>
#import "ios/chrome/browser/ui/tab_switcher/tab_switcher_panel_cell.h" // Placeholder cell implementation for use in the tab grid.
// A square cell with rounded corners and a label placed in the center.
@interface TabGridTabCell : UICollectionViewCell
// Cell represents a tab for use in the tab grid. It has a title, favicon, // The label in the center of the tab cell.
// screenshot image, and close button. Cell selection is represented by a border @property(nonatomic, readonly) UILabel* label;
// highlight in the tintColor.
// PLACEHOLDER: Create custom implemementation rather than subclassing.
@interface TabGridTabCell : TabSwitcherLocalSessionCell
@end @end
......
...@@ -13,22 +13,38 @@ ...@@ -13,22 +13,38 @@
#endif #endif
namespace { namespace {
const CGFloat kSelectedBorderCornerRadius = 8.0f; const CGFloat kCornerRadius = 4.0;
const CGFloat kSelectedBorderWidth = 4.0f; const CGFloat kSelectedBorderWidth = 2.0;
} }
@implementation TabGridTabCell @implementation TabGridTabCell
@synthesize label = _label;
- (instancetype)initWithFrame:(CGRect)frame { - (instancetype)initWithFrame:(CGRect)frame {
if ((self = [super initWithFrame:frame])) { if ((self = [super initWithFrame:frame])) {
self.selectedBackgroundView = [[UIView alloc] init]; self.contentView.layer.cornerRadius = kCornerRadius;
self.selectedBackgroundView.backgroundColor = [UIColor blackColor]; self.selectedBackgroundView.layer.cornerRadius = kCornerRadius;
self.selectedBackgroundView.layer.cornerRadius =
kSelectedBorderCornerRadius;
self.selectedBackgroundView.layer.borderWidth = kSelectedBorderWidth; self.selectedBackgroundView.layer.borderWidth = kSelectedBorderWidth;
self.selectedBackgroundView.layer.borderColor = self.tintColor.CGColor; self.selectedBackgroundView.layer.borderColor = [UIColor blueColor].CGColor;
self.selectedBackgroundView.transform = CGAffineTransformScale( self.selectedBackgroundView.transform = CGAffineTransformScale(
self.selectedBackgroundView.transform, 1.08, 1.08); self.selectedBackgroundView.transform, 1.05, 1.05);
_label = [[UILabel alloc] initWithFrame:CGRectZero];
_label.translatesAutoresizingMaskIntoConstraints = NO;
_label.numberOfLines = 1;
_label.textAlignment = NSTextAlignmentCenter;
[self.contentView addSubview:_label];
[NSLayoutConstraint activateConstraints:@[
[_label.centerYAnchor
constraintEqualToAnchor:self.contentView.centerYAnchor],
[_label.leadingAnchor
constraintEqualToAnchor:self.contentView.layoutMarginsGuide
.leadingAnchor],
[_label.trailingAnchor
constraintEqualToAnchor:self.contentView.layoutMarginsGuide
.trailingAnchor],
]];
} }
return self; return self;
} }
......
...@@ -29,9 +29,6 @@ ...@@ -29,9 +29,6 @@
// Title for the tab at |index| in the grid. // Title for the tab at |index| in the grid.
- (NSString*)titleAtIndex:(NSInteger)index; - (NSString*)titleAtIndex:(NSInteger)index;
// Index for the active tab.
- (NSInteger)indexOfActiveTab;
@end @end
// Controller for a scrolling view displaying square cells that represent // Controller for a scrolling view displaying square cells that represent
......
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
#import "ios/clean/chrome/browser/ui/tab_grid/tab_grid_view_controller.h" #import "ios/clean/chrome/browser/ui/tab_grid/tab_grid_view_controller.h"
#include "base/mac/foundation_util.h" #include "base/mac/foundation_util.h"
#import "ios/chrome/browser/ui/tab_switcher/tab_switcher_panel_cell.h"
#import "ios/chrome/browser/ui/tab_switcher/tab_switcher_panel_collection_view_layout.h" #import "ios/chrome/browser/ui/tab_switcher/tab_switcher_panel_collection_view_layout.h"
#import "ios/chrome/browser/ui/tab_switcher/tab_switcher_panel_overlay_view.h" #import "ios/chrome/browser/ui/tab_switcher/tab_switcher_panel_overlay_view.h"
#import "ios/clean/chrome/browser/ui/actions/settings_actions.h" #import "ios/clean/chrome/browser/ui/actions/settings_actions.h"
...@@ -18,7 +19,6 @@ ...@@ -18,7 +19,6 @@
#import "ios/clean/chrome/browser/ui/commands/tab_grid_commands.h" #import "ios/clean/chrome/browser/ui/commands/tab_grid_commands.h"
#import "ios/clean/chrome/browser/ui/tab_grid/mdc_floating_button+cr_tab_grid.h" #import "ios/clean/chrome/browser/ui/tab_grid/mdc_floating_button+cr_tab_grid.h"
#import "ios/clean/chrome/browser/ui/tab_grid/tab_grid_collection_view_layout.h" #import "ios/clean/chrome/browser/ui/tab_grid/tab_grid_collection_view_layout.h"
#import "ios/clean/chrome/browser/ui/tab_grid/tab_grid_tab_cell.h"
#import "ios/clean/chrome/browser/ui/tab_grid/ui_stack_view+cr_tab_grid.h" #import "ios/clean/chrome/browser/ui/tab_grid/ui_stack_view+cr_tab_grid.h"
#if !defined(__has_feature) || !__has_feature(objc_arc) #if !defined(__has_feature) || !__has_feature(objc_arc)
...@@ -73,8 +73,8 @@ const CGFloat kToolbarHeight = 64.0f; ...@@ -73,8 +73,8 @@ const CGFloat kToolbarHeight = 64.0f;
self.grid = grid; self.grid = grid;
self.grid.dataSource = self; self.grid.dataSource = self;
self.grid.delegate = self; self.grid.delegate = self;
[self.grid registerClass:[TabGridTabCell class] [self.grid registerClass:[TabSwitcherLocalSessionCell class]
forCellWithReuseIdentifier:[TabGridTabCell identifier]]; forCellWithReuseIdentifier:[TabSwitcherLocalSessionCell identifier]];
[NSLayoutConstraint activateConstraints:@[ [NSLayoutConstraint activateConstraints:@[
[self.grid.topAnchor constraintEqualToAnchor:toolbar.bottomAnchor], [self.grid.topAnchor constraintEqualToAnchor:toolbar.bottomAnchor],
...@@ -119,27 +119,19 @@ const CGFloat kToolbarHeight = 64.0f; ...@@ -119,27 +119,19 @@ const CGFloat kToolbarHeight = 64.0f;
- (UICollectionViewCell*)collectionView:(UICollectionView*)collectionView - (UICollectionViewCell*)collectionView:(UICollectionView*)collectionView
cellForItemAtIndexPath:(nonnull NSIndexPath*)indexPath { cellForItemAtIndexPath:(nonnull NSIndexPath*)indexPath {
TabGridTabCell* cell = TabSwitcherLocalSessionCell* cell =
base::mac::ObjCCastStrict<TabGridTabCell>([collectionView base::mac::ObjCCastStrict<TabSwitcherLocalSessionCell>([collectionView
dequeueReusableCellWithReuseIdentifier:[TabGridTabCell identifier] dequeueReusableCellWithReuseIdentifier:
[TabSwitcherLocalSessionCell identifier]
forIndexPath:indexPath]); forIndexPath:indexPath]);
cell.delegate = self; cell.delegate = self;
[cell setSessionType:TabSwitcherSessionType::REGULAR_SESSION]; [cell setSessionType:TabSwitcherSessionType::REGULAR_SESSION];
[cell setAppearanceForTabTitle:[self.dataSource titleAtIndex:indexPath.item] [cell setAppearanceForTabTitle:[self.dataSource titleAtIndex:indexPath.item]
favicon:nil favicon:nil
cellSize:CGSizeZero]; cellSize:CGSizeZero];
[cell setSelected:(indexPath.item == [self.dataSource indexOfActiveTab])];
return cell; return cell;
} }
#pragma mark - UICollectionViewDelegate methods
- (BOOL)collectionView:(UICollectionView*)collectionView
shouldSelectItemAtIndexPath:(NSIndexPath*)indexPath {
// Prevent user selection of items.
return NO;
}
#pragma mark - ZoomTransitionDelegate methods #pragma mark - ZoomTransitionDelegate methods
- (CGRect)rectForZoomWithKey:(NSObject*)key inView:(UIView*)view { - (CGRect)rectForZoomWithKey:(NSObject*)key inView:(UIView*)view {
...@@ -168,13 +160,6 @@ const CGFloat kToolbarHeight = 64.0f; ...@@ -168,13 +160,6 @@ const CGFloat kToolbarHeight = 64.0f;
NSInteger index = [self.grid numberOfItemsInSection:0]; NSInteger index = [self.grid numberOfItemsInSection:0];
NSIndexPath* indexPath = [NSIndexPath indexPathForItem:index inSection:0]; NSIndexPath* indexPath = [NSIndexPath indexPathForItem:index inSection:0];
auto updateBlock = ^{ auto updateBlock = ^{
// Unselect current selected item.
NSInteger selectedIndex = [self.dataSource indexOfActiveTab];
NSIndexPath* selectedIndexPath =
[NSIndexPath indexPathForItem:selectedIndex inSection:0];
[self.grid reloadItemsAtIndexPaths:@[ selectedIndexPath ]];
// Create and show new tab.
[self.tabCommandHandler createNewTabAtIndexPath:indexPath]; [self.tabCommandHandler createNewTabAtIndexPath:indexPath];
[self.tabCommandHandler showTabAtIndexPath:indexPath]; [self.tabCommandHandler showTabAtIndexPath:indexPath];
[self.grid insertItemsAtIndexPaths:@[ indexPath ]]; [self.grid insertItemsAtIndexPaths:@[ indexPath ]];
...@@ -190,14 +175,7 @@ const CGFloat kToolbarHeight = 64.0f; ...@@ -190,14 +175,7 @@ const CGFloat kToolbarHeight = 64.0f;
} }
- (void)cellPressed:(UICollectionViewCell*)cell { - (void)cellPressed:(UICollectionViewCell*)cell {
NSInteger selectedIndex = [self.dataSource indexOfActiveTab]; [self.tabCommandHandler showTabAtIndexPath:[self.grid indexPathForCell:cell]];
NSIndexPath* selectedIndexPath =
[NSIndexPath indexPathForItem:selectedIndex inSection:0];
NSIndexPath* newSelectedIndexPath = [self.grid indexPathForCell:cell];
[self.tabCommandHandler showTabAtIndexPath:newSelectedIndexPath];
[self.grid
reloadItemsAtIndexPaths:@[ selectedIndexPath, newSelectedIndexPath ]];
} }
- (void)deleteButtonPressedForCell:(UICollectionViewCell*)cell { - (void)deleteButtonPressedForCell:(UICollectionViewCell*)cell {
......
...@@ -48,8 +48,4 @@ ...@@ -48,8 +48,4 @@
return [NSString stringWithFormat:@"Tab %" PRIdNS, index]; return [NSString stringWithFormat:@"Tab %" PRIdNS, index];
} }
- (NSInteger)indexOfActiveTab {
return 0;
}
@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