Context:
To allow us to create APIs for our users to set different appearances based on the different states the drawer can be in, we need to create an initial state system.
The Problem:
Without defining a state for our drawer, we won't be able to differentiate between different presentations the drawer may be in, and then alter the drawer's appearance effectively.
The Fix:
Provide a state enum as part of MDCBottomDrawerController, that is read only, and is set using a delegate that is initially set by the internal implementation.
Testing:
Unit Tests + Tested on an iPhone X and iPhone 7 with smaller and bigger preferredContentSize to imitate different states.
Related Bugs:
Closes#5524
This PR is the last step in graduating the Navigation Drawer component from Beta to Ready.
We have resolved all the outstanding issues in the Navigation Drawer Project here: https://github.com/material-components/material-components-ios/projects/85 and hotlist: 1230549 .
The only outstanding issue is the unit tests ( #5466 , #5465 ) which were approved and are pending due to GitHub issues causing CI not to run.
We are essentially migrating here the NavigationDrawer component from the MaterialComponentsAlpha podspec to the MaterialComponents podspec so it can be used publicly using the normal means of installing our Pod.
This PR is blocked and can land once #5466 and #5465 land.
Closes#5333
### Context
NavigationDrawer is missing unit test. One of the _heavy lifting_ functions is `cacheLayoutCalculation`, which has many side effects. One of those side effects is setting the `contentHeightSurplus`. `contentHeightSurplus` effects `scrollsToReveal` so those test were also added.
**_Note:_** I didn't add any comments in the test but those may be necessary to give future maintainers context on why the test are a given result.
### Related issues
#4911
### Related PR
#5465
### Content
NavigationDrawer is missing unit test. One of the _heavy lifting_ functions is `cacheLayoutCalculation`, which has many side effects. One of those side effects is setting the `contentHeaderTopInset`. In cacheLayoutCalculations there is two paths to set `contentHeaderTopInset` one is with scrollable content and one is without scrollable content. If the content isn't scrollable then the `contentHeaderTopInset` is the size of the `presentingViewBounds.size.height` minus the `headerViewController.preferredContentSize.height` and the `contentViewController.preferredContentSize.height`. If the content is scrollable then the `contentHeaderTopInset` is the size of the `presentingViewBounds` * `initialDrawerFactor`.
### Work in the PR
Test `presentingViewBounds`
Test `contentHeaderTopInset`
- Scrollable
- With large headerViewController
- With large contentViewController
- With large contentViewController and headerViewController
- Non-scrollable
- With only a headerViewController
- With only a contentViewController
- With both a contentViewController and a headerViewController
- With no contentViewController or headerViewController
### Remaining Work
For `cacheLayoutCalculations` we still need to test `contentHeightSurplus`
### Related issues
#4911
### Context
We currently are missing a lot unit test for NavigationDrawer. In order to keep the PR's manageable I have decided to break them up into related groups. This group is the two properties that look at the headerViewControllers.preferredContentSize.height and tests those two.
### The problem
We are missing a lot of unit test for NavigationDrawer
### The fix
Add test for `topHeaderHeight` and `contentHeaderHeight`
### Bugs
Related to #4911
### The problem
BottomDrawer previously had no color themer support
### The fix
This change adds a color themer for BottomDrawer. Additionally this adds unit tests and updates the example to use the color themer. The guidelines indicate the content and header should utilize the semantic surface color, so that is what the themer applies to the BottomDrawer.
**Note:** The drawer should be configured with its header and content ViewControllers before applying the theme.
### Related issues
Closes#4910
### Code snippet
#### Swift
```
let bottomDrawerViewController = MDCBottomDrawerViewController()
bottomDrawerViewController.contentViewController = contentViewController
bottomDrawerViewController.headerViewController = headerViewController
MDCBottomDrawerColorThemer.applySemanticColorScheme(colorScheme,
toBottomDrawer: bottomDrawerViewController)
```
#### ObjC
```
MDCBottomDrawerViewController *bottomDrawer = [[MDCBottomDrawerViewController alloc] init];
bottomDrawer.contentViewController = contentViewController
bottomDrawer.headerViewController = headerViewController
[MDCBottomDrawerColorThemer applySemanticColorScheme:self.colorScheme
toBottomDrawer:bottomDrawer];
```
### Context
This is a bug fix to finalize the VoiceOver full screen presentation of the drawer, and allows the full screen presentation of the drawer to work correctly on all devices on Landscape as well.
### The problem
Up until today we have been using FLT_EPSILON as a number for comparison, but on 32 bit devices, in certain numbers that take more bits than others, the floating point precision loses the FLT_EPSILON. Example:
```
(lldb) po 20.f + FLT_EPSILON
20
(lldb) po 0 + FLT_EPSILON
0.00000011920929
```
### The fix
The EPSILON number is set to a significant enough number to allow easy comparison, and not get "lost" when added/subtracted into `CGFloat`s. Because the numbers using the epsilon are numbers that represent screen points, this new number also is small enough to not alter any visual changes due to it changing the screen points too drastically.
### Bug
Closes#5442
### Tests
Tested on an iPhone 4S, iPhone 5, iPhone X, iPhone 7, portrait, landscape, VO on/off, iOS 8.1, 10, 12, on all Nav Drawer examples by dragging the drawer to see accurate dismissal.
### Context
In #5423 my thinking was that we would need to test MDCBottomDrawerViewController but majority of the test are going to be related to MDCBottomDrawerContainerViewController. We may still want to test MDCBottomDrawerViewController so that is why I haven't completely removed that file for tests. But, we need fakes in a couple places so this adds _Fakes_ files so that code can be shared.
### The problem
We need fakes for test in MaterialNavigationDrawer because we can't present and that code should be shared.
### The fix
Add a `MDCNavigationDrawerFakes` files so we can have fakes and they can be shared across test files.
### Related bugs
#4911
When the Drawer is presented in a mobile landscape presentation (or a compact size class), it should be presented in full screen based on design guidelines.
There is an issue opened regarding a full screen presentation with 32 bit devices that needs to be addressed: https://github.com/material-components/material-components-ios/issues/5442
Added conformation to MDCBottomDrawerHeader for DrawerHeaderViewController.swift file in **NavigationDrawer** examples as it was not showing up if code was run.
Context
Set up the everything to start work on unit test for Navigation Drawer. In order to make small changes that are easier to review this sets up the files to get ready for test. This will allow us to work in tandem on unit test for this component once the files are in place.
The problem
MDCNavigationDrawer doesn't have any unit test
The fix
This adds the files to the build file and basic setup to add tests
Related bug
b/117175875
### Context
In working on navigation drawer bugs the navigation drawer presents itself right when you open the example view controller.
### The problem
This makes it hard to do screenshot testing and harder to work on because you have to go back to the table view and then select the example again every time you want to present.
### The fix
Add a button to present the navigation drawer.
### Context
In #4915 I believe both ActionSheet and NavDrawer weren't in the codebase yet and didn't remove the checks this removes the checks that are no longer needed as we no longer support XCode 8.
This code allows us to have the navigation drawer be presented at full screen when VoiceOver or SwitchControl is enabled. Even if the content doesn't take up the full screen, this still makes the content show at full screen.
This has been tested by imitating the VoiceOver by enabling the `isAccessibilityMode` method to always return true. Has been tested on all examples, by altering their preferred content size to be small, and also in their default state. Has been tested on iOS 8.1, and iOS 11. iPhone 6, iPhone SE, and iPhone X. Portrait and Landscape.
This change allows us to set any kInitialDrawerHeightFactor value for the Navigation Drawer, which decides what percentage of the screen to display the drawer at when presented. This opens up the functionality to allow us to set the drawer to open at 100% height when in VoiceOver. This doesn't necessarily mean I will expose an API to set the height factor, but it does allow us to set it to 100% for VoiceOver.
This functionality has been tested on iOS 9, 10, 11, 12. On an iPhone 7, SE, and X, on Landscape and Portrait. It was also tested on all the 5 different examples, with different kInitialDrawerHeightFactor values of 0.5, 0.8, and 1.0.
This is the first part of multiple improvements to get the Navigation Drawer to the state that it can receive an arbitrary percentage from 0%-100% of how much of the drawer to present on the screen when displayed (currently it is only at 50% and is uncustomizable).
This PR allows us to set the drawer an arbitrary number without it breaking, with the caveat that it doesnt yet support percentages that are 100% or close to 100%. Once that is supported we will be able to support 100% drawer presented for VO, solving bug #4899
This also has performance improvements as before when scrolling the drawer up with the trackingScrollView being set, it would call `viewWillLayoutSubviews` because it would think for an instance that it is not in full screen anymore, before reverting back to the correct state.
**Testing:**
Currently to test this addition, I have ran all the examples that provide all the needed use cases of usage for the drawer. They have been run in both portrait and landscape, and by dragging the drawer from the start position, to full screen, to edge of content, and back up again. This process has been run on an iPhone SE with iOS 9.4, an iPhone X with iOS 11.4, an iPhone 6 Plus with iOS 10, and an iPad running iOS 11.4.
I can't see any edge cases with the current support we allow with this component, with the addition that this is an alpha component.
I noticed that while trying to dismiss the bottom drawer on iOS 9 I got the following error message:
```
attempt to dismiss modal view controller whose view does not currently appear.
```
Then I noticed that if I commented out our override of `-presentedView` I _could_ dismiss the bottom drawer, but I couldn't interact with it.
Finally, I noticed that if I added `self.bottomDrawerContainerViewController.view` as a subview of `super.presentedView` instead of `self.containerView`, I could both dismiss and interact with the bottom drawer, as expected.
This seems to be a good fix, but I'm not really sure. I'm kind of afraid to break something here. Going to wait for @yarneo's input since he has the most knowledge of this component.
Closes#5153.
Removes the need to copy-paste stanzas from other files anymore as we'll rely on #4478 to generate the correct stanza for us instead.
This was an automated change generated by running a find-and-replace regular expression:
```
/\*
Copyright ([0-9]+)-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\.
\*/
```
```
/\*
Copyright ([0-9]+)-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\.
\*/
```
```
/\*
Copyright ([0-9]+)-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\.
\*/
```
```
// Copyright $1-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.
```
Adding the navigation drawer component that adds a presentation controller for showing UIViewControllers as a bottom drawer.
History of the component (last CL submitted for it): cl/209765207
Design doc: go/mdc-ios-navigation-drawer
This component will be the first alpha component in this repo, this means that it can still change and will not be included as part of the podspec at first.