30 Commits

Author SHA1 Message Date
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
guylivneh
bfa674da94 [NavigationDrawer] Fix the init of the MDCBottomDrawerViewController to use the designated inits (#5546)
Fix the init of the MDCBottomDrawerViewController to use the designated inits.
2018-10-30 13:22:47 +02:00
guylivneh
08b71a81ee [BottomDrawer] Adding an example for dynamically changing content size (#5545)
Adding an example for dynamically changing content size.
2018-10-29 17:52:24 +02:00
Yarden Eitan
5dafdbaa86
graduate navigation drawer from Beta to Ready (#5470)
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
2018-10-23 01:26:46 -04: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
rami-a
70457a398a
[NavigationDrawer] Add Color Themer support (#5458)
### 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];
```
2018-10-19 15:36:58 -04:00
Yarden Eitan
58380e7c75
[NavigationDrawer] fix drawer not dismissing in full screen on 32 bit devices (#5454)
### 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.
2018-10-19 13:43:53 -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
Yarden Eitan
8c3aedd5ea
[NavigationDrawer] Present the drawer in full screen when in a compact size class (#5443)
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
2018-10-18 11:53:25 -04:00
Anuran Barman
b71390dbc4 [NavigationDrawer] Made DrawerHeaderViewController.swift file to conform to MDCBottomDrawerHeader to fix header not showing issue in components examples (#5325)
Added conformation to MDCBottomDrawerHeader for DrawerHeaderViewController.swift file in **NavigationDrawer** examples as it was not showing up if code was run.
2018-10-16 13:58:54 -04:00
Cody Weaver
b18f9987b6
[NavigationDrawer] Setup for tests (#5423)
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
2018-10-15 20:25:44 -04:00
Cody Weaver
d9c9e741d9
[NavigationDrawer] Add rounded corners when there is scrollable content (#5410)
### Context
The guidelines indicate that a Navigation Drawer should have rounded corners if there is more content to scroll. Currently Navigation Drawer has a corner radius of 0 no matter what. This doesn't indicate to the user that there is scrollable content so they may not be able to find content that is offscreen. The navigation drawer should slowly animate to a corner radius of 0 as it approaches the top of the screen or the top of the content. 
### The problem
No rounded corners if there is scrollable content.
### The fix
Add a mask to the highest view, either the `headerViewController.view` or the `contentViewController.view` (if there is no header). Additionally animate the mask as the user scrolls.
### Related issues
Closes #5152
### Screenshots
| Before | After | 
| - | - |
|![simulator screen shot - iphone xs max - 2018-10-12 at 17 27 47](https://user-images.githubusercontent.com/7131294/46894990-7de41e00-ce44-11e8-809e-c6aec2249b7a.png)|![simulator screen shot - iphone xs max - 2018-10-12 at 17 22 29](https://user-images.githubusercontent.com/7131294/46894995-82103b80-ce44-11e8-9b01-acbcfe4e86cc.png)|
### Videos
| Before | After |
| - | - |
|![develop](https://user-images.githubusercontent.com/7131294/46895012-92c0b180-ce44-11e8-88d8-b9a0eda3de7b.gif)|![fix](https://user-images.githubusercontent.com/7131294/46895018-96543880-ce44-11e8-9d73-cec8c170a648.gif)|
2018-10-15 18:00:53 -04:00
Cody Weaver
d1a8746ad1
[NavigationDrawer] Add buttons to example to present navigation drawer (#5419)
### 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.
2018-10-15 18:00:37 -04:00
Cody Weaver
d85eee86cb
Remove remaining _IPHONE_11 checks (#5417)
### 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.
2018-10-15 11:22:15 -04:00
Yarden Eitan
6e31fd6d79
[NavigationDrawer] Added VoiceOver support to have the drawer show at full screen. (#5411)
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.
2018-10-15 10:38:47 -04:00
Yarden Eitan
4c5dfa93bd
[NavigationDrawer] Support any kInitialDrawerHeightFactor value (#5337)
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.
2018-10-08 11:34:45 -04:00
Yarden Eitan
0f35751373
[NavigationDrawer] Performance improvements and increased support for customizing initial drawer percentage height (#5255)
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.
2018-10-04 15:46:00 -04:00
Andrew Overton
07981be315
Use CGRect accessor methods (#5244)
Follow up to #5179 that replaces frame.size.height with CGRectGetHeight(...), etc.
2018-09-26 13:11:03 -04:00
Andrew Overton
d56a82e0e5
[NavigationDrawer] Fix iOS 9 bottom drawer dismissals (#5202)
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.
2018-09-26 12:22:20 -04:00
Andrew Overton
fbaa6b5fcb
[NavigationDrawer] Fix bug where BottomDrawer layout breaks when there isn't enough cont… (#5179)
From the internal issue:

> If there is less content in a bottom drawer than vertical available screen space and the content gets dragged to the top (by overextending with the rubber band effect), the layout of the drawer content gets broken and the drawer content snaps to the bottom. This can be reproduced on any iOS version and device I have tested (tested on iOS 9 iPhone 4S, iOS 10 iPhone 5 and iOS 12 iPhone XS Max simulators).

---
Here is a before video of the bug in action:
![shortscrollbroken](https://user-images.githubusercontent.com/8020010/45780222-119e4200-bc2b-11e8-90c4-df558c51b059.gif)

Here is an after video of the bottom drawer working as intended with short trackingScrollView content:
![shortscrollfixed](https://user-images.githubusercontent.com/8020010/45780202-05b28000-bc2b-11e8-94c7-af3dea29229f.gif)

Here is an after video of the bottom drawer working as intended with long trackingScrollView content:
![scrollingwithlongcontent](https://user-images.githubusercontent.com/8020010/45780212-0a773400-bc2b-11e8-9714-128f04939647.gif)

Closes #5147
2018-09-25 17:37:07 -04:00
Robert Moore
aef3cc73af
[NavigationDrawer] Fix Swift imports in examples. (#5096)
The Swift examples were not compiling internally because they were
missing many imports.
2018-09-11 14:52:07 -04:00
featherless
2181084272
[automated] Standardize our open source license stanza to what Xcode generates. (#4985)
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.
```
2018-08-31 12:13:07 -04:00
Yarden Eitan
3480c50c67
updated to newest CbC standard (#4956)
Move to the new CbC standard released in CatalogByConvention v2.5.0. See PR: material-foundation/cocoapods-catalog-by-convention#27 for more info on the change.
2018-08-29 20:45:13 -04:00
Yarden Eitan
358050f1c3
[NavigationDrawer] Initial doc write-up of overview, and usage. (#4927)
This includes an initial write-up of the navigation drawer docs. closes #4925
2018-08-28 22:46:36 -04:00
guylivneh
b2d17e1ed6 [NavigationDrawer] Adding the navigation drawer component (#4886)
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.
2018-08-27 16:00:40 -04:00
featherless
a0c3ee3e3e
Update navigation drawer readme to point to the project (#4630) 2018-07-25 10:43:24 -04:00
sfdexter
3e68e9761f Placeholder documentation for future components and guidance (#3568) 2018-04-27 19:05:00 -04:00