| Index: ios/chrome/browser/ui/tools_menu/tools_menu_view_controller.mm
|
| diff --git a/ios/chrome/browser/ui/tools_menu/tools_menu_view_controller.mm b/ios/chrome/browser/ui/tools_menu/tools_menu_view_controller.mm
|
| index 84adea1713b824939d1baac28267bf0f4fbb3371..e01c61f959c5780c155f6c46bedb653c18b2d3ff 100644
|
| --- a/ios/chrome/browser/ui/tools_menu/tools_menu_view_controller.mm
|
| +++ b/ios/chrome/browser/ui/tools_menu/tools_menu_view_controller.mm
|
| @@ -20,11 +20,10 @@
|
| #include "ios/chrome/browser/ui/commands/ios_command_ids.h"
|
| #import "ios/chrome/browser/ui/reading_list/reading_list_menu_notification_delegate.h"
|
| #import "ios/chrome/browser/ui/reading_list/reading_list_menu_notifier.h"
|
| -#include "ios/chrome/browser/ui/rtl_geometry.h"
|
| -#include "ios/chrome/browser/ui/toolbar/toolbar_resource_macros.h"
|
| #import "ios/chrome/browser/ui/tools_menu/reading_list_menu_view_item.h"
|
| #import "ios/chrome/browser/ui/tools_menu/tools_menu_context.h"
|
| #import "ios/chrome/browser/ui/tools_menu/tools_menu_view_item.h"
|
| +#import "ios/chrome/browser/ui/tools_menu/tools_menu_view_tools_cell.h"
|
| #import "ios/chrome/browser/ui/tools_menu/tools_popup_controller.h"
|
| #include "ios/chrome/browser/ui/ui_util.h"
|
| #import "ios/chrome/browser/ui/uikit_ui_util.h"
|
| @@ -218,13 +217,6 @@ NS_INLINE void AnimateInViews(NSArray* views,
|
| }
|
| } // anonymous namespace
|
|
|
| -@interface ToolsMenuButton : UIButton
|
| -@end
|
| -
|
| -@implementation ToolsMenuButton
|
| -
|
| -@end
|
| -
|
| @interface ToolsMenuCollectionView : UICollectionView
|
| @property(nonatomic, assign) CGPoint touchBeginPoint;
|
| @property(nonatomic, assign) CGPoint touchEndPoint;
|
| @@ -247,201 +239,6 @@ NS_INLINE void AnimateInViews(NSArray* views,
|
|
|
| @end
|
|
|
| -@interface ToolsMenuViewToolsCell : UICollectionViewCell
|
| -@property(nonatomic, retain) ToolsMenuButton* reloadButton;
|
| -@property(nonatomic, retain) ToolsMenuButton* shareButton;
|
| -@property(nonatomic, retain) ToolsMenuButton* starButton;
|
| -@property(nonatomic, retain) ToolsMenuButton* starredButton;
|
| -@property(nonatomic, retain) ToolsMenuButton* stopButton;
|
| -@property(nonatomic, retain) ToolsMenuButton* toolsButton;
|
| -@end
|
| -
|
| -@implementation ToolsMenuViewToolsCell {
|
| - base::mac::ObjCPropertyReleaser _propertyReleaser_ToolsMenuViewToolsCell;
|
| -}
|
| -
|
| -@synthesize reloadButton = _reloadButton;
|
| -@synthesize shareButton = _shareButton;
|
| -@synthesize starButton = _starButton;
|
| -@synthesize starredButton = _starredButton;
|
| -@synthesize stopButton = _stopButton;
|
| -@synthesize toolsButton = _toolsButton;
|
| -
|
| -- (instancetype)initWithCoder:(NSCoder*)aDecoder {
|
| - self = [super initWithCoder:aDecoder];
|
| - if (self)
|
| - [self commonInitialization];
|
| -
|
| - return self;
|
| -}
|
| -
|
| -- (instancetype)initWithFrame:(CGRect)frame {
|
| - self = [super initWithFrame:frame];
|
| - if (self)
|
| - [self commonInitialization];
|
| -
|
| - return self;
|
| -}
|
| -
|
| -- (void)commonInitialization {
|
| - _propertyReleaser_ToolsMenuViewToolsCell.Init(self,
|
| - [ToolsMenuViewToolsCell class]);
|
| -
|
| - [self setBackgroundColor:[UIColor whiteColor]];
|
| - [self setOpaque:YES];
|
| -
|
| - int star[2][3] = TOOLBAR_IDR_TWO_STATE(STAR);
|
| - _starButton = [self newButtonForImageIds:star
|
| - commandID:IDC_BOOKMARK_PAGE
|
| - accessibilityLabelID:IDS_BOOKMARK_ADD_EDITOR_TITLE
|
| - automationName:@"Add Bookmark"];
|
| -
|
| - int star_pressed[2][3] = TOOLBAR_IDR_ONE_STATE(STAR_PRESSED);
|
| - _starredButton = [self newButtonForImageIds:star_pressed
|
| - commandID:IDC_TEMP_EDIT_BOOKMARK
|
| - accessibilityLabelID:IDS_IOS_TOOLS_MENU_EDIT_BOOKMARK
|
| - automationName:@"Edit Bookmark"];
|
| -
|
| - int reload[2][3] = TOOLBAR_IDR_TWO_STATE(RELOAD);
|
| - _reloadButton = [self newButtonForImageIds:reload
|
| - commandID:IDC_RELOAD
|
| - accessibilityLabelID:IDS_IOS_ACCNAME_RELOAD
|
| - automationName:@"Reload"
|
| - reverseForRTL:YES];
|
| -
|
| - int stop[2][3] = TOOLBAR_IDR_TWO_STATE(STOP);
|
| - _stopButton = [self newButtonForImageIds:stop
|
| - commandID:IDC_STOP
|
| - accessibilityLabelID:IDS_IOS_ACCNAME_STOP
|
| - automationName:@"Stop"];
|
| -
|
| - int share[2][3] = TOOLBAR_IDR_THREE_STATE(SHARE);
|
| - _shareButton = [self newButtonForImageIds:share
|
| - commandID:IDC_SHARE_PAGE
|
| - accessibilityLabelID:IDS_IOS_TOOLS_MENU_SHARE
|
| - automationName:@"Stop"];
|
| - int tools[2][3] = TOOLBAR_IDR_ONE_STATE(TOOLS_PRESSED);
|
| - _toolsButton =
|
| - [self newButtonForImageIds:tools
|
| - commandID:IDC_SHOW_TOOLS_MENU
|
| - accessibilityLabelID:IDS_IOS_TOOLBAR_CLOSE_MENU
|
| - automationName:@"kToolbarToolsMenuButtonIdentifier"];
|
| -
|
| - UIView* contentView = [self contentView];
|
| - [contentView setBackgroundColor:[self backgroundColor]];
|
| - [contentView setOpaque:YES];
|
| -
|
| - [contentView addSubview:_starredButton];
|
| - [contentView addSubview:_starButton];
|
| - [contentView addSubview:_stopButton];
|
| - [contentView addSubview:_reloadButton];
|
| - [contentView addSubview:_shareButton];
|
| -
|
| - [self addConstraints];
|
| -}
|
| -
|
| -- (ToolsMenuButton*)newButtonForImageIds:(int[2][3])imageIds
|
| - commandID:(int)commandID
|
| - accessibilityLabelID:(int)labelID
|
| - automationName:(NSString*)name {
|
| - return [self newButtonForImageIds:imageIds
|
| - commandID:commandID
|
| - accessibilityLabelID:labelID
|
| - automationName:name
|
| - reverseForRTL:NO];
|
| -}
|
| -
|
| -- (ToolsMenuButton*)newButtonForImageIds:(int[2][3])imageIds
|
| - commandID:(int)commandID
|
| - accessibilityLabelID:(int)labelID
|
| - automationName:(NSString*)name
|
| - reverseForRTL:(BOOL)reverseForRTL {
|
| - ToolsMenuButton* button = [[ToolsMenuButton alloc] initWithFrame:CGRectZero];
|
| - [button setTranslatesAutoresizingMaskIntoConstraints:NO];
|
| -
|
| - if (imageIds[0][0]) {
|
| - [button setImage:NativeReversableImage(imageIds[0][0], reverseForRTL)
|
| - forState:UIControlStateNormal];
|
| - }
|
| - [[button imageView] setContentMode:UIViewContentModeCenter];
|
| - [button setBackgroundColor:[self backgroundColor]];
|
| - [button setTag:commandID];
|
| - [button setOpaque:YES];
|
| -
|
| - SetA11yLabelAndUiAutomationName(button, labelID, name);
|
| -
|
| - if (imageIds[0][1]) {
|
| - UIImage* pressedImage =
|
| - NativeReversableImage(imageIds[0][1], reverseForRTL);
|
| - if (pressedImage) {
|
| - [button setImage:pressedImage forState:UIControlStateHighlighted];
|
| - }
|
| - }
|
| -
|
| - if (imageIds[0][2]) {
|
| - UIImage* disabledImage =
|
| - NativeReversableImage(imageIds[0][2], reverseForRTL);
|
| - if (disabledImage) {
|
| - [button setImage:disabledImage forState:UIControlStateDisabled];
|
| - }
|
| - }
|
| -
|
| - return button;
|
| -}
|
| -
|
| -- (void)addConstraints {
|
| - UIView* contentView = [self contentView];
|
| -
|
| - for (UIButton* button in [self allButtons]) {
|
| - NSDictionary* view = @{ @"button" : button };
|
| - NSArray* constraints = @[ @"V:|-(0)-[button]-(0)-|", @"H:[button(==48)]" ];
|
| - ApplyVisualConstraints(constraints, view, self);
|
| - }
|
| -
|
| - NSDictionary* views = @{
|
| - @"share" : _shareButton,
|
| - @"star" : _starButton,
|
| - @"reload" : _reloadButton,
|
| - @"starred" : _starredButton,
|
| - @"stop" : _stopButton
|
| - };
|
| - // Leading offset is 16, minus the button image inset of 12.
|
| - NSDictionary* metrics = @{ @"offset" : @4, @"space" : @24 };
|
| - // clang-format off
|
| - NSArray* constraints = @[
|
| - @"H:|-(offset)-[share]-(space)-[star]-(space)-[reload]",
|
| - @"H:[share]-(space)-[starred]",
|
| - @"H:[star]-(space)-[stop]"
|
| - ];
|
| - // clang-format on
|
| - ApplyVisualConstraintsWithMetricsAndOptions(
|
| - constraints, views, metrics, LayoutOptionForRTLSupport(), contentView);
|
| -}
|
| -
|
| -// These should be added in display order, so they are animated in display
|
| -// order.
|
| -- (NSArray*)allButtons {
|
| - NSMutableArray* allButtons = [NSMutableArray array];
|
| - if (_shareButton)
|
| - [allButtons addObject:_shareButton];
|
| -
|
| - if (_starButton)
|
| - [allButtons addObject:_starButton];
|
| -
|
| - if (_starredButton)
|
| - [allButtons addObject:_starredButton];
|
| -
|
| - if (_reloadButton)
|
| - [allButtons addObject:_reloadButton];
|
| -
|
| - if (_stopButton)
|
| - [allButtons addObject:_stopButton];
|
| -
|
| - return allButtons;
|
| -}
|
| -
|
| -@end
|
| -
|
| // Class Extension for private methods.
|
| @interface ToolsMenuViewController ()<UICollectionViewDelegateFlowLayout,
|
| UICollectionViewDataSource,
|
|
|