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 // ====== New Architecture ===== | 5 // ====== New Architecture ===== |
6 // = This code is only used in the new iOS Chrome architecture. = | 6 // = This code is only used in the new iOS Chrome architecture. = |
7 // ============================================================================ | 7 // ============================================================================ |
8 | 8 |
9 #import "ios/clean/chrome/browser/ui/tab_grid/tab_grid_view_controller.h" | 9 #import "ios/clean/chrome/browser/ui/tab_grid/tab_grid_view_controller.h" |
10 | 10 |
11 #include "base/mac/foundation_util.h" | 11 #include "base/mac/foundation_util.h" |
12 #import "ios/chrome/browser/ui/tab_switcher/tab_switcher_panel_cell.h" | 12 #import "ios/chrome/browser/ui/tab_switcher/tab_switcher_panel_cell.h" |
13 #import "ios/chrome/browser/ui/tab_switcher/tab_switcher_panel_collection_view_l
ayout.h" | 13 #import "ios/chrome/browser/ui/tab_switcher/tab_switcher_panel_collection_view_l
ayout.h" |
14 #import "ios/clean/chrome/browser/ui/actions/settings_actions.h" | 14 #import "ios/clean/chrome/browser/ui/actions/settings_actions.h" |
15 #import "ios/clean/chrome/browser/ui/actions/tab_grid_actions.h" | 15 #import "ios/clean/chrome/browser/ui/actions/tab_grid_actions.h" |
16 #import "ios/clean/chrome/browser/ui/commands/settings_commands.h" | 16 #import "ios/clean/chrome/browser/ui/commands/settings_commands.h" |
17 #import "ios/clean/chrome/browser/ui/commands/tab_commands.h" | 17 #import "ios/clean/chrome/browser/ui/commands/tab_commands.h" |
18 #import "ios/clean/chrome/browser/ui/commands/tab_grid_commands.h" | 18 #import "ios/clean/chrome/browser/ui/commands/tab_grid_commands.h" |
19 #import "ios/clean/chrome/browser/ui/tab_grid/mdc_floating_button+cr_tab_grid.h" | 19 #import "ios/clean/chrome/browser/ui/tab_grid/mdc_floating_button+cr_tab_grid.h" |
| 20 #import "ios/clean/chrome/browser/ui/tab_grid/tab_grid_collection_view_layout.h" |
20 #import "ios/clean/chrome/browser/ui/tab_grid/ui_stack_view+cr_tab_grid.h" | 21 #import "ios/clean/chrome/browser/ui/tab_grid/ui_stack_view+cr_tab_grid.h" |
21 | 22 |
22 #if !defined(__has_feature) || !__has_feature(objc_arc) | 23 #if !defined(__has_feature) || !__has_feature(objc_arc) |
23 #error "This file requires ARC support." | 24 #error "This file requires ARC support." |
24 #endif | 25 #endif |
25 | 26 |
26 namespace { | 27 namespace { |
27 const CGFloat kSpace = 20.0f; | |
28 const CGFloat kTabSize = 150.0f; | |
29 // Height of toolbar in tab grid. | 28 // Height of toolbar in tab grid. |
30 const CGFloat kToolbarHeight = 64.0f; | 29 const CGFloat kToolbarHeight = 64.0f; |
31 } | 30 } |
32 | 31 |
33 @interface TabGridViewController ()<SettingsActions, | 32 @interface TabGridViewController ()<SettingsActions, |
34 TabGridActions, | 33 TabGridActions, |
35 UICollectionViewDataSource, | 34 UICollectionViewDataSource, |
36 UICollectionViewDelegate, | 35 UICollectionViewDelegate, |
37 SessionCellDelegate> | 36 SessionCellDelegate> |
38 @property(nonatomic, weak) UICollectionView* grid; | 37 @property(nonatomic, weak) UICollectionView* grid; |
(...skipping 14 matching lines...) Expand all Loading... |
53 [self.view addSubview:toolbar]; | 52 [self.view addSubview:toolbar]; |
54 | 53 |
55 toolbar.translatesAutoresizingMaskIntoConstraints = NO; | 54 toolbar.translatesAutoresizingMaskIntoConstraints = NO; |
56 [NSLayoutConstraint activateConstraints:@[ | 55 [NSLayoutConstraint activateConstraints:@[ |
57 [toolbar.heightAnchor constraintEqualToConstant:kToolbarHeight], | 56 [toolbar.heightAnchor constraintEqualToConstant:kToolbarHeight], |
58 [toolbar.widthAnchor constraintEqualToAnchor:self.view.widthAnchor], | 57 [toolbar.widthAnchor constraintEqualToAnchor:self.view.widthAnchor], |
59 [toolbar.topAnchor constraintEqualToAnchor:self.view.topAnchor], | 58 [toolbar.topAnchor constraintEqualToAnchor:self.view.topAnchor], |
60 [toolbar.centerXAnchor constraintEqualToAnchor:self.view.centerXAnchor] | 59 [toolbar.centerXAnchor constraintEqualToAnchor:self.view.centerXAnchor] |
61 ]]; | 60 ]]; |
62 | 61 |
63 TabSwitcherPanelCollectionViewLayout* layout = | 62 TabGridCollectionViewLayout* layout = |
64 [[TabSwitcherPanelCollectionViewLayout alloc] init]; | 63 [[TabGridCollectionViewLayout alloc] init]; |
65 layout.minimumLineSpacing = kSpace; | |
66 layout.minimumInteritemSpacing = kSpace; | |
67 layout.sectionInset = UIEdgeInsetsMake(kSpace, kSpace, kSpace, kSpace); | |
68 layout.itemSize = CGSizeMake(kTabSize, kTabSize); | |
69 | |
70 UICollectionView* grid = [[UICollectionView alloc] initWithFrame:CGRectZero | 64 UICollectionView* grid = [[UICollectionView alloc] initWithFrame:CGRectZero |
71 collectionViewLayout:layout]; | 65 collectionViewLayout:layout]; |
72 grid.translatesAutoresizingMaskIntoConstraints = NO; | 66 grid.translatesAutoresizingMaskIntoConstraints = NO; |
73 grid.backgroundColor = [UIColor blackColor]; | 67 grid.backgroundColor = [UIColor blackColor]; |
74 | 68 |
75 [self.view addSubview:grid]; | 69 [self.view addSubview:grid]; |
76 self.grid = grid; | 70 self.grid = grid; |
77 self.grid.dataSource = self; | 71 self.grid.dataSource = self; |
78 self.grid.delegate = self; | 72 self.grid.delegate = self; |
79 [self.grid registerClass:[TabSwitcherLocalSessionCell class] | 73 [self.grid registerClass:[TabSwitcherLocalSessionCell class] |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
159 - (void)deleteButtonPressedForCell:(UICollectionViewCell*)cell { | 153 - (void)deleteButtonPressedForCell:(UICollectionViewCell*)cell { |
160 auto updateBlock = ^{ | 154 auto updateBlock = ^{ |
161 NSIndexPath* indexPath = [self.grid indexPathForCell:cell]; | 155 NSIndexPath* indexPath = [self.grid indexPathForCell:cell]; |
162 [self.tabCommandHandler closeTabAtIndexPath:indexPath]; | 156 [self.tabCommandHandler closeTabAtIndexPath:indexPath]; |
163 [self.grid deleteItemsAtIndexPaths:@[ indexPath ]]; | 157 [self.grid deleteItemsAtIndexPaths:@[ indexPath ]]; |
164 }; | 158 }; |
165 [self.grid performBatchUpdates:updateBlock completion:nil]; | 159 [self.grid performBatchUpdates:updateBlock completion:nil]; |
166 } | 160 } |
167 | 161 |
168 @end | 162 @end |
OLD | NEW |