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

Side by Side Diff: ios/chrome/browser/ui/settings/translate_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/translate_collection_view_controller.h" 5 #import "ios/chrome/browser/ui/settings/translate_collection_view_controller.h"
6 6
7 #import <Foundation/Foundation.h> 7 #import <Foundation/Foundation.h>
8 #include <memory> 8 #include <memory>
9 9
10 #include "base/mac/foundation_util.h" 10 #include "base/mac/foundation_util.h"
11 #include "base/mac/scoped_nsobject.h" 11 #include "base/mac/scoped_nsobject.h"
12 #include "components/google/core/browser/google_util.h" 12 #include "components/google/core/browser/google_util.h"
13 #include "components/prefs/pref_member.h" 13 #include "components/prefs/pref_member.h"
14 #include "components/prefs/pref_service.h" 14 #include "components/prefs/pref_service.h"
15 #include "components/translate/core/browser/translate_prefs.h" 15 #include "components/translate/core/browser/translate_prefs.h"
16 #include "components/translate/core/common/translate_pref_names.h" 16 #include "components/translate/core/common/translate_pref_names.h"
17 #include "ios/chrome/browser/application_context.h" 17 #include "ios/chrome/browser/application_context.h"
18 #import "ios/chrome/browser/translate/chrome_ios_translate_client.h" 18 #import "ios/chrome/browser/translate/chrome_ios_translate_client.h"
19 #import "ios/chrome/browser/ui/collection_view/cells/MDCCollectionViewCell+Chrom e.h" 19 #import "ios/chrome/browser/ui/collection_view/cells/MDCCollectionViewCell+Chrom e.h"
20 #import "ios/chrome/browser/ui/collection_view/cells/collection_view_footer_item .h" 20 #import "ios/chrome/browser/ui/collection_view/cells/collection_view_footer_item .h"
21 #import "ios/chrome/browser/ui/collection_view/cells/collection_view_switch_item .h" 21 #import "ios/chrome/browser/ui/collection_view/cells/collection_view_switch_item .h"
22 #import "ios/chrome/browser/ui/collection_view/cells/collection_view_text_cell.h "
22 #import "ios/chrome/browser/ui/collection_view/cells/collection_view_text_item.h " 23 #import "ios/chrome/browser/ui/collection_view/cells/collection_view_text_item.h "
23 #import "ios/chrome/browser/ui/collection_view/collection_view_model.h" 24 #import "ios/chrome/browser/ui/collection_view/collection_view_model.h"
24 #import "ios/chrome/browser/ui/settings/settings_utils.h" 25 #import "ios/chrome/browser/ui/settings/settings_utils.h"
25 #import "ios/chrome/browser/ui/settings/utils/pref_backed_boolean.h" 26 #import "ios/chrome/browser/ui/settings/utils/pref_backed_boolean.h"
26 #include "ios/chrome/browser/ui/uikit_ui_util.h" 27 #include "ios/chrome/browser/ui/uikit_ui_util.h"
27 #include "ios/chrome/grit/ios_chromium_strings.h" 28 #include "ios/chrome/grit/ios_chromium_strings.h"
28 #include "ios/chrome/grit/ios_strings.h" 29 #include "ios/chrome/grit/ios_strings.h"
29 #import "ios/third_party/material_components_ios/src/components/Palettes/src/Mat erialPalettes.h" 30 #import "ios/third_party/material_components_ios/src/components/Palettes/src/Mat erialPalettes.h"
30 #import "ios/third_party/material_components_ios/src/components/Snackbar/src/Mat erialSnackbar.h" 31 #import "ios/third_party/material_components_ios/src/components/Snackbar/src/Mat erialSnackbar.h"
31 #import "ios/third_party/material_components_ios/src/components/Typography/src/M aterialTypography.h" 32 #import "ios/third_party/material_components_ios/src/components/Typography/src/M aterialTypography.h"
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 _translationItem.get().text = 101 _translationItem.get().text =
101 l10n_util::GetNSString(IDS_IOS_TRANSLATE_SETTING); 102 l10n_util::GetNSString(IDS_IOS_TRANSLATE_SETTING);
102 _translationItem.get().on = [_translationEnabled value]; 103 _translationItem.get().on = [_translationEnabled value];
103 [model addItem:_translationItem 104 [model addItem:_translationItem
104 toSectionWithIdentifier:SectionIdentifierTranslate]; 105 toSectionWithIdentifier:SectionIdentifierTranslate];
105 106
106 CollectionViewTextItem* resetTranslate = [[[CollectionViewTextItem alloc] 107 CollectionViewTextItem* resetTranslate = [[[CollectionViewTextItem alloc]
107 initWithType:ItemTypeResetTranslate] autorelease]; 108 initWithType:ItemTypeResetTranslate] autorelease];
108 resetTranslate.text = l10n_util::GetNSString(IDS_IOS_TRANSLATE_SETTING_RESET); 109 resetTranslate.text = l10n_util::GetNSString(IDS_IOS_TRANSLATE_SETTING_RESET);
109 resetTranslate.accessibilityTraits |= UIAccessibilityTraitButton; 110 resetTranslate.accessibilityTraits |= UIAccessibilityTraitButton;
110 resetTranslate.textFont = [MDCTypography body2Font];
111 [model addItem:resetTranslate 111 [model addItem:resetTranslate
112 toSectionWithIdentifier:SectionIdentifierTranslate]; 112 toSectionWithIdentifier:SectionIdentifierTranslate];
113 113
114 // Footer Section 114 // Footer Section
115 [model addSectionWithIdentifier:SectionIdentifierFooter]; 115 [model addSectionWithIdentifier:SectionIdentifierFooter];
116 CollectionViewFooterItem* footer = [[[CollectionViewFooterItem alloc] 116 CollectionViewFooterItem* footer = [[[CollectionViewFooterItem alloc]
117 initWithType:ItemTypeFooter] autorelease]; 117 initWithType:ItemTypeFooter] autorelease];
118 footer.text = l10n_util::GetNSString(IDS_IOS_TRANSLATE_SETTING_DESCRIPTION); 118 footer.text = l10n_util::GetNSString(IDS_IOS_TRANSLATE_SETTING_DESCRIPTION);
119 footer.linkURL = google_util::AppendGoogleLocaleParam( 119 footer.linkURL = google_util::AppendGoogleLocaleParam(
120 GURL(kTranslateLearnMoreUrl), 120 GURL(kTranslateLearnMoreUrl),
(...skipping 13 matching lines...) Expand all
134 134
135 switch (itemType) { 135 switch (itemType) {
136 case ItemTypeTranslate: { 136 case ItemTypeTranslate: {
137 CollectionViewSwitchCell* switchCell = 137 CollectionViewSwitchCell* switchCell =
138 base::mac::ObjCCastStrict<CollectionViewSwitchCell>(cell); 138 base::mac::ObjCCastStrict<CollectionViewSwitchCell>(cell);
139 [switchCell.switchView addTarget:self 139 [switchCell.switchView addTarget:self
140 action:@selector(translateToggled:) 140 action:@selector(translateToggled:)
141 forControlEvents:UIControlEventValueChanged]; 141 forControlEvents:UIControlEventValueChanged];
142 break; 142 break;
143 } 143 }
144 case ItemTypeResetTranslate: {
145 CollectionViewTextCell* textCell =
146 base::mac::ObjCCastStrict<CollectionViewTextCell>(cell);
147 textCell.textLabel.font = [MDCTypography body2Font];
148 textCell.textLabel.textColor = [[MDCPalette greyPalette] tint900];
149 textCell.detailTextLabel.font = [MDCTypography body1Font];
150 textCell.detailTextLabel.textColor = [[MDCPalette greyPalette] tint500];
151 break;
152 }
144 default: 153 default:
145 break; 154 break;
146 } 155 }
147 156
148 return cell; 157 return cell;
149 } 158 }
150 159
151 #pragma mark UICollectionViewDelegate 160 #pragma mark UICollectionViewDelegate
152 - (void)collectionView:(UICollectionView*)collectionView 161 - (void)collectionView:(UICollectionView*)collectionView
153 didSelectItemAtIndexPath:(NSIndexPath*)indexPath { 162 didSelectItemAtIndexPath:(NSIndexPath*)indexPath {
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
247 base::mac::ObjCCastStrict<CollectionViewSwitchCell>( 256 base::mac::ObjCCastStrict<CollectionViewSwitchCell>(
248 [self.collectionView cellForItemAtIndexPath:switchPath]); 257 [self.collectionView cellForItemAtIndexPath:switchPath]);
249 258
250 DCHECK_EQ(switchCell.switchView, sender); 259 DCHECK_EQ(switchCell.switchView, sender);
251 BOOL isOn = switchCell.switchView.isOn; 260 BOOL isOn = switchCell.switchView.isOn;
252 switchItem.on = isOn; 261 switchItem.on = isOn;
253 [_translationEnabled setValue:isOn]; 262 [_translationEnabled setValue:isOn];
254 } 263 }
255 264
256 @end 265 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698