Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(259)

Side by Side Diff: ios/clean/chrome/browser/ui/tab_grid/tab_grid_view_controller.mm

Issue 2723453003: [ios] Improve toolbar in tab_grid (Closed)
Patch Set: Unsafe retained assign fix Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ios/clean/chrome/browser/ui/tab_grid/tab_grid_toolbar.mm ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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_collection_view_l ayout.h" 12 #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_overlay_view.h" 13 #import "ios/chrome/browser/ui/tab_switcher/tab_switcher_panel_overlay_view.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/tab_grid_collection_view_layout.h"
21 #import "ios/clean/chrome/browser/ui/tab_grid/tab_grid_tab_cell.h" 21 #import "ios/clean/chrome/browser/ui/tab_grid/tab_grid_tab_cell.h"
22 #import "ios/clean/chrome/browser/ui/tab_grid/ui_stack_view+cr_tab_grid.h" 22 #import "ios/clean/chrome/browser/ui/tab_grid/tab_grid_toolbar.h"
23 23
24 #if !defined(__has_feature) || !__has_feature(objc_arc) 24 #if !defined(__has_feature) || !__has_feature(objc_arc)
25 #error "This file requires ARC support." 25 #error "This file requires ARC support."
26 #endif 26 #endif
27 27
28 namespace {
29 // Height of toolbar in tab grid.
30 const CGFloat kToolbarHeight = 64.0f;
31 }
32
33 @interface TabGridViewController ()<SettingsActions, 28 @interface TabGridViewController ()<SettingsActions,
34 TabGridActions, 29 TabGridActions,
35 UICollectionViewDataSource, 30 UICollectionViewDataSource,
36 UICollectionViewDelegate, 31 UICollectionViewDelegate,
37 SessionCellDelegate> 32 SessionCellDelegate>
38 @property(nonatomic, weak) UICollectionView* grid; 33 @property(nonatomic, weak) UICollectionView* grid;
39 @property(nonatomic, weak) UIView* noTabsOverlay; 34 @property(nonatomic, weak) UIView* noTabsOverlay;
40 @property(nonatomic, strong) MDCFloatingButton* floatingNewTabButton; 35 @property(nonatomic, weak) TabGridToolbar* toolbar;
36 @property(nonatomic, weak) MDCFloatingButton* floatingNewTabButton;
41 @end 37 @end
42 38
43 @implementation TabGridViewController 39 @implementation TabGridViewController
44 40
45 @synthesize dataSource = _dataSource; 41 @synthesize dataSource = _dataSource;
46 @synthesize settingsCommandHandler = _settingsCommandHandler; 42 @synthesize settingsCommandHandler = _settingsCommandHandler;
47 @synthesize tabGridCommandHandler = _tabGridCommandHandler; 43 @synthesize tabGridCommandHandler = _tabGridCommandHandler;
48 @synthesize tabCommandHandler = _tabCommandHandler; 44 @synthesize tabCommandHandler = _tabCommandHandler;
49 @synthesize grid = _grid; 45 @synthesize grid = _grid;
50 @synthesize noTabsOverlay = _noTabsOverlay; 46 @synthesize noTabsOverlay = _noTabsOverlay;
47 @synthesize toolbar = _toolbar;
51 @synthesize floatingNewTabButton = _floatingNewTabButton; 48 @synthesize floatingNewTabButton = _floatingNewTabButton;
52 49
53 - (void)viewDidLoad { 50 - (void)viewDidLoad {
54 UIView* toolbar = [UIStackView cr_tabGridToolbarStackView];
55 [self.view addSubview:toolbar];
56
57 toolbar.translatesAutoresizingMaskIntoConstraints = NO;
58 [NSLayoutConstraint activateConstraints:@[
59 [toolbar.heightAnchor constraintEqualToConstant:kToolbarHeight],
60 [toolbar.widthAnchor constraintEqualToAnchor:self.view.widthAnchor],
61 [toolbar.topAnchor constraintEqualToAnchor:self.view.topAnchor],
62 [toolbar.centerXAnchor constraintEqualToAnchor:self.view.centerXAnchor]
63 ]];
64
65 TabGridCollectionViewLayout* layout = 51 TabGridCollectionViewLayout* layout =
66 [[TabGridCollectionViewLayout alloc] init]; 52 [[TabGridCollectionViewLayout alloc] init];
67 UICollectionView* grid = [[UICollectionView alloc] initWithFrame:CGRectZero 53 UICollectionView* grid = [[UICollectionView alloc] initWithFrame:CGRectZero
68 collectionViewLayout:layout]; 54 collectionViewLayout:layout];
69 grid.translatesAutoresizingMaskIntoConstraints = NO; 55 grid.translatesAutoresizingMaskIntoConstraints = NO;
70 grid.backgroundColor = [UIColor blackColor]; 56 grid.backgroundColor = [UIColor blackColor];
71 57
72 [self.view addSubview:grid]; 58 [self.view addSubview:grid];
73 self.grid = grid; 59 self.grid = grid;
74 self.grid.dataSource = self; 60 self.grid.dataSource = self;
75 self.grid.delegate = self; 61 self.grid.delegate = self;
76 [self.grid registerClass:[TabGridTabCell class] 62 [self.grid registerClass:[TabGridTabCell class]
77 forCellWithReuseIdentifier:[TabGridTabCell identifier]]; 63 forCellWithReuseIdentifier:[TabGridTabCell identifier]];
78 64
79 [NSLayoutConstraint activateConstraints:@[ 65 [NSLayoutConstraint activateConstraints:@[
80 [self.grid.topAnchor constraintEqualToAnchor:toolbar.bottomAnchor], 66 [self.grid.topAnchor constraintEqualToAnchor:self.view.topAnchor],
81 [self.grid.bottomAnchor constraintEqualToAnchor:self.view.bottomAnchor], 67 [self.grid.bottomAnchor constraintEqualToAnchor:self.view.bottomAnchor],
82 [self.grid.leadingAnchor constraintEqualToAnchor:self.view.leadingAnchor], 68 [self.grid.leadingAnchor constraintEqualToAnchor:self.view.leadingAnchor],
83 [self.grid.trailingAnchor constraintEqualToAnchor:self.view.trailingAnchor], 69 [self.grid.trailingAnchor constraintEqualToAnchor:self.view.trailingAnchor],
84 ]]; 70 ]];
71
72 TabGridToolbar* toolbar = [[TabGridToolbar alloc] init];
73 self.toolbar = toolbar;
74 [self.view addSubview:self.toolbar];
75 self.toolbar.translatesAutoresizingMaskIntoConstraints = NO;
76 [NSLayoutConstraint activateConstraints:@[
77 [self.toolbar.topAnchor constraintEqualToAnchor:self.view.topAnchor],
78 [self.toolbar.heightAnchor
79 constraintEqualToAnchor:self.topLayoutGuide.heightAnchor
80 constant:self.toolbar.intrinsicContentSize.height],
81 [self.toolbar.leadingAnchor
82 constraintEqualToAnchor:self.view.leadingAnchor],
83 [self.toolbar.trailingAnchor
84 constraintEqualToAnchor:self.view.trailingAnchor]
85 ]];
85 } 86 }
86 87
87 - (void)viewWillAppear:(BOOL)animated { 88 - (void)viewWillAppear:(BOOL)animated {
88 self.floatingNewTabButton = [MDCFloatingButton cr_tabGridNewTabButton]; 89 MDCFloatingButton* floatingNewTabButton =
90 [MDCFloatingButton cr_tabGridNewTabButton];
91 self.floatingNewTabButton = floatingNewTabButton;
89 [self.floatingNewTabButton 92 [self.floatingNewTabButton
90 setFrame:[MDCFloatingButton 93 setFrame:[MDCFloatingButton
91 cr_frameForTabGridNewTabButtonInRect:self.view.bounds]]; 94 cr_frameForTabGridNewTabButtonInRect:self.view.bounds]];
92 [self.view addSubview:self.floatingNewTabButton]; 95 [self.view addSubview:self.floatingNewTabButton];
93 } 96 }
94 97
98 - (void)viewDidLayoutSubviews {
99 [super viewDidLayoutSubviews];
100 self.grid.contentInset =
101 UIEdgeInsetsMake(CGRectGetMaxY(self.toolbar.frame), 0, 0, 0);
102 }
103
95 - (UIStatusBarStyle)preferredStatusBarStyle { 104 - (UIStatusBarStyle)preferredStatusBarStyle {
96 return UIStatusBarStyleLightContent; 105 return UIStatusBarStyleLightContent;
97 } 106 }
98 107
99 #pragma mark - UICollectionViewDataSource methods 108 #pragma mark - UICollectionViewDataSource methods
100 109
101 - (NSInteger)numberOfSectionsInCollectionView: 110 - (NSInteger)numberOfSectionsInCollectionView:
102 (UICollectionView*)collectionView { 111 (UICollectionView*)collectionView {
103 return 1; 112 return 1;
104 } 113 }
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
229 [self.grid addSubview:overlayView]; 238 [self.grid addSubview:overlayView];
230 self.noTabsOverlay = overlayView; 239 self.noTabsOverlay = overlayView;
231 } 240 }
232 241
233 // Removes the noTabsOverlay covering the entire tab grid. 242 // Removes the noTabsOverlay covering the entire tab grid.
234 - (void)removeNoTabsOverlay { 243 - (void)removeNoTabsOverlay {
235 [self.noTabsOverlay removeFromSuperview]; 244 [self.noTabsOverlay removeFromSuperview];
236 } 245 }
237 246
238 @end 247 @end
OLDNEW
« no previous file with comments | « ios/clean/chrome/browser/ui/tab_grid/tab_grid_toolbar.mm ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698