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

Side by Side Diff: ios/clean/chrome/browser/ui/tab_grid/tab_grid_collection_view_layout.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
OLDNEW
1 // Copyright 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 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_collection_view_layout.h" 5 #import "ios/clean/chrome/browser/ui/tab_grid/tab_grid_collection_view_layout.h"
6 6
7 #if !defined(__has_feature) || !__has_feature(objc_arc) 7 #if !defined(__has_feature) || !__has_feature(objc_arc)
8 #error "This file requires ARC support." 8 #error "This file requires ARC support."
9 #endif 9 #endif
10 10
11 namespace { 11 namespace {
12 const CGFloat kMinTabWidth = 200.0f; 12 const CGFloat kMinTabWidth = 200.0f;
13 const CGFloat kMaxTabWidth = 250.0f; 13 const CGFloat kMaxTabWidth = 250.0f;
14 const CGFloat kInterTabSpacing = 20.0f; 14 const CGFloat kInterTabSpacing = 20.0f;
15 const UIEdgeInsets kSectionInset = {20.0f, 20.0f, 20.0f, 20.0f};
16 } 15 }
17 16
18 @implementation TabGridCollectionViewLayout 17 @implementation TabGridCollectionViewLayout
19 18
20 #pragma mark - UICollectionViewLayout 19 #pragma mark - UICollectionViewLayout
21 20
22 // This is called whenever the layout is invalidated, including during rotation. 21 // This is called whenever the layout is invalidated, including during rotation.
23 - (void)prepareLayout { 22 - (void)prepareLayout {
24 [super prepareLayout]; 23 [super prepareLayout];
25 [self updateLayoutWithBounds:[[self collectionView] bounds].size]; 24 [self updateLayoutWithBounds:[[self collectionView] bounds].size];
26 } 25 }
27 26
28 #pragma mark - Private 27 #pragma mark - Private
29 28
30 // This sets the appropriate itemSize given the bounds of the collection view. 29 // This sets the appropriate itemSize given the bounds of the collection view.
31 - (void)updateLayoutWithBounds:(CGSize)boundsSize { 30 - (void)updateLayoutWithBounds:(CGSize)boundsSize {
32 int columns = static_cast<int>(floor(boundsSize.width - kInterTabSpacing) / 31 int columns = static_cast<int>(floor(boundsSize.width - kInterTabSpacing) /
33 (kMinTabWidth + kInterTabSpacing)); 32 (kMinTabWidth + kInterTabSpacing));
34 CGFloat tabWidth = 33 CGFloat tabWidth =
35 (boundsSize.width - kInterTabSpacing * (columns + 1)) / columns; 34 (boundsSize.width - kInterTabSpacing * (columns + 1)) / columns;
36 while (columns < 2 || tabWidth > kMaxTabWidth) { 35 while (columns < 2 || tabWidth > kMaxTabWidth) {
37 columns++; 36 columns++;
38 tabWidth = (boundsSize.width - kInterTabSpacing * (columns + 1)) / columns; 37 tabWidth = (boundsSize.width - kInterTabSpacing * (columns + 1)) / columns;
39 } 38 }
40 self.itemSize = CGSizeMake(tabWidth, tabWidth); 39 self.itemSize = CGSizeMake(tabWidth, tabWidth);
41 self.sectionInset = kSectionInset; 40 self.sectionInset = UIEdgeInsetsMake(10.0f, 20.0f, 20.0f, 20.0f);
42 self.minimumLineSpacing = kInterTabSpacing; 41 self.minimumLineSpacing = kInterTabSpacing;
43 self.minimumInteritemSpacing = kInterTabSpacing; 42 self.minimumInteritemSpacing = kInterTabSpacing;
44 } 43 }
45 44
46 @end 45 @end
OLDNEW
« no previous file with comments | « ios/clean/chrome/browser/ui/tab_grid/BUILD.gn ('k') | ios/clean/chrome/browser/ui/tab_grid/tab_grid_toolbar.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698