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

Side by Side Diff: ios/chrome/browser/ui/settings/about_chrome_collection_view_controller.mm

Issue 2817953002: CollectionViewTextItem no longer styles CollectionViewTextCell (Closed)
Patch Set: rebase Created 3 years, 8 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/settings/about_chrome_collection_view_controller. h" 5 #import "ios/chrome/browser/ui/settings/about_chrome_collection_view_controller. h"
6 6
7 #import "base/ios/block_types.h" 7 #import "base/ios/block_types.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #import "base/mac/foundation_util.h" 9 #import "base/mac/foundation_util.h"
10 #include "base/strings/sys_string_conversions.h" 10 #include "base/strings/sys_string_conversions.h"
11 #include "base/strings/utf_string_conversions.h" 11 #include "base/strings/utf_string_conversions.h"
12 #include "components/version_info/version_info.h" 12 #include "components/version_info/version_info.h"
13 #include "ios/chrome/browser/chrome_url_constants.h" 13 #include "ios/chrome/browser/chrome_url_constants.h"
14 #import "ios/chrome/browser/ui/collection_view/cells/collection_view_item.h" 14 #import "ios/chrome/browser/ui/collection_view/cells/collection_view_item.h"
15 #import "ios/chrome/browser/ui/collection_view/cells/collection_view_text_cell.h "
15 #import "ios/chrome/browser/ui/collection_view/cells/collection_view_text_item.h " 16 #import "ios/chrome/browser/ui/collection_view/cells/collection_view_text_item.h "
16 #import "ios/chrome/browser/ui/collection_view/collection_view_model.h" 17 #import "ios/chrome/browser/ui/collection_view/collection_view_model.h"
18 #import "ios/chrome/browser/ui/colors/MDCPalette+CrAdditions.h"
17 #import "ios/chrome/browser/ui/settings/cells/version_item.h" 19 #import "ios/chrome/browser/ui/settings/cells/version_item.h"
18 #import "ios/chrome/browser/ui/settings/settings_utils.h" 20 #import "ios/chrome/browser/ui/settings/settings_utils.h"
19 #include "ios/chrome/browser/ui/uikit_ui_util.h" 21 #include "ios/chrome/browser/ui/uikit_ui_util.h"
20 #include "ios/chrome/common/channel_info.h" 22 #include "ios/chrome/common/channel_info.h"
21 #include "ios/chrome/grit/ios_chromium_strings.h" 23 #include "ios/chrome/grit/ios_chromium_strings.h"
22 #include "ios/chrome/grit/ios_strings.h" 24 #include "ios/chrome/grit/ios_strings.h"
23 #import "ios/third_party/material_components_ios/src/components/CollectionCells/ src/MaterialCollectionCells.h" 25 #import "ios/third_party/material_components_ios/src/components/CollectionCells/ src/MaterialCollectionCells.h"
24 #import "ios/third_party/material_components_ios/src/components/Snackbar/src/Mat erialSnackbar.h" 26 #import "ios/third_party/material_components_ios/src/components/Snackbar/src/Mat erialSnackbar.h"
27 #import "ios/third_party/material_components_ios/src/components/Typography/src/M aterialTypography.h"
25 #include "ui/base/l10n/l10n_util.h" 28 #include "ui/base/l10n/l10n_util.h"
26 #include "ui/base/l10n/l10n_util_mac.h" 29 #include "ui/base/l10n/l10n_util_mac.h"
27 #include "url/gurl.h" 30 #include "url/gurl.h"
28 31
29 #if !defined(__has_feature) || !__has_feature(objc_arc) 32 #if !defined(__has_feature) || !__has_feature(objc_arc)
30 #error "This file requires ARC support." 33 #error "This file requires ARC support."
31 #endif 34 #endif
32 35
33 namespace { 36 namespace {
34 37
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 [model addItem:privacy toSectionWithIdentifier:SectionIdentifierLinks]; 92 [model addItem:privacy toSectionWithIdentifier:SectionIdentifierLinks];
90 93
91 [model addSectionWithIdentifier:SectionIdentifierFooter]; 94 [model addSectionWithIdentifier:SectionIdentifierFooter];
92 95
93 VersionItem* version = [[VersionItem alloc] initWithType:ItemTypeVersion]; 96 VersionItem* version = [[VersionItem alloc] initWithType:ItemTypeVersion];
94 version.text = [self versionDescriptionString]; 97 version.text = [self versionDescriptionString];
95 version.accessibilityTraits = UIAccessibilityTraitButton; 98 version.accessibilityTraits = UIAccessibilityTraitButton;
96 [model addItem:version toSectionWithIdentifier:SectionIdentifierFooter]; 99 [model addItem:version toSectionWithIdentifier:SectionIdentifierFooter];
97 } 100 }
98 101
102 #pragma mark UICollectionViewDataSource
103
104 - (UICollectionViewCell*)collectionView:(UICollectionView*)collectionView
105 cellForItemAtIndexPath:(nonnull NSIndexPath*)indexPath {
106 UICollectionViewCell* cell =
107 [super collectionView:collectionView cellForItemAtIndexPath:indexPath];
108
109 NSInteger itemType =
110 [self.collectionViewModel itemTypeForIndexPath:indexPath];
111 switch (itemType) {
112 case ItemTypeLinksCredits:
113 case ItemTypeLinksTerms:
114 case ItemTypeLinksPrivacy: {
115 CollectionViewTextCell* textCell =
116 base::mac::ObjCCastStrict<CollectionViewTextCell>(cell);
117 textCell.textLabel.font = [MDCTypography body2Font];
118 textCell.textLabel.textColor = [[MDCPalette greyPalette] tint900];
119 textCell.detailTextLabel.font = [MDCTypography body1Font];
120 textCell.detailTextLabel.textColor = [[MDCPalette greyPalette] tint500];
121 break;
122 }
123 default:
124 break;
125 }
126 return cell;
127 }
128
99 #pragma mark UICollectionViewDelegate 129 #pragma mark UICollectionViewDelegate
100 130
101 - (void)collectionView:(UICollectionView*)collectionView 131 - (void)collectionView:(UICollectionView*)collectionView
102 didSelectItemAtIndexPath:(NSIndexPath*)indexPath { 132 didSelectItemAtIndexPath:(NSIndexPath*)indexPath {
103 [super collectionView:collectionView didSelectItemAtIndexPath:indexPath]; 133 [super collectionView:collectionView didSelectItemAtIndexPath:indexPath];
104 NSInteger itemType = 134 NSInteger itemType =
105 [self.collectionViewModel itemTypeForIndexPath:indexPath]; 135 [self.collectionViewModel itemTypeForIndexPath:indexPath];
106 switch (itemType) { 136 switch (itemType) {
107 case ItemTypeLinksCredits: 137 case ItemTypeLinksCredits:
108 [self openURL:GURL(kChromeUICreditsURL)]; 138 [self openURL:GURL(kChromeUICreditsURL)];
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
178 - (NSString*)versionDescriptionString { 208 - (NSString*)versionDescriptionString {
179 return l10n_util::GetNSStringF(IDS_IOS_VERSION, 209 return l10n_util::GetNSStringF(IDS_IOS_VERSION,
180 base::UTF8ToUTF16([self versionString])); 210 base::UTF8ToUTF16([self versionString]));
181 } 211 }
182 212
183 - (NSString*)versionOnlyString { 213 - (NSString*)versionOnlyString {
184 return base::SysUTF8ToNSString([self versionString]); 214 return base::SysUTF8ToNSString([self versionString]);
185 } 215 }
186 216
187 @end 217 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698