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

Unified Diff: ios/chrome/browser/ui/payments/billing_address_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/billing_address_selection_mediator.mm
diff --git a/ios/chrome/browser/ui/payments/billing_address_selection_mediator.mm b/ios/chrome/browser/ui/payments/billing_address_selection_mediator.mm
index 2f1c5f087c051a0407c33633ee8e5f21b5cbad68..472477eec51df9adf09ecbb60006e4c08c7e823f 100644
--- a/ios/chrome/browser/ui/payments/billing_address_selection_mediator.mm
+++ b/ios/chrome/browser/ui/payments/billing_address_selection_mediator.mm
@@ -38,7 +38,7 @@ using ::payment_request_util::GetPhoneNumberLabelFromAutofillProfile;
@property(nonatomic, assign) autofill::AutofillProfile* selectedBillingProfile;
// The selectable items to display in the collection.
-@property(nonatomic, strong) NSArray<AutofillProfileItem*>* items;
+@property(nonatomic, strong) NSMutableArray<AutofillProfileItem*>* items;
@end
@@ -59,13 +59,17 @@ using ::payment_request_util::GetPhoneNumberLabelFromAutofillProfile;
_paymentRequest = paymentRequest;
_selectedBillingProfile = selectedBillingProfile;
_selectedItemIndex = NSUIntegerMax;
- _items = [self createItems];
+ [self loadItems];
}
return self;
}
#pragma mark - PaymentRequestSelectorViewControllerDataSource
+- (BOOL)allowsEditMode {
+ return YES;
+}
+
- (CollectionViewItem*)headerItem {
return nil;
}
@@ -81,14 +85,13 @@ using ::payment_request_util::GetPhoneNumberLabelFromAutofillProfile;
return addButtonItem;
}
-#pragma mark - Helper methods
+#pragma mark - Public methods
-- (NSArray<AutofillProfileItem*>*)createItems {
+- (void)loadItems {
const std::vector<autofill::AutofillProfile*>& billingProfiles =
_paymentRequest->billing_profiles();
- NSMutableArray<AutofillProfileItem*>* items =
- [NSMutableArray arrayWithCapacity:billingProfiles.size()];
+ _items = [NSMutableArray arrayWithCapacity:billingProfiles.size()];
for (size_t index = 0; index < billingProfiles.size(); ++index) {
autofill::AutofillProfile* billingProfile = billingProfiles[index];
DCHECK(billingProfile);
@@ -99,10 +102,8 @@ using ::payment_request_util::GetPhoneNumberLabelFromAutofillProfile;
if (self.selectedBillingProfile == billingProfile)
_selectedItemIndex = index;
- [items addObject:item];
+ [_items addObject:item];
}
-
- return items;
}
@end

Powered by Google App Engine
This is Rietveld 408576698