| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #import "ios/clean/chrome/browser/ui/tab_grid/tab_grid_view_controller.h" | 5 #import "ios/clean/chrome/browser/ui/tab_grid/tab_grid_view_controller.h" |
| 6 | 6 |
| 7 #include "base/mac/foundation_util.h" | 7 #include "base/mac/foundation_util.h" |
| 8 #import "ios/chrome/browser/ui/tab_switcher/tab_switcher_panel_overlay_view.h" | 8 #import "ios/chrome/browser/ui/tab_switcher/tab_switcher_panel_overlay_view.h" |
| 9 #import "ios/clean/chrome/browser/ui/actions/settings_actions.h" | 9 #import "ios/clean/chrome/browser/ui/actions/settings_actions.h" |
| 10 #import "ios/clean/chrome/browser/ui/actions/tab_grid_actions.h" | 10 #import "ios/clean/chrome/browser/ui/actions/tab_grid_actions.h" |
| 11 #import "ios/clean/chrome/browser/ui/commands/settings_commands.h" | 11 #import "ios/clean/chrome/browser/ui/commands/settings_commands.h" |
| 12 #import "ios/clean/chrome/browser/ui/commands/tab_grid_commands.h" | 12 #import "ios/clean/chrome/browser/ui/commands/tab_grid_commands.h" |
| 13 #import "ios/clean/chrome/browser/ui/commands/tools_menu_commands.h" | 13 #import "ios/clean/chrome/browser/ui/commands/tools_menu_commands.h" |
| 14 #import "ios/clean/chrome/browser/ui/tab_collection/tab_collection_data_source.h
" | 14 #import "ios/clean/chrome/browser/ui/tab_collection/tab_collection_data_source.h
" |
| 15 #import "ios/clean/chrome/browser/ui/tab_collection/tab_collection_tab_cell.h" | 15 #import "ios/clean/chrome/browser/ui/tab_collection/tab_collection_tab_cell.h" |
| 16 #import "ios/clean/chrome/browser/ui/tab_grid/mdc_floating_button+cr_tab_grid.h" | 16 #import "ios/clean/chrome/browser/ui/tab_grid/mdc_floating_button+cr_tab_grid.h" |
| 17 #import "ios/clean/chrome/browser/ui/tab_grid/tab_grid_collection_view_layout.h" | 17 #import "ios/clean/chrome/browser/ui/tab_grid/tab_grid_collection_view_layout.h" |
| 18 #import "ios/clean/chrome/browser/ui/tab_grid/tab_grid_toolbar.h" | 18 #import "ios/clean/chrome/browser/ui/tab_grid/tab_grid_toolbar.h" |
| 19 | 19 |
| 20 #if !defined(__has_feature) || !__has_feature(objc_arc) | 20 #if !defined(__has_feature) || !__has_feature(objc_arc) |
| 21 #error "This file requires ARC support." | 21 #error "This file requires ARC support." |
| 22 #endif | 22 #endif |
| 23 | 23 |
| 24 @interface TabGridViewController ()<SettingsActions, TabGridActions> | 24 @interface TabGridViewController ()<SettingsActions, TabGridActions> |
| 25 @property(nonatomic, weak) UIView* noTabsOverlay; | 25 @property(nonatomic, weak) UIView* noTabsOverlay; |
| 26 @property(nonatomic, weak) TabGridToolbar* toolbar; | 26 @property(nonatomic, weak) TabGridToolbar* toolbar; |
| 27 @property(nonatomic, weak) MDCFloatingButton* floatingNewTabButton; | 27 @property(nonatomic, weak) MDCFloatingButton* floatingNewTabButton; |
| 28 @property(nonatomic, assign) CGRect currentFrame; |
| 28 @end | 29 @end |
| 29 | 30 |
| 30 @implementation TabGridViewController | 31 @implementation TabGridViewController |
| 31 @synthesize dispatcher = _dispatcher; | 32 @synthesize dispatcher = _dispatcher; |
| 32 @synthesize noTabsOverlay = _noTabsOverlay; | 33 @synthesize noTabsOverlay = _noTabsOverlay; |
| 33 @synthesize toolbar = _toolbar; | 34 @synthesize toolbar = _toolbar; |
| 34 @synthesize floatingNewTabButton = _floatingNewTabButton; | 35 @synthesize floatingNewTabButton = _floatingNewTabButton; |
| 36 @synthesize currentFrame = _currentFrame; |
| 35 | 37 |
| 36 #pragma mark - Required subclass override | 38 #pragma mark - Required subclass override |
| 37 | 39 |
| 38 - (UICollectionViewLayout*)collectionViewLayout { | 40 - (UICollectionViewLayout*)collectionViewLayout { |
| 39 return [[TabGridCollectionViewLayout alloc] init]; | 41 return [[TabGridCollectionViewLayout alloc] init]; |
| 40 } | 42 } |
| 41 | 43 |
| 42 - (void)showTabAtIndex:(int)index { | 44 - (void)showTabAtIndex:(int)index { |
| 43 [self.dispatcher showTabGridTabAtIndex:index]; | 45 [self.dispatcher showTabGridTabAtIndex:index]; |
| 44 } | 46 } |
| (...skipping 14 matching lines...) Expand all Loading... |
| 59 [NSLayoutConstraint activateConstraints:@[ | 61 [NSLayoutConstraint activateConstraints:@[ |
| 60 [self.toolbar.topAnchor constraintEqualToAnchor:self.view.topAnchor], | 62 [self.toolbar.topAnchor constraintEqualToAnchor:self.view.topAnchor], |
| 61 [self.toolbar.heightAnchor | 63 [self.toolbar.heightAnchor |
| 62 constraintEqualToAnchor:self.topLayoutGuide.heightAnchor | 64 constraintEqualToAnchor:self.topLayoutGuide.heightAnchor |
| 63 constant:self.toolbar.intrinsicContentSize.height], | 65 constant:self.toolbar.intrinsicContentSize.height], |
| 64 [self.toolbar.leadingAnchor | 66 [self.toolbar.leadingAnchor |
| 65 constraintEqualToAnchor:self.view.leadingAnchor], | 67 constraintEqualToAnchor:self.view.leadingAnchor], |
| 66 [self.toolbar.trailingAnchor | 68 [self.toolbar.trailingAnchor |
| 67 constraintEqualToAnchor:self.view.trailingAnchor] | 69 constraintEqualToAnchor:self.view.trailingAnchor] |
| 68 ]]; | 70 ]]; |
| 71 |
| 72 self.currentFrame = self.view.frame; |
| 69 } | 73 } |
| 70 | 74 |
| 71 - (void)viewWillAppear:(BOOL)animated { | 75 - (void)viewWillAppear:(BOOL)animated { |
| 72 [super viewWillAppear:animated]; | 76 [super viewWillAppear:animated]; |
| 73 MDCFloatingButton* floatingNewTabButton = | 77 MDCFloatingButton* floatingNewTabButton = |
| 74 [MDCFloatingButton cr_tabGridNewTabButton]; | 78 [MDCFloatingButton cr_tabGridNewTabButton]; |
| 75 self.floatingNewTabButton = floatingNewTabButton; | 79 self.floatingNewTabButton = floatingNewTabButton; |
| 76 [self.floatingNewTabButton | 80 [self.floatingNewTabButton |
| 77 setFrame:[MDCFloatingButton | 81 setFrame:[MDCFloatingButton |
| 78 cr_frameForTabGridNewTabButtonInRect:self.view.bounds]]; | 82 cr_frameForTabGridNewTabButtonInRect:self.view.bounds]]; |
| 79 [self.view addSubview:self.floatingNewTabButton]; | 83 [self.view addSubview:self.floatingNewTabButton]; |
| 80 } | 84 } |
| 81 | 85 |
| 82 - (void)viewDidLayoutSubviews { | 86 - (void)viewDidLayoutSubviews { |
| 83 [super viewDidLayoutSubviews]; | 87 [super viewDidLayoutSubviews]; |
| 84 self.tabs.contentInset = | 88 self.tabs.contentInset = |
| 85 UIEdgeInsetsMake(CGRectGetMaxY(self.toolbar.frame), 0, 0, 0); | 89 UIEdgeInsetsMake(CGRectGetMaxY(self.toolbar.frame), 0, 0, 0); |
| 86 } | 90 } |
| 87 | 91 |
| 92 - (void)viewWillLayoutSubviews { |
| 93 // We need to dismiss the ToolsMenu everytime the Toolbar frame changes |
| 94 // (e.g. Size changes, rotation changes, etc.) |
| 95 if (!CGRectEqualToRect(self.currentFrame, self.view.frame)) { |
| 96 [self.dispatcher closeToolsMenu]; |
| 97 } |
| 98 self.currentFrame = self.view.frame; |
| 99 } |
| 100 |
| 88 #pragma mark - SettingsActions | 101 #pragma mark - SettingsActions |
| 89 | 102 |
| 90 - (void)showSettings:(id)sender { | 103 - (void)showSettings:(id)sender { |
| 91 [self.dispatcher showSettings]; | 104 [self.dispatcher showSettings]; |
| 92 } | 105 } |
| 93 | 106 |
| 94 #pragma mark - ToolsMenuActions | 107 #pragma mark - ToolsMenuActions |
| 95 | 108 |
| 96 - (void)showToolsMenu:(id)sender { | 109 - (void)showToolsMenu:(id)sender { |
| 97 [self.dispatcher showToolsMenu]; | 110 [self.dispatcher showToolsMenu]; |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 137 UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight; | 150 UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight; |
| 138 [self.tabs addSubview:overlayView]; | 151 [self.tabs addSubview:overlayView]; |
| 139 self.noTabsOverlay = overlayView; | 152 self.noTabsOverlay = overlayView; |
| 140 } | 153 } |
| 141 | 154 |
| 142 - (void)removeNoTabsOverlay { | 155 - (void)removeNoTabsOverlay { |
| 143 [self.noTabsOverlay removeFromSuperview]; | 156 [self.noTabsOverlay removeFromSuperview]; |
| 144 } | 157 } |
| 145 | 158 |
| 146 @end | 159 @end |
| OLD | NEW |