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) { ...@@ -210,14 +210,23 @@ typedef NS_ENUM(NSInteger, ItemType) {
- (void)setCreditCardNumber:(NSString*)cardNumber - (void)setCreditCardNumber:(NSString*)cardNumber
expirationMonth:(NSString*)expirationMonth expirationMonth:(NSString*)expirationMonth
expirationYear:(NSString*)expirationYear { expirationYear:(NSString*)expirationYear {
self.cardNumber = cardNumber; if (cardNumber) {
self.expirationMonth = expirationMonth; [self updateCellForItemType:ItemTypeCardNumber
self.expirationYear = expirationYear; inSectionIdentifier:SectionIdentifierCreditCardDetails
withText:cardNumber];
}
// TODO(crbug.com/984545): Update each tableview cell independently. if (expirationMonth) {
// Reload the model. [self updateCellForItemType:ItemTypeExpirationMonth
[self loadModel]; inSectionIdentifier:SectionIdentifierCreditCardDetails
[self.tableView reloadData]; withText:expirationMonth];
}
if (expirationYear) {
[self updateCellForItemType:ItemTypeExpirationYear
inSectionIdentifier:SectionIdentifierCreditCardDetails
withText:expirationYear];
}
} }
#pragma mark - Private #pragma mark - Private
...@@ -264,6 +273,20 @@ typedef NS_ENUM(NSInteger, ItemType) { ...@@ -264,6 +273,20 @@ typedef NS_ENUM(NSInteger, ItemType) {
return text; 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. // Dimisses this view controller when Cancel button is tapped.
- (void)handleCancelButton:(id)sender { - (void)handleCancelButton:(id)sender {
[self.delegate addCreditCardViewControllerDidCancel:self]; [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