BottomSheet at its default behavior allows clients to drag the bottom sheet downwards to dismiss it, and also allow it to be dismissed by tapping the scrim background when it is presented.
While there is an API to customize the behavior of tapping the scrim to not allow dismissal using dismissOnBackgroundTap. There is no way to customize the dragging behavior to not dismiss.
Therefore in this PR I have introduced a dismissOnDraggingDownSheet that does exactly that. It does so by returning NO in the gestureRecognizerShouldBegin if the MDCDraggableView if dismissOnDraggingDownSheet is set to NO.
Unit tests and documentation has been added along with the new API.
Closes#8457
Currently the MDCBottomSheet controller does not mark its init method as unavailable but the contentViewController is marked as readonly so clients would have to initialize with a contentViewController. If the contentViewController is nil then when addChildViewController is called in viewDidLoad this causes a crash as you cannot pass nil to an array.
Closes#8109
Adds an elevation property to MDCBottomSheet and MDCBottomSheet presentation controller. Snapshot test have been added for the MDCBottomSheetControlller.view as well as unit test for all public APIs.
Prework for #8025
Additional API to the MDCBottomSheetControllerDelegate delegate, allowing clients to conform to the delegate and get callbacks for:
1. The offset of the sheet changes in respect to the top of the screen in points.
2. The state of the sheet changes to one of the possible states of type MDCSheetState.
This has been tested on examples to check for correctness of values and that the methods are called appropriately once the controller conforms to the protocol.
Additional unit tests have been written to test that the added delegate methods are rightly called when the value changes and a callback needs to be made.
Resolves: #7227
Fixes the `develop` branch by:
* Pinning kokoro to CocoaPods 1.5.3
* Restoring missing imports causing bazel builds to fail.
Closes#6574
Related to #6356
* Add Bottom Sheet dragon which helps reproduce an issue with bottom sheet centering and iPad Split View.
* Updated copyright and import ordering.
* Add a `scrimColor` property to the bottom sheet presentation controller.
This new property behaves the same way that the analogous property on Dialogs does.
Also added a new test that tests the scrim color in the same way that the dialog
color is tested.
* Add scrim color to the bottom sheet controller.
The scrim color is eventually set on the presentation controller
via the transition controller when the presentation controller is
first initialized.
* Updating comment for scrim color on the controller.
* Clang format
** This is a breaking change to the Shape Scheme **
Based on recent conversations with design, there has been some updates to the way we theme our bottom sheet using shapes. Namely, the discussions revolved around the different states the sheet can be shaped in, and the different variations of sheets having different shape mappings ([Standard Bottom Sheet](https://material.io/design/components/sheets-bottom.html#standard-bottom-sheet) and [Modal Bottom Sheet](https://material.io/design/components/sheets-bottom.html#modal-bottom-sheet).
In conclusion, it has been decided that for the case of the Modal Bottom Sheet (our current bottom sheet), we map the top 2 corners to the Large Component Shape category when the sheet isn't in a full screen state. When the sheet is in full screen, we should not map it or shape it at all.
### Context
ActionSheet is using MDCBottomSheet presentation controller which uses `MDCSheetContainerView` within the method `safeAreaInsetsDidChange` the `MDCSheetContainerView` would subtract the top safe area inset from the scrollView frame. This caused components using this presentation controller to have the correct layout initially but after a user interacts with it they wouldn't layout correctly.
### The problem
After the bottom sheet rebounds from an upward nudge it doesn't respect the safe area
### The fix
Remove the subtraction from the scrollView's frame.
### Related bugs
b/117286643, #5331
### Videos
| Before | After |
| - | - |
|||
**<><>This is a breaking change<><>**
There are slight terminology updates to the current Shape Scheme.
First, we are staying with the Cut notion for cut corners rather than Angled. This is on par with our current naming of the CutCornerTreatment.
Secondly, we are moving from the term S/M/L Surface to S/M/L Component for the scheme categories.
Previously clients could only set a custom height for bottom sheet by setting the `preferredContentSize` this adds a property so clients can set a specific height and not touch `preferredContentSize`.
Related to #4945
The method `updateSheetViewHeight` had no inputs and no outputs. Since
its purpose it to assign a new value to
`sheetView.preferredSheetHeight`, it should accept a new value and use
fall-back/defaulting behavior if that value is 0.
Part of #4945
Upcoming changes to `-updatePreferredSheetHeight` will create new inputs to
the method. I'm adding some new unit tests (and fixing a small error) to
capture the current behavior of the method under typical conditions.
Related to #4945
This PR allows our users to set specific corners in the shape scheme and have it applied correctly to the components.
Some components may allow only some of their corners to be set (i.e., BottomSheet)
This will allow us to set percentage support for a corner treatment as a follow up PR. Reason being is that the MDCCornerTreatment is part of the shape of the component itself, and hence has control to set the value of the corner when it is right in the lifecycle and the frame has been set. If we keep the percentage value setting in the Shape Themer, then the themer could be applied too early in the lifecycle and thus take a percentage off a 0 value (frame height).
Overall this simplifies the API and causes less duplication.
The other approach would be to *also* add percentage support to MDCCornerTreatment and leave MDCShapeCorner as is, but that would just make it too cumbersome and redundant.
This PR changes the recent addition of convenience initializers of MDCCornerTreatments to become a certain instance subclass to use concrete types rather than a generic NSNumber with parsing. This resolves#5063
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.
```
* [BottomSheet] Add BUILD file for kokoro + bazel support.
I will be sending out a variety of pull requests soon to the bottom sheet. Adding the component to kokoro will let the PRs land more quickly.
* Remove unused load statements.