33 Commits

Author SHA1 Message Date
Nobody
515ba2f70e Fixed up imports and nullability for BottomSheet
PiperOrigin-RevId: 490088242
2022-11-21 15:39:51 -08:00
Jeff Verkoeyen
fbf2f90376 [BottomSheet] Delete the ShapeThemer library.
Also removed examples that made use of the ShapeThemer and removed all of the ShapeScheme examples.

PiperOrigin-RevId: 404270856
2021-10-19 08:45:05 -07:00
Randall Li
502bc5d910 Ran a Swift formatter
PiperOrigin-RevId: 395947664
2021-09-10 09:48:14 -07:00
Jeff Verkoeyen
29803522c6 Optimizing imports
PiperOrigin-RevId: 357185525
2021-02-12 07:27:05 -08:00
Andrew Overton
1b985100ec [BottomSheet] Add flag that turns off simulated bouncing when there isn't a tracking scroll view
PiperOrigin-RevId: 353639927
2021-01-25 07:14:17 -08:00
Alyssa Weiss
1fefeaf032 Add BOOL property for whether or not the height of the bottom sheet should adjust for safe area insets.
PiperOrigin-RevId: 353309637
2021-01-22 13:40:12 -08:00
Bryan Oltman
da4b8f7c7f Fix mdc_elevationDidChangeBlock block parameter types for Xcode 12
PiperOrigin-RevId: 331843566
2020-09-15 13:39:15 -07:00
Randall Li
0100cfe414 [MDC-iOS/BottomSheet] Fix dismissOnDraggingDownSheet behavior
The bottom sheet incorrectly allowed the sheet to be drag dismissed when `dismissOnDraggingDownSheet` was set to NO.

This change permits the gesture to dismiss to begin but prevents it from actually closing the sheet.

https://github.com/material-components/material-components-ios/issues/9723

Closes https://github.com/material-components/material-components-ios/pull/9885

PiperOrigin-RevId: 307802500
2020-04-22 06:21:26 -07:00
Yarden Eitan
8841f90ff4
[BottomSheet] Add API to not allow dragging of Bottom Sheet to dismiss. (#9004)
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
2019-11-22 14:53:27 -05:00
Wenyu Zhang
0891e70dfc
[BottomSheet] Add snapshot tests to ensure BottomSheet's default presentation behavior doesn't change under iOS 13. (#8364)
Part of b/135017125.

Added a snapshot test to ensure BottomSheet's appearance doesn't change when presented under iOS 13.
2019-08-27 10:30:20 -04:00
Cody Weaver
c336d025e8
[BottomSheet] Mark init unavailable (#8108)
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
2019-07-29 10:47:33 -07:00
Cody Weaver
606f0386b3
[BottomSheet] Add MaterialElevation support (#8102)
Adds conformance to MDCElevatable and MDCElevationOverriding to
MDCBottomSheetController.

Closes #8025
2019-07-29 07:02:16 -07:00
Cody Weaver
43dddb988e
[BottomSheet] Add elevation property (#8089)
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
2019-07-26 14:08:16 -07:00
Wenyu Zhang
81938277b6
[BottomSheet] add traitCollectionDidChangeBlock support. (#7966)
Closes https://github.com/material-components/material-components-ios/issues/7926
2019-07-18 19:50:56 -04:00
Yarden Eitan
405fcd3b3c [BottomSheet] Additional API providing callbacks for sheet offset and current state changes. (#7275)
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
2019-04-26 01:08:38 -04:00
Cody Weaver
aa28d8516c
[BottomSheet] Add API to flashScrollIndicators (#7127)
## The problem
Currently `MDCBottomSheet` does not indicate to users that there is scrollable content by default. If a client is using this component and want to inform their users that the content is scrollable they currently have no way to do that.

## The fix
Add a behavioral flag for when clients want to `flashScrollIndicators` so that clients can opt into this behavior if they need it. This is recommended by Apple when:

> [You should call this method whenever you bring the scroll view to front.](https://developer.apple.com/documentation/uikit/uiscrollview/1619435-flashscrollindicators?language=objc).

## Alternatives considered
Calling `flashScrollIndicators` by default.

## Videos
| Before | After | 
| - | - |
|![before](https://user-images.githubusercontent.com/7131294/55986827-36f9a880-5c6e-11e9-86e0-f9fe7df936db.gif)|![after](https://user-images.githubusercontent.com/7131294/55986838-3bbe5c80-5c6e-11e9-8909-e518524a7b7b.gif)|
2019-04-13 22:02:56 -04:00
Robert Moore
46ff9c3173
{kokoro} Fix develop (#6575)
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
2019-02-08 12:24:55 -05:00
Ian Gordon
e61e89a592 Fix podspec validation issues 2019-02-07 16:31:09 -05:00
danblakemore
cf81763cdc [BottomSheet] Create property to allow scrim color to be set on presentation controller. (#5892)
* 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
2018-12-10 13:43:21 -05:00
Yarden Eitan
03691cad8e
[BottomSheet] [Shape]! Update to the Bottom Sheet Shape Themer (#5503)
** 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.
2018-10-24 07:45:37 -04:00
Cody Weaver
fb59ac5f1b
[BottomSheet] Respect safe area after upward nudge (#5486)
### 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 |
| - | - |
|![before](https://user-images.githubusercontent.com/7131294/47359992-25aae880-d69c-11e8-81fd-7c6675130e93.gif)|![after](https://user-images.githubusercontent.com/7131294/47360004-2b083300-d69c-11e8-864c-bc2022459f25.gif)|
2018-10-23 11:18:48 -04:00
Robert Moore
675235ed05
{Tests} Deallocate test objects at the end of tests. (#5397)
Deallocating many of the properties created for each unit test. Since all
XCTestCase instances survive until the end of the test suite, any properties
created for a test will be preserved as well. This frees up around 3.7 MB
(~6%) of memory from the entire test suite, as measured on my desktop.

|Before|After|
|----|----|
|![test-objcs-before](https://user-images.githubusercontent.com/1753199/46813473-c3b9bd00-cd44-11e8-990c-28dff4ab5ad2.png)|![test-objcs-after](https://user-images.githubusercontent.com/1753199/46813481-c7e5da80-cd44-11e8-90e4-2e6d532ebbfb.png)|

See also: https://qualitycoding.org/xctestcase-teardown/

Closes #5395
2018-10-12 08:33:58 -04:00
Yarden Eitan
bfc674a631
[Shape]! Terminology updates to the Shape Scheme (#5247)
**<><>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.
2018-09-26 13:01:08 -04:00
Cody Weaver
553fb019e7
[BottomSheet] Add property so clients can set a custom height for bottom sheet (#5139)
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
2018-09-18 11:00:56 -04:00
Robert Moore
b5c096009f
[BottomSheet] Use setter for sheet view height. (#5125)
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
2018-09-14 11:17:48 -04:00
Robert Moore
c906e41fe6
[BottomSheet] Make sheetView a property. (#5122)
To make testing a bit easier, sheetView can become a property declared
in a class extension.

Part of #4945
2018-09-14 09:35:47 -04:00
Robert Moore
db3f1f287b [BottomSheet] Add tests for updatePreferredSheetHeight. (#5115)
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
2018-09-13 15:36:14 -04:00
Yarden Eitan
c741ba4904
[Shape]! Provide more granularity for corner setting for the theming (#5116)
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)
2018-09-13 15:24:29 -04:00
Yarden Eitan
75ddb21ed0
[Shapes] merge MDCShapeCorner and MDCCornerTreatment into one (#5090)
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.
2018-09-11 17:01:58 -04:00
Yarden Eitan
c01cd70170
[ShapeLibrary] Make the new CornerTreatment initializers use concrete types (#5076)
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
2018-09-10 15:41:50 -04:00
Yarden Eitan
3dc5721da3
[BottomSheet] Addition of a Bottom Sheet Shape Themer (#5062)
In this PR I am adding a Bottom Sheet shape themer along with unit tests.

This closes issue #5057
2018-09-07 19:02:00 -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
featherless
5c87a3fd9a
[BottomSheet] Add BUILD file for kokoro + bazel support. (#2396)
* [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.
2017-11-10 17:35:16 -05:00