Commit c4ee5df6 authored by Chris Lu's avatar Chris Lu Committed by Commit Bot

[ios] Migrate PaymentRequestPickerViewController to AppBarViewControllerPresenting


Bug: 874471
Change-Id: I536285a49e60006fb6ed6f5cde97ca97df8eb108
Reviewed-on: https://chromium-review.googlesource.com/1208725Reviewed-by: default avatarMoe Ahmadi <mahmadi@chromium.org>
Commit-Queue: Chris Lu <thegreenfrog@chromium.org>
Cr-Commit-Position: refs/heads/master@{#590037}
parent 6a64e88e
......@@ -90,7 +90,6 @@ source_set("payments") {
"//ios/chrome/browser/ui/coordinators:chrome_coordinators",
"//ios/chrome/browser/ui/icons",
"//ios/chrome/browser/ui/payments/cells",
"//ios/third_party/material_components_ios",
"//ios/third_party/material_roboto_font_loader_ios",
"//ios/web",
"//third_party/libaddressinput",
......
......@@ -7,7 +7,7 @@
#import <UIKit/UIKit.h>
#import "ios/chrome/browser/ui/material_components/app_bar_presenting.h"
#import "ios/chrome/browser/ui/material_components/app_bar_view_controller_presenting.h"
extern NSString* const kPaymentRequestPickerRowAccessibilityID;
extern NSString* const kPaymentRequestPickerViewControllerAccessibilityID;
......@@ -33,7 +33,7 @@ extern NSString* const kPaymentRequestPickerSearchBarAccessibilityID;
// TableViewController that displays a searchable list of rows featuring a
// selected row as well as an index list.
@interface PaymentRequestPickerViewController
: UITableViewController<AppBarPresenting>
: UITableViewController<AppBarViewControllerPresenting>
// The delegate to be notified when the user selects a row.
@property(nonatomic, weak) id<PaymentRequestPickerViewControllerDelegate>
......
......@@ -7,10 +7,10 @@
#import "base/logging.h"
#import "base/mac/foundation_util.h"
#import "ios/chrome/browser/ui/icons/chrome_icon.h"
#import "ios/chrome/browser/ui/material_components/chrome_app_bar_view_controller.h"
#import "ios/chrome/browser/ui/material_components/utils.h"
#import "ios/chrome/browser/ui/payments/payment_request_picker_row.h"
#include "ios/chrome/browser/ui/ui_util.h"
#import "ios/third_party/material_components_ios/src/components/AppBar/src/MaterialAppBar.h"
#import "ios/third_party/material_components_ios/src/components/CollectionCells/src/MaterialCollectionCells.h"
#include "third_party/libaddressinput/messages.h"
#include "ui/base/l10n/l10n_util.h"
......@@ -47,7 +47,7 @@ NSString* const kPaymentRequestPickerSearchBarAccessibilityID =
@implementation PaymentRequestPickerViewController
@synthesize appBar = _appBar;
@synthesize appBarViewController = _appBarViewController;
@synthesize searchController = _searchController;
@synthesize allRows = _allRows;
@synthesize displayedRows = _displayedRows;
......@@ -69,16 +69,14 @@ NSString* const kPaymentRequestPickerSearchBarAccessibilityID =
// Default to displaying all the rows.
self.displayedRows = self.allRows;
_appBar = [[MDCAppBar alloc] init];
[self addChildViewController:_appBar.headerViewController];
ConfigureAppBarWithCardStyle(_appBar);
_appBarViewController = [[ChromeAppBarViewController alloc] init];
// Set up leading (back) button.
UIBarButtonItem* backButton =
[ChromeIcon templateBarButtonItemWithImage:[ChromeIcon backIcon]
target:self
action:@selector(onBack)];
self.appBar.navigationBar.backItem = backButton;
self.appBarViewController.navigationBar.backItem = backButton;
}
return self;
}
......@@ -137,17 +135,19 @@ NSString* const kPaymentRequestPickerSearchBarAccessibilityID =
// controller does not present on top of the navigation controller.
self.definesPresentationContext = YES;
self.appBar.headerViewController.headerView.trackingScrollView =
self.tableView;
[self.appBar addSubviewsToParent];
[self addChildViewController:self.appBarViewController];
ConfigureAppBarViewControllerWithCardStyle(self.appBarViewController);
self.appBarViewController.headerView.trackingScrollView = self.tableView;
[self.view addSubview:self.appBarViewController.view];
[self.appBarViewController didMoveToParentViewController:self];
}
- (UIViewController*)childViewControllerForStatusBarHidden {
return self.appBar.headerViewController;
return self.appBarViewController;
}
- (UIViewController*)childViewControllerForStatusBarStyle {
return self.appBar.headerViewController;
return self.appBarViewController;
}
#pragma mark - UITableViewDataSource
......@@ -196,16 +196,14 @@ NSString* const kPaymentRequestPickerSearchBarAccessibilityID =
#pragma mark - UIScrollViewDelegate
- (void)scrollViewDidScroll:(UIScrollView*)scrollView {
MDCFlexibleHeaderView* headerView =
self.appBar.headerViewController.headerView;
MDCFlexibleHeaderView* headerView = self.appBarViewController.headerView;
if (scrollView == headerView.trackingScrollView) {
[headerView trackingScrollViewDidScroll];
}
}
- (void)scrollViewDidEndDecelerating:(UIScrollView*)scrollView {
MDCFlexibleHeaderView* headerView =
self.appBar.headerViewController.headerView;
MDCFlexibleHeaderView* headerView = self.appBarViewController.headerView;
if (scrollView == headerView.trackingScrollView) {
[headerView trackingScrollViewDidEndDecelerating];
}
......@@ -213,8 +211,7 @@ NSString* const kPaymentRequestPickerSearchBarAccessibilityID =
- (void)scrollViewDidEndDragging:(UIScrollView*)scrollView
willDecelerate:(BOOL)decelerate {
MDCFlexibleHeaderView* headerView =
self.appBar.headerViewController.headerView;
MDCFlexibleHeaderView* headerView = self.appBarViewController.headerView;
if (scrollView == headerView.trackingScrollView) {
[headerView trackingScrollViewDidEndDraggingWillDecelerate:decelerate];
}
......@@ -223,8 +220,7 @@ NSString* const kPaymentRequestPickerSearchBarAccessibilityID =
- (void)scrollViewWillEndDragging:(UIScrollView*)scrollView
withVelocity:(CGPoint)velocity
targetContentOffset:(inout CGPoint*)targetContentOffset {
MDCFlexibleHeaderView* headerView =
self.appBar.headerViewController.headerView;
MDCFlexibleHeaderView* headerView = self.appBarViewController.headerView;
if (scrollView == headerView.trackingScrollView) {
[headerView
trackingScrollViewWillEndDraggingWithVelocity:velocity
......
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