| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/material_cell_catalog_view_controller.h" | 5 #import "ios/chrome/browser/ui/settings/material_cell_catalog_view_controller.h" |
| 6 | 6 |
| 7 #import <UIKit/UIKit.h> | 7 #import <UIKit/UIKit.h> |
| 8 | 8 |
| 9 #import "base/mac/foundation_util.h" | 9 #import "base/mac/foundation_util.h" |
| 10 #import "base/mac/scoped_nsobject.h" |
| 10 #include "components/autofill/core/browser/autofill_data_util.h" | 11 #include "components/autofill/core/browser/autofill_data_util.h" |
| 11 #include "components/autofill/core/browser/credit_card.h" | 12 #include "components/autofill/core/browser/credit_card.h" |
| 12 #include "components/grit/components_scaled_resources.h" | 13 #include "components/grit/components_scaled_resources.h" |
| 13 #import "ios/chrome/browser/payments/cells/autofill_profile_item.h" | 14 #import "ios/chrome/browser/payments/cells/autofill_profile_item.h" |
| 14 #import "ios/chrome/browser/payments/cells/payments_text_item.h" | 15 #import "ios/chrome/browser/payments/cells/payments_text_item.h" |
| 15 #import "ios/chrome/browser/payments/cells/price_item.h" | 16 #import "ios/chrome/browser/payments/cells/price_item.h" |
| 16 #import "ios/chrome/browser/ui/authentication/account_control_item.h" | 17 #import "ios/chrome/browser/ui/authentication/account_control_item.h" |
| 18 #import "ios/chrome/browser/ui/authentication/signin_promo_item.h" |
| 19 #import "ios/chrome/browser/ui/authentication/signin_promo_view_mediator.h" |
| 17 #import "ios/chrome/browser/ui/autofill/cells/cvc_item.h" | 20 #import "ios/chrome/browser/ui/autofill/cells/cvc_item.h" |
| 18 #import "ios/chrome/browser/ui/autofill/cells/status_item.h" | 21 #import "ios/chrome/browser/ui/autofill/cells/status_item.h" |
| 19 #import "ios/chrome/browser/ui/autofill/cells/storage_switch_item.h" | 22 #import "ios/chrome/browser/ui/autofill/cells/storage_switch_item.h" |
| 20 #import "ios/chrome/browser/ui/collection_view/cells/MDCCollectionViewCell+Chrom
e.h" | 23 #import "ios/chrome/browser/ui/collection_view/cells/MDCCollectionViewCell+Chrom
e.h" |
| 21 #import "ios/chrome/browser/ui/collection_view/cells/collection_view_account_ite
m.h" | 24 #import "ios/chrome/browser/ui/collection_view/cells/collection_view_account_ite
m.h" |
| 22 #import "ios/chrome/browser/ui/collection_view/cells/collection_view_detail_item
.h" | 25 #import "ios/chrome/browser/ui/collection_view/cells/collection_view_detail_item
.h" |
| 23 #import "ios/chrome/browser/ui/collection_view/cells/collection_view_footer_item
.h" | 26 #import "ios/chrome/browser/ui/collection_view/cells/collection_view_footer_item
.h" |
| 24 #import "ios/chrome/browser/ui/collection_view/cells/collection_view_switch_item
.h" | 27 #import "ios/chrome/browser/ui/collection_view/cells/collection_view_switch_item
.h" |
| 25 #import "ios/chrome/browser/ui/collection_view/cells/collection_view_text_item.h
" | 28 #import "ios/chrome/browser/ui/collection_view/cells/collection_view_text_item.h
" |
| 26 #import "ios/chrome/browser/ui/collection_view/collection_view_model.h" | 29 #import "ios/chrome/browser/ui/collection_view/collection_view_model.h" |
| 27 #import "ios/chrome/browser/ui/content_suggestions/content_suggestions_article_i
tem.h" | 30 #import "ios/chrome/browser/ui/content_suggestions/content_suggestions_article_i
tem.h" |
| 28 #import "ios/chrome/browser/ui/content_suggestions/content_suggestions_footer_it
em.h" | 31 #import "ios/chrome/browser/ui/content_suggestions/content_suggestions_footer_it
em.h" |
| 29 #import "ios/chrome/browser/ui/icons/chrome_icon.h" | 32 #import "ios/chrome/browser/ui/icons/chrome_icon.h" |
| 30 #import "ios/chrome/browser/ui/settings/cells/account_signin_item.h" | 33 #import "ios/chrome/browser/ui/settings/cells/account_signin_item.h" |
| 31 #import "ios/chrome/browser/ui/settings/cells/autofill_data_item.h" | 34 #import "ios/chrome/browser/ui/settings/cells/autofill_data_item.h" |
| 32 #import "ios/chrome/browser/ui/settings/cells/autofill_edit_item.h" | 35 #import "ios/chrome/browser/ui/settings/cells/autofill_edit_item.h" |
| 33 #import "ios/chrome/browser/ui/settings/cells/native_app_item.h" | 36 #import "ios/chrome/browser/ui/settings/cells/native_app_item.h" |
| 34 #import "ios/chrome/browser/ui/settings/cells/signin_promo_item.h" | |
| 35 #import "ios/chrome/browser/ui/settings/cells/sync_switch_item.h" | 37 #import "ios/chrome/browser/ui/settings/cells/sync_switch_item.h" |
| 36 #import "ios/chrome/browser/ui/settings/cells/text_and_error_item.h" | 38 #import "ios/chrome/browser/ui/settings/cells/text_and_error_item.h" |
| 37 #import "ios/chrome/browser/ui/uikit_ui_util.h" | 39 #import "ios/chrome/browser/ui/uikit_ui_util.h" |
| 38 #import "ios/public/provider/chrome/browser/chrome_browser_provider.h" | 40 #import "ios/public/provider/chrome/browser/chrome_browser_provider.h" |
| 39 #import "ios/public/provider/chrome/browser/signin/signin_resources_provider.h" | 41 #import "ios/public/provider/chrome/browser/signin/signin_resources_provider.h" |
| 40 #import "ios/third_party/material_components_ios/src/components/CollectionCells/
src/MaterialCollectionCells.h" | 42 #import "ios/third_party/material_components_ios/src/components/CollectionCells/
src/MaterialCollectionCells.h" |
| 41 #import "ios/third_party/material_components_ios/src/components/Palettes/src/Mat
erialPalettes.h" | 43 #import "ios/third_party/material_components_ios/src/components/Palettes/src/Mat
erialPalettes.h" |
| 42 #import "ios/third_party/material_roboto_font_loader_ios/src/src/MaterialRobotoF
ontLoader.h" | 44 #import "ios/third_party/material_roboto_font_loader_ios/src/src/MaterialRobotoF
ontLoader.h" |
| 43 | 45 |
| 44 namespace { | 46 namespace { |
| (...skipping 21 matching lines...) Expand all Loading... |
| 66 ItemTypeDetailLeftLong, | 68 ItemTypeDetailLeftLong, |
| 67 ItemTypeDetailRightLong, | 69 ItemTypeDetailRightLong, |
| 68 ItemTypeDetailBothLong, | 70 ItemTypeDetailBothLong, |
| 69 ItemTypeSwitchBasic, | 71 ItemTypeSwitchBasic, |
| 70 ItemTypeSwitchDynamicHeight, | 72 ItemTypeSwitchDynamicHeight, |
| 71 ItemTypeSwitchSync, | 73 ItemTypeSwitchSync, |
| 72 ItemTypeHeader, | 74 ItemTypeHeader, |
| 73 ItemTypeAccountDetail, | 75 ItemTypeAccountDetail, |
| 74 ItemTypeAccountCheckMark, | 76 ItemTypeAccountCheckMark, |
| 75 ItemTypeAccountSignIn, | 77 ItemTypeAccountSignIn, |
| 76 ItemTypeSigninPromo, | 78 ItemTypeColdStateSigninPromo, |
| 79 ItemTypeWarmStateSigninPromo, |
| 77 ItemTypeApp, | 80 ItemTypeApp, |
| 78 ItemTypePaymentsSingleLine, | 81 ItemTypePaymentsSingleLine, |
| 79 ItemTypePaymentsDynamicHeight, | 82 ItemTypePaymentsDynamicHeight, |
| 80 ItemTypeAutofillDynamicHeight, | 83 ItemTypeAutofillDynamicHeight, |
| 81 ItemTypeAutofillCVC, | 84 ItemTypeAutofillCVC, |
| 82 ItemTypeAutofillStatus, | 85 ItemTypeAutofillStatus, |
| 83 ItemTypeAutofillStorageSwitch, | 86 ItemTypeAutofillStorageSwitch, |
| 84 ItemTypeAccountControlDynamicHeight, | 87 ItemTypeAccountControlDynamicHeight, |
| 85 ItemTypeFooter, | 88 ItemTypeFooter, |
| 86 ItemTypeContentSuggestions, | 89 ItemTypeContentSuggestions, |
| 87 }; | 90 }; |
| 88 | 91 |
| 89 // Image fixed horizontal size. | 92 // Image fixed horizontal size. |
| 90 const CGFloat kHorizontalImageFixedSize = 40; | 93 const CGFloat kHorizontalImageFixedSize = 40; |
| 91 | 94 |
| 92 } // namespace | 95 } // namespace |
| 93 | 96 |
| 94 @implementation MaterialCellCatalogViewController | 97 @implementation MaterialCellCatalogViewController { |
| 98 base::scoped_nsobject<SigninPromoViewMediator> _coldStateMediator; |
| 99 base::scoped_nsobject<SigninPromoViewMediator> _warmStateMediator; |
| 100 } |
| 95 | 101 |
| 96 - (instancetype)init { | 102 - (instancetype)init { |
| 97 self = [super initWithStyle:CollectionViewControllerStyleAppBar]; | 103 self = [super initWithStyle:CollectionViewControllerStyleAppBar]; |
| 98 if (self) { | 104 if (self) { |
| 99 [self loadModel]; | 105 [self loadModel]; |
| 100 } | 106 } |
| 101 return self; | 107 return self; |
| 102 } | 108 } |
| 103 | 109 |
| 104 - (void)loadModel { | 110 - (void)loadModel { |
| (...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 289 toSectionWithIdentifier:SectionIdentifierPayments]; | 295 toSectionWithIdentifier:SectionIdentifierPayments]; |
| 290 | 296 |
| 291 // Account cells. | 297 // Account cells. |
| 292 [model addSectionWithIdentifier:SectionIdentifierAccountCell]; | 298 [model addSectionWithIdentifier:SectionIdentifierAccountCell]; |
| 293 [model addItem:[self accountItemDetailWithError] | 299 [model addItem:[self accountItemDetailWithError] |
| 294 toSectionWithIdentifier:SectionIdentifierAccountCell]; | 300 toSectionWithIdentifier:SectionIdentifierAccountCell]; |
| 295 [model addItem:[self accountItemCheckMark] | 301 [model addItem:[self accountItemCheckMark] |
| 296 toSectionWithIdentifier:SectionIdentifierAccountCell]; | 302 toSectionWithIdentifier:SectionIdentifierAccountCell]; |
| 297 [model addItem:[self accountSignInItem] | 303 [model addItem:[self accountSignInItem] |
| 298 toSectionWithIdentifier:SectionIdentifierAccountCell]; | 304 toSectionWithIdentifier:SectionIdentifierAccountCell]; |
| 299 [model addItem:[self signinPromoItem] | 305 [model addItem:[self coldStateSigninPromoItem] |
| 306 toSectionWithIdentifier:SectionIdentifierAccountCell]; |
| 307 [model addItem:[self warmStateSigninPromoItem] |
| 300 toSectionWithIdentifier:SectionIdentifierAccountCell]; | 308 toSectionWithIdentifier:SectionIdentifierAccountCell]; |
| 301 | 309 |
| 302 // Account control cells. | 310 // Account control cells. |
| 303 [model addSectionWithIdentifier:SectionIdentifierAccountControlCell]; | 311 [model addSectionWithIdentifier:SectionIdentifierAccountControlCell]; |
| 304 [model addItem:[self accountControlItem] | 312 [model addItem:[self accountControlItem] |
| 305 toSectionWithIdentifier:SectionIdentifierAccountControlCell]; | 313 toSectionWithIdentifier:SectionIdentifierAccountControlCell]; |
| 306 [model addItem:[self accountControlItemWithExtraLongText] | 314 [model addItem:[self accountControlItemWithExtraLongText] |
| 307 toSectionWithIdentifier:SectionIdentifierAccountControlCell]; | 315 toSectionWithIdentifier:SectionIdentifierAccountControlCell]; |
| 308 | 316 |
| 309 // Content Suggestions cells. | 317 // Content Suggestions cells. |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 359 case ItemTypeFooter: | 367 case ItemTypeFooter: |
| 360 case ItemTypeSwitchDynamicHeight: | 368 case ItemTypeSwitchDynamicHeight: |
| 361 case ItemTypeSwitchSync: | 369 case ItemTypeSwitchSync: |
| 362 case ItemTypeAccountControlDynamicHeight: | 370 case ItemTypeAccountControlDynamicHeight: |
| 363 case ItemTypeTextError: | 371 case ItemTypeTextError: |
| 364 case ItemTypeAutofillCVC: | 372 case ItemTypeAutofillCVC: |
| 365 case ItemTypeAutofillStatus: | 373 case ItemTypeAutofillStatus: |
| 366 case ItemTypeAutofillStorageSwitch: | 374 case ItemTypeAutofillStorageSwitch: |
| 367 case ItemTypePaymentsDynamicHeight: | 375 case ItemTypePaymentsDynamicHeight: |
| 368 case ItemTypeAutofillDynamicHeight: | 376 case ItemTypeAutofillDynamicHeight: |
| 369 case ItemTypeSigninPromo: | 377 case ItemTypeColdStateSigninPromo: |
| 378 case ItemTypeWarmStateSigninPromo: |
| 370 return [MDCCollectionViewCell | 379 return [MDCCollectionViewCell |
| 371 cr_preferredHeightForWidth:CGRectGetWidth(collectionView.bounds) | 380 cr_preferredHeightForWidth:CGRectGetWidth(collectionView.bounds) |
| 372 forItem:item]; | 381 forItem:item]; |
| 373 case ItemTypeApp: | 382 case ItemTypeApp: |
| 374 return MDCCellDefaultOneLineWithAvatarHeight; | 383 return MDCCellDefaultOneLineWithAvatarHeight; |
| 375 case ItemTypeAccountDetail: | 384 case ItemTypeAccountDetail: |
| 376 return MDCCellDefaultTwoLineHeight; | 385 return MDCCellDefaultTwoLineHeight; |
| 377 case ItemTypeAccountCheckMark: | 386 case ItemTypeAccountCheckMark: |
| 378 return MDCCellDefaultTwoLineHeight; | 387 return MDCCellDefaultTwoLineHeight; |
| 379 case ItemTypeAccountSignIn: | 388 case ItemTypeAccountSignIn: |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 413 | 422 |
| 414 - (BOOL)collectionView:(nonnull UICollectionView*)collectionView | 423 - (BOOL)collectionView:(nonnull UICollectionView*)collectionView |
| 415 hidesInkViewAtIndexPath:(nonnull NSIndexPath*)indexPath { | 424 hidesInkViewAtIndexPath:(nonnull NSIndexPath*)indexPath { |
| 416 NSInteger sectionIdentifier = | 425 NSInteger sectionIdentifier = |
| 417 [self.collectionViewModel sectionIdentifierForSection:indexPath.section]; | 426 [self.collectionViewModel sectionIdentifierForSection:indexPath.section]; |
| 418 if (sectionIdentifier == SectionIdentifierFooters) | 427 if (sectionIdentifier == SectionIdentifierFooters) |
| 419 return YES; | 428 return YES; |
| 420 CollectionViewItem* item = | 429 CollectionViewItem* item = |
| 421 [self.collectionViewModel itemAtIndexPath:indexPath]; | 430 [self.collectionViewModel itemAtIndexPath:indexPath]; |
| 422 switch (item.type) { | 431 switch (item.type) { |
| 432 case ItemTypeApp: |
| 433 case ItemTypeAutofillStorageSwitch: |
| 434 case ItemTypeColdStateSigninPromo: |
| 423 case ItemTypeSwitchBasic: | 435 case ItemTypeSwitchBasic: |
| 424 case ItemTypeSwitchDynamicHeight: | 436 case ItemTypeSwitchDynamicHeight: |
| 425 case ItemTypeApp: | |
| 426 case ItemTypeAutofillStorageSwitch: | |
| 427 case ItemTypeSwitchSync: | 437 case ItemTypeSwitchSync: |
| 428 case ItemTypeSigninPromo: | 438 case ItemTypeWarmStateSigninPromo: |
| 429 return YES; | 439 return YES; |
| 430 default: | 440 default: |
| 431 return NO; | 441 return NO; |
| 432 } | 442 } |
| 433 } | 443 } |
| 434 | 444 |
| 435 #pragma mark Item models | 445 #pragma mark Item models |
| 436 | 446 |
| 437 - (CollectionViewItem*)accountItemDetailWithError { | 447 - (CollectionViewItem*)accountItemDetailWithError { |
| 438 CollectionViewAccountItem* accountItemDetail = | 448 CollectionViewAccountItem* accountItemDetail = |
| (...skipping 28 matching lines...) Expand all Loading... |
| 467 AccountSignInItem* accountSignInItem = [[[AccountSignInItem alloc] | 477 AccountSignInItem* accountSignInItem = [[[AccountSignInItem alloc] |
| 468 initWithType:ItemTypeAccountSignIn] autorelease]; | 478 initWithType:ItemTypeAccountSignIn] autorelease]; |
| 469 accountSignInItem.image = | 479 accountSignInItem.image = |
| 470 CircularImageFromImage(ios::GetChromeBrowserProvider() | 480 CircularImageFromImage(ios::GetChromeBrowserProvider() |
| 471 ->GetSigninResourcesProvider() | 481 ->GetSigninResourcesProvider() |
| 472 ->GetDefaultAvatar(), | 482 ->GetDefaultAvatar(), |
| 473 kHorizontalImageFixedSize); | 483 kHorizontalImageFixedSize); |
| 474 return accountSignInItem; | 484 return accountSignInItem; |
| 475 } | 485 } |
| 476 | 486 |
| 477 - (CollectionViewItem*)signinPromoItem { | 487 - (CollectionViewItem*)coldStateSigninPromoItem { |
| 478 SigninPromoItem* signinPromoItem = | 488 _coldStateMediator.reset([[SigninPromoViewMediator alloc] init]); |
| 479 [[[SigninPromoItem alloc] initWithType:ItemTypeSigninPromo] autorelease]; | 489 return |
| 480 signinPromoItem.profileName = @"Jane"; | 490 [[[SigninPromoItem alloc] initWithType:ItemTypeWarmStateSigninPromo |
| 481 signinPromoItem.profileEmail = @"jane@example.com"; | 491 configurator:_coldStateMediator] autorelease]; |
| 482 signinPromoItem.profileImage = | 492 } |
| 483 CircularImageFromImage(ios::GetChromeBrowserProvider() | 493 |
| 484 ->GetSigninResourcesProvider() | 494 - (CollectionViewItem*)warmStateSigninPromoItem { |
| 485 ->GetDefaultAvatar(), | 495 _warmStateMediator.reset([[SigninPromoViewMediator alloc] init]); |
| 486 kHorizontalImageFixedSize); | 496 _warmStateMediator.get().userFullName = @"John Doe"; |
| 487 return signinPromoItem; | 497 _warmStateMediator.get().userEmail = @"johndoe@example.com"; |
| 498 return |
| 499 [[[SigninPromoItem alloc] initWithType:ItemTypeColdStateSigninPromo |
| 500 configurator:_warmStateMediator] autorelease]; |
| 488 } | 501 } |
| 489 | 502 |
| 490 - (CollectionViewItem*)accountControlItem { | 503 - (CollectionViewItem*)accountControlItem { |
| 491 AccountControlItem* item = [[[AccountControlItem alloc] | 504 AccountControlItem* item = [[[AccountControlItem alloc] |
| 492 initWithType:ItemTypeAccountControlDynamicHeight] autorelease]; | 505 initWithType:ItemTypeAccountControlDynamicHeight] autorelease]; |
| 493 item.image = [UIImage imageNamed:@"settings_sync"]; | 506 item.image = [UIImage imageNamed:@"settings_sync"]; |
| 494 item.text = @"Account Sync Settings"; | 507 item.text = @"Account Sync Settings"; |
| 495 item.detailText = @"Detail text"; | 508 item.detailText = @"Detail text"; |
| 496 item.accessoryType = MDCCollectionViewCellAccessoryDisclosureIndicator; | 509 item.accessoryType = MDCCollectionViewCellAccessoryDisclosureIndicator; |
| 497 return item; | 510 return item; |
| (...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 697 - (ContentSuggestionsFooterItem*)contentSuggestionsFooterItem { | 710 - (ContentSuggestionsFooterItem*)contentSuggestionsFooterItem { |
| 698 ContentSuggestionsFooterItem* footerItem = | 711 ContentSuggestionsFooterItem* footerItem = |
| 699 [[ContentSuggestionsFooterItem alloc] | 712 [[ContentSuggestionsFooterItem alloc] |
| 700 initWithType:ItemTypeContentSuggestions | 713 initWithType:ItemTypeContentSuggestions |
| 701 title:@"Footer title" | 714 title:@"Footer title" |
| 702 block:nil]; | 715 block:nil]; |
| 703 return footerItem; | 716 return footerItem; |
| 704 } | 717 } |
| 705 | 718 |
| 706 @end | 719 @end |
| OLD | NEW |