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 #include "components/autofill/core/browser/autofill_data_util.h" | 10 #include "components/autofill/core/browser/autofill_data_util.h" |
11 #include "components/autofill/core/browser/credit_card.h" | 11 #include "components/autofill/core/browser/credit_card.h" |
12 #include "components/grit/components_scaled_resources.h" | 12 #include "components/grit/components_scaled_resources.h" |
13 #import "ios/chrome/browser/payments/cells/autofill_profile_item.h" | 13 #import "ios/chrome/browser/payments/cells/autofill_profile_item.h" |
14 #import "ios/chrome/browser/payments/cells/payments_text_item.h" | 14 #import "ios/chrome/browser/payments/cells/payments_text_item.h" |
15 #import "ios/chrome/browser/payments/cells/price_item.h" | 15 #import "ios/chrome/browser/payments/cells/price_item.h" |
16 #import "ios/chrome/browser/ui/authentication/account_control_item.h" | 16 #import "ios/chrome/browser/ui/authentication/account_control_item.h" |
17 #import "ios/chrome/browser/ui/authentication/signin_promo_item.h" | |
18 #import "ios/chrome/browser/ui/authentication/signin_promo_view_mediator.h" | |
lpromero
2017/03/22 16:18:49
You shouldn't need the mediator here. You need to
jlebel
2017/03/24 20:59:10
I need to alloc a SigninPromoViewMediator instance
lpromero
2017/03/27 13:14:46
Can't you just use here:
@interface MyConfigurato
| |
17 #import "ios/chrome/browser/ui/autofill/cells/cvc_item.h" | 19 #import "ios/chrome/browser/ui/autofill/cells/cvc_item.h" |
18 #import "ios/chrome/browser/ui/autofill/cells/status_item.h" | 20 #import "ios/chrome/browser/ui/autofill/cells/status_item.h" |
19 #import "ios/chrome/browser/ui/autofill/cells/storage_switch_item.h" | 21 #import "ios/chrome/browser/ui/autofill/cells/storage_switch_item.h" |
20 #import "ios/chrome/browser/ui/collection_view/cells/MDCCollectionViewCell+Chrom e.h" | 22 #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" | 23 #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" | 24 #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" | 25 #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" | 26 #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 " | 27 #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" | 28 #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" | 29 #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" | 30 #import "ios/chrome/browser/ui/content_suggestions/content_suggestions_footer_it em.h" |
29 #import "ios/chrome/browser/ui/icons/chrome_icon.h" | 31 #import "ios/chrome/browser/ui/icons/chrome_icon.h" |
30 #import "ios/chrome/browser/ui/settings/cells/account_signin_item.h" | 32 #import "ios/chrome/browser/ui/settings/cells/account_signin_item.h" |
31 #import "ios/chrome/browser/ui/settings/cells/autofill_data_item.h" | 33 #import "ios/chrome/browser/ui/settings/cells/autofill_data_item.h" |
32 #import "ios/chrome/browser/ui/settings/cells/autofill_edit_item.h" | 34 #import "ios/chrome/browser/ui/settings/cells/autofill_edit_item.h" |
33 #import "ios/chrome/browser/ui/settings/cells/native_app_item.h" | 35 #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" | 36 #import "ios/chrome/browser/ui/settings/cells/sync_switch_item.h" |
36 #import "ios/chrome/browser/ui/settings/cells/text_and_error_item.h" | 37 #import "ios/chrome/browser/ui/settings/cells/text_and_error_item.h" |
37 #import "ios/chrome/browser/ui/uikit_ui_util.h" | 38 #import "ios/chrome/browser/ui/uikit_ui_util.h" |
38 #import "ios/public/provider/chrome/browser/chrome_browser_provider.h" | 39 #import "ios/public/provider/chrome/browser/chrome_browser_provider.h" |
39 #import "ios/public/provider/chrome/browser/signin/signin_resources_provider.h" | 40 #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" | 41 #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" | 42 #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" | 43 #import "ios/third_party/material_roboto_font_loader_ios/src/src/MaterialRobotoF ontLoader.h" |
43 | 44 |
44 namespace { | 45 namespace { |
(...skipping 21 matching lines...) Expand all Loading... | |
66 ItemTypeDetailLeftLong, | 67 ItemTypeDetailLeftLong, |
67 ItemTypeDetailRightLong, | 68 ItemTypeDetailRightLong, |
68 ItemTypeDetailBothLong, | 69 ItemTypeDetailBothLong, |
69 ItemTypeSwitchBasic, | 70 ItemTypeSwitchBasic, |
70 ItemTypeSwitchDynamicHeight, | 71 ItemTypeSwitchDynamicHeight, |
71 ItemTypeSwitchSync, | 72 ItemTypeSwitchSync, |
72 ItemTypeHeader, | 73 ItemTypeHeader, |
73 ItemTypeAccountDetail, | 74 ItemTypeAccountDetail, |
74 ItemTypeAccountCheckMark, | 75 ItemTypeAccountCheckMark, |
75 ItemTypeAccountSignIn, | 76 ItemTypeAccountSignIn, |
76 ItemTypeSigninPromo, | 77 ItemTypeColdStartSigninPromo, |
78 ItemTypeWarmStartSigninPromo, | |
lpromero
2017/03/24 10:36:20
BTW, what happened to the hot version?
jlebel
2017/03/24 20:59:10
It will be done by the current code.
| |
77 ItemTypeApp, | 79 ItemTypeApp, |
78 ItemTypePaymentsSingleLine, | 80 ItemTypePaymentsSingleLine, |
79 ItemTypePaymentsDynamicHeight, | 81 ItemTypePaymentsDynamicHeight, |
80 ItemTypeAutofillDynamicHeight, | 82 ItemTypeAutofillDynamicHeight, |
81 ItemTypeAutofillCVC, | 83 ItemTypeAutofillCVC, |
82 ItemTypeAutofillStatus, | 84 ItemTypeAutofillStatus, |
83 ItemTypeAutofillStorageSwitch, | 85 ItemTypeAutofillStorageSwitch, |
84 ItemTypeAccountControlDynamicHeight, | 86 ItemTypeAccountControlDynamicHeight, |
85 ItemTypeFooter, | 87 ItemTypeFooter, |
86 ItemTypeContentSuggestions, | 88 ItemTypeContentSuggestions, |
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
289 toSectionWithIdentifier:SectionIdentifierPayments]; | 291 toSectionWithIdentifier:SectionIdentifierPayments]; |
290 | 292 |
291 // Account cells. | 293 // Account cells. |
292 [model addSectionWithIdentifier:SectionIdentifierAccountCell]; | 294 [model addSectionWithIdentifier:SectionIdentifierAccountCell]; |
293 [model addItem:[self accountItemDetailWithError] | 295 [model addItem:[self accountItemDetailWithError] |
294 toSectionWithIdentifier:SectionIdentifierAccountCell]; | 296 toSectionWithIdentifier:SectionIdentifierAccountCell]; |
295 [model addItem:[self accountItemCheckMark] | 297 [model addItem:[self accountItemCheckMark] |
296 toSectionWithIdentifier:SectionIdentifierAccountCell]; | 298 toSectionWithIdentifier:SectionIdentifierAccountCell]; |
297 [model addItem:[self accountSignInItem] | 299 [model addItem:[self accountSignInItem] |
298 toSectionWithIdentifier:SectionIdentifierAccountCell]; | 300 toSectionWithIdentifier:SectionIdentifierAccountCell]; |
299 [model addItem:[self signinPromoItem] | 301 [model addItem:[self coldStartSigninPromoItem] |
302 toSectionWithIdentifier:SectionIdentifierAccountCell]; | |
303 [model addItem:[self warmStartSigninPromoItem] | |
300 toSectionWithIdentifier:SectionIdentifierAccountCell]; | 304 toSectionWithIdentifier:SectionIdentifierAccountCell]; |
301 | 305 |
302 // Account control cells. | 306 // Account control cells. |
303 [model addSectionWithIdentifier:SectionIdentifierAccountControlCell]; | 307 [model addSectionWithIdentifier:SectionIdentifierAccountControlCell]; |
304 [model addItem:[self accountControlItem] | 308 [model addItem:[self accountControlItem] |
305 toSectionWithIdentifier:SectionIdentifierAccountControlCell]; | 309 toSectionWithIdentifier:SectionIdentifierAccountControlCell]; |
306 [model addItem:[self accountControlItemWithExtraLongText] | 310 [model addItem:[self accountControlItemWithExtraLongText] |
307 toSectionWithIdentifier:SectionIdentifierAccountControlCell]; | 311 toSectionWithIdentifier:SectionIdentifierAccountControlCell]; |
308 | 312 |
309 // Content Suggestions cells. | 313 // Content Suggestions cells. |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
359 case ItemTypeFooter: | 363 case ItemTypeFooter: |
360 case ItemTypeSwitchDynamicHeight: | 364 case ItemTypeSwitchDynamicHeight: |
361 case ItemTypeSwitchSync: | 365 case ItemTypeSwitchSync: |
362 case ItemTypeAccountControlDynamicHeight: | 366 case ItemTypeAccountControlDynamicHeight: |
363 case ItemTypeTextError: | 367 case ItemTypeTextError: |
364 case ItemTypeAutofillCVC: | 368 case ItemTypeAutofillCVC: |
365 case ItemTypeAutofillStatus: | 369 case ItemTypeAutofillStatus: |
366 case ItemTypeAutofillStorageSwitch: | 370 case ItemTypeAutofillStorageSwitch: |
367 case ItemTypePaymentsDynamicHeight: | 371 case ItemTypePaymentsDynamicHeight: |
368 case ItemTypeAutofillDynamicHeight: | 372 case ItemTypeAutofillDynamicHeight: |
369 case ItemTypeSigninPromo: | 373 case ItemTypeColdStartSigninPromo: |
374 case ItemTypeWarmStartSigninPromo: | |
370 return [MDCCollectionViewCell | 375 return [MDCCollectionViewCell |
371 cr_preferredHeightForWidth:CGRectGetWidth(collectionView.bounds) | 376 cr_preferredHeightForWidth:CGRectGetWidth(collectionView.bounds) |
372 forItem:item]; | 377 forItem:item]; |
373 case ItemTypeApp: | 378 case ItemTypeApp: |
374 return MDCCellDefaultOneLineWithAvatarHeight; | 379 return MDCCellDefaultOneLineWithAvatarHeight; |
375 case ItemTypeAccountDetail: | 380 case ItemTypeAccountDetail: |
376 return MDCCellDefaultTwoLineHeight; | 381 return MDCCellDefaultTwoLineHeight; |
377 case ItemTypeAccountCheckMark: | 382 case ItemTypeAccountCheckMark: |
378 return MDCCellDefaultTwoLineHeight; | 383 return MDCCellDefaultTwoLineHeight; |
379 case ItemTypeAccountSignIn: | 384 case ItemTypeAccountSignIn: |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
413 | 418 |
414 - (BOOL)collectionView:(nonnull UICollectionView*)collectionView | 419 - (BOOL)collectionView:(nonnull UICollectionView*)collectionView |
415 hidesInkViewAtIndexPath:(nonnull NSIndexPath*)indexPath { | 420 hidesInkViewAtIndexPath:(nonnull NSIndexPath*)indexPath { |
416 NSInteger sectionIdentifier = | 421 NSInteger sectionIdentifier = |
417 [self.collectionViewModel sectionIdentifierForSection:indexPath.section]; | 422 [self.collectionViewModel sectionIdentifierForSection:indexPath.section]; |
418 if (sectionIdentifier == SectionIdentifierFooters) | 423 if (sectionIdentifier == SectionIdentifierFooters) |
419 return YES; | 424 return YES; |
420 CollectionViewItem* item = | 425 CollectionViewItem* item = |
421 [self.collectionViewModel itemAtIndexPath:indexPath]; | 426 [self.collectionViewModel itemAtIndexPath:indexPath]; |
422 switch (item.type) { | 427 switch (item.type) { |
428 case ItemTypeApp: | |
429 case ItemTypeAutofillStorageSwitch: | |
430 case ItemTypeColdStartSigninPromo: | |
423 case ItemTypeSwitchBasic: | 431 case ItemTypeSwitchBasic: |
424 case ItemTypeSwitchDynamicHeight: | 432 case ItemTypeSwitchDynamicHeight: |
425 case ItemTypeApp: | |
426 case ItemTypeAutofillStorageSwitch: | |
427 case ItemTypeSwitchSync: | 433 case ItemTypeSwitchSync: |
428 case ItemTypeSigninPromo: | 434 case ItemTypeWarmStartSigninPromo: |
429 return YES; | 435 return YES; |
430 default: | 436 default: |
431 return NO; | 437 return NO; |
432 } | 438 } |
433 } | 439 } |
434 | 440 |
435 #pragma mark Item models | 441 #pragma mark Item models |
436 | 442 |
437 - (CollectionViewItem*)accountItemDetailWithError { | 443 - (CollectionViewItem*)accountItemDetailWithError { |
438 CollectionViewAccountItem* accountItemDetail = | 444 CollectionViewAccountItem* accountItemDetail = |
(...skipping 28 matching lines...) Expand all Loading... | |
467 AccountSignInItem* accountSignInItem = [[[AccountSignInItem alloc] | 473 AccountSignInItem* accountSignInItem = [[[AccountSignInItem alloc] |
468 initWithType:ItemTypeAccountSignIn] autorelease]; | 474 initWithType:ItemTypeAccountSignIn] autorelease]; |
469 accountSignInItem.image = | 475 accountSignInItem.image = |
470 CircularImageFromImage(ios::GetChromeBrowserProvider() | 476 CircularImageFromImage(ios::GetChromeBrowserProvider() |
471 ->GetSigninResourcesProvider() | 477 ->GetSigninResourcesProvider() |
472 ->GetDefaultAvatar(), | 478 ->GetDefaultAvatar(), |
473 kHorizontalImageFixedSize); | 479 kHorizontalImageFixedSize); |
474 return accountSignInItem; | 480 return accountSignInItem; |
475 } | 481 } |
476 | 482 |
477 - (CollectionViewItem*)signinPromoItem { | 483 - (CollectionViewItem*)coldStartSigninPromoItem { |
478 SigninPromoItem* signinPromoItem = | 484 SigninPromoViewMediator* signinPromoViewMediator = |
479 [[[SigninPromoItem alloc] initWithType:ItemTypeSigninPromo] autorelease]; | 485 [[SigninPromoViewMediator alloc] init]; |
480 signinPromoItem.profileName = @"Jane"; | 486 SigninPromoItem* signinPromoItem = [[[SigninPromoItem alloc] |
481 signinPromoItem.profileEmail = @"jane@example.com"; | 487 initWithType:ItemTypeWarmStartSigninPromo |
482 signinPromoItem.profileImage = | 488 signinPromoViewConfigurator:signinPromoViewMediator] autorelease]; |
483 CircularImageFromImage(ios::GetChromeBrowserProvider() | |
484 ->GetSigninResourcesProvider() | |
485 ->GetDefaultAvatar(), | |
486 kHorizontalImageFixedSize); | |
487 return signinPromoItem; | 489 return signinPromoItem; |
488 } | 490 } |
489 | 491 |
492 - (CollectionViewItem*)warmStartSigninPromoItem { | |
493 SigninPromoViewMediator* signinPromoViewMediator = | |
494 [[SigninPromoViewMediator alloc] init]; | |
495 signinPromoViewMediator.userFullName = @"John Doe"; | |
496 signinPromoViewMediator.userEmail = @"johndoe@example.com"; | |
497 SigninPromoItem* signinPromoItem = [[[SigninPromoItem alloc] | |
498 initWithType:ItemTypeColdStartSigninPromo | |
499 signinPromoViewConfigurator:signinPromoViewMediator] autorelease]; | |
500 return signinPromoItem; | |
501 } | |
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; |
498 } | 511 } |
499 | 512 |
(...skipping 197 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 |