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/payments/payment_request_view_controller.h" | 5 #import "ios/chrome/browser/ui/payments/payment_request_view_controller.h" |
6 | 6 |
7 #include "base/mac/foundation_util.h" | 7 #include "base/mac/foundation_util.h" |
8 | 8 |
9 #include "base/strings/stringprintf.h" | 9 #include "base/strings/stringprintf.h" |
10 #include "base/strings/sys_string_conversions.h" | 10 #include "base/strings/sys_string_conversions.h" |
(...skipping 390 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
401 self.styler.cellStyle = MDCCollectionViewCellStyleCard; | 401 self.styler.cellStyle = MDCCollectionViewCellStyleCard; |
402 self.styler.separatorInset = | 402 self.styler.separatorInset = |
403 UIEdgeInsetsMake(0, kSeparatorEdgeInset, 0, kSeparatorEdgeInset); | 403 UIEdgeInsetsMake(0, kSeparatorEdgeInset, 0, kSeparatorEdgeInset); |
404 } | 404 } |
405 | 405 |
406 - (void)updatePaymentSummaryWithTotalValueChanged:(BOOL)totalValueChanged { | 406 - (void)updatePaymentSummaryWithTotalValueChanged:(BOOL)totalValueChanged { |
407 [self fillPaymentSummaryItem:_paymentSummaryItem | 407 [self fillPaymentSummaryItem:_paymentSummaryItem |
408 withPaymentItem:_paymentRequest->payment_details().total | 408 withPaymentItem:_paymentRequest->payment_details().total |
409 withTotalValueChanged:totalValueChanged]; | 409 withTotalValueChanged:totalValueChanged]; |
410 NSIndexPath* indexPath = | 410 NSIndexPath* indexPath = |
411 [self.collectionViewModel indexPathForItem:_paymentSummaryItem | 411 [self.collectionViewModel indexPathForItem:_paymentSummaryItem]; |
412 inSectionWithIdentifier:SectionIdentifierSummary]; | |
413 [self.collectionView reloadItemsAtIndexPaths:@[ indexPath ]]; | 412 [self.collectionView reloadItemsAtIndexPaths:@[ indexPath ]]; |
414 } | 413 } |
415 | 414 |
416 - (void)updateSelectedShippingAddressUI { | 415 - (void)updateSelectedShippingAddressUI { |
417 [self fillShippingAddressItem:_selectedShippingAddressItem | 416 [self fillShippingAddressItem:_selectedShippingAddressItem |
418 withAutofillProfile:_paymentRequest->selected_shipping_profile()]; | 417 withAutofillProfile:_paymentRequest->selected_shipping_profile()]; |
419 NSIndexPath* indexPath = | 418 NSIndexPath* indexPath = |
420 [self.collectionViewModel indexPathForItem:_selectedShippingAddressItem | 419 [self.collectionViewModel indexPathForItem:_selectedShippingAddressItem]; |
421 inSectionWithIdentifier:SectionIdentifierShipping]; | |
422 [self.collectionView reloadItemsAtIndexPaths:@[ indexPath ]]; | 420 [self.collectionView reloadItemsAtIndexPaths:@[ indexPath ]]; |
423 } | 421 } |
424 | 422 |
425 - (void)updateSelectedShippingOptionUI { | 423 - (void)updateSelectedShippingOptionUI { |
426 [self fillShippingOptionItem:_selectedShippingOptionItem | 424 [self fillShippingOptionItem:_selectedShippingOptionItem |
427 withOption:_paymentRequest->selected_shipping_option()]; | 425 withOption:_paymentRequest->selected_shipping_option()]; |
428 NSIndexPath* indexPath = | 426 NSIndexPath* indexPath = |
429 [self.collectionViewModel indexPathForItem:_selectedShippingOptionItem | 427 [self.collectionViewModel indexPathForItem:_selectedShippingOptionItem]; |
430 inSectionWithIdentifier:SectionIdentifierShipping]; | |
431 [self.collectionView reloadItemsAtIndexPaths:@[ indexPath ]]; | 428 [self.collectionView reloadItemsAtIndexPaths:@[ indexPath ]]; |
432 } | 429 } |
433 | 430 |
434 - (void)updateSelectedPaymentMethodUI { | 431 - (void)updateSelectedPaymentMethodUI { |
435 [self fillPaymentMethodItem:_selectedPaymentMethodItem | 432 [self fillPaymentMethodItem:_selectedPaymentMethodItem |
436 withCreditCard:_paymentRequest->selected_credit_card()]; | 433 withCreditCard:_paymentRequest->selected_credit_card()]; |
437 NSIndexPath* indexPath = | 434 NSIndexPath* indexPath = |
438 [self.collectionViewModel indexPathForItem:_selectedPaymentMethodItem | 435 [self.collectionViewModel indexPathForItem:_selectedPaymentMethodItem]; |
439 inSectionWithIdentifier:SectionIdentifierPayment]; | |
440 [self.collectionView reloadItemsAtIndexPaths:@[ indexPath ]]; | 436 [self.collectionView reloadItemsAtIndexPaths:@[ indexPath ]]; |
441 } | 437 } |
442 | 438 |
443 #pragma mark - Helper methods | 439 #pragma mark - Helper methods |
444 | 440 |
445 - (void)fillPaymentSummaryItem:(PriceItem*)item | 441 - (void)fillPaymentSummaryItem:(PriceItem*)item |
446 withPaymentItem:(web::PaymentItem)paymentItem | 442 withPaymentItem:(web::PaymentItem)paymentItem |
447 withTotalValueChanged:(BOOL)totalValueChanged { | 443 withTotalValueChanged:(BOOL)totalValueChanged { |
448 item.item = | 444 item.item = |
449 base::SysUTF16ToNSString(_paymentRequest->payment_details().total.label); | 445 base::SysUTF16ToNSString(_paymentRequest->payment_details().total.label); |
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
625 | 621 |
626 - (BOOL)collectionView:(UICollectionView*)collectionView | 622 - (BOOL)collectionView:(UICollectionView*)collectionView |
627 shouldHideItemBackgroundAtIndexPath:(NSIndexPath*)indexPath { | 623 shouldHideItemBackgroundAtIndexPath:(NSIndexPath*)indexPath { |
628 // No background on the footer text item. | 624 // No background on the footer text item. |
629 NSInteger sectionIdentifier = | 625 NSInteger sectionIdentifier = |
630 [self.collectionViewModel sectionIdentifierForSection:indexPath.section]; | 626 [self.collectionViewModel sectionIdentifierForSection:indexPath.section]; |
631 return sectionIdentifier == SectionIdentifierFooter ? YES : NO; | 627 return sectionIdentifier == SectionIdentifierFooter ? YES : NO; |
632 } | 628 } |
633 | 629 |
634 @end | 630 @end |
OLD | NEW |