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

Side by Side Diff: ios/chrome/browser/ui/settings/dataplan_usage_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/dataplan_usage_collection_view_controlle r.h" 5 #import "ios/chrome/browser/ui/settings/dataplan_usage_collection_view_controlle r.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #import "base/mac/foundation_util.h" 8 #import "base/mac/foundation_util.h"
9 #import "base/mac/scoped_nsobject.h" 9 #import "base/mac/scoped_nsobject.h"
10 #include "components/prefs/pref_member.h" 10 #include "components/prefs/pref_member.h"
11 #include "components/prefs/pref_service.h" 11 #include "components/prefs/pref_service.h"
12 #import "ios/chrome/browser/ui/collection_view/cells/collection_view_text_cell.h "
12 #import "ios/chrome/browser/ui/collection_view/cells/collection_view_text_item.h " 13 #import "ios/chrome/browser/ui/collection_view/cells/collection_view_text_item.h "
13 #import "ios/chrome/browser/ui/collection_view/collection_view_model.h" 14 #import "ios/chrome/browser/ui/collection_view/collection_view_model.h"
14 #include "ios/chrome/grit/ios_strings.h" 15 #include "ios/chrome/grit/ios_strings.h"
15 #import "ios/third_party/material_components_ios/src/components/CollectionCells/ src/MaterialCollectionCells.h" 16 #import "ios/third_party/material_components_ios/src/components/CollectionCells/ src/MaterialCollectionCells.h"
17 #import "ios/third_party/material_components_ios/src/components/Palettes/src/Mat erialPalettes.h"
18 #import "ios/third_party/material_components_ios/src/components/Typography/src/M aterialTypography.h"
16 #include "ui/base/l10n/l10n_util.h" 19 #include "ui/base/l10n/l10n_util.h"
17 #include "ui/base/l10n/l10n_util_mac.h" 20 #include "ui/base/l10n/l10n_util_mac.h"
18 21
19 namespace { 22 namespace {
20 23
21 typedef NS_ENUM(NSInteger, SectionIdentifier) { 24 typedef NS_ENUM(NSInteger, SectionIdentifier) {
22 SectionIdentifierOptions = kSectionIdentifierEnumZero, 25 SectionIdentifierOptions = kSectionIdentifierEnumZero,
23 }; 26 };
24 27
25 typedef NS_ENUM(NSInteger, ItemType) { 28 typedef NS_ENUM(NSInteger, ItemType) {
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 return nil; 140 return nil;
138 if (prefs->GetBoolean(basePreference)) { 141 if (prefs->GetBoolean(basePreference)) {
139 if (prefs->GetBoolean(wifiPreference)) 142 if (prefs->GetBoolean(wifiPreference))
140 return l10n_util::GetNSString(IDS_IOS_OPTIONS_DATA_USAGE_ONLY_WIFI); 143 return l10n_util::GetNSString(IDS_IOS_OPTIONS_DATA_USAGE_ONLY_WIFI);
141 else 144 else
142 return l10n_util::GetNSString(IDS_IOS_OPTIONS_DATA_USAGE_ALWAYS); 145 return l10n_util::GetNSString(IDS_IOS_OPTIONS_DATA_USAGE_ALWAYS);
143 } 146 }
144 return l10n_util::GetNSString(IDS_IOS_OPTIONS_DATA_USAGE_NEVER); 147 return l10n_util::GetNSString(IDS_IOS_OPTIONS_DATA_USAGE_NEVER);
145 } 148 }
146 149
150 #pragma mark - UICollectionViewDataSource
151
152 - (UICollectionViewCell*)collectionView:(UICollectionView*)collectionView
153 cellForItemAtIndexPath:(NSIndexPath*)indexPath {
154 UICollectionViewCell* cell =
155 [super collectionView:collectionView cellForItemAtIndexPath:indexPath];
156
157 NSInteger type = [self.collectionViewModel itemTypeForIndexPath:indexPath];
158 switch (type) {
159 case ItemTypeOptionsAlways:
160 case ItemTypeOptionsOnlyOnWiFi:
161 case ItemTypeOptionsNever: {
162 CollectionViewTextCell* textCell =
163 base::mac::ObjCCastStrict<CollectionViewTextCell>(cell);
164 textCell.textLabel.font = [MDCTypography body2Font];
165 textCell.textLabel.textColor = [[MDCPalette greyPalette] tint900];
166 textCell.detailTextLabel.font = [MDCTypography body1Font];
167 textCell.detailTextLabel.textColor = [[MDCPalette greyPalette] tint500];
168 break;
169 }
170 }
171 return cell;
172 }
173
147 #pragma mark - UICollectionViewDelegate 174 #pragma mark - UICollectionViewDelegate
148 175
149 - (void)collectionView:(UICollectionView*)collectionView 176 - (void)collectionView:(UICollectionView*)collectionView
150 didSelectItemAtIndexPath:(NSIndexPath*)indexPath { 177 didSelectItemAtIndexPath:(NSIndexPath*)indexPath {
151 [super collectionView:collectionView didSelectItemAtIndexPath:indexPath]; 178 [super collectionView:collectionView didSelectItemAtIndexPath:indexPath];
152 179
153 NSInteger type = [self.collectionViewModel itemTypeForIndexPath:indexPath]; 180 NSInteger type = [self.collectionViewModel itemTypeForIndexPath:indexPath];
154 switch (type) { 181 switch (type) {
155 case ItemTypeOptionsAlways: 182 case ItemTypeOptionsAlways:
156 [self updateBasePref:YES wifiPref:NO]; 183 [self updateBasePref:YES wifiPref:NO];
157 break; 184 break;
158 case ItemTypeOptionsOnlyOnWiFi: 185 case ItemTypeOptionsOnlyOnWiFi:
159 [self updateBasePref:YES wifiPref:YES]; 186 [self updateBasePref:YES wifiPref:YES];
160 break; 187 break;
161 case ItemTypeOptionsNever: 188 case ItemTypeOptionsNever:
162 [self updateBasePref:NO wifiPref:NO]; 189 [self updateBasePref:NO wifiPref:NO];
163 break; 190 break;
164 } 191 }
165 } 192 }
166 193
167 @end 194 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698