Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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/payments/payment_request_selector_view_controller.h" | 5 #import "ios/chrome/browser/payments/payment_request_selector_view_controller.h" |
| 6 | 6 |
| 7 #include "base/mac/foundation_util.h" | 7 #include "base/mac/foundation_util.h" |
| 8 #include "components/strings/grit/components_strings.h" | 8 #include "components/strings/grit/components_strings.h" |
| 9 #import "ios/chrome/browser/payments/cells/payments_text_item.h" | 9 #import "ios/chrome/browser/payments/cells/payments_text_item.h" |
| 10 #import "ios/chrome/browser/payments/payment_request_selector_view_controller_ac tions.h" | 10 #import "ios/chrome/browser/payments/payment_request_selector_view_controller_ac tions.h" |
| 11 #import "ios/chrome/browser/payments/payment_request_selector_view_controller_da ta_source.h" | 11 #import "ios/chrome/browser/payments/payment_request_selector_view_controller_da ta_source.h" |
| 12 #import "ios/chrome/browser/ui/autofill/cells/status_item.h" | 12 #import "ios/chrome/browser/ui/autofill/cells/status_item.h" |
| 13 #import "ios/chrome/browser/ui/collection_view/cells/MDCCollectionViewCell+Chrom e.h" | 13 #import "ios/chrome/browser/ui/collection_view/cells/MDCCollectionViewCell+Chrom e.h" |
| 14 #import "ios/chrome/browser/ui/collection_view/cells/collection_view_item+collec tion_view_controller.h" | 14 #import "ios/chrome/browser/ui/collection_view/cells/collection_view_item+collec tion_view_controller.h" |
| 15 #import "ios/chrome/browser/ui/collection_view/cells/collection_view_item.h" | 15 #import "ios/chrome/browser/ui/collection_view/cells/collection_view_item.h" |
| 16 #import "ios/chrome/browser/ui/collection_view/collection_view_model.h" | 16 #import "ios/chrome/browser/ui/collection_view/collection_view_model.h" |
| 17 #import "ios/chrome/browser/ui/colors/MDCPalette+CrAdditions.h" | 17 #import "ios/chrome/browser/ui/colors/MDCPalette+CrAdditions.h" |
| 18 #import "ios/chrome/browser/ui/icons/chrome_icon.h" | 18 #import "ios/chrome/browser/ui/icons/chrome_icon.h" |
| 19 #include "ios/chrome/browser/ui/uikit_ui_util.h" | |
| 20 #include "ios/chrome/grit/ios_strings.h" | 19 #include "ios/chrome/grit/ios_strings.h" |
| 21 #include "ios/chrome/grit/ios_theme_resources.h" | 20 #import "ios/third_party/material_components_ios/src/components/Typography/src/M aterialTypography.h" |
| 22 #include "ui/base/l10n/l10n_util.h" | 21 #include "ui/base/l10n/l10n_util.h" |
| 23 | 22 |
| 24 #if !defined(__has_feature) || !__has_feature(objc_arc) | 23 #if !defined(__has_feature) || !__has_feature(objc_arc) |
| 25 #error "This file requires ARC support." | 24 #error "This file requires ARC support." |
| 26 #endif | 25 #endif |
| 27 | 26 |
| 28 namespace { | 27 namespace { |
| 29 | 28 |
| 30 NSString* const kPaymentRequestSelectorCollectionViewAccessibilityID = | 29 NSString* const kPaymentRequestSelectorCollectionViewAccessibilityID = |
| 31 @"kPaymentRequestSelectorCollectionViewAccessibilityID"; | 30 @"kPaymentRequestSelectorCollectionViewAccessibilityID"; |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 123 [super viewDidLoad]; | 122 [super viewDidLoad]; |
| 124 self.collectionView.accessibilityIdentifier = | 123 self.collectionView.accessibilityIdentifier = |
| 125 kPaymentRequestSelectorCollectionViewAccessibilityID; | 124 kPaymentRequestSelectorCollectionViewAccessibilityID; |
| 126 | 125 |
| 127 // Customize collection view settings. | 126 // Customize collection view settings. |
| 128 self.styler.cellStyle = MDCCollectionViewCellStyleCard; | 127 self.styler.cellStyle = MDCCollectionViewCellStyleCard; |
| 129 self.styler.separatorInset = | 128 self.styler.separatorInset = |
| 130 UIEdgeInsetsMake(0, kSeparatorEdgeInset, 0, kSeparatorEdgeInset); | 129 UIEdgeInsetsMake(0, kSeparatorEdgeInset, 0, kSeparatorEdgeInset); |
| 131 } | 130 } |
| 132 | 131 |
| 132 #pragma mark UICollectionViewDataSource | |
|
Moe
2017/04/18 13:58:18
Hopefully we won't need this once the styler API h
gambard
2017/04/18 14:34:46
Acknowledged.
| |
| 133 | |
| 134 - (UICollectionViewCell*)collectionView:(UICollectionView*)collectionView | |
| 135 cellForItemAtIndexPath:(nonnull NSIndexPath*)indexPath { | |
| 136 CollectionViewModel* model = self.collectionViewModel; | |
| 137 | |
| 138 UICollectionViewCell* cell = | |
| 139 [super collectionView:collectionView cellForItemAtIndexPath:indexPath]; | |
| 140 | |
| 141 NSInteger itemType = [model itemTypeForIndexPath:indexPath]; | |
| 142 switch (itemType) { | |
| 143 case ItemTypeHeader: { | |
| 144 if ([cell isKindOfClass:[PaymentsTextCell class]]) { | |
| 145 PaymentsTextCell* textCell = | |
| 146 base::mac::ObjCCastStrict<PaymentsTextCell>(cell); | |
| 147 textCell.textLabel.textColor = | |
| 148 self.dataSource.state == PaymentRequestSelectorStateError | |
| 149 ? [[MDCPalette cr_redPalette] tint600] | |
| 150 : [[MDCPalette greyPalette] tint600]; | |
| 151 } | |
| 152 break; | |
| 153 } | |
| 154 default: | |
| 155 break; | |
| 156 } | |
| 157 | |
| 158 return cell; | |
| 159 } | |
| 160 | |
| 133 #pragma mark UICollectionViewDelegate | 161 #pragma mark UICollectionViewDelegate |
| 134 | 162 |
| 135 - (void)collectionView:(UICollectionView*)collectionView | 163 - (void)collectionView:(UICollectionView*)collectionView |
| 136 didSelectItemAtIndexPath:(NSIndexPath*)indexPath { | 164 didSelectItemAtIndexPath:(NSIndexPath*)indexPath { |
| 137 [super collectionView:collectionView didSelectItemAtIndexPath:indexPath]; | 165 [super collectionView:collectionView didSelectItemAtIndexPath:indexPath]; |
| 138 | 166 |
| 139 CollectionViewModel* model = self.collectionViewModel; | 167 CollectionViewModel* model = self.collectionViewModel; |
| 140 | 168 |
| 141 CollectionViewItem<PaymentsHasAccessoryType>* item = | 169 CollectionViewItem<PaymentsHasAccessoryType>* item = |
| 142 [model itemAtIndexPath:indexPath]; | 170 [model itemAtIndexPath:indexPath]; |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 195 hidesInkViewAtIndexPath:(NSIndexPath*)indexPath { | 223 hidesInkViewAtIndexPath:(NSIndexPath*)indexPath { |
| 196 NSInteger type = [self.collectionViewModel itemTypeForIndexPath:indexPath]; | 224 NSInteger type = [self.collectionViewModel itemTypeForIndexPath:indexPath]; |
| 197 if (type == ItemTypeHeader) { | 225 if (type == ItemTypeHeader) { |
| 198 return YES; | 226 return YES; |
| 199 } else { | 227 } else { |
| 200 return NO; | 228 return NO; |
| 201 } | 229 } |
| 202 } | 230 } |
| 203 | 231 |
| 204 @end | 232 @end |
| OLD | NEW |