Commit a504f941 authored by edchin's avatar edchin Committed by Commit Bot

[ios] Clean up tab grid toolbars

Removes dead and unnecessary code.

Bug: 818198
Cq-Include-Trybots: master.tryserver.chromium.mac:ios-simulator-cronet;master.tryserver.chromium.mac:ios-simulator-full-configs
Change-Id: I468a5018ec794b4c921f569362d37f1da3d1d6a5
Reviewed-on: https://chromium-review.googlesource.com/963319Reviewed-by: default avatarSergio Collazos <sczs@chromium.org>
Reviewed-by: default avataredchin <edchin@chromium.org>
Commit-Queue: edchin <edchin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#543253}
parent 492b6c2f
...@@ -7,25 +7,15 @@ ...@@ -7,25 +7,15 @@
#import <UIKit/UIKit.h> #import <UIKit/UIKit.h>
// Pre-set color configurations. // Toolbar view with three buttons. The contents have a fixed height and are
typedef NS_ENUM(NSUInteger, TabGridBottomToolbarTheme) { // pinned to the top of this view, therefore it is intended to be used as a
TabGridBottomToolbarThemeInvalid = 0, // bottom toolbar.
TabGridBottomToolbarThemeWhiteRoundButton,
TabGridBottomToolbarThemeBlueRoundButton,
TabGridBottomToolbarThemePartiallyDisabled,
};
// Toolbar view with two text buttons and a center round button. The contents
// have a fixed height and are pinned to the top of this view, therefore it is
// intended to be used as a bottom toolbar.
@interface TabGridBottomToolbar : UIView @interface TabGridBottomToolbar : UIView
// The color configuration of the toolbar.
@property(nonatomic, assign) TabGridBottomToolbarTheme theme;
// These components are publicly available to allow the user to set their // These components are publicly available to allow the user to set their
// contents, visibility and actions. // contents, visibility and actions.
@property(nonatomic, weak, readonly) UIButton* leadingButton; @property(nonatomic, weak, readonly) UIButton* leadingButton;
@property(nonatomic, weak, readonly) UIButton* trailingButton; @property(nonatomic, weak, readonly) UIButton* trailingButton;
@property(nonatomic, weak, readonly) UIButton* roundButton; @property(nonatomic, weak, readonly) UIButton* centerButton;
- (instancetype)init NS_DESIGNATED_INITIALIZER; - (instancetype)init NS_DESIGNATED_INITIALIZER;
- (instancetype)initWithFrame:(CGRect)frame NS_UNAVAILABLE; - (instancetype)initWithFrame:(CGRect)frame NS_UNAVAILABLE;
......
...@@ -13,15 +13,12 @@ ...@@ -13,15 +13,12 @@
namespace { namespace {
// Height of the toolbar. // Height of the toolbar.
const CGFloat kToolbarHeight = 44.0f; const CGFloat kToolbarHeight = 44.0f;
// Diameter of the center round button.
const CGFloat kRoundButtonDiameter = 44.0f;
} // namespace } // namespace
@implementation TabGridBottomToolbar @implementation TabGridBottomToolbar
@synthesize theme = _theme;
@synthesize leadingButton = _leadingButton; @synthesize leadingButton = _leadingButton;
@synthesize trailingButton = _trailingButton; @synthesize trailingButton = _trailingButton;
@synthesize roundButton = _roundButton; @synthesize centerButton = _centerButton;
- (instancetype)init { - (instancetype)init {
if (self = [super initWithFrame:CGRectZero]) { if (self = [super initWithFrame:CGRectZero]) {
...@@ -34,25 +31,17 @@ const CGFloat kRoundButtonDiameter = 44.0f; ...@@ -34,25 +31,17 @@ const CGFloat kRoundButtonDiameter = 44.0f;
UIButton* leadingButton = [UIButton buttonWithType:UIButtonTypeSystem]; UIButton* leadingButton = [UIButton buttonWithType:UIButtonTypeSystem];
leadingButton.translatesAutoresizingMaskIntoConstraints = NO; leadingButton.translatesAutoresizingMaskIntoConstraints = NO;
[leadingButton setTitle:@"Button" forState:UIControlStateNormal];
UIButton* trailingButton = [UIButton buttonWithType:UIButtonTypeSystem]; UIButton* trailingButton = [UIButton buttonWithType:UIButtonTypeSystem];
trailingButton.translatesAutoresizingMaskIntoConstraints = NO; trailingButton.translatesAutoresizingMaskIntoConstraints = NO;
[trailingButton setTitle:@"Button" forState:UIControlStateNormal]; UIButton* centerButton = [UIButton buttonWithType:UIButtonTypeSystem];
centerButton.translatesAutoresizingMaskIntoConstraints = NO;
UIButton* roundButton = [UIButton buttonWithType:UIButtonTypeSystem];
roundButton.translatesAutoresizingMaskIntoConstraints = NO;
[roundButton setTitle:@"Btn" forState:UIControlStateNormal];
roundButton.layer.cornerRadius = 22.f;
roundButton.layer.masksToBounds = YES;
[toolbar.contentView addSubview:leadingButton]; [toolbar.contentView addSubview:leadingButton];
[toolbar.contentView addSubview:trailingButton]; [toolbar.contentView addSubview:trailingButton];
[toolbar.contentView addSubview:roundButton]; [toolbar.contentView addSubview:centerButton];
_leadingButton = leadingButton; _leadingButton = leadingButton;
_trailingButton = trailingButton; _trailingButton = trailingButton;
_roundButton = roundButton; _centerButton = centerButton;
NSArray* constraints = @[ NSArray* constraints = @[
[toolbar.topAnchor constraintEqualToAnchor:self.topAnchor], [toolbar.topAnchor constraintEqualToAnchor:self.topAnchor],
...@@ -63,10 +52,9 @@ const CGFloat kRoundButtonDiameter = 44.0f; ...@@ -63,10 +52,9 @@ const CGFloat kRoundButtonDiameter = 44.0f;
[leadingButton.leadingAnchor [leadingButton.leadingAnchor
constraintEqualToAnchor:toolbar.layoutMarginsGuide.leadingAnchor], constraintEqualToAnchor:toolbar.layoutMarginsGuide.leadingAnchor],
[leadingButton.topAnchor constraintEqualToAnchor:toolbar.topAnchor], [leadingButton.topAnchor constraintEqualToAnchor:toolbar.topAnchor],
[roundButton.widthAnchor constraintEqualToConstant:kRoundButtonDiameter], [centerButton.centerXAnchor
[roundButton.heightAnchor constraintEqualToConstant:kRoundButtonDiameter], constraintEqualToAnchor:toolbar.centerXAnchor],
[roundButton.centerXAnchor constraintEqualToAnchor:toolbar.centerXAnchor], [centerButton.topAnchor constraintEqualToAnchor:toolbar.topAnchor],
[roundButton.topAnchor constraintEqualToAnchor:toolbar.topAnchor],
[trailingButton.heightAnchor constraintEqualToConstant:kToolbarHeight], [trailingButton.heightAnchor constraintEqualToConstant:kToolbarHeight],
[trailingButton.trailingAnchor [trailingButton.trailingAnchor
constraintEqualToAnchor:toolbar.layoutMarginsGuide.trailingAnchor], constraintEqualToAnchor:toolbar.layoutMarginsGuide.trailingAnchor],
...@@ -81,42 +69,4 @@ const CGFloat kRoundButtonDiameter = 44.0f; ...@@ -81,42 +69,4 @@ const CGFloat kRoundButtonDiameter = 44.0f;
return CGSizeMake(UIViewNoIntrinsicMetric, kToolbarHeight); return CGSizeMake(UIViewNoIntrinsicMetric, kToolbarHeight);
} }
#pragma mark - Public
- (void)setTheme:(TabGridBottomToolbarTheme)theme {
if (_theme == theme)
return;
switch (theme) {
case TabGridBottomToolbarThemeWhiteRoundButton:
self.trailingButton.enabled = YES;
self.roundButton.enabled = YES;
self.roundButton.backgroundColor = [UIColor whiteColor];
self.roundButton.tintColor = [UIColor blackColor];
self.leadingButton.tintColor = [UIColor whiteColor];
self.trailingButton.tintColor = [UIColor whiteColor];
break;
case TabGridBottomToolbarThemeBlueRoundButton:
self.trailingButton.enabled = YES;
self.roundButton.enabled = YES;
self.roundButton.backgroundColor =
[UIColor colorWithRed:0.0 green:122.0 / 255.0 blue:1.0 alpha:1.0];
self.roundButton.tintColor = [UIColor whiteColor];
self.leadingButton.tintColor = [UIColor whiteColor];
self.trailingButton.tintColor = [UIColor whiteColor];
break;
case TabGridBottomToolbarThemePartiallyDisabled:
self.trailingButton.enabled = NO;
self.roundButton.enabled = NO;
self.roundButton.backgroundColor = [UIColor grayColor];
self.roundButton.tintColor = [UIColor blackColor];
self.leadingButton.tintColor = [UIColor whiteColor];
self.trailingButton.tintColor = [UIColor whiteColor];
break;
default:
NOTREACHED() << "Invalid theme for TabGridBottomToolbar.";
break;
}
_theme = theme;
}
@end @end
...@@ -33,7 +33,6 @@ const CGFloat kSegmentedControlHeight = 30.0f; ...@@ -33,7 +33,6 @@ const CGFloat kSegmentedControlHeight = 30.0f;
UIButton* leadingButton = [UIButton buttonWithType:UIButtonTypeSystem]; UIButton* leadingButton = [UIButton buttonWithType:UIButtonTypeSystem];
leadingButton.translatesAutoresizingMaskIntoConstraints = NO; leadingButton.translatesAutoresizingMaskIntoConstraints = NO;
leadingButton.tintColor = [UIColor whiteColor]; leadingButton.tintColor = [UIColor whiteColor];
[leadingButton setTitle:@"Button" forState:UIControlStateNormal];
UILabel* segmentedControl = [[UILabel alloc] init]; UILabel* segmentedControl = [[UILabel alloc] init];
segmentedControl.translatesAutoresizingMaskIntoConstraints = NO; segmentedControl.translatesAutoresizingMaskIntoConstraints = NO;
...@@ -45,7 +44,6 @@ const CGFloat kSegmentedControlHeight = 30.0f; ...@@ -45,7 +44,6 @@ const CGFloat kSegmentedControlHeight = 30.0f;
UIButton* trailingButton = [UIButton buttonWithType:UIButtonTypeSystem]; UIButton* trailingButton = [UIButton buttonWithType:UIButtonTypeSystem];
trailingButton.translatesAutoresizingMaskIntoConstraints = NO; trailingButton.translatesAutoresizingMaskIntoConstraints = NO;
trailingButton.tintColor = [UIColor whiteColor]; trailingButton.tintColor = [UIColor whiteColor];
[trailingButton setTitle:@"Button" forState:UIControlStateNormal];
[toolbar.contentView addSubview:leadingButton]; [toolbar.contentView addSubview:leadingButton];
[toolbar.contentView addSubview:trailingButton]; [toolbar.contentView addSubview:trailingButton];
......
...@@ -495,7 +495,7 @@ typedef NS_ENUM(NSUInteger, TabGridConfiguration) { ...@@ -495,7 +495,7 @@ typedef NS_ENUM(NSUInteger, TabGridConfiguration) {
self.floatingButton.hidden = YES; self.floatingButton.hidden = YES;
self.doneButton = self.bottomToolbar.leadingButton; self.doneButton = self.bottomToolbar.leadingButton;
self.closeAllButton = self.bottomToolbar.trailingButton; self.closeAllButton = self.bottomToolbar.trailingButton;
self.newTabButton = self.bottomToolbar.roundButton; self.newTabButton = self.bottomToolbar.centerButton;
break; break;
case TabGridConfigurationFloatingButton: case TabGridConfigurationFloatingButton:
self.topToolbar.leadingButton.hidden = NO; self.topToolbar.leadingButton.hidden = NO;
......
...@@ -19,22 +19,18 @@ ...@@ -19,22 +19,18 @@
TabGridTopToolbar* topToolbar = [[TabGridTopToolbar alloc] init]; TabGridTopToolbar* topToolbar = [[TabGridTopToolbar alloc] init];
topToolbar.translatesAutoresizingMaskIntoConstraints = NO; topToolbar.translatesAutoresizingMaskIntoConstraints = NO;
[topToolbar.leadingButton setTitle:@"Leading" forState:UIControlStateNormal];
[topToolbar.trailingButton setTitle:@"Trailing"
forState:UIControlStateNormal];
[self.view addSubview:topToolbar]; [self.view addSubview:topToolbar];
TabGridBottomToolbar* bottomToolbar1 = [[TabGridBottomToolbar alloc] init]; TabGridBottomToolbar* bottomToolbar = [[TabGridBottomToolbar alloc] init];
bottomToolbar1.translatesAutoresizingMaskIntoConstraints = NO; bottomToolbar.translatesAutoresizingMaskIntoConstraints = NO;
bottomToolbar1.theme = TabGridBottomToolbarThemeWhiteRoundButton; [bottomToolbar.leadingButton setTitle:@"Leading"
[self.view addSubview:bottomToolbar1]; forState:UIControlStateNormal];
[bottomToolbar.trailingButton setTitle:@"Trailing"
TabGridBottomToolbar* bottomToolbar2 = [[TabGridBottomToolbar alloc] init]; forState:UIControlStateNormal];
bottomToolbar2.translatesAutoresizingMaskIntoConstraints = NO; [self.view addSubview:bottomToolbar];
bottomToolbar2.theme = TabGridBottomToolbarThemeBlueRoundButton;
[self.view addSubview:bottomToolbar2];
TabGridBottomToolbar* bottomToolbar3 = [[TabGridBottomToolbar alloc] init];
bottomToolbar3.translatesAutoresizingMaskIntoConstraints = NO;
bottomToolbar3.theme = TabGridBottomToolbarThemePartiallyDisabled;
[self.view addSubview:bottomToolbar3];
NSArray* constraints = @[ NSArray* constraints = @[
[topToolbar.topAnchor constraintEqualToAnchor:self.view.topAnchor [topToolbar.topAnchor constraintEqualToAnchor:self.view.topAnchor
...@@ -44,32 +40,14 @@ ...@@ -44,32 +40,14 @@
constraintEqualToAnchor:self.view.trailingAnchor], constraintEqualToAnchor:self.view.trailingAnchor],
[topToolbar.heightAnchor [topToolbar.heightAnchor
constraintEqualToConstant:topToolbar.intrinsicContentSize.height], constraintEqualToConstant:topToolbar.intrinsicContentSize.height],
[bottomToolbar1.topAnchor constraintEqualToAnchor:topToolbar.bottomAnchor [bottomToolbar.topAnchor constraintEqualToAnchor:topToolbar.bottomAnchor
constant:10.0f], constant:10.0f],
[bottomToolbar1.leadingAnchor [bottomToolbar.leadingAnchor
constraintEqualToAnchor:self.view.leadingAnchor],
[bottomToolbar1.trailingAnchor
constraintEqualToAnchor:self.view.trailingAnchor],
[bottomToolbar1.heightAnchor
constraintEqualToConstant:bottomToolbar1.intrinsicContentSize.height],
[bottomToolbar2.topAnchor
constraintEqualToAnchor:bottomToolbar1.bottomAnchor
constant:10.0f],
[bottomToolbar2.leadingAnchor
constraintEqualToAnchor:self.view.leadingAnchor],
[bottomToolbar2.trailingAnchor
constraintEqualToAnchor:self.view.trailingAnchor],
[bottomToolbar2.heightAnchor
constraintEqualToConstant:bottomToolbar2.intrinsicContentSize.height],
[bottomToolbar3.topAnchor
constraintEqualToAnchor:bottomToolbar2.bottomAnchor
constant:10.0f],
[bottomToolbar3.leadingAnchor
constraintEqualToAnchor:self.view.leadingAnchor], constraintEqualToAnchor:self.view.leadingAnchor],
[bottomToolbar3.trailingAnchor [bottomToolbar.trailingAnchor
constraintEqualToAnchor:self.view.trailingAnchor], constraintEqualToAnchor:self.view.trailingAnchor],
[bottomToolbar3.heightAnchor [bottomToolbar.heightAnchor
constraintEqualToConstant:bottomToolbar3.intrinsicContentSize.height], constraintEqualToConstant:bottomToolbar.intrinsicContentSize.height],
]; ];
[NSLayoutConstraint activateConstraints:constraints]; [NSLayoutConstraint activateConstraints:constraints];
} }
......
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