49 Commits

Author SHA1 Message Date
Cody Weaver
f9eb3494e3 #NavigationDrawer Disable failing tests
PiperOrigin-RevId: 555627853
2023-08-10 13:26:58 -07:00
Nobody
4f1010ffd1 Fixed up imports for NavigationDrawer
PiperOrigin-RevId: 478778261
2022-10-04 07:25:05 -07:00
Jeff Verkoeyen
86a8c97dc7 Remove all pre-iOS 12 logic.
PiperOrigin-RevId: 400788645
2021-10-04 12:41:07 -07:00
Yarden Eitan
1e8dcc273e [NavDrawer] Increase code coverage by adding more tests.
PiperOrigin-RevId: 358039838
2021-02-17 15:00:27 -08:00
Jeff Verkoeyen
b3fa42005b Optimizing imports
PiperOrigin-RevId: 356966407
2021-02-11 07:12:37 -08:00
Nobody
6ad0683d1a [BottomDrawer] Fix the bug caused by regression in the PR "Optional dismiss on accessibilityPerformEscape", where the forwarded touch events are interfered by gesture recognizer introduced in the CL.
Cause:
The variable dismissOnBackgroundTap should be used to determine whether gesture recognizer is added to the presentation view controller. When the check was removed, gesture recognizer is interfering and touchesended is not propagated.
Fix:
Add back the check and add tap gesture recognizer only when dismissOnBackgroundTap is set to true.

PiperOrigin-RevId: 336292017
2020-10-09 07:51:04 -07:00
Nobody
4cba6bbf5c [MDCBottomDrawerViewController] Adds shouldDisplayMobileLandscapeFullscreen property to MDCBottomDrawerContainerViewController and MDCBottomDrawerPresentationController to share the property between MDCBottomDrawerContainerViewController and MDCBottomDrawerViewController.
This adds a new property to MDCBottomDrawerViewController and MDCBottomDrawerContainerViewController that allows for non-fullscreen mobile landscape bottom drawer view.

PiperOrigin-RevId: 327626953
2020-08-20 08:06:39 -07:00
Nobody
d63936f671 [MDCBottomDrawerViewController] Adds shouldDisplayMobileLandscapeFullscreen property to MDCBottomDrawerViewController.
This adds a new property to MDCBottomDrawerViewController that allows for non-fullscreen mobile landscape bottom drawer view.

PiperOrigin-RevId: 327070504
2020-08-17 12:14:11 -07:00
Nobody
f3b77c466b [MDCBottomDrawerViewController] Add new delegate for when scrim is tapped.
This adds a new optional MDCBottomDrawerViewController delegate method for when the scrim is tapped.

PiperOrigin-RevId: 324593723
2020-08-03 06:43:52 -07:00
Yarden Eitan
19c171280b [NavigationDrawer] Add ability to change the maximumInitialDrawerHeight after drawer has been presented.
PiperOrigin-RevId: 292305019
2020-01-30 02:06:23 -08:00
Yarden Eitan
62fc063481 [NavigationDrawer] Adding a flag to allow clients to opt-in to when the preferredContentSize of the contentViewController changes, it visually updates the drawer height.
PiperOrigin-RevId: 292303752
2020-01-30 01:57:11 -08:00
Nobody
c9eba44c69 Implemented opt-in ability to have a "sticky" view, presented behind top safe area, when a headerViewController is not provided (continuation of #9464).
PiperOrigin-RevId: 292038584
2020-01-28 23:01:55 -05:00
Nobody
afe22513f7 Move off of MDCDeviceTopSafeAreaInset (continuation of #9476).
PiperOrigin-RevId: 291998789
2020-01-28 13:17:56 -08:00
Jeff Verkoeyen
e2197af115 Revert "[NavigationDrawer] Enable changing the preferred size and maximum height (#8224)"
This reverts commit 3112e8e228ea7914a111b0f3dbc4ed9919bf24b7.
2020-01-27 07:37:46 -05:00
Jonathan Willing
3112e8e228 [NavigationDrawer] Enable changing the preferred size and maximum height (#8224)
Prior to these changes, changing the maximumInitialDrawerHeight did not have any effect after initial presentation. This adds the ability to modify the value after presentation.

Also enables the ability to change the preferred content size with an animation. If the preferred content size is less than the maximum initial drawer height, the visible portion of the content will be adjusted. Previously, the visible portion would remain the same size, even if more could be shown on screen.

Closes #7369.
2020-01-22 12:50:28 +02:00
Yarden Eitan
ead4785d5c
[NavigationDrawer] allow trackingScrollView to be resettable (#9206)
This allows trackingScrollView to be set to a different value after the drawer has been presented.

Closes #7553

Before gif:
![beforedrawer](https://user-images.githubusercontent.com/4066863/70638889-a4981300-1c07-11ea-97c8-9419132ec867.gif)

After gif:
![afterdrawer](https://user-images.githubusercontent.com/4066863/70638896-a8c43080-1c07-11ea-97e3-dc959723cfa3.gif)
2019-12-11 13:11:17 -05:00
Randall Li
b578f9ee67
[BottomDrawer] Allow touch events to propagate to delegate for MDCBottomNavigationDrawer (#8578)
[BottomDrawer] Allow touch events to propagate to delegate for  MDCBottomNavigationDrawer

Allow the drawer to optionally forward touch events to the delegate for handling. This enables tap thru to the underlying VC if the client needs that behavior.

An example use case would be when the client wants to present the drawer on top of a VC that has controls that they want to still be tappable. For example: A video player or a podcast player with play/pause controls. Then the client VC could still receive the tap event on the control and respond to that and close the drawer at the same time. This would allow the user to save a tap.

this is a second attempt at https://github.com/material-components/material-components-ios/pull/8486

original cl/270318683
2019-10-14 16:29:00 -04:00
Randall Li
a91bf9c2ec
[NavigationDrawer] Add delegate methods to allow the presenting VC to gain access to the transitionCoordinator used during the present/dismiss transitions. (#8566)
[NavigationDrawer] Add delegate methods to allow the presenting VC to gain access to the transitionCoordinator used during the present/dismiss transitions. Also provide callbacks for y-offset changes so that the presenting VC can animate content along with the y-offset changes.

Fixed requests from previous PR and added some tests for the callbacks.

Screen recording of the usage:
https://github.com/material-components/material-components-ios/files/3633638/navdrawer.mov.zip
2019-10-11 15:20:34 -04:00
randallli
306d52355d Revert "[NavDrawer] Allow animations alongside movement in MDCBottomNavigatio… (#8474)"
This reverts commit bf5361b55cc17600317ce4ff2f02e73f1e69e630.
2019-10-03 16:17:28 -04:00
randallli
56cf652a21 Revert "[NavDrawer] Allow touch events to propagate to delegate for MDCBottomNavigationDrawer (#8486)"
This reverts commit 8df9fcdf33d5ead19668f364c6b048ff0bf043e0.
2019-10-03 16:17:19 -04:00
Hiedi Utley
8df9fcdf33 [NavDrawer] Allow touch events to propagate to delegate for MDCBottomNavigationDrawer (#8486)
Allow the drawer to optionally forward touch events to the delegate for handling. This enables tap thru to the underlying VC if the client needs that behavior.

An example use case would be when the client wants to present the drawer on top of a VC that has controls that they want to still be tappable. For example: A video player or a podcast player with play/pause controls. Then the client VC could still receive the tap event on the control and respond to that and close the drawer at the same time. This would allow the user to save a tap.
2019-09-25 17:08:21 -04:00
Hiedi Utley
bf5361b55c [NavDrawer] Allow animations alongside movement in MDCBottomNavigatio… (#8474)
Add delegate methods to allow the presenting VC to gain access to the transitionCoordinator used during the present/dismiss transitions. Also provide callbacks for y-offset changes so that the presenting VC can animate content along with the y-offset changes.

Fixed requests from previous PR and added some tests for the callbacks.

Screen recording of the usage:

[navdrawer.mov.zip](https://github.com/material-components/material-components-ios/files/3633638/navdrawer.mov.zip)
2019-09-23 11:16:57 -04:00
Yarden Eitan
7ded643143
[NavigationDrawer] Adds an elevation and shadow to Bottom Drawer. (#8095)
This adds the notion of elevation and a customizable shadow color to the Bottom Drawer.

Addition of unit tests and snapshot tests.

This now allows the Navigation Drawer to properly support MDCElevation as part of the Dark Mode work.
2019-07-26 16:22:07 -04:00
Bryan Oltman
b243d5e842
[NavigationDrawer] Update cacheLayoutCalculationsWithAddedContentHeight recursion check to factor out floating point rounding issues (#7654)
The `_contentHeaderTopInset > _contentHeightSurplus` check in `MDCBottomDrawerContainerViewController`'s `cacheLayoutCalculationsWithAddedContentHeight:` function was erroneously evaluating to `true` when presenting content:

- in full screen
- with no header
- with the content's height being equal to the available height

Because of how `_contentHeightSurplus` is calculated, it was almost (but not quite) equal to `_contentHeaderTopInset`, which was causing the function to infinitely recurse.

This PR also adds an example that demonstrates the issue. To reproduce:

1. Open MDCDragons
1. Navigate to the "Bottom Drawer No Header Less Content" example
1. Rotate the phone/simulator to landscape
1. Show the bottom navigation drawer by tapping on the menu icon

Expected:

The bottom drawer is displayed.

Actual:

The `cacheLayoutCalculationsWithAddedContentHeight:` infinitely recurses and the app crashes due to stack overflow.

Closes #7633
2019-06-19 18:27:08 -04:00
Yarden Eitan
37fbe0ba48
[NavigationDrawer] Include safe area insets in content height (#7545)
This adds a new opt-in flag for clients to tell the drawer to add the bottom safe area inset to the content height. That way the content can be seen correctly without overlapping on the bottom safe area.

This issue has been reported by an internal client and helps with bug: b/123500336 .

This is a follow up PR to https://github.com/material-components/material-components-ios/pull/7544
2019-06-06 16:11:31 -04:00
Yarden Eitan
bff29146de
update (#7544)
In some cases, clients may have their contentViewController's preferredContentSize only update later in the lifecycle. In cases like that, the _preferredContentSize property may still be 0. Before this change, it would cause the drawer to be much smaller than it should be. This resolves the problem by not updating the drawer height if the content height is still 0.

This has been reported by 2 internal clients so far.
Related bugs: b/123500336 , #7369
2019-06-06 15:59:43 -04:00
Yarden Eitan
4badd38cf5
update (#7345)
The current ShadowElevation value for NavigationDrawer is incorrect and is currently 16.0. It should be 4.0 based on [Material Guidelines](https://material.io/design/components/navigation-drawer.html#standard-drawer):
"A full-height navigation drawer is at the same elevation as a top app bar."
"When initially opened to 50% of the screen height, the drawer must be dragged to screen height before additional items are revealed. Upon scroll, the drawer's header becomes an elevated top app bar with a close affordance."

|Before|After|
|---|---|
|![Simulator Screen Shot - iPhone X - 2019-05-06 at 14 52 37](https://user-images.githubusercontent.com/4066863/57248201-cac15900-700f-11e9-92ac-03a303352918.png)|![Simulator Screen Shot - iPhone X - 2019-05-06 at 14 51 40](https://user-images.githubusercontent.com/4066863/57248208-d01ea380-700f-11e9-86be-f2034a449907.png)|
|---|---|

Resolves #7335
2019-05-06 15:50:36 -04:00
Yarden Eitan
07417dfa71
[NavigationDrawer] Added support for customizing the initial drawer height factor (#7112)
We are adding a new property for NavigationDrawer's API called `maximumInitialDrawerHeight` which allows clients to set the initial height of the drawer, rather than it always being 50% of the screen's height.

We also had to be mindful that in some cases allowing any percentage could have the offset of the scrollView be a fractional number that wasn't reasonable, and therefore UIKit would round the scrollView's contentOffset to a close (yet different) value. Therefore to not cause inconsistencies between what the scrollView content offset returns and the drawer's initial offset, we rounded the number after the initial percentage calculation.

Unit tests have been added and all examples have been tested with and without the variable.

Resolves #7080
2019-04-12 15:33:06 -04:00
Cody Weaver
7050808d62
[NavigationDrawer] Fix issue where scrim is shown below content (#6514)
## Related links
* Original PR: #5876 
* Related Bug: #5782 
## Introduction
This fixes the issue where the scrim is shown if a user scrolls too far into the content. This does **NOT** fix the issue if a user has set a `trackingScrollView`. If there is a trackingScrollView then the behavior doesn't change at all.
## The problem
When a user scrolls up passed the height of the content the scrim is shown.
## The fix
As a user scrolls we continually add additional height to the contentViewController.
## Videos
| Before | After |
| --- | --- |
|![before](https://user-images.githubusercontent.com/7131294/51933190-bd704f00-23ce-11e9-814d-f19f0668fe2a.gif)|![after](https://user-images.githubusercontent.com/7131294/51933211-c3663000-23ce-11e9-943f-01758139d9b1.gif)|
2019-01-29 14:13:11 -05:00
Cody Weaver
4a3ca45176
[NavigationDrawer] Fix issue when setting trackingScrollView (#6492)
## Related links
* Related bugs: #5804 #6305 
* Component: [NavigationDrawer](https://github.com/material-components/material-components-ios/tree/develop/components/NavigationDrawer)
## Introduction
While working on #6305 I noticed that in certain cases the NavigationDrawer would not set the `trackingScrollView` correctly in certain cases.
## The problem
There was a race condition that if a user set any one of the properties on the `presentationController` before they set the `trackingScrollView` then the `trackingScrollView` internally would be nil.
## The fix
Set the tracking scroll view on the `presentationController` instead of on the `transitionController`.
2019-01-28 16:16:23 -05:00
Cody Weaver
63c8c54ec2
[NavigationDrawer] Fix issue where drawer opens passed initialDrawerFactor (#6491)
## Related links
* Bug: #6305 
* Component: [NavigationDrawer](https://github.com/material-components/material-components-ios/tree/develop/components/NavigationDrawer)
* Related PRs: #5928 #5587 #5520 #5443
## Introduction
The navigation drawer should support resizable content. This content should be able to change and the drawer stay at the same height or not _jump_ to another height. There was a problem where the drawer would jump between heights for certain `preferredContentSize`'s of the `contentViewController`. This was thought to be addressed in #5928. Upon investigation the root cause was not that the drawer jumped when `preferredContentSize` changed but that some how the drawer was able to open passed it's `initialDrawerFactor`. Therefore when the `preferredContentSize` did change the drawer go to the correct `initialDrawerFactor` and when it changed back it would go to the incorrect value. Additionally, when the drawer got into this state it would be in an `.expanded` drawer state because the drawer thought it should open up passed the `initialDrawerFactor`.
## The problem
The drawer thought it had less content that it actually had and therefore would go into the incorrect state and override `initialDrawerFactor`.
## The fix
Upon investigation fixing the drawer's internal calculation as to how much _content_ it actually has vs how tall the `presentingViewBounds.height` multiplied by `initialDrawerFactor`.
## Tests
Tests were updated as well as comments around them to understand why they were updated.
## Code snippet
In order to test the before and after behavior edit `BottomDrawerInfiniteScrollingExample.swift` as outlined below.
```diff
let bottomDrawerViewController = MDCBottomDrawerViewController()
+ contentViewController.supportsScrollToTop = false
bottomDrawerViewController.contentViewController = contentViewController
```
Doing the above will showcase how the drawer got into it's broken state.
2019-01-28 13:07:46 -05:00
Yarden Eitan
5a98df2b39
[NavigationDrawer] Navigation Drawer Present at Fullscreen (#5995)
This PR closes #5600 .

The drawer now has added functionality allowing users to expand the drawer to full screen with duration and completion. 
Clients have asked for this functionality, and it is also providing the expand to full screen functionality correctly even when the content is less than the full height of the screen.
2018-12-13 11:15:43 -05:00
Cody Weaver
f8d595ef04
[NavigationDrawer] Fix jump when perferredContentSize changes (#5928)
### Context
Currently `MDCBottomDrawerViewController` _jumps_ if the preferredContentSize changes. A client is asking for this _jump_ to not happen but instead the drawer will look the same but have more content. 

#### Conditional checks

1. The check to see if `_contentVCPreferredContentSizeHeightCached` is zero is because on initial layout this value is 0 until we call `cacheLayoutCalculations` which sets this value. 
2. The check to see if `percentageFullScreen > 0.5` is there to make sure we never have an initial drawer factor more than design has specified.

### The problem
`MDCBottomDrawerViewController` _jumps_ if the preferredContentSize changes

### The fix
Set initialDrawerFactor to a custom value so that change doesn't cause a jump.

### Videos
| Before | After |
| - | - |
|![before](https://user-images.githubusercontent.com/7131294/49542847-a0267500-f8a4-11e8-90c9-e5304e5da9a2.gif)|![after](https://user-images.githubusercontent.com/7131294/49542855-a4eb2900-f8a4-11e8-9db3-3b163dbe5e9b.gif)|
2018-12-05 15:49:44 -05:00
Cody Weaver
b96909eba0
[NavigationDrawer] Refactor test (#5910)
### Context
A lot of the test used the same code in the given portion of the test. All of those given statements can be summarized into a function to reduce complexity of the test.
### The problem
Similar code throughout the test.
### The fix
Pull all of that code into a function.
2018-12-04 15:40:48 -05:00
Yarden Eitan
137a3e920c
[NavigationDrawer] API to allow content to scroll to top (#5776)
**Context:**
Clients want the ability to scroll their content in the drawer to a specific content offset, most commonly to the top of the content.

**Problem:**
There is no current API that exposes a set content offset or moreover no API that exposes the internal scrollView to allow our clients to set its content offset as they will.

**Solution:**
Provide an API to set the content offset Y of the scrolled content of the drawer. Setting that offset Y to 0 essentially scrolls the user to the top. This API also allows the scrolling to be animated or not.

**Related Bugs:**
Closes #5713
2018-11-19 17:46:15 -05:00
Yarden Eitan
bccd163467
[NavigationDrawer] Improve performance for heavy preferredContentSize calls (#5744)
**Context:**
There is degraded scrolling performance for clients who have heavier calculations when providing the `contentViewController`'s `preferredContentSize`. This is pretty common for dynamically sized content.

**Problem:**
We are calling preferredContentSize more times than we should, when we can defer re-calling it unless we are receiving a `preferredContentSizeDidChangeForChildContentContainer` call.

**Solution:**
Have `preferredContentSize` only called in `cacheLayoutCalculations`. The other unneeded `preferredContentSize` calls take their value either from another class that has already calculated the `preferredContentSize`, or within its own class as a property which caches the latest `preferredContentSize`.

**Related Bugs**
Closes #5715
2018-11-19 15:03:54 -05:00
Robert Moore
74a27253e8
Global replace of integral single-precision literals with integer literals. (#5709)
Global replace of integral single-precision literals with integer literals.

Regular expression used:
```perl
/[^\w]([0-9]+)\.[0]*[fF]/$1/
```
2018-11-08 14:02:04 -05:00
Yarden Eitan
c9f2279af9
[NavigationDrawer] Adding a top inset delegate for the drawer (#5674)
**Context:**
Clients need a way to know the content inset of the drawer to be able to lay out their content appropriately.

**The Problem:**
Because things like the status bar, safe area, and the top handle take up more space at the top of the drawer, the content that is laid out initially will be clipped if not able to move the content appropriately as the drawer is dragged.

**The Fix:**
Add an MDCBottomDrawerViewControllerDelegate that listens to topInset changes as the drawer is dragged and provides the top inset in which the content should be laid out below.

**Testing:**
Unit Test + Tested on an iPhone X and iPhone 7 on all examples, portrait and landscape.
2018-11-08 15:14:56 +02:00
Yarden Eitan
3693683b0f
[NavigationDrawer] Added Color API for the top handle. (#5592)
**Context:**
The navigation drawer's top handle should have an API to be able to customize its color.

**The Problem:**
Currently our top handle only has a default color set and can't have clients customize its color.

**The Fix:**
Provide an API to MDCBottomDrawerViewController to set the handle's background color.

**Testing:**
Unit Test + Tested on an iPhone X and iPhone 7 on all examples, portrait and landscape.

**Screenshot**
![simulator screen shot - iphone 7 - 2018-11-05 at 14 28 06](https://user-images.githubusercontent.com/4066863/47998168-07ff6980-e107-11e8-8882-d4f4cf70dc7c.png)
2018-11-08 09:46:34 +02:00
Yarden Eitan
31e3f33df3
[NavigationDrawer] Add dynamically sizing support for the drawer + performance improvements (#5587)
**Context:**
Clients need the ability to dynamically size their navigation drawer content and have the drawer work appropriately and correctly.

**The Problem:**
Currently we have no mechanism where we let the drawer know that the size of the content has changed and the internal calculations need to be re-calculated and re-applied.

Also, before we were partially listening to the `preferredContentSize` by asking if it has changed every so often using the conditional in the `contentHeightSurplus` getter. Some clients can have a very calculations heavy `preferredContentSize`, which will cause the whole drawer mechanism to lag.

**The Fix:**
Because the `contentViewController` and the `headerViewController` are child view controllers of `MDCBottomDrawerContainerViewController` , we can listen to `preferredContentSizeDidChangeForChildContentContainer` and reset the previously calculated variables and relayout the drawer.

**Testing:**
Unit Test + Tested on an iPhone X and iPhone 7 on all examples, portrait and landscape. A dragons example has been created exactly for the testing of the dynamically changing content size here: #5545 

**Related Bugs:**
Closes #5514
2018-11-08 09:46:22 +02:00
Yarden Eitan
43a996674a
[NavigationDrawer] Added a top handle to the drawer (#5591)
**Context:**
The Navigation Drawer should have an affordance to show scrollability in a shape of a top handle.

**The Problem:**
Currently we have no top handle in our drawer to show scrollability.

**The Fix:**
In this PR we are adding a top handle to our drawer. the top handle is hidden by default. when the top handle isn't hidden, it is visible when there is more scrolling to perform for the drawer, and then it fades away as the drawer reaches its full height, or when it goes to full screen.

**Testing:**
Unit Tests + Tested on an iPhone X and iPhone 7 on all examples, portrait and landscape.

**Related Bugs:**
Closes #5515 

**Screenshot**
![simulator screen shot - iphone x - 2018-11-05 at 14 22 10](https://user-images.githubusercontent.com/4066863/47997942-3e88b480-e106-11e8-9968-1e77f49014a5.png)

**Video of transition**
![2018-11-05 14-23-41 2018-11-05 14_24_27](https://user-images.githubusercontent.com/4066863/47998041-8dcee500-e106-11e8-8c64-552a149c2c7a.gif)
2018-11-07 23:30:56 +02:00
Yarden Eitan
2127004680
automatically disable scrolling (#5586)
**Context:**
Some clients were not aware that their content's scroll view needs to be disabled so the content will not start scrolling while dragging the drawer.

**The Problem:**
Clients need to explicitly set their tracking scroll view scrolling to disabled manually.

**The Fix:**
If a tracking scroll view is provided, set the scrolling to disabled automatically and therefore cause less client confusion

**Testing:**
Unit Test + Tested on an iPhone X on all examples.
2018-11-07 11:12:51 +02:00
Yarden Eitan
bc584d9e0e
[NavigationDrawer] Added a top corners radius for state API. (#5543)
Context:
This change opens up an API to the nav drawer to allow clients to round the top corners using the state system. allowing them to define what corner radius will the top corners have based on the state the drawer is in.

The Problem:
There was no way for users to customize and set the top corners' radius of the drawer.

The Fix:
We now have an API open that allows users to set the corner radius using the drawer's state system. The corner radius logic was moved to the MDCBottomDrawerViewController because that logic isn't part of the drawer scrolling mechanism and shouldn't sit in MDCBottomDrawerContainerViewController if not necessary. To achieve the desired outcome we exposed internally the bottomDrawerTopTransitionRatio:transitionRatio API to the MDCBottomDrawerViewController so it can animate the transition between corner radius shapes smoothly.

Testing:
Unit Tests + Tested on an iPhone X and iPhone 7 with smaller and bigger preferredContentSize to imitate different states. Tested on Portrait and Landscape on all examples.

Related Bugs:
Closes #5516
2018-10-30 19:38:06 +02:00
Yarden Eitan
a8d3794de3
[NavigationDrawer] Added a state system to the Nav Drawer (#5520)
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
2018-10-30 13:27:17 +02:00
Cody Weaver
690b81efdd
[NavigationDrawer] Test content height surplus and scrolls to reveal (#5466)
### 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
2018-10-22 17:11:56 -04:00
Cody Weaver
b2c690d209
[NavigationDrawer] Add test for contentHeaderTopInset and presentingViewBounds (#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
2018-10-22 15:20:18 -04:00
Cody Weaver
f925ce48db
[NavigationDrawer] Add unit test for height related properties (#5461)
### 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
2018-10-19 16:05:34 -04:00
Cody Weaver
596f72b395
[NavigationDrawer] Add Fakes files for tests (#5453)
### 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
2018-10-19 12:31:27 -04:00
Cody Weaver
90d84a4bf5
[NavigationDrawer] Add scroll view test (#5445)
### Context
Add basic test for the scroll view. Related to #4911
2018-10-18 14:22:47 -04:00