OLD | NEW |
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" |
(...skipping 10 matching lines...) Expand all Loading... |
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_item.h
" | 22 #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" | 23 #import "ios/chrome/browser/ui/collection_view/collection_view_model.h" |
24 #import "ios/chrome/browser/ui/settings/settings_utils.h" | 24 #import "ios/chrome/browser/ui/settings/settings_utils.h" |
25 #import "ios/chrome/browser/ui/settings/utils/pref_backed_boolean.h" | 25 #import "ios/chrome/browser/ui/settings/utils/pref_backed_boolean.h" |
26 #include "ios/chrome/browser/ui/uikit_ui_util.h" | 26 #include "ios/chrome/browser/ui/uikit_ui_util.h" |
27 #include "ios/chrome/grit/ios_chromium_strings.h" | 27 #include "ios/chrome/grit/ios_chromium_strings.h" |
28 #include "ios/chrome/grit/ios_strings.h" | 28 #include "ios/chrome/grit/ios_strings.h" |
29 #import "ios/third_party/material_components_ios/src/components/Palettes/src/Mat
erialPalettes.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/Snackbar/src/Mat
erialSnackbar.h" | 30 #import "ios/third_party/material_components_ios/src/components/Snackbar/src/Mat
erialSnackbar.h" |
31 #import "ios/third_party/material_roboto_font_loader_ios/src/src/MaterialRobotoF
ontLoader.h" | 31 #import "ios/third_party/material_components_ios/src/components/Typography/src/M
aterialTypography.h" |
32 #include "ui/base/l10n/l10n_util.h" | 32 #include "ui/base/l10n/l10n_util.h" |
33 #include "url/gurl.h" | 33 #include "url/gurl.h" |
34 | 34 |
35 namespace { | 35 namespace { |
36 | 36 |
37 typedef NS_ENUM(NSInteger, SectionIdentifier) { | 37 typedef NS_ENUM(NSInteger, SectionIdentifier) { |
38 SectionIdentifierTranslate = kSectionIdentifierEnumZero, | 38 SectionIdentifierTranslate = kSectionIdentifierEnumZero, |
39 SectionIdentifierFooter, | 39 SectionIdentifierFooter, |
40 }; | 40 }; |
41 | 41 |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
100 _translationItem.get().text = | 100 _translationItem.get().text = |
101 l10n_util::GetNSString(IDS_IOS_TRANSLATE_SETTING); | 101 l10n_util::GetNSString(IDS_IOS_TRANSLATE_SETTING); |
102 _translationItem.get().on = [_translationEnabled value]; | 102 _translationItem.get().on = [_translationEnabled value]; |
103 [model addItem:_translationItem | 103 [model addItem:_translationItem |
104 toSectionWithIdentifier:SectionIdentifierTranslate]; | 104 toSectionWithIdentifier:SectionIdentifierTranslate]; |
105 | 105 |
106 CollectionViewTextItem* resetTranslate = [[[CollectionViewTextItem alloc] | 106 CollectionViewTextItem* resetTranslate = [[[CollectionViewTextItem alloc] |
107 initWithType:ItemTypeResetTranslate] autorelease]; | 107 initWithType:ItemTypeResetTranslate] autorelease]; |
108 resetTranslate.text = l10n_util::GetNSString(IDS_IOS_TRANSLATE_SETTING_RESET); | 108 resetTranslate.text = l10n_util::GetNSString(IDS_IOS_TRANSLATE_SETTING_RESET); |
109 resetTranslate.accessibilityTraits |= UIAccessibilityTraitButton; | 109 resetTranslate.accessibilityTraits |= UIAccessibilityTraitButton; |
| 110 resetTranslate.textFont = [MDCTypography body2Font]; |
110 [model addItem:resetTranslate | 111 [model addItem:resetTranslate |
111 toSectionWithIdentifier:SectionIdentifierTranslate]; | 112 toSectionWithIdentifier:SectionIdentifierTranslate]; |
112 | 113 |
113 // Footer Section | 114 // Footer Section |
114 [model addSectionWithIdentifier:SectionIdentifierFooter]; | 115 [model addSectionWithIdentifier:SectionIdentifierFooter]; |
115 CollectionViewFooterItem* footer = [[[CollectionViewFooterItem alloc] | 116 CollectionViewFooterItem* footer = [[[CollectionViewFooterItem alloc] |
116 initWithType:ItemTypeFooter] autorelease]; | 117 initWithType:ItemTypeFooter] autorelease]; |
117 footer.text = l10n_util::GetNSString(IDS_IOS_TRANSLATE_SETTING_DESCRIPTION); | 118 footer.text = l10n_util::GetNSString(IDS_IOS_TRANSLATE_SETTING_DESCRIPTION); |
118 footer.linkURL = google_util::AppendGoogleLocaleParam( | 119 footer.linkURL = google_util::AppendGoogleLocaleParam( |
119 GURL(kTranslateLearnMoreUrl), | 120 GURL(kTranslateLearnMoreUrl), |
(...skipping 13 matching lines...) Expand all Loading... |
133 | 134 |
134 switch (itemType) { | 135 switch (itemType) { |
135 case ItemTypeTranslate: { | 136 case ItemTypeTranslate: { |
136 CollectionViewSwitchCell* switchCell = | 137 CollectionViewSwitchCell* switchCell = |
137 base::mac::ObjCCastStrict<CollectionViewSwitchCell>(cell); | 138 base::mac::ObjCCastStrict<CollectionViewSwitchCell>(cell); |
138 [switchCell.switchView addTarget:self | 139 [switchCell.switchView addTarget:self |
139 action:@selector(translateToggled:) | 140 action:@selector(translateToggled:) |
140 forControlEvents:UIControlEventValueChanged]; | 141 forControlEvents:UIControlEventValueChanged]; |
141 break; | 142 break; |
142 } | 143 } |
143 case ItemTypeResetTranslate: { | |
144 MDCCollectionViewTextCell* textCell = | |
145 base::mac::ObjCCastStrict<MDCCollectionViewTextCell>(cell); | |
146 textCell.textLabel.font = | |
147 [[MDFRobotoFontLoader sharedInstance] mediumFontOfSize:14]; | |
148 break; | |
149 } | |
150 default: | 144 default: |
151 break; | 145 break; |
152 } | 146 } |
153 | 147 |
154 return cell; | 148 return cell; |
155 } | 149 } |
156 | 150 |
157 #pragma mark UICollectionViewDelegate | 151 #pragma mark UICollectionViewDelegate |
158 - (void)collectionView:(UICollectionView*)collectionView | 152 - (void)collectionView:(UICollectionView*)collectionView |
159 didSelectItemAtIndexPath:(NSIndexPath*)indexPath { | 153 didSelectItemAtIndexPath:(NSIndexPath*)indexPath { |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
253 base::mac::ObjCCastStrict<CollectionViewSwitchCell>( | 247 base::mac::ObjCCastStrict<CollectionViewSwitchCell>( |
254 [self.collectionView cellForItemAtIndexPath:switchPath]); | 248 [self.collectionView cellForItemAtIndexPath:switchPath]); |
255 | 249 |
256 DCHECK_EQ(switchCell.switchView, sender); | 250 DCHECK_EQ(switchCell.switchView, sender); |
257 BOOL isOn = switchCell.switchView.isOn; | 251 BOOL isOn = switchCell.switchView.isOn; |
258 switchItem.on = isOn; | 252 switchItem.on = isOn; |
259 [_translationEnabled setValue:isOn]; | 253 [_translationEnabled setValue:isOn]; |
260 } | 254 } |
261 | 255 |
262 @end | 256 @end |
OLD | NEW |