-
Notifications
You must be signed in to change notification settings - Fork 946
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'release-candidate' into stable
- Loading branch information
Showing
53 changed files
with
843 additions
and
444 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
109.3.1 | ||
109.4.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
159 changes: 159 additions & 0 deletions
159
components/AppBar/examples/AppBarNavigationControllerWithAppBarInitiallyHiddenExample.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,159 @@ | ||
// Copyright 2020-present the Material Components for iOS authors. All Rights Reserved. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
import Foundation | ||
import MaterialComponents.MaterialAppBar | ||
import MaterialComponents.MaterialAppBar_Theming | ||
import MaterialComponents.MaterialContainerScheme | ||
|
||
class AppBarNavigationControllerWithAppBarInitiallyHiddenExample: | ||
UIViewController, | ||
MDCAppBarNavigationControllerDelegate { | ||
|
||
@objc var containerScheme: MDCContainerScheming = MDCContainerScheme() | ||
|
||
init() { | ||
super.init(nibName: nil, bundle: nil) | ||
|
||
self.title = "Navigation Controller" | ||
} | ||
|
||
required init?(coder aDecoder: NSCoder) { | ||
super.init(coder: aDecoder) | ||
} | ||
|
||
override func viewDidLoad() { | ||
super.viewDidLoad() | ||
|
||
self.view.backgroundColor = self.containerScheme.colorScheme.backgroundColor | ||
|
||
self.navigationItem.rightBarButtonItem = | ||
UIBarButtonItem(title: "Present", | ||
style: .done, | ||
target: self, | ||
action: #selector(presentModalAnimated)) | ||
} | ||
|
||
@objc func presentModalAnimated() { | ||
presentModal(animated: true) | ||
} | ||
|
||
func presentModal(animated: Bool) { | ||
let contentViewController = PresentedViewController() | ||
let navigationController = MDCAppBarNavigationController() | ||
navigationController.shouldSetNavigationBarHiddenHideAppBar = true | ||
navigationController.delegate = self | ||
navigationController.pushViewController(contentViewController, animated: false) | ||
|
||
contentViewController.navigationItem.rightBarButtonItem = | ||
UIBarButtonItem(title: "Dismiss", | ||
style: .done, | ||
target: self, | ||
action: #selector(dismissModal)) | ||
|
||
// Explicitly use the full-screen style to validate safe area insets behavior. | ||
navigationController.modalPresentationStyle = .fullScreen | ||
|
||
self.present(navigationController, animated: animated, completion: nil) | ||
} | ||
|
||
@objc func dismissModal() { | ||
dismiss(animated: true) | ||
} | ||
|
||
// MARK: - MDCAppBarNavigationControllerDelegate | ||
|
||
func appBarNavigationController(_ navigationController: MDCAppBarNavigationController, | ||
willAdd appBarViewController: MDCAppBarViewController, | ||
asChildOf viewController: UIViewController) { | ||
appBarViewController.applyPrimaryTheme(withScheme: self.containerScheme) | ||
} | ||
} | ||
|
||
private class PresentedViewController: UITableViewController { | ||
|
||
init() { | ||
super.init(nibName: nil, bundle: nil) | ||
|
||
self.title = "Presented" | ||
|
||
self.navigationItem.leftBarButtonItem = | ||
UIBarButtonItem(title: "Toggle", | ||
style: .done, | ||
target: self, | ||
action: #selector(toggleVisibility)) | ||
} | ||
|
||
required init?(coder aDecoder: NSCoder) { | ||
super.init(coder: aDecoder) | ||
} | ||
|
||
override func viewDidLoad() { | ||
super.viewDidLoad() | ||
|
||
navigationController?.setNavigationBarHidden(true, animated: false) | ||
} | ||
|
||
// MARK - Actions | ||
|
||
@objc func toggleVisibility() { | ||
guard let navigationController = navigationController else { | ||
return | ||
} | ||
navigationController.setNavigationBarHidden(!navigationController.isNavigationBarHidden, | ||
animated: true) | ||
} | ||
|
||
// MARK: - UITableViewDataSource | ||
|
||
override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { | ||
return 50 | ||
} | ||
|
||
override func tableView(_ tableView: UITableView, | ||
cellForRowAt indexPath: IndexPath) -> UITableViewCell { | ||
|
||
return self.tableView.dequeueReusableCell(withIdentifier: "cell") ?? | ||
UITableViewCell(style: .default, reuseIdentifier: "cell") | ||
} | ||
|
||
// MARK - UITableViewDelegate | ||
|
||
override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { | ||
toggleVisibility() | ||
|
||
tableView.deselectRow(at: indexPath, animated: true) | ||
} | ||
} | ||
|
||
// MARK: Catalog by convention | ||
extension AppBarNavigationControllerWithAppBarInitiallyHiddenExample { | ||
|
||
@objc class func catalogMetadata() -> [String: Any] { | ||
return [ | ||
"breadcrumbs": ["App Bar", "Navigation Controller (app bar hidden)"], | ||
"primaryDemo": false, | ||
"presentable": false, | ||
] | ||
} | ||
} | ||
|
||
// MARK: Snapshot testing by convention | ||
extension AppBarNavigationControllerWithAppBarInitiallyHiddenExample { | ||
|
||
@objc func testPresented() { | ||
// TODO(b/152510959): The AppBar is expected to be hidden, but it is not. | ||
presentModal(animated: false) | ||
} | ||
} |
Oops, something went wrong.