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