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" |
(...skipping 11 matching lines...) Expand all Loading... |
22 #import "ios/chrome/browser/ui/collection_view/cells/collection_view_footer_item
.h" | 22 #import "ios/chrome/browser/ui/collection_view/cells/collection_view_footer_item
.h" |
23 #import "ios/chrome/browser/ui/collection_view/cells/collection_view_switch_item
.h" | 23 #import "ios/chrome/browser/ui/collection_view/cells/collection_view_switch_item
.h" |
24 #import "ios/chrome/browser/ui/collection_view/cells/collection_view_text_item.h
" | 24 #import "ios/chrome/browser/ui/collection_view/cells/collection_view_text_item.h
" |
25 #import "ios/chrome/browser/ui/collection_view/collection_view_model.h" | 25 #import "ios/chrome/browser/ui/collection_view/collection_view_model.h" |
26 #import "ios/chrome/browser/ui/icons/chrome_icon.h" | 26 #import "ios/chrome/browser/ui/icons/chrome_icon.h" |
27 #import "ios/chrome/browser/ui/settings/cells/account_control_item.h" | 27 #import "ios/chrome/browser/ui/settings/cells/account_control_item.h" |
28 #import "ios/chrome/browser/ui/settings/cells/account_signin_item.h" | 28 #import "ios/chrome/browser/ui/settings/cells/account_signin_item.h" |
29 #import "ios/chrome/browser/ui/settings/cells/autofill_data_item.h" | 29 #import "ios/chrome/browser/ui/settings/cells/autofill_data_item.h" |
30 #import "ios/chrome/browser/ui/settings/cells/autofill_edit_item.h" | 30 #import "ios/chrome/browser/ui/settings/cells/autofill_edit_item.h" |
31 #import "ios/chrome/browser/ui/settings/cells/native_app_item.h" | 31 #import "ios/chrome/browser/ui/settings/cells/native_app_item.h" |
| 32 #import "ios/chrome/browser/ui/settings/cells/signin_promo_item.h" |
32 #import "ios/chrome/browser/ui/settings/cells/sync_switch_item.h" | 33 #import "ios/chrome/browser/ui/settings/cells/sync_switch_item.h" |
33 #import "ios/chrome/browser/ui/settings/cells/text_and_error_item.h" | 34 #import "ios/chrome/browser/ui/settings/cells/text_and_error_item.h" |
34 #import "ios/chrome/browser/ui/uikit_ui_util.h" | 35 #import "ios/chrome/browser/ui/uikit_ui_util.h" |
35 #import "ios/public/provider/chrome/browser/chrome_browser_provider.h" | 36 #import "ios/public/provider/chrome/browser/chrome_browser_provider.h" |
36 #import "ios/public/provider/chrome/browser/signin/signin_resources_provider.h" | 37 #import "ios/public/provider/chrome/browser/signin/signin_resources_provider.h" |
37 #import "ios/third_party/material_components_ios/src/components/CollectionCells/
src/MaterialCollectionCells.h" | 38 #import "ios/third_party/material_components_ios/src/components/CollectionCells/
src/MaterialCollectionCells.h" |
38 #import "ios/third_party/material_components_ios/src/components/Palettes/src/Mat
erialPalettes.h" | 39 #import "ios/third_party/material_components_ios/src/components/Palettes/src/Mat
erialPalettes.h" |
39 #import "ios/third_party/material_roboto_font_loader_ios/src/src/MaterialRobotoF
ontLoader.h" | 40 #import "ios/third_party/material_roboto_font_loader_ios/src/src/MaterialRobotoF
ontLoader.h" |
40 | 41 |
41 namespace { | 42 namespace { |
(...skipping 20 matching lines...) Expand all Loading... |
62 ItemTypeDetailLeftLong, | 63 ItemTypeDetailLeftLong, |
63 ItemTypeDetailRightLong, | 64 ItemTypeDetailRightLong, |
64 ItemTypeDetailBothLong, | 65 ItemTypeDetailBothLong, |
65 ItemTypeSwitchBasic, | 66 ItemTypeSwitchBasic, |
66 ItemTypeSwitchDynamicHeight, | 67 ItemTypeSwitchDynamicHeight, |
67 ItemTypeSwitchSync, | 68 ItemTypeSwitchSync, |
68 ItemTypeHeader, | 69 ItemTypeHeader, |
69 ItemTypeAccountDetail, | 70 ItemTypeAccountDetail, |
70 ItemTypeAccountCheckMark, | 71 ItemTypeAccountCheckMark, |
71 ItemTypeAccountSignIn, | 72 ItemTypeAccountSignIn, |
| 73 ItemTypeSigninPromo, |
72 ItemTypeApp, | 74 ItemTypeApp, |
73 ItemTypePaymentsSingleLine, | 75 ItemTypePaymentsSingleLine, |
74 ItemTypePaymentsDynamicHeight, | 76 ItemTypePaymentsDynamicHeight, |
75 ItemTypeAutofillDynamicHeight, | 77 ItemTypeAutofillDynamicHeight, |
76 ItemTypeAutofillCVC, | 78 ItemTypeAutofillCVC, |
77 ItemTypeAutofillStatus, | 79 ItemTypeAutofillStatus, |
78 ItemTypeAutofillStorageSwitch, | 80 ItemTypeAutofillStorageSwitch, |
79 ItemTypeAccountControlDynamicHeight, | 81 ItemTypeAccountControlDynamicHeight, |
80 ItemTypeFooter, | 82 ItemTypeFooter, |
81 }; | 83 }; |
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
283 toSectionWithIdentifier:SectionIdentifierPayments]; | 285 toSectionWithIdentifier:SectionIdentifierPayments]; |
284 | 286 |
285 // Account cells. | 287 // Account cells. |
286 [model addSectionWithIdentifier:SectionIdentifierAccountCell]; | 288 [model addSectionWithIdentifier:SectionIdentifierAccountCell]; |
287 [model addItem:[self accountItemDetailWithError] | 289 [model addItem:[self accountItemDetailWithError] |
288 toSectionWithIdentifier:SectionIdentifierAccountCell]; | 290 toSectionWithIdentifier:SectionIdentifierAccountCell]; |
289 [model addItem:[self accountItemCheckMark] | 291 [model addItem:[self accountItemCheckMark] |
290 toSectionWithIdentifier:SectionIdentifierAccountCell]; | 292 toSectionWithIdentifier:SectionIdentifierAccountCell]; |
291 [model addItem:[self accountSignInItem] | 293 [model addItem:[self accountSignInItem] |
292 toSectionWithIdentifier:SectionIdentifierAccountCell]; | 294 toSectionWithIdentifier:SectionIdentifierAccountCell]; |
| 295 [model addItem:[self signinPromoItem] |
| 296 toSectionWithIdentifier:SectionIdentifierAccountCell]; |
293 | 297 |
294 // Account control cells. | 298 // Account control cells. |
295 [model addSectionWithIdentifier:SectionIdentifierAccountControlCell]; | 299 [model addSectionWithIdentifier:SectionIdentifierAccountControlCell]; |
296 [model addItem:[self accountControlItem] | 300 [model addItem:[self accountControlItem] |
297 toSectionWithIdentifier:SectionIdentifierAccountControlCell]; | 301 toSectionWithIdentifier:SectionIdentifierAccountControlCell]; |
298 [model addItem:[self accountControlItemWithExtraLongText] | 302 [model addItem:[self accountControlItemWithExtraLongText] |
299 toSectionWithIdentifier:SectionIdentifierAccountControlCell]; | 303 toSectionWithIdentifier:SectionIdentifierAccountControlCell]; |
300 | 304 |
301 // Footers. | 305 // Footers. |
302 [model addSectionWithIdentifier:SectionIdentifierFooters]; | 306 [model addSectionWithIdentifier:SectionIdentifierFooters]; |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
343 case ItemTypeFooter: | 347 case ItemTypeFooter: |
344 case ItemTypeSwitchDynamicHeight: | 348 case ItemTypeSwitchDynamicHeight: |
345 case ItemTypeSwitchSync: | 349 case ItemTypeSwitchSync: |
346 case ItemTypeAccountControlDynamicHeight: | 350 case ItemTypeAccountControlDynamicHeight: |
347 case ItemTypeTextError: | 351 case ItemTypeTextError: |
348 case ItemTypeAutofillCVC: | 352 case ItemTypeAutofillCVC: |
349 case ItemTypeAutofillStatus: | 353 case ItemTypeAutofillStatus: |
350 case ItemTypeAutofillStorageSwitch: | 354 case ItemTypeAutofillStorageSwitch: |
351 case ItemTypePaymentsDynamicHeight: | 355 case ItemTypePaymentsDynamicHeight: |
352 case ItemTypeAutofillDynamicHeight: | 356 case ItemTypeAutofillDynamicHeight: |
| 357 case ItemTypeSigninPromo: |
353 return [MDCCollectionViewCell | 358 return [MDCCollectionViewCell |
354 cr_preferredHeightForWidth:CGRectGetWidth(collectionView.bounds) | 359 cr_preferredHeightForWidth:CGRectGetWidth(collectionView.bounds) |
355 forItem:item]; | 360 forItem:item]; |
356 case ItemTypeApp: | 361 case ItemTypeApp: |
357 return MDCCellDefaultOneLineWithAvatarHeight; | 362 return MDCCellDefaultOneLineWithAvatarHeight; |
358 case ItemTypeAccountDetail: | 363 case ItemTypeAccountDetail: |
359 return MDCCellDefaultTwoLineHeight; | 364 return MDCCellDefaultTwoLineHeight; |
360 case ItemTypeAccountCheckMark: | 365 case ItemTypeAccountCheckMark: |
361 return MDCCellDefaultTwoLineHeight; | 366 return MDCCellDefaultTwoLineHeight; |
362 case ItemTypeAccountSignIn: | 367 case ItemTypeAccountSignIn: |
(...skipping 28 matching lines...) Expand all Loading... |
391 return YES; | 396 return YES; |
392 default: | 397 default: |
393 return NO; | 398 return NO; |
394 } | 399 } |
395 } | 400 } |
396 | 401 |
397 - (BOOL)collectionView:(nonnull UICollectionView*)collectionView | 402 - (BOOL)collectionView:(nonnull UICollectionView*)collectionView |
398 hidesInkViewAtIndexPath:(nonnull NSIndexPath*)indexPath { | 403 hidesInkViewAtIndexPath:(nonnull NSIndexPath*)indexPath { |
399 NSInteger sectionIdentifier = | 404 NSInteger sectionIdentifier = |
400 [self.collectionViewModel sectionIdentifierForSection:indexPath.section]; | 405 [self.collectionViewModel sectionIdentifierForSection:indexPath.section]; |
401 switch (sectionIdentifier) { | 406 if (sectionIdentifier == SectionIdentifierFooters) |
402 case SectionIdentifierFooters: | 407 return YES; |
| 408 CollectionViewItem* item = |
| 409 [self.collectionViewModel itemAtIndexPath:indexPath]; |
| 410 switch (item.type) { |
403 case ItemTypeSwitchBasic: | 411 case ItemTypeSwitchBasic: |
404 case ItemTypeSwitchDynamicHeight: | 412 case ItemTypeSwitchDynamicHeight: |
405 case ItemTypeApp: | 413 case ItemTypeApp: |
406 case ItemTypeAutofillStorageSwitch: | 414 case ItemTypeAutofillStorageSwitch: |
407 case ItemTypeSwitchSync: | 415 case ItemTypeSwitchSync: |
| 416 case ItemTypeSigninPromo: |
408 return YES; | 417 return YES; |
409 default: | 418 default: |
410 return NO; | 419 return NO; |
411 } | 420 } |
412 } | 421 } |
413 | 422 |
414 #pragma mark Item models | 423 #pragma mark Item models |
415 | 424 |
416 - (CollectionViewItem*)accountItemDetailWithError { | 425 - (CollectionViewItem*)accountItemDetailWithError { |
417 CollectionViewAccountItem* accountItemDetail = | 426 CollectionViewAccountItem* accountItemDetail = |
(...skipping 28 matching lines...) Expand all Loading... |
446 AccountSignInItem* accountSignInItem = [[[AccountSignInItem alloc] | 455 AccountSignInItem* accountSignInItem = [[[AccountSignInItem alloc] |
447 initWithType:ItemTypeAccountSignIn] autorelease]; | 456 initWithType:ItemTypeAccountSignIn] autorelease]; |
448 accountSignInItem.image = | 457 accountSignInItem.image = |
449 CircularImageFromImage(ios::GetChromeBrowserProvider() | 458 CircularImageFromImage(ios::GetChromeBrowserProvider() |
450 ->GetSigninResourcesProvider() | 459 ->GetSigninResourcesProvider() |
451 ->GetDefaultAvatar(), | 460 ->GetDefaultAvatar(), |
452 kHorizontalImageFixedSize); | 461 kHorizontalImageFixedSize); |
453 return accountSignInItem; | 462 return accountSignInItem; |
454 } | 463 } |
455 | 464 |
| 465 - (CollectionViewItem*)signinPromoItem { |
| 466 SigninPromoItem* signinPromoItem = |
| 467 [[[SigninPromoItem alloc] initWithType:ItemTypeSigninPromo] autorelease]; |
| 468 signinPromoItem.profileName = @"Jane"; |
| 469 signinPromoItem.profileEmail = @"jane@example.com"; |
| 470 signinPromoItem.profileImage = |
| 471 CircularImageFromImage(ios::GetChromeBrowserProvider() |
| 472 ->GetSigninResourcesProvider() |
| 473 ->GetDefaultAvatar(), |
| 474 kHorizontalImageFixedSize); |
| 475 return signinPromoItem; |
| 476 } |
| 477 |
456 - (CollectionViewItem*)accountControlItem { | 478 - (CollectionViewItem*)accountControlItem { |
457 AccountControlItem* item = [[[AccountControlItem alloc] | 479 AccountControlItem* item = [[[AccountControlItem alloc] |
458 initWithType:ItemTypeAccountControlDynamicHeight] autorelease]; | 480 initWithType:ItemTypeAccountControlDynamicHeight] autorelease]; |
459 item.image = [UIImage imageNamed:@"settings_sync"]; | 481 item.image = [UIImage imageNamed:@"settings_sync"]; |
460 item.text = @"Account Sync Settings"; | 482 item.text = @"Account Sync Settings"; |
461 item.detailText = @"Detail text"; | 483 item.detailText = @"Detail text"; |
462 item.accessoryType = MDCCollectionViewCellAccessoryDisclosureIndicator; | 484 item.accessoryType = MDCCollectionViewCellAccessoryDisclosureIndicator; |
463 return item; | 485 return item; |
464 } | 486 } |
465 | 487 |
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
640 CollectionViewFooterItem* footerItem = [[[CollectionViewFooterItem alloc] | 662 CollectionViewFooterItem* footerItem = [[[CollectionViewFooterItem alloc] |
641 initWithType:ItemTypeFooter] autorelease]; | 663 initWithType:ItemTypeFooter] autorelease]; |
642 footerItem.text = @"Hello Hello Hello Hello Hello Hello Hello Hello Hello " | 664 footerItem.text = @"Hello Hello Hello Hello Hello Hello Hello Hello Hello " |
643 @"Hello Hello Hello Hello Hello Hello Hello Hello Hello " | 665 @"Hello Hello Hello Hello Hello Hello Hello Hello Hello " |
644 @"Hello Hello Hello Hello Hello Hello Hello Hello Hello "; | 666 @"Hello Hello Hello Hello Hello Hello Hello Hello Hello "; |
645 footerItem.image = [UIImage imageNamed:@"app_icon_placeholder"]; | 667 footerItem.image = [UIImage imageNamed:@"app_icon_placeholder"]; |
646 return footerItem; | 668 return footerItem; |
647 } | 669 } |
648 | 670 |
649 @end | 671 @end |
OLD | NEW |