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

[ios] Migrate HistoryPanelViewController to use MDCAppViewController

Bug: 874471
Change-Id: Ica1ed661560c979893d583b693ac58b59bf3d4d8
Reviewed-on: https://chromium-review.googlesource.com/1213551
Commit-Queue: Chris Lu <thegreenfrog@chromium.org>
Reviewed-by: default avatarSergio Collazos <sczs@chromium.org>
Cr-Commit-Position: refs/heads/master@{#589577}
parent 9c9663f4
...@@ -28,7 +28,7 @@ ...@@ -28,7 +28,7 @@
#import "ios/chrome/browser/ui/url_loader.h" #import "ios/chrome/browser/ui/url_loader.h"
#import "ios/chrome/common/ui_util/constraints_ui_util.h" #import "ios/chrome/common/ui_util/constraints_ui_util.h"
#include "ios/chrome/grit/ios_strings.h" #include "ios/chrome/grit/ios_strings.h"
#import "ios/third_party/material_components_ios/src/components/AppBar/src/MaterialAppBar.h" #import "ios/third_party/material_components_ios/src/components/AppBar/src/MDCAppBarViewController.h"
#import "ios/third_party/material_components_ios/src/components/NavigationBar/src/MaterialNavigationBar.h" #import "ios/third_party/material_components_ios/src/components/NavigationBar/src/MaterialNavigationBar.h"
#include "ui/base/l10n/l10n_util_mac.h" #include "ui/base/l10n/l10n_util_mac.h"
...@@ -56,8 +56,8 @@ CGFloat kShadowOpacity = 0.2f; ...@@ -56,8 +56,8 @@ CGFloat kShadowOpacity = 0.2f;
// Container view for history collection and clear browsing button to enable // Container view for history collection and clear browsing button to enable
// use of autolayout in conjunction with Material App Bar. // use of autolayout in conjunction with Material App Bar.
UIView* _containerView; UIView* _containerView;
// The header view. // The header view controller.
MDCAppBar* _appBar; MDCAppBarViewController* _appBarViewController;
// Left bar button item for Search. // Left bar button item for Search.
UIBarButtonItem* _leftBarButtonItem; UIBarButtonItem* _leftBarButtonItem;
// Right bar button item for Dismiss history action. // Right bar button item for Dismiss history action.
...@@ -129,8 +129,7 @@ CGFloat kShadowOpacity = 0.2f; ...@@ -129,8 +129,7 @@ CGFloat kShadowOpacity = 0.2f;
[self setModalTransitionStyle:UIModalTransitionStyleCoverVertical]; [self setModalTransitionStyle:UIModalTransitionStyleCoverVertical];
// Add and configure header. // Add and configure header.
_appBar = [[MDCAppBar alloc] init]; _appBarViewController = [[MDCAppBarViewController alloc] init];
[self addChildViewController:_appBar.headerViewController];
} }
return self; return self;
} }
...@@ -173,14 +172,16 @@ CGFloat kShadowOpacity = 0.2f; ...@@ -173,14 +172,16 @@ CGFloat kShadowOpacity = 0.2f;
[_containerView addSubview:_clearBrowsingBar]; [_containerView addSubview:_clearBrowsingBar];
[self configureClearBrowsingBar]; [self configureClearBrowsingBar];
ConfigureAppBarWithCardStyle(_appBar); ConfigureAppBarViewControllerWithCardStyle(_appBarViewController);
[_appBar headerViewController].headerView.trackingScrollView = [self addChildViewController:_appBarViewController];
_appBarViewController.headerView.trackingScrollView =
[_historyCollectionController collectionView]; [_historyCollectionController collectionView];
[_appBar addSubviewsToParent]; [self.view addSubview:_appBarViewController.view];
[_appBarViewController didMoveToParentViewController:self];
// Prevent the touch events on appBar from being forwarded to the // Prevent the touch events on appBar from being forwarded to the
// collectionView. See https://crbug.com/773580 // collectionView. See https://crbug.com/773580
[_appBar.headerViewController.headerView [_appBarViewController.headerView
stopForwardingTouchEventsForView:_appBar.navigationBar]; stopForwardingTouchEventsForView:_appBarViewController.navigationBar];
// Add navigation bar buttons. // Add navigation bar buttons.
_leftBarButtonItem = _leftBarButtonItem =
...@@ -234,7 +235,7 @@ CGFloat kShadowOpacity = 0.2f; ...@@ -234,7 +235,7 @@ CGFloat kShadowOpacity = 0.2f;
(LegacyHistoryCollectionViewController*)controller (LegacyHistoryCollectionViewController*)controller
didScrollToOffset:(CGPoint)offset { didScrollToOffset:(CGPoint)offset {
// Display a shadow on the header when the collection is scrolled. // Display a shadow on the header when the collection is scrolled.
MDCFlexibleHeaderView* headerView = _appBar.headerViewController.headerView; MDCFlexibleHeaderView* headerView = _appBarViewController.headerView;
headerView.visibleShadowOpacity = headerView.visibleShadowOpacity =
offset.y > -CGRectGetHeight(headerView.frame) ? kShadowOpacity : 0.0f; offset.y > -CGRectGetHeight(headerView.frame) ? kShadowOpacity : 0.0f;
} }
...@@ -341,7 +342,7 @@ CGFloat kShadowOpacity = 0.2f; ...@@ -341,7 +342,7 @@ CGFloat kShadowOpacity = 0.2f;
// Constraints to make search bar cover header. // Constraints to make search bar cover header.
[searchBarView setTranslatesAutoresizingMaskIntoConstraints:NO]; [searchBarView setTranslatesAutoresizingMaskIntoConstraints:NO];
MDCFlexibleHeaderView* headerView = _appBar.headerViewController.headerView; MDCFlexibleHeaderView* headerView = _appBarViewController.headerView;
NSArray* constraints = @[ NSArray* constraints = @[
[[searchBarView topAnchor] constraintEqualToAnchor:headerView.topAnchor], [[searchBarView topAnchor] constraintEqualToAnchor:headerView.topAnchor],
[[searchBarView leadingAnchor] [[searchBarView leadingAnchor]
......
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