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