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

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

Issue 2761263003: Allow CollectionViewModel/Controller queries without SectionIdentifier (Closed)
Patch Set: Cleanup 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 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 211 matching lines...) Expand 10 before | Expand all | Expand 10 after
222 222
223 #pragma mark - BooleanObserver 223 #pragma mark - BooleanObserver
224 224
225 - (void)booleanDidChange:(id<ObservableBoolean>)observableBoolean { 225 - (void)booleanDidChange:(id<ObservableBoolean>)observableBoolean {
226 DCHECK_EQ(observableBoolean, _translationEnabled.get()); 226 DCHECK_EQ(observableBoolean, _translationEnabled.get());
227 227
228 // Update the item. 228 // Update the item.
229 _translationItem.get().on = [_translationEnabled value]; 229 _translationItem.get().on = [_translationEnabled value];
230 230
231 // Update the cell. 231 // Update the cell.
232 [self reconfigureCellsForItems:@[ _translationItem ] 232 [self reconfigureCellsForItems:@[ _translationItem ]];
233 inSectionWithIdentifier:SectionIdentifierTranslate];
234 } 233 }
235 234
236 #pragma mark - Actions 235 #pragma mark - Actions
237 236
238 - (void)translateToggled:(id)sender { 237 - (void)translateToggled:(id)sender {
239 NSIndexPath* switchPath = [self.collectionViewModel 238 NSIndexPath* switchPath = [self.collectionViewModel
240 indexPathForItemType:ItemTypeTranslate 239 indexPathForItemType:ItemTypeTranslate
241 sectionIdentifier:SectionIdentifierTranslate]; 240 sectionIdentifier:SectionIdentifierTranslate];
242 241
243 CollectionViewSwitchItem* switchItem = 242 CollectionViewSwitchItem* switchItem =
244 base::mac::ObjCCastStrict<CollectionViewSwitchItem>( 243 base::mac::ObjCCastStrict<CollectionViewSwitchItem>(
245 [self.collectionViewModel itemAtIndexPath:switchPath]); 244 [self.collectionViewModel itemAtIndexPath:switchPath]);
246 CollectionViewSwitchCell* switchCell = 245 CollectionViewSwitchCell* switchCell =
247 base::mac::ObjCCastStrict<CollectionViewSwitchCell>( 246 base::mac::ObjCCastStrict<CollectionViewSwitchCell>(
248 [self.collectionView cellForItemAtIndexPath:switchPath]); 247 [self.collectionView cellForItemAtIndexPath:switchPath]);
249 248
250 DCHECK_EQ(switchCell.switchView, sender); 249 DCHECK_EQ(switchCell.switchView, sender);
251 BOOL isOn = switchCell.switchView.isOn; 250 BOOL isOn = switchCell.switchView.isOn;
252 switchItem.on = isOn; 251 switchItem.on = isOn;
253 [_translationEnabled setValue:isOn]; 252 [_translationEnabled setValue:isOn];
254 } 253 }
255 254
256 @end 255 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698