Commit e7e94349 authored by redatawfik's avatar redatawfik Committed by Commit Bot

Update TableView Cells Individually

1- Add Method "updateCellForItemType" which update TableView
   cells with received text.
2- Update only cells which there is received data from scanner for it.

Bug: 984545
Change-Id: Iddf9d7002bb18f0416c170d39f492831bac21f9b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1774633Reviewed-by: default avatarJavier Ernesto Flores Robles <javierrobles@chromium.org>
Reviewed-by: default avatarGauthier Ambard <gambard@chromium.org>
Commit-Queue: Reda Tawfik <redatawfik@google.com>
Cr-Commit-Position: refs/heads/master@{#692002}
parent cc547a84
......@@ -210,14 +210,23 @@ typedef NS_ENUM(NSInteger, ItemType) {
- (void)setCreditCardNumber:(NSString*)cardNumber
expirationMonth:(NSString*)expirationMonth
expirationYear:(NSString*)expirationYear {
self.cardNumber = cardNumber;
self.expirationMonth = expirationMonth;
self.expirationYear = expirationYear;
if (cardNumber) {
[self updateCellForItemType:ItemTypeCardNumber
inSectionIdentifier:SectionIdentifierCreditCardDetails
withText:cardNumber];
}
// TODO(crbug.com/984545): Update each tableview cell independently.
// Reload the model.
[self loadModel];
[self.tableView reloadData];
if (expirationMonth) {
[self updateCellForItemType:ItemTypeExpirationMonth
inSectionIdentifier:SectionIdentifierCreditCardDetails
withText:expirationMonth];
}
if (expirationYear) {
[self updateCellForItemType:ItemTypeExpirationYear
inSectionIdentifier:SectionIdentifierCreditCardDetails
withText:expirationYear];
}
}
#pragma mark - Private
......@@ -264,6 +273,20 @@ typedef NS_ENUM(NSInteger, ItemType) {
return text;
}
// Updates TableView cell of |itemType| in |sectionIdentifier| textfieldValue
// with |text|.
- (void)updateCellForItemType:(NSInteger)itemType
inSectionIdentifier:(NSInteger)sectionIdentifier
withText:(NSString*)text {
NSIndexPath* path =
[self.tableViewModel indexPathForItemType:itemType
sectionIdentifier:sectionIdentifier];
AutofillEditItem* item = base::mac::ObjCCastStrict<AutofillEditItem>(
[self.tableViewModel itemAtIndexPath:path]);
item.textFieldValue = text;
[self reconfigureCellsForItems:@[ item ]];
}
// Dimisses this view controller when Cancel button is tapped.
- (void)handleCancelButton:(id)sender {
[self.delegate addCreditCardViewControllerDidCancel:self];
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment