| 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/accounts_collection_view_controller.h" | 5 #import "ios/chrome/browser/ui/settings/accounts_collection_view_controller.h" |
| 6 | 6 |
| 7 #import "base/ios/weak_nsobject.h" | 7 #import "base/ios/weak_nsobject.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 "base/metrics/user_metrics.h" | 10 #include "base/metrics/user_metrics.h" |
| (...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 236 toSectionWithIdentifier:SectionIdentifierSignOut]; | 236 toSectionWithIdentifier:SectionIdentifierSignOut]; |
| 237 } | 237 } |
| 238 | 238 |
| 239 #pragma mark - Model objects | 239 #pragma mark - Model objects |
| 240 | 240 |
| 241 - (CollectionViewItem*)header { | 241 - (CollectionViewItem*)header { |
| 242 CollectionViewTextItem* header = [ | 242 CollectionViewTextItem* header = [ |
| 243 [[CollectionViewTextItem alloc] initWithType:ItemTypeHeader] autorelease]; | 243 [[CollectionViewTextItem alloc] initWithType:ItemTypeHeader] autorelease]; |
| 244 header.text = l10n_util::GetNSString(IDS_IOS_OPTIONS_ACCOUNTS_DESCRIPTION); | 244 header.text = l10n_util::GetNSString(IDS_IOS_OPTIONS_ACCOUNTS_DESCRIPTION); |
| 245 header.accessibilityIdentifier = kSettingsHeaderId; | 245 header.accessibilityIdentifier = kSettingsHeaderId; |
| 246 header.textColor = [[MDCPalette greyPalette] tint500]; |
| 246 return header; | 247 return header; |
| 247 } | 248 } |
| 248 | 249 |
| 249 - (CollectionViewItem*)accountItem:(ChromeIdentity*)identity { | 250 - (CollectionViewItem*)accountItem:(ChromeIdentity*)identity { |
| 250 CollectionViewAccountItem* item = [[[CollectionViewAccountItem alloc] | 251 CollectionViewAccountItem* item = [[[CollectionViewAccountItem alloc] |
| 251 initWithType:ItemTypeAccount] autorelease]; | 252 initWithType:ItemTypeAccount] autorelease]; |
| 252 [self updateAccountItem:item withIdentity:identity]; | 253 [self updateAccountItem:item withIdentity:identity]; |
| 253 return item; | 254 return item; |
| 254 } | 255 } |
| 255 | 256 |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 363 [self showGoogleActivitySettings]; | 364 [self showGoogleActivitySettings]; |
| 364 break; | 365 break; |
| 365 case ItemTypeSignOut: | 366 case ItemTypeSignOut: |
| 366 [self showDisconnect]; | 367 [self showDisconnect]; |
| 367 break; | 368 break; |
| 368 default: | 369 default: |
| 369 break; | 370 break; |
| 370 } | 371 } |
| 371 } | 372 } |
| 372 | 373 |
| 373 #pragma mark - UICollectionViewDataSource | |
| 374 | |
| 375 - (UICollectionReusableView*)collectionView:(UICollectionView*)collectionView | |
| 376 viewForSupplementaryElementOfKind:(NSString*)kind | |
| 377 atIndexPath:(NSIndexPath*)indexPath { | |
| 378 UICollectionReusableView* view = [super collectionView:collectionView | |
| 379 viewForSupplementaryElementOfKind:kind | |
| 380 atIndexPath:indexPath]; | |
| 381 MDCCollectionViewTextCell* textCell = | |
| 382 base::mac::ObjCCast<MDCCollectionViewTextCell>(view); | |
| 383 if (textCell) { | |
| 384 textCell.textLabel.textColor = [[MDCPalette greyPalette] tint500]; | |
| 385 } | |
| 386 return view; | |
| 387 } | |
| 388 | |
| 389 #pragma mark - MDCCollectionViewStylingDelegate | 374 #pragma mark - MDCCollectionViewStylingDelegate |
| 390 | 375 |
| 391 - (CGFloat)collectionView:(UICollectionView*)collectionView | 376 - (CGFloat)collectionView:(UICollectionView*)collectionView |
| 392 cellHeightAtIndexPath:(NSIndexPath*)indexPath { | 377 cellHeightAtIndexPath:(NSIndexPath*)indexPath { |
| 393 CollectionViewItem* item = | 378 CollectionViewItem* item = |
| 394 [self.collectionViewModel itemAtIndexPath:indexPath]; | 379 [self.collectionViewModel itemAtIndexPath:indexPath]; |
| 395 if (item.type == ItemTypeGoogleActivityControls || | 380 if (item.type == ItemTypeGoogleActivityControls || |
| 396 item.type == ItemTypeSync) { | 381 item.type == ItemTypeSync) { |
| 397 return [MDCCollectionViewCell | 382 return [MDCCollectionViewCell |
| 398 cr_preferredHeightForWidth:CGRectGetWidth(collectionView.bounds) | 383 cr_preferredHeightForWidth:CGRectGetWidth(collectionView.bounds) |
| (...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 667 [self.collectionViewModel indexPathForItem:item | 652 [self.collectionViewModel indexPathForItem:item |
| 668 inSectionWithIdentifier:SectionIdentifierAccounts]; | 653 inSectionWithIdentifier:SectionIdentifierAccounts]; |
| 669 [self.collectionView reloadItemsAtIndexPaths:@[ indexPath ]]; | 654 [self.collectionView reloadItemsAtIndexPaths:@[ indexPath ]]; |
| 670 } | 655 } |
| 671 | 656 |
| 672 - (void)onChromeIdentityServiceWillBeDestroyed { | 657 - (void)onChromeIdentityServiceWillBeDestroyed { |
| 673 _identityServiceObserver.reset(); | 658 _identityServiceObserver.reset(); |
| 674 } | 659 } |
| 675 | 660 |
| 676 @end | 661 @end |
| OLD | NEW |