Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(96)

Unified Diff: ios/chrome/browser/ui/payments/payment_method_selection_mediator.mm

Issue 2938673003: [Payment Request] Selector view edit mode (Closed)
Patch Set: Addressed comments Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: ios/chrome/browser/ui/payments/payment_method_selection_mediator.mm
diff --git a/ios/chrome/browser/ui/payments/payment_method_selection_mediator.mm b/ios/chrome/browser/ui/payments/payment_method_selection_mediator.mm
index 885959a547befc3bdc9d437ad182d2d1ef576459..53f748aa784f87a78a3c66823cedec5f9b0d41e7 100644
--- a/ios/chrome/browser/ui/payments/payment_method_selection_mediator.mm
+++ b/ios/chrome/browser/ui/payments/payment_method_selection_mediator.mm
@@ -36,7 +36,7 @@ using ::payment_request_util::GetBillingAddressLabelFromAutofillProfile;
@property(nonatomic, assign) PaymentRequest* paymentRequest;
// The selectable items to display in the collection.
-@property(nonatomic, strong) NSArray<PaymentMethodItem*>* items;
+@property(nonatomic, strong) NSMutableArray<PaymentMethodItem*>* items;
@end
@@ -52,13 +52,17 @@ using ::payment_request_util::GetBillingAddressLabelFromAutofillProfile;
if (self) {
_paymentRequest = paymentRequest;
_selectedItemIndex = NSUIntegerMax;
- _items = [self createItems];
+ [self loadItems];
}
return self;
}
#pragma mark - PaymentRequestSelectorViewControllerDataSource
+- (BOOL)allowsEditMode {
+ return YES;
+}
+
- (CollectionViewItem*)headerItem {
return nil;
}
@@ -74,13 +78,12 @@ using ::payment_request_util::GetBillingAddressLabelFromAutofillProfile;
return addButtonItem;
}
-#pragma mark - Helper methods
+#pragma mark - Public methods
-- (NSArray<PaymentMethodItem*>*)createItems {
+- (void)loadItems {
const std::vector<autofill::CreditCard*>& paymentMethods =
_paymentRequest->credit_cards();
- NSMutableArray<PaymentMethodItem*>* items =
- [NSMutableArray arrayWithCapacity:paymentMethods.size()];
+ _items = [NSMutableArray arrayWithCapacity:paymentMethods.size()];
for (size_t index = 0; index < paymentMethods.size(); ++index) {
autofill::CreditCard* paymentMethod = paymentMethods[index];
DCHECK(paymentMethod);
@@ -108,9 +111,8 @@ using ::payment_request_util::GetBillingAddressLabelFromAutofillProfile;
if (_paymentRequest->selected_credit_card() == paymentMethod)
_selectedItemIndex = index;
- [items addObject:item];
+ [_items addObject:item];
}
- return items;
}
@end

Powered by Google App Engine
This is Rietveld 408576698