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/ui/payments/payment_request_edit_view_controller.h" | 5 #import "ios/chrome/browser/ui/payments/payment_request_edit_view_controller.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #import "base/mac/foundation_util.h" | 8 #import "base/mac/foundation_util.h" |
9 #include "base/strings/sys_string_conversions.h" | 9 #include "base/strings/sys_string_conversions.h" |
10 #include "components/strings/grit/components_strings.h" | 10 #include "components/strings/grit/components_strings.h" |
(...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
315 item.textFieldValue = field.value; | 315 item.textFieldValue = field.value; |
316 | 316 |
317 // Cache the options if there are any and set the text field's UIPickerView. | 317 // Cache the options if there are any and set the text field's UIPickerView. |
318 if (options.count) { | 318 if (options.count) { |
319 NSNumber* key = [NSNumber numberWithInt:field.autofillUIType]; | 319 NSNumber* key = [NSNumber numberWithInt:field.autofillUIType]; |
320 [self.options setObject:options forKey:key]; | 320 [self.options setObject:options forKey:key]; |
321 | 321 |
322 UIPickerView* pickerView = [[UIPickerView alloc] initWithFrame:CGRectZero]; | 322 UIPickerView* pickerView = [[UIPickerView alloc] initWithFrame:CGRectZero]; |
323 pickerView.delegate = self; | 323 pickerView.delegate = self; |
324 pickerView.dataSource = self; | 324 pickerView.dataSource = self; |
| 325 pickerView.accessibilityIdentifier = |
| 326 [NSString stringWithFormat:@"%@_pickerView", field.label]; |
325 [self.pickerViews setObject:pickerView forKey:key]; | 327 [self.pickerViews setObject:pickerView forKey:key]; |
326 item.inputView = pickerView; | 328 item.inputView = pickerView; |
| 329 |
| 330 // Set UIPickerView's default selected row. |
| 331 [pickerView reloadAllComponents]; |
| 332 [pickerView selectRow:[options indexOfObject:field.value] |
| 333 inComponent:0 |
| 334 animated:NO]; |
327 } | 335 } |
328 | 336 |
329 // Reload the item. | 337 // Reload the item. |
330 NSIndexPath* indexPath = | 338 NSIndexPath* indexPath = |
331 [self.collectionViewModel indexPathForItemType:ItemTypeTextField | 339 [self.collectionViewModel indexPathForItemType:ItemTypeTextField |
332 sectionIdentifier:field.sectionIdentifier]; | 340 sectionIdentifier:field.sectionIdentifier]; |
333 [self.collectionView reloadItemsAtIndexPaths:@[ indexPath ]]; | 341 [self.collectionView reloadItemsAtIndexPaths:@[ indexPath ]]; |
334 } | 342 } |
335 | 343 |
336 #pragma mark - UITextFieldDelegate | 344 #pragma mark - UITextFieldDelegate |
(...skipping 389 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
726 [_currentEditingCell.textField resignFirstResponder]; | 734 [_currentEditingCell.textField resignFirstResponder]; |
727 | 735 |
728 if (![self validateForm]) | 736 if (![self validateForm]) |
729 return; | 737 return; |
730 | 738 |
731 [self.delegate paymentRequestEditViewController:self | 739 [self.delegate paymentRequestEditViewController:self |
732 didFinishEditingFields:self.fields]; | 740 didFinishEditingFields:self.fields]; |
733 } | 741 } |
734 | 742 |
735 @end | 743 @end |
OLD | NEW |