| 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/payments/payment_request_view_controller.h" | 5 #import "ios/chrome/browser/payments/payment_request_view_controller.h" | 
| 6 | 6 | 
| 7 #import "base/ios/weak_nsobject.h" | 7 #import "base/ios/weak_nsobject.h" | 
| 8 #include "base/mac/foundation_util.h" | 8 #include "base/mac/foundation_util.h" | 
| 9 #include "base/mac/objc_property_releaser.h" | 9 #include "base/mac/objc_property_releaser.h" | 
| 10 #include "base/mac/scoped_nsobject.h" | 10 #include "base/mac/scoped_nsobject.h" | 
| (...skipping 24 matching lines...) Expand all  Loading... | 
| 35 #import "ios/third_party/material_components_ios/src/components/CollectionCells/
     src/MaterialCollectionCells.h" | 35 #import "ios/third_party/material_components_ios/src/components/CollectionCells/
     src/MaterialCollectionCells.h" | 
| 36 #import "ios/third_party/material_components_ios/src/components/Typography/src/M
     aterialTypography.h" | 36 #import "ios/third_party/material_components_ios/src/components/Typography/src/M
     aterialTypography.h" | 
| 37 #import "ios/third_party/material_roboto_font_loader_ios/src/src/MaterialRobotoF
     ontLoader.h" | 37 #import "ios/third_party/material_roboto_font_loader_ios/src/src/MaterialRobotoF
     ontLoader.h" | 
| 38 #include "ui/base/l10n/l10n_util.h" | 38 #include "ui/base/l10n/l10n_util.h" | 
| 39 #include "ui/base/resource/resource_bundle.h" | 39 #include "ui/base/resource/resource_bundle.h" | 
| 40 | 40 | 
| 41 using payment_request_util::NameLabelFromAutofillProfile; | 41 using payment_request_util::NameLabelFromAutofillProfile; | 
| 42 using payment_request_util::AddressLabelFromAutofillProfile; | 42 using payment_request_util::AddressLabelFromAutofillProfile; | 
| 43 using payment_request_util::PhoneNumberLabelFromAutofillProfile; | 43 using payment_request_util::PhoneNumberLabelFromAutofillProfile; | 
| 44 | 44 | 
| 45 NSString* const kPaymentRequestCollectionViewId = | 45 NSString* const kPaymentRequestCollectionViewID = | 
| 46     @"kPaymentRequestCollectionViewId"; | 46     @"kPaymentRequestCollectionViewID"; | 
| 47 | 47 | 
| 48 namespace { | 48 namespace { | 
| 49 | 49 | 
| 50 const CGFloat kButtonEdgeInset = 9; | 50 const CGFloat kButtonEdgeInset = 9; | 
| 51 const CGFloat kSeparatorEdgeInset = 14; | 51 const CGFloat kSeparatorEdgeInset = 14; | 
| 52 | 52 | 
| 53 typedef NS_ENUM(NSInteger, SectionIdentifier) { | 53 typedef NS_ENUM(NSInteger, SectionIdentifier) { | 
| 54   SectionIdentifierSummary = kSectionIdentifierEnumZero, | 54   SectionIdentifierSummary = kSectionIdentifierEnumZero, | 
| 55   SectionIdentifierShipping, | 55   SectionIdentifierShipping, | 
| 56   SectionIdentifierPayment, | 56   SectionIdentifierPayment, | 
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 106 @synthesize pageHost = _pageHost; | 106 @synthesize pageHost = _pageHost; | 
| 107 | 107 | 
| 108 - (instancetype)initWithPaymentRequest:(PaymentRequest*)paymentRequest { | 108 - (instancetype)initWithPaymentRequest:(PaymentRequest*)paymentRequest { | 
| 109   DCHECK(paymentRequest); | 109   DCHECK(paymentRequest); | 
| 110   if ((self = [super initWithStyle:CollectionViewControllerStyleAppBar])) { | 110   if ((self = [super initWithStyle:CollectionViewControllerStyleAppBar])) { | 
| 111     _propertyReleaser_PaymentRequestViewController.Init( | 111     _propertyReleaser_PaymentRequestViewController.Init( | 
| 112         self, [PaymentRequestViewController class]); | 112         self, [PaymentRequestViewController class]); | 
| 113 | 113 | 
| 114     [self setTitle:l10n_util::GetNSString(IDS_IOS_PAYMENT_REQUEST_TITLE)]; | 114     [self setTitle:l10n_util::GetNSString(IDS_IOS_PAYMENT_REQUEST_TITLE)]; | 
| 115 | 115 | 
| 116     // Set up left (cancel) button. | 116     // Set up leading (cancel) button. | 
| 117     _cancelButton.reset([[UIBarButtonItem alloc] | 117     _cancelButton.reset([[UIBarButtonItem alloc] | 
| 118         initWithTitle:l10n_util::GetNSString( | 118         initWithTitle:l10n_util::GetNSString( | 
| 119                           IDS_IOS_PAYMENT_REQUEST_CANCEL_BUTTON) | 119                           IDS_IOS_PAYMENT_REQUEST_CANCEL_BUTTON) | 
| 120                 style:UIBarButtonItemStylePlain | 120                 style:UIBarButtonItemStylePlain | 
| 121                target:nil | 121                target:nil | 
| 122                action:@selector(onCancel)]); | 122                action:@selector(onCancel)]); | 
| 123     [_cancelButton setTitleTextAttributes:@{ | 123     [_cancelButton setTitleTextAttributes:@{ | 
| 124       NSForegroundColorAttributeName : [UIColor lightGrayColor] | 124       NSForegroundColorAttributeName : [UIColor lightGrayColor] | 
| 125     } | 125     } | 
| 126                                  forState:UIControlStateDisabled]; | 126                                  forState:UIControlStateDisabled]; | 
| 127     [_cancelButton | 127     [_cancelButton | 
| 128         setAccessibilityLabel:l10n_util::GetNSString(IDS_ACCNAME_CANCEL)]; | 128         setAccessibilityLabel:l10n_util::GetNSString(IDS_ACCNAME_CANCEL)]; | 
| 129     [self navigationItem].leftBarButtonItem = _cancelButton; | 129     [self navigationItem].leftBarButtonItem = _cancelButton; | 
| 130 | 130 | 
| 131     // Set up right (pay) button. | 131     // Set up trailing (pay) button. | 
| 132     _payButton.reset([[MDCFlatButton alloc] init]); | 132     _payButton.reset([[MDCFlatButton alloc] init]); | 
| 133     [_payButton | 133     [_payButton | 
| 134         setTitle:l10n_util::GetNSString(IDS_IOS_PAYMENT_REQUEST_PAY_BUTTON) | 134         setTitle:l10n_util::GetNSString(IDS_IOS_PAYMENT_REQUEST_PAY_BUTTON) | 
| 135         forState:UIControlStateNormal]; | 135         forState:UIControlStateNormal]; | 
| 136     [_payButton setBackgroundColor:[[MDCPalette cr_bluePalette] tint500] | 136     [_payButton setBackgroundColor:[[MDCPalette cr_bluePalette] tint500] | 
| 137                           forState:UIControlStateNormal]; | 137                           forState:UIControlStateNormal]; | 
| 138     [_payButton setInkColor:[UIColor colorWithWhite:1 alpha:0.2]]; | 138     [_payButton setInkColor:[UIColor colorWithWhite:1 alpha:0.2]]; | 
| 139     [_payButton setBackgroundColor:[UIColor grayColor] | 139     [_payButton setBackgroundColor:[UIColor grayColor] | 
| 140                           forState:UIControlStateDisabled]; | 140                           forState:UIControlStateDisabled]; | 
| 141     [_payButton addTarget:nil | 141     [_payButton addTarget:nil | 
| (...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 305         IDS_IOS_PAYMENT_REQUEST_ADD_SHIPPING_ADDRESS_BUTTON) | 305         IDS_IOS_PAYMENT_REQUEST_ADD_SHIPPING_ADDRESS_BUTTON) | 
| 306         uppercaseStringWithLocale:[NSLocale currentLocale]]; | 306         uppercaseStringWithLocale:[NSLocale currentLocale]]; | 
| 307   } | 307   } | 
| 308   paymentMethodItem.accessibilityTraits |= UIAccessibilityTraitButton; | 308   paymentMethodItem.accessibilityTraits |= UIAccessibilityTraitButton; | 
| 309   [model addItem:paymentMethodItem | 309   [model addItem:paymentMethodItem | 
| 310       toSectionWithIdentifier:SectionIdentifierPayment]; | 310       toSectionWithIdentifier:SectionIdentifierPayment]; | 
| 311 } | 311 } | 
| 312 | 312 | 
| 313 - (void)viewDidLoad { | 313 - (void)viewDidLoad { | 
| 314   [super viewDidLoad]; | 314   [super viewDidLoad]; | 
| 315   self.collectionView.accessibilityIdentifier = kPaymentRequestCollectionViewId; | 315   self.collectionView.accessibilityIdentifier = kPaymentRequestCollectionViewID; | 
| 316 | 316 | 
| 317   // Customize collection view settings. | 317   // Customize collection view settings. | 
| 318   self.styler.cellStyle = MDCCollectionViewCellStyleCard; | 318   self.styler.cellStyle = MDCCollectionViewCellStyleCard; | 
| 319   self.styler.separatorInset = | 319   self.styler.separatorInset = | 
| 320       UIEdgeInsetsMake(0, kSeparatorEdgeInset, 0, kSeparatorEdgeInset); | 320       UIEdgeInsetsMake(0, kSeparatorEdgeInset, 0, kSeparatorEdgeInset); | 
| 321 } | 321 } | 
| 322 | 322 | 
| 323 - (void)updatePaymentSummaryWithTotalValueChanged:(BOOL)totalValueChanged { | 323 - (void)updatePaymentSummaryWithTotalValueChanged:(BOOL)totalValueChanged { | 
| 324   [self fillPaymentSummaryItem:_paymentSummaryItem | 324   [self fillPaymentSummaryItem:_paymentSummaryItem | 
| 325                withPaymentItem:_paymentRequest->payment_details().total | 325                withPaymentItem:_paymentRequest->payment_details().total | 
| (...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 502   NSInteger type = [self.collectionViewModel itemTypeForIndexPath:indexPath]; | 502   NSInteger type = [self.collectionViewModel itemTypeForIndexPath:indexPath]; | 
| 503   if (type == ItemTypeSummaryTotal && | 503   if (type == ItemTypeSummaryTotal && | 
| 504       _paymentRequest->payment_details().display_items.empty()) { | 504       _paymentRequest->payment_details().display_items.empty()) { | 
| 505     return YES; | 505     return YES; | 
| 506   } else { | 506   } else { | 
| 507     return NO; | 507     return NO; | 
| 508   } | 508   } | 
| 509 } | 509 } | 
| 510 | 510 | 
| 511 @end | 511 @end | 
| OLD | NEW | 
|---|