Commit a3c59a6c authored by Nazerke's avatar Nazerke Committed by Commit Bot

[ios] Adding the add-new-tab-"button" with no functionality.

This CL adds the add-new-tab-button, which is not tappable and which is
not moving the position according to the number of tabs.

Bug: 1134132,1128249
Change-Id: Ia72835684f8d65879c863041a503835dad2a67d3
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2536469
Commit-Queue: Nazerke Kalidolda <nazerke@google.com>
Reviewed-by: default avatarGauthier Ambard <gambard@chromium.org>
Cr-Commit-Position: refs/heads/master@{#828143}
parent 811101f7
...@@ -20,6 +20,8 @@ ...@@ -20,6 +20,8 @@
@property(nonatomic, weak) id<TabFaviconDataSource> faviconDataSource; @property(nonatomic, weak) id<TabFaviconDataSource> faviconDataSource;
@property(nonatomic, readonly, retain) UIButton* buttonNewTab;
- (instancetype)init NS_DESIGNATED_INITIALIZER; - (instancetype)init NS_DESIGNATED_INITIALIZER;
- (instancetype)initWithNibName:(NSString*)nibNameOrNil - (instancetype)initWithNibName:(NSString*)nibNameOrNil
......
...@@ -9,16 +9,25 @@ ...@@ -9,16 +9,25 @@
#import "ios/chrome/browser/ui/tab_switcher/tab_strip/tab_strip_mediator.h" #import "ios/chrome/browser/ui/tab_switcher/tab_strip/tab_strip_mediator.h"
#import "ios/chrome/browser/ui/tab_switcher/tab_strip/tab_strip_view_layout.h" #import "ios/chrome/browser/ui/tab_switcher/tab_strip/tab_strip_view_layout.h"
#import "ios/chrome/browser/ui/tab_switcher/tab_switcher_item.h" #import "ios/chrome/browser/ui/tab_switcher/tab_switcher_item.h"
#import "ios/chrome/common/ui/colors/semantic_color_names.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
namespace { namespace {
static NSString* const kReuseIdentifier = @"TabView"; static NSString* const kReuseIdentifier = @"TabView";
NSIndexPath* CreateIndexPath(NSInteger index) { NSIndexPath* CreateIndexPath(NSInteger index) {
return [NSIndexPath indexPathForItem:index inSection:0]; return [NSIndexPath indexPathForItem:index inSection:0];
} }
// The size of the new tab button.
const CGFloat kNewTabButtonWidth = 44;
// Default image insets for the new tab button.
const CGFloat kNewTabButtonLeadingImageInset = -10.0;
const CGFloat kNewTabButtonBottomImageInset = -2.0;
} // namespace } // namespace
@interface TabStripViewController () @interface TabStripViewController ()
...@@ -48,6 +57,25 @@ NSIndexPath* CreateIndexPath(NSInteger index) { ...@@ -48,6 +57,25 @@ NSIndexPath* CreateIndexPath(NSInteger index) {
self.collectionView.alwaysBounceHorizontal = YES; self.collectionView.alwaysBounceHorizontal = YES;
[self.collectionView registerClass:[TabStripCell class] [self.collectionView registerClass:[TabStripCell class]
forCellWithReuseIdentifier:kReuseIdentifier]; forCellWithReuseIdentifier:kReuseIdentifier];
_buttonNewTab = [[UIButton alloc] init];
_buttonNewTab.translatesAutoresizingMaskIntoConstraints = NO;
_buttonNewTab.imageView.contentMode = UIViewContentModeCenter;
UIImage* buttonNewTabImage = [[UIImage imageNamed:@"tabstrip_new_tab"]
imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate];
[_buttonNewTab setImage:buttonNewTabImage forState:UIControlStateNormal];
[_buttonNewTab.imageView setTintColor:[UIColor colorNamed:kGrey500Color]];
UIEdgeInsets imageInsets = UIEdgeInsetsMake(0, kNewTabButtonLeadingImageInset,
kNewTabButtonBottomImageInset, 0);
_buttonNewTab.imageEdgeInsets = imageInsets;
[self.view addSubview:_buttonNewTab];
[NSLayoutConstraint activateConstraints:@[
[_buttonNewTab.trailingAnchor
constraintEqualToAnchor:self.view.trailingAnchor],
[_buttonNewTab.topAnchor constraintEqualToAnchor:self.view.topAnchor],
[_buttonNewTab.heightAnchor constraintEqualToAnchor:self.view.heightAnchor],
[_buttonNewTab.widthAnchor constraintEqualToConstant:kNewTabButtonWidth],
]];
} }
- (NSInteger)numberOfSectionsInCollectionView: - (NSInteger)numberOfSectionsInCollectionView:
......
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