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

Side by Side Diff: ios/chrome/browser/ui/bookmarks/bookmark_collection_view.mm

Issue 2838373002: Adding Sign-in promo for bookmark view. (Closed)
Patch Set: From CGFLOAT_MAX to 1000 Created 3 years, 7 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/chrome/browser/ui/bookmarks/bookmark_collection_view.h" 5 #import "ios/chrome/browser/ui/bookmarks/bookmark_collection_view.h"
6 6
7 #import <UIKit/UIGestureRecognizerSubclass.h> 7 #import <UIKit/UIGestureRecognizerSubclass.h>
8 #include <algorithm> 8 #include <algorithm>
9 #include <map> 9 #include <map>
10 #include <memory> 10 #include <memory>
11 11
12 #include "base/mac/bind_objc_block.h" 12 #include "base/mac/bind_objc_block.h"
13 #include "base/mac/foundation_util.h" 13 #include "base/mac/foundation_util.h"
14 #include "base/strings/sys_string_conversions.h" 14 #include "base/strings/sys_string_conversions.h"
15 #include "components/bookmarks/browser/bookmark_model.h" 15 #include "components/bookmarks/browser/bookmark_model.h"
16 #include "components/bookmarks/browser/bookmark_model_observer.h" 16 #include "components/bookmarks/browser/bookmark_model_observer.h"
17 #include "components/favicon/core/fallback_url_util.h" 17 #include "components/favicon/core/fallback_url_util.h"
18 #include "components/favicon/core/large_icon_service.h" 18 #include "components/favicon/core/large_icon_service.h"
19 #include "components/favicon_base/fallback_icon_style.h" 19 #include "components/favicon_base/fallback_icon_style.h"
20 #include "components/favicon_base/favicon_types.h" 20 #include "components/favicon_base/favicon_types.h"
21 #include "ios/chrome/browser/bookmarks/bookmark_model_factory.h" 21 #include "ios/chrome/browser/bookmarks/bookmark_model_factory.h"
22 #include "ios/chrome/browser/bookmarks/bookmarks_utils.h" 22 #include "ios/chrome/browser/bookmarks/bookmarks_utils.h"
23 #include "ios/chrome/browser/favicon/ios_chrome_large_icon_service_factory.h" 23 #include "ios/chrome/browser/favicon/ios_chrome_large_icon_service_factory.h"
24 #import "ios/chrome/browser/ui/bookmarks/bookmark_collection_cells.h" 24 #import "ios/chrome/browser/ui/bookmarks/bookmark_collection_cells.h"
25 #import "ios/chrome/browser/ui/bookmarks/bookmark_collection_view_background.h" 25 #import "ios/chrome/browser/ui/bookmarks/bookmark_collection_view_background.h"
26 #import "ios/chrome/browser/ui/bookmarks/bookmark_promo_cell.h" 26 #import "ios/chrome/browser/ui/bookmarks/bookmark_promo_cell.h"
27 #import "ios/chrome/browser/ui/bookmarks/bookmark_signin_promo_cell.h"
27 #import "ios/chrome/browser/ui/bookmarks/bookmark_utils_ios.h" 28 #import "ios/chrome/browser/ui/bookmarks/bookmark_utils_ios.h"
28 #include "ios/chrome/browser/ui/ui_util.h" 29 #include "ios/chrome/browser/ui/ui_util.h"
29 #import "ios/chrome/browser/ui/uikit_ui_util.h" 30 #import "ios/chrome/browser/ui/uikit_ui_util.h"
30 #include "ios/chrome/grit/ios_strings.h" 31 #include "ios/chrome/grit/ios_strings.h"
31 #include "skia/ext/skia_utils_ios.h" 32 #include "skia/ext/skia_utils_ios.h"
32 #include "ui/base/l10n/l10n_util_mac.h" 33 #include "ui/base/l10n/l10n_util_mac.h"
33 34
34 #if !defined(__has_feature) || !__has_feature(objc_arc) 35 #if !defined(__has_feature) || !__has_feature(objc_arc)
35 #error "This file requires ARC support." 36 #error "This file requires ARC support."
36 #endif 37 #endif
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 forCellWithReuseIdentifier:[BookmarkItemCell reuseIdentifier]]; 190 forCellWithReuseIdentifier:[BookmarkItemCell reuseIdentifier]];
190 [self.collectionView registerClass:[BookmarkHeaderView class] 191 [self.collectionView registerClass:[BookmarkHeaderView class]
191 forSupplementaryViewOfKind:UICollectionElementKindSectionHeader 192 forSupplementaryViewOfKind:UICollectionElementKindSectionHeader
192 withReuseIdentifier:[BookmarkHeaderView reuseIdentifier]]; 193 withReuseIdentifier:[BookmarkHeaderView reuseIdentifier]];
193 [self.collectionView 194 [self.collectionView
194 registerClass:[BookmarkHeaderSeparatorView class] 195 registerClass:[BookmarkHeaderSeparatorView class]
195 forSupplementaryViewOfKind:UICollectionElementKindSectionHeader 196 forSupplementaryViewOfKind:UICollectionElementKindSectionHeader
196 withReuseIdentifier:[BookmarkHeaderSeparatorView reuseIdentifier]]; 197 withReuseIdentifier:[BookmarkHeaderSeparatorView reuseIdentifier]];
197 [self.collectionView registerClass:[BookmarkPromoCell class] 198 [self.collectionView registerClass:[BookmarkPromoCell class]
198 forCellWithReuseIdentifier:[BookmarkPromoCell reuseIdentifier]]; 199 forCellWithReuseIdentifier:[BookmarkPromoCell reuseIdentifier]];
200 [self.collectionView registerClass:[BookmarkSigninPromoCell class]
201 forCellWithReuseIdentifier:[BookmarkSigninPromoCell reuseIdentifier]];
199 202
200 [self addSubview:self.collectionView]; 203 [self addSubview:self.collectionView];
201 204
202 // Set up the background view shown when the collection is empty. 205 // Set up the background view shown when the collection is empty.
203 BookmarkCollectionViewBackground* emptyCollectionBackgroundView = 206 BookmarkCollectionViewBackground* emptyCollectionBackgroundView =
204 [[BookmarkCollectionViewBackground alloc] initWithFrame:CGRectZero]; 207 [[BookmarkCollectionViewBackground alloc] initWithFrame:CGRectZero];
205 self.emptyCollectionBackgroundView = emptyCollectionBackgroundView; 208 self.emptyCollectionBackgroundView = emptyCollectionBackgroundView;
206 self.emptyCollectionBackgroundView.autoresizingMask = 209 self.emptyCollectionBackgroundView.autoresizingMask =
207 UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth; 210 UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth;
208 self.emptyCollectionBackgroundView.alpha = 0; 211 self.emptyCollectionBackgroundView.alpha = 0;
(...skipping 470 matching lines...) Expand 10 before | Expand all | Expand 10 after
679 return UIEdgeInsetsZero; 682 return UIEdgeInsetsZero;
680 683
681 if (IsIPadIdiom()) { 684 if (IsIPadIdiom()) {
682 return UIEdgeInsetsMake(10, rowMarginTablet, 0, rowMarginTablet); 685 return UIEdgeInsetsMake(10, rowMarginTablet, 0, rowMarginTablet);
683 } else { 686 } else {
684 return UIEdgeInsetsZero; 687 return UIEdgeInsetsZero;
685 } 688 }
686 } 689 }
687 690
688 - (CGSize)cellSizeForIndexPath:(NSIndexPath*)indexPath { 691 - (CGSize)cellSizeForIndexPath:(NSIndexPath*)indexPath {
689 if ([self isPromoSection:indexPath.section]) { 692 DCHECK(![self isPromoSection:indexPath.section]);
690 CGRect estimatedFrame = CGRectMake(0, 0, CGRectGetWidth(self.bounds), 100);
691 UICollectionViewCell* cell =
692 [self.collectionView cellForItemAtIndexPath:indexPath];
693 if (!cell) {
694 cell = [[BookmarkPromoCell alloc] initWithFrame:estimatedFrame];
695 }
696 cell.frame = estimatedFrame;
697 [cell layoutIfNeeded];
698 return [cell systemLayoutSizeFittingSize:UILayoutFittingCompressedSize];
699 }
700
701 UIEdgeInsets insets = [self insetForSectionAtIndex:indexPath.section]; 693 UIEdgeInsets insets = [self insetForSectionAtIndex:indexPath.section];
702 return CGSizeMake(self.bounds.size.width - (insets.right + insets.left), 694 return CGSizeMake(self.bounds.size.width - (insets.right + insets.left),
703 rowHeight); 695 rowHeight);
704 } 696 }
705 697
706 - (CGFloat)minimumInteritemSpacingForSectionAtIndex:(NSInteger)section { 698 - (CGFloat)minimumInteritemSpacingForSectionAtIndex:(NSInteger)section {
707 return 0; 699 return 0;
708 } 700 }
709 701
710 - (CGFloat)minimumLineSpacingForSectionAtIndex:(NSInteger)section { 702 - (CGFloat)minimumLineSpacingForSectionAtIndex:(NSInteger)section {
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
839 831
840 - (BOOL)shouldShowPromoCell { 832 - (BOOL)shouldShowPromoCell {
841 return NO; 833 return NO;
842 } 834 }
843 835
844 - (BOOL)isPromoActive { 836 - (BOOL)isPromoActive {
845 return NO; 837 return NO;
846 } 838 }
847 839
848 @end 840 @end
OLDNEW
« no previous file with comments | « ios/chrome/browser/ui/bookmarks/BUILD.gn ('k') | ios/chrome/browser/ui/bookmarks/bookmark_folder_collection_view.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698