Commit bfb461fe authored by Yuwei Huang's avatar Yuwei Huang Committed by Commit Bot

[CRD iOS] Migrate MDCAppBar to MDCAppBarViewController

MDCAppBar will soon be deprecated. This CL migrates all MDCAppBar code
to use MDCAppBarViewController.

It is basically following the migration guide here:
https://github.com/material-components/material-components-ios/tree/develop/components/AppBar#migration-guide-mdcappbar-to-mdcappbarviewcontroller

Bug: 874534
Change-Id: Ibe3ea272763b98bd7ded513111167221f06c9e6b
Reviewed-on: https://chromium-review.googlesource.com/1187402Reviewed-by: default avatarJamie Walch <jamiewalch@chromium.org>
Commit-Queue: Yuwei Huang <yuweih@chromium.org>
Cr-Commit-Position: refs/heads/master@{#586042}
parent 47388944
......@@ -58,7 +58,7 @@ std::string GetAuthorizationCodeUri() {
} // namespace
@interface RemotingMenuViewController () {
MDCAppBar* _appBar;
MDCAppBarViewController* _appBarViewController;
NSArray<NSArray<SideMenuItem*>*>* _content;
}
@end
......@@ -78,12 +78,12 @@ std::string GetAuthorizationCodeUri() {
if (self) {
self.title = l10n_util::GetNSString(IDS_SETTINGS_BUTTON);
_appBar = [[MDCAppBar alloc] init];
[self addChildViewController:_appBar.headerViewController];
_appBarViewController = [[MDCAppBarViewController alloc] init];
[self addChildViewController:_appBarViewController];
_appBar.headerViewController.headerView.backgroundColor = kBackgroundColor;
_appBar.navigationBar.tintColor = [UIColor whiteColor];
_appBar.navigationBar.titleTextAttributes =
_appBarViewController.headerView.backgroundColor = kBackgroundColor;
_appBarViewController.navigationBar.tintColor = [UIColor whiteColor];
_appBarViewController.navigationBar.titleTextAttributes =
@{NSForegroundColorAttributeName : [UIColor whiteColor]};
}
return self;
......@@ -94,9 +94,9 @@ std::string GetAuthorizationCodeUri() {
- (void)viewDidLoad {
[super viewDidLoad];
_appBar.headerViewController.headerView.trackingScrollView =
self.collectionView;
[_appBar addSubviewsToParent];
_appBarViewController.headerView.trackingScrollView = self.collectionView;
[self.view addSubview:_appBarViewController.view];
[_appBarViewController didMoveToParentViewController:self];
UIBarButtonItem* backButton =
[[UIBarButtonItem alloc] initWithImage:RemotingTheme.backIcon
......
......@@ -13,7 +13,7 @@
#import "base/bind.h"
#import "ios/third_party/material_components_ios/src/components/AnimationTiming/src/MaterialAnimationTiming.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/Dialogs/src/MaterialDialogs.h"
#import "ios/third_party/material_components_ios/src/components/ShadowElevations/src/MaterialShadowElevations.h"
#import "ios/third_party/material_components_ios/src/components/ShadowLayer/src/MaterialShadowLayer.h"
......@@ -88,7 +88,7 @@ using remoting::HostListService;
UIViewControllerAnimatedTransitioning,
UIViewControllerTransitioningDelegate> {
MDCDialogTransitionController* _dialogTransitionController;
MDCAppBar* _appBar;
MDCAppBarViewController* _appBarViewController;
HostCollectionViewController* _collectionViewController;
HostFetchingViewController* _fetchingViewController;
HostFetchingErrorViewController* _fetchingErrorViewController;
......@@ -135,8 +135,8 @@ using remoting::HostListService;
_setupViewController = [[HostSetupViewController alloc] init];
_setupViewController.scrollViewDelegate = self.headerViewController;
_appBar = [[MDCAppBar alloc] init];
[self addChildViewController:_appBar.headerViewController];
_appBarViewController = [[MDCAppBarViewController alloc] init];
[self addChildViewController:_appBarViewController];
self.navigationItem.title =
l10n_util::GetNSString(IDS_PRODUCT_NAME).lowercaseString;
......@@ -149,13 +149,13 @@ using remoting::HostListService;
remoting::SetAccessibilityInfoFromImage(menuButton);
self.navigationItem.leftBarButtonItem = menuButton;
_appBar.headerViewController.headerView.backgroundColor =
_appBarViewController.headerView.backgroundColor =
RemotingTheme.hostListBackgroundColor;
_appBar.navigationBar.backgroundColor =
_appBarViewController.navigationBar.backgroundColor =
RemotingTheme.hostListBackgroundColor;
MDCNavigationBarTextColorAccessibilityMutator* mutator =
[[MDCNavigationBarTextColorAccessibilityMutator alloc] init];
[mutator mutate:_appBar.navigationBar];
[mutator mutate:_appBarViewController.navigationBar];
MDCFlexibleHeaderView* headerView = self.headerViewController.headerView;
headerView.backgroundColor = [UIColor clearColor];
......@@ -202,7 +202,8 @@ using remoting::HostListService;
constraintGreaterThanOrEqualToAnchor:[self.view heightAnchor]],
]];
[_appBar addSubviewsToParent];
[self.view addSubview:_appBarViewController.view];
[_appBarViewController didMoveToParentViewController:self];
__weak __typeof(self) weakSelf = self;
_hostListStateSubscription =
......
......@@ -25,7 +25,7 @@ static NSString* const kReusableIdentifierItem = @"remotingSettingsVCItem";
static const CGFloat kSectionSeparatorHeight = 1.f;
@interface RemotingSettingsViewController () {
MDCAppBar* _appBar;
MDCAppBarViewController* _appBarViewController;
NSArray* _sections;
NSMutableArray* _content;
}
......@@ -42,19 +42,19 @@ static const CGFloat kSectionSeparatorHeight = 1.f;
- (void)viewDidLoad {
[super viewDidLoad];
_appBar = [[MDCAppBar alloc] init];
[self addChildViewController:_appBar.headerViewController];
_appBarViewController = [[MDCAppBarViewController alloc] init];
[self addChildViewController:_appBarViewController];
self.view.backgroundColor = RemotingTheme.menuBlueColor;
_appBar.headerViewController.headerView.backgroundColor =
_appBarViewController.headerView.backgroundColor =
RemotingTheme.menuBlueColor;
MDCNavigationBarTextColorAccessibilityMutator* mutator =
[[MDCNavigationBarTextColorAccessibilityMutator alloc] init];
[mutator mutate:_appBar.navigationBar];
[mutator mutate:_appBarViewController.navigationBar];
_appBar.headerViewController.headerView.trackingScrollView =
self.collectionView;
[_appBar addSubviewsToParent];
_appBarViewController.headerView.trackingScrollView = self.collectionView;
[self.view addSubview:_appBarViewController.view];
[_appBarViewController didMoveToParentViewController:self];
self.collectionView.backgroundColor = RemotingTheme.menuBlueColor;
......
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