| 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_collection_view_l
ayout.h" | |
| 9 #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" |
| 10 #import "ios/clean/chrome/browser/ui/actions/settings_actions.h" | 9 #import "ios/clean/chrome/browser/ui/actions/settings_actions.h" |
| 11 #import "ios/clean/chrome/browser/ui/actions/tab_grid_actions.h" | 10 #import "ios/clean/chrome/browser/ui/actions/tab_grid_actions.h" |
| 12 #import "ios/clean/chrome/browser/ui/commands/settings_commands.h" | 11 #import "ios/clean/chrome/browser/ui/commands/settings_commands.h" |
| 13 #import "ios/clean/chrome/browser/ui/commands/tab_commands.h" | |
| 14 #import "ios/clean/chrome/browser/ui/commands/tab_grid_commands.h" | 12 #import "ios/clean/chrome/browser/ui/commands/tab_grid_commands.h" |
| 15 #import "ios/clean/chrome/browser/ui/tab_collection/tab_collection_data_source.h
" | 13 #import "ios/clean/chrome/browser/ui/tab_collection/tab_collection_data_source.h
" |
| 16 #import "ios/clean/chrome/browser/ui/tab_collection/tab_collection_tab_cell.h" | 14 #import "ios/clean/chrome/browser/ui/tab_collection/tab_collection_tab_cell.h" |
| 17 #import "ios/clean/chrome/browser/ui/tab_grid/mdc_floating_button+cr_tab_grid.h" | 15 #import "ios/clean/chrome/browser/ui/tab_grid/mdc_floating_button+cr_tab_grid.h" |
| 18 #import "ios/clean/chrome/browser/ui/tab_grid/tab_grid_collection_view_layout.h" | 16 #import "ios/clean/chrome/browser/ui/tab_grid/tab_grid_collection_view_layout.h" |
| 19 #import "ios/clean/chrome/browser/ui/tab_grid/tab_grid_toolbar.h" | 17 #import "ios/clean/chrome/browser/ui/tab_grid/tab_grid_toolbar.h" |
| 20 | 18 |
| 21 #if !defined(__has_feature) || !__has_feature(objc_arc) | 19 #if !defined(__has_feature) || !__has_feature(objc_arc) |
| 22 #error "This file requires ARC support." | 20 #error "This file requires ARC support." |
| 23 #endif | 21 #endif |
| 24 | 22 |
| 25 @interface TabGridViewController ()<SettingsActions, TabGridActions> | 23 @interface TabGridViewController ()<SettingsActions, TabGridActions> |
| 26 @property(nonatomic, weak) UIView* noTabsOverlay; | 24 @property(nonatomic, weak) UIView* noTabsOverlay; |
| 27 @property(nonatomic, weak) TabGridToolbar* toolbar; | 25 @property(nonatomic, weak) TabGridToolbar* toolbar; |
| 28 @property(nonatomic, weak) MDCFloatingButton* floatingNewTabButton; | 26 @property(nonatomic, weak) MDCFloatingButton* floatingNewTabButton; |
| 29 @end | 27 @end |
| 30 | 28 |
| 31 @implementation TabGridViewController | 29 @implementation TabGridViewController |
| 32 @synthesize settingsCommandHandler = _settingsCommandHandler; | 30 @synthesize dispatcher = _dispatcher; |
| 33 @synthesize tabGridCommandHandler = _tabGridCommandHandler; | |
| 34 @synthesize noTabsOverlay = _noTabsOverlay; | 31 @synthesize noTabsOverlay = _noTabsOverlay; |
| 35 @synthesize toolbar = _toolbar; | 32 @synthesize toolbar = _toolbar; |
| 36 @synthesize floatingNewTabButton = _floatingNewTabButton; | 33 @synthesize floatingNewTabButton = _floatingNewTabButton; |
| 37 | 34 |
| 38 #pragma mark - Required subclass override | 35 #pragma mark - Required subclass override |
| 39 | 36 |
| 40 - (UICollectionViewLayout*)collectionViewLayout { | 37 - (UICollectionViewLayout*)collectionViewLayout { |
| 41 return [[TabGridCollectionViewLayout alloc] init]; | 38 return [[TabGridCollectionViewLayout alloc] init]; |
| 42 } | 39 } |
| 43 | 40 |
| 41 - (void)showTabAtIndex:(int)index { |
| 42 [self.dispatcher showTabGridTabAtIndex:index]; |
| 43 } |
| 44 |
| 45 - (void)closeTabAtIndex:(int)index { |
| 46 [self.dispatcher closeTabGridTabAtIndex:index]; |
| 47 } |
| 48 |
| 44 #pragma mark - View lifecyle | 49 #pragma mark - View lifecyle |
| 45 | 50 |
| 46 - (void)viewDidLoad { | 51 - (void)viewDidLoad { |
| 47 [super viewDidLoad]; | 52 [super viewDidLoad]; |
| 48 | 53 |
| 49 TabGridToolbar* toolbar = [[TabGridToolbar alloc] init]; | 54 TabGridToolbar* toolbar = [[TabGridToolbar alloc] init]; |
| 50 self.toolbar = toolbar; | 55 self.toolbar = toolbar; |
| 51 [self.view addSubview:self.toolbar]; | 56 [self.view addSubview:self.toolbar]; |
| 52 self.toolbar.translatesAutoresizingMaskIntoConstraints = NO; | 57 self.toolbar.translatesAutoresizingMaskIntoConstraints = NO; |
| 53 [NSLayoutConstraint activateConstraints:@[ | 58 [NSLayoutConstraint activateConstraints:@[ |
| (...skipping 21 matching lines...) Expand all Loading... |
| 75 | 80 |
| 76 - (void)viewDidLayoutSubviews { | 81 - (void)viewDidLayoutSubviews { |
| 77 [super viewDidLayoutSubviews]; | 82 [super viewDidLayoutSubviews]; |
| 78 self.tabs.contentInset = | 83 self.tabs.contentInset = |
| 79 UIEdgeInsetsMake(CGRectGetMaxY(self.toolbar.frame), 0, 0, 0); | 84 UIEdgeInsetsMake(CGRectGetMaxY(self.toolbar.frame), 0, 0, 0); |
| 80 } | 85 } |
| 81 | 86 |
| 82 #pragma mark - SettingsActions | 87 #pragma mark - SettingsActions |
| 83 | 88 |
| 84 - (void)showSettings:(id)sender { | 89 - (void)showSettings:(id)sender { |
| 85 [self.settingsCommandHandler showSettings]; | 90 [self.dispatcher showSettings]; |
| 86 } | 91 } |
| 87 | 92 |
| 88 #pragma mark - TabGridActions | 93 #pragma mark - TabGridActions |
| 89 | 94 |
| 90 - (void)showTabGrid:(id)sender { | 95 - (void)showTabGrid:(id)sender { |
| 91 [self.tabGridCommandHandler showTabGrid]; | 96 [self.dispatcher showTabGrid]; |
| 92 } | 97 } |
| 93 | 98 |
| 94 - (void)createNewTab:(id)sender { | 99 - (void)createNewTab:(id)sender { |
| 95 [self.tabCommandHandler createAndShowNewTab]; | 100 [self.dispatcher createAndShowNewTabInTabGrid]; |
| 96 } | 101 } |
| 97 | 102 |
| 98 #pragma mark - ZoomTransitionDelegate methods | 103 #pragma mark - ZoomTransitionDelegate methods |
| 99 | 104 |
| 100 - (CGRect)rectForZoomWithKey:(NSObject*)key inView:(UIView*)view { | 105 - (CGRect)rectForZoomWithKey:(NSObject*)key inView:(UIView*)view { |
| 101 NSIndexPath* cellPath = base::mac::ObjCCastStrict<NSIndexPath>(key); | 106 NSIndexPath* cellPath = base::mac::ObjCCastStrict<NSIndexPath>(key); |
| 102 if (!key) | 107 if (!key) |
| 103 return CGRectNull; | 108 return CGRectNull; |
| 104 UICollectionViewCell* cell = [self.tabs cellForItemAtIndexPath:cellPath]; | 109 UICollectionViewCell* cell = [self.tabs cellForItemAtIndexPath:cellPath]; |
| 105 return [view convertRect:cell.bounds fromView:cell]; | 110 return [view convertRect:cell.bounds fromView:cell]; |
| (...skipping 14 matching lines...) Expand all Loading... |
| 120 UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight; | 125 UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight; |
| 121 [self.tabs addSubview:overlayView]; | 126 [self.tabs addSubview:overlayView]; |
| 122 self.noTabsOverlay = overlayView; | 127 self.noTabsOverlay = overlayView; |
| 123 } | 128 } |
| 124 | 129 |
| 125 - (void)removeNoTabsOverlay { | 130 - (void)removeNoTabsOverlay { |
| 126 [self.noTabsOverlay removeFromSuperview]; | 131 [self.noTabsOverlay removeFromSuperview]; |
| 127 } | 132 } |
| 128 | 133 |
| 129 @end | 134 @end |
| OLD | NEW |