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

Add Keyboard Accessory Bar

1- Change parent class of "AutofillAddCreditCardViewController" to
   "AutofillEditTableViewController".
2- Set "AutofillAddCreditCardViewController" as a delegate for TableView Cells.
3- Add a check for type of the TableView cells in "AutofillEditTableViewController".

Bug: 984545
Change-Id: I82296c8defbcd20b4b04d0c6465bb5127a52428f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1771913Reviewed-by: default avatarGauthier Ambard <gambard@chromium.org>
Reviewed-by: default avatarJavier Ernesto Flores Robles <javierrobles@chromium.org>
Commit-Queue: Reda Tawfik <redatawfik@google.com>
Cr-Commit-Position: refs/heads/master@{#692003}
parent e7e94349
...@@ -7,14 +7,14 @@ ...@@ -7,14 +7,14 @@
#import <UIKit/UIKit.h> #import <UIKit/UIKit.h>
#import "ios/chrome/browser/ui/settings/autofill/autofill_edit_table_view_controller.h"
#import "ios/chrome/browser/ui/settings/credit_card_scanner/credit_card_consumer.h" #import "ios/chrome/browser/ui/settings/credit_card_scanner/credit_card_consumer.h"
#import "ios/chrome/browser/ui/settings/settings_root_table_view_controller.h"
@protocol AddCreditCardViewControllerDelegate; @protocol AddCreditCardViewControllerDelegate;
// The view controller for adding new credit card. // The view controller for adding new credit card.
@interface AutofillAddCreditCardViewController @interface AutofillAddCreditCardViewController
: SettingsRootTableViewController <CreditCardConsumer> : AutofillEditTableViewController <CreditCardConsumer>
// Initializes a AutofillAddCreditCardViewController with passed delegate. // Initializes a AutofillAddCreditCardViewController with passed delegate.
- (instancetype)initWithDelegate: - (instancetype)initWithDelegate:
......
...@@ -203,6 +203,25 @@ typedef NS_ENUM(NSInteger, ItemType) { ...@@ -203,6 +203,25 @@ typedef NS_ENUM(NSInteger, ItemType) {
} }
return nil; return nil;
} }
#pragma mark - UITableViewDataSource
- (UITableViewCell*)tableView:(UITableView*)tableView
cellForRowAtIndexPath:(NSIndexPath*)indexPath {
UITableViewCell* cell = [super tableView:tableView
cellForRowAtIndexPath:indexPath];
// Use |ObjCCast| because |cell| might not be |TableViewTextEditCell|.
// Set the delegate and style for only |TableViewTextEditCell| type of cell
// not other types.
TableViewTextEditCell* editCell =
base::mac::ObjCCast<TableViewTextEditCell>(cell);
editCell.textField.delegate = self;
editCell.selectionStyle = UITableViewCellSelectionStyleNone;
return cell;
}
#pragma mark - CreditCardConsumer #pragma mark - CreditCardConsumer
// TODO(crbug.com/984545): This method will be called from // TODO(crbug.com/984545): This method will be called from
......
...@@ -178,8 +178,15 @@ ...@@ -178,8 +178,15 @@
NSIndexPath* previousPath = [self indexForCellPathWithOffset:-1 NSIndexPath* previousPath = [self indexForCellPathWithOffset:-1
fromPath:currentPath]; fromPath:currentPath];
[self.formInputAccessoryView.previousButton setEnabled:previousPath != nil]; BOOL isValidPreviousPath =
[self.formInputAccessoryView.nextButton setEnabled:nextPath != nil]; previousPath && [[self.tableView cellForRowAtIndexPath:previousPath]
isKindOfClass:TableViewTextEditCell.class];
self.formInputAccessoryView.previousButton.enabled = isValidPreviousPath;
BOOL isValidNextPath =
nextPath && [[self.tableView cellForRowAtIndexPath:nextPath]
isKindOfClass:TableViewTextEditCell.class];
self.formInputAccessoryView.nextButton.enabled = isValidNextPath;
} }
#pragma mark - Keyboard handling #pragma mark - Keyboard handling
......
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