148 Commits

Author SHA1 Message Date
Andrew Overton
588d9d2fe5 [BottomSheet] Mask elevation on bottom edge
PiperOrigin-RevId: 332461973
2020-09-18 09:08:35 -07:00
Jeff Verkoeyen
fbb1f20aa2 Internal change
PiperOrigin-RevId: 332151481
2020-09-16 21:01:21 -07:00
Bryan Oltman
da4b8f7c7f Fix mdc_elevationDidChangeBlock block parameter types for Xcode 12
PiperOrigin-RevId: 331843566
2020-09-15 13:39:15 -07:00
Andrew Overton
225cd3c0cb [BottomSheet] Ensure transition controller pass-through accessors work following presentation controller initialization
PiperOrigin-RevId: 326304121
2020-08-12 13:49:59 -07:00
Nobody
87c8968e66 Updating BottomSheet examples organization
PiperOrigin-RevId: 315266913
2020-06-08 07:03:09 -07:00
Bryan Oltman
464f202058 [BottomSheet] Add bottomSheetDismissalAnimationCompleted method to MDCBottomSheetPresentationController.
This function is invoked by MDCBottomSheetPresentationControllers when the bottom sheet dismissal animation has completed. This will be followed by a change to add a similar function to MDCActionSheetControllerDelegate, which will close the associated issue.

PiperOrigin-RevId: 314948223
2020-06-05 10:10:26 -07:00
Bryan Oltman
b169119b9f Internal change
PiperOrigin-RevId: 314926035
2020-06-05 07:47:15 -07:00
Bryan Oltman
4e461e2c13 [Catalog] Add BottomSheetPresentationControllerDelegateExample to demonstrate usage of MDCBottomSheetPresentationControllerDelegate.
PiperOrigin-RevId: 314784259
2020-06-04 12:47:00 -07:00
Bryan Oltman
ee0b388c5c [Catalog] Rename BottomSheetPresentationExample to BottomSheetModalPresentationExample to better represent its purpose.
PiperOrigin-RevId: 314778352
2020-06-04 12:18:05 -07:00
Yarden Eitan
65b749fb56 [BottomSheet] Have the container sheet be laid out by the container view's bounds, not frame.
In cases where there is a call and the status bar pushes the UITransitionView (container view) down by 20 points, we don't want the sheet view to take the Y offset of 20 points from the container view and add another 20 points to its Y origin as well.

PiperOrigin-RevId: 309715718
2020-05-04 04:08:30 -07:00
Wenyu Zhang
c8ba09ff95 [BottomSheet]Set MDCSheetStateExtended for MDCBottomSheetController in its initializer.
PiperOrigin-RevId: 309121727
2020-04-29 16:36:28 -07:00
Wenyu Zhang
a3381717f7
Fix the bazel BUILD files and snapshot that were restored unintentionally.(#9983) 2020-04-29 11:00:00 -04:00
Randall Li
da90ed6640 [MDCBottomSheet] Better logging output in example.
PiperOrigin-RevId: 308843160
2020-04-28 10:01:41 -07:00
Randall Li
fa0e96173d [MDCBottomSheet] TableViewExample: Fixed swift format and added class description to example.
PiperOrigin-RevId: 308734272
2020-04-27 17:47:58 -07:00
Randall Li
ceff0080c1 [MDCBottomSheet] recreate bug in catalog.
Landscape presented tableviews resist scrolling up with longer content.

PiperOrigin-RevId: 308726855
2020-04-27 16:58:20 -07:00
Yarden Eitan
59631d0077 [BottomSheet] Set the contentView's frame later in the lifecycle.
Currently setting the contentView's frame to its parent view is only done in viewDidLoad.
In that point in time, it is too early and the self.view.bounds height is still 0.
Due to that, in certain cases the view itself goes through a layout pass and updates itself to a frame height
that is larger than its parent view, causing problems like inability to scroll if it is a table view, as the content is already "fully displayed".
By setting the content view to the frame of the superview in viewWillAppear, we are assuring it stays the correct height.

PiperOrigin-RevId: 308593193
2020-04-27 04:02:48 -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
Dave MacLachlan
ebac2a8eb7 As of iOS 9/macOS 10.11 (circa 2015) removing objective C objects from the NSNotificationCenter in - (void)dealloc. is no longer required (the classic example is: [[NSNotificationCenter defaultCenter] removeObserver:self] but there are several variations).
In many cases this is the only thing being done in - (void)dealloc, so we can remove the whole thing.

PiperOrigin-RevId: 307663440
2020-04-21 13:00:30 -07:00
Andrew Overton
b5c894e7e3 Present in full screen in vertical compact size classes when the content height is taller than the sheet view's bounds.
This CL makes it so that the bottom sheet presents in full screen when A) the bottom sheet presentation view controller's sheet container view's scroll view's content height is taller than the max height of the sheet, and B) the vertical size class is compact.

PiperOrigin-RevId: 307048307
2020-04-17 08:33:02 -07:00
Jeff Verkoeyen
8abbb099a9 Delete all bazel support.
We no longer support bazel.

This PR deletes everything related to bazel support from our repo.

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

PiperOrigin-RevId: 306227127
2020-04-13 07:13:47 -07:00
Jeff Verkoeyen
1cf770cc40 [BottomSheet] Deprecate the ShapeThemer.
PiperOrigin-RevId: 305856422
2020-04-10 04:14:38 -07:00
Cody Weaver
fdf87c5995 [MDC/ColorScheme] Remove usage of init within MDC.
We recommend using `initWithDefaults` and we should follow the recommendation. This change removes all usage of `init` within MDC components in order to let us remove that initializer from the public surface.

PiperOrigin-RevId: 302958447
2020-03-25 13:36:51 -07:00
Andrew Overton
3b7dfcd48c Give MDCBottomSheetPresentationController an opt-in mechanism to propagate presentingViewController safeAreaInsets to the presentedViewController.
This CL adds the presentingViewController's safeAreaInsets as additionalSafeAreaInsets on the presentedViewController in MDCBottomSheetPresentationViewController when the shouldPropagateSafeAreaInsetsToPresentedViewController is set to YES.

Originally I wasn't going to put this behavior behind a flag, but it was breaking some clients, so I added the flag.

PiperOrigin-RevId: 302683940
2020-03-24 09:42:50 -07:00
Bryan Oltman
c6a586b72e [BottomSheet] Remove private header imports from MaterialBottomSheet.h
PiperOrigin-RevId: 301909458
2020-03-19 15:41:07 -07:00
Bryan Oltman
7cd01d2fba [BottomSheet] Move protocol definitions into separate header files
PiperOrigin-RevId: 301859388
2020-03-19 11:39:10 -07:00
featherless
2ca4e3e229
[BottomSheet] Anchor movement of the bottom sheet along the y axis. (#9835)
Prior to this change, it was possible to make the bottom sheet "wobble" on the x-axis if you threw it just right, or if you adjusted the width of the application in a split-screen environment.

This bug was due to the fact that bottom sheet is implemented with UIDynamics and it was using a stock UIAttachmentBehavior to animate the bottom sheet to its destination. UIAttachmentBehavior supports both x and y movement out of the box, but bottom sheet appears to have historically attempted to mitigate this fact by resetting the x velocity to 0 in several places. For example:

a42a84cca9/components/BottomSheet/src/private/MDCDraggableView.m (L63-L64)

and

a42a84cca9/components/BottomSheet/src/private/MDCDraggableView.m (L87-L88)

After this change, the bottom sheet's allowed range of movement will only be along the y axis. This is now enforced through a custom action block that explicitly resets the x position of the behavior's target to _targetPoint.x.

Closes https://github.com/material-components/material-components-ios/issues/9836
Closes https://github.com/material-components/material-components-ios/issues/5330

## Testing

Testing steps:

1. Open MDCDragons on an iPad.
2. Open the "Static content" Bottom Sheet example.
3. Present the bottom sheet.
4. Drag Safari from the dock to the side of the screen to enter split-screen mode.
4. Adjust the split screen divider to adjust the side of the MDCDragons app.

Verify that that bottom sheet is not wobbling on its x-axis.

Similarly, try tossing the bottom sheet up and to the left or up and to the right and verify that it does not wobble on its x-axis.
2020-03-05 10:58:09 -05:00
Bryan Oltman
d83af534c3
[TextFields] implement resignFirstResponder in MDCMultilineTextField (#9793) 2020-02-25 16:17:19 -05:00
Bryan Oltman
00a4f37a4a
[BottomSheet] Add example to reproduce issue 9773 (#9789)
A reproduction of an issue found internally. To reproduce:

1. Navigate to this example
1. Turn VoiceOver on
1. Tap the button to display the bottom sheet

Expected behavior:
The bottom sheet becomes focused

Actual behavior:
The text field behind the bottom sheet reclaims focus after the bottom sheet finishes presenting

Reproduces #9773
2020-02-24 17:48:35 -05:00
Robert Moore
b027eeed70
[BottomSheet] KVO contentInset property (#9726)
When a client or implementation updates the `contentInset` property, the
presented content may no longer be visible. Similar to observing the
`contentSize` property, when a change to `contentInset` takes place, the sheet
should reposition itself to make its content visible once more.

This change is specifically required for ActionSheet. ActionSheet adds a
header view above its table view and adjusts the table view's `contentInset`
to account for the header view's height. If this height changes, then the
`contentInset` value will change, but the `contentSize` will not. If the
`contentInset` value is not directly observed, the presented ActionSheet may
end up showing less than the total available content (when the height is less
than half the screen height).  By observing the `contentInset` property, the
sheet is presented with all content visible on-screen.

Part of #8709
2020-02-24 17:39:54 +02:00
featherless
b7cf0de915
[bazel] Remove all unused swift_library load statements. (#9369)
Found by searching for all references to `\bswift_library` and removing load statements from files that only returned one result.

Clean up as part of https://github.com/material-components/material-components-ios/issues/5491
2020-01-02 11:01:31 -05: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
Bryan Oltman
78fe3701d0
[Catalog] Add accessibility elements to BottomSheetExamples (#8923)
* [Catalog] Add accessibility element to BottomSheetTallExample

* [Catalog] Add accessibility element to BottomSheetSimpleExample

* Add dismissOnBackgroundTap to BottomSheetPresentationExample

* clang
2019-11-15 12:10:37 -05:00
Bryan Oltman
adfe99ed30
[Catalog] Add VoiceOver support to BottomSheetShortCollectionExample (#8849) 2019-11-14 23:20:03 -05:00
Bryan Oltman
5b826f163a
[Catalog] Remove scrim accessibility logic from BottomSheetUIControlExample (#8848)
* [BottomSheet] Ignore background tap location if VoiceOver is on

* Verify that the scrim view is focused in voice over

* cleanup

* Remove VoiceOver logic from bottom sheet, update example

* cleanup
2019-11-14 17:25:50 -05:00
Andrew Overton
7807cf53fa
[BottomSheet] Make bottom sheet be in extended state when voiceover is on (#8787)
This PR makes it so that the MDCBottomSheetController's MDCSheetState property accurately reflects the actual state its in during VoiceOver. Its previous VoiceOver behavior made it _look_ like it was extended, but `po bottomSheetController.state` would yield `MDCSheetStatePreferred`. Now it outputs `MDCSheetStateExtended`.

Thoroughly manually tested.

Closes #6758.
2019-11-12 16:34:41 -05:00
Linksmt
948199ab04 [BottomSheet] Disable pan gesture on UIControl (#8491)
This change prevents touches to UIControl from being recognized by the bottomsheet's swipe gesture. This way a user doesn't accidentally starts dismissing the sheet while they are trying to interact with a control on the sheet.
2019-10-10 15:08:22 -04:00
Wenyu Zhang
9bd8770ae4
[BottomSheet] replace UIWebView usage with WKWebView. (#8453)
closes https://github.com/material-components/material-components-ios/issues/8381.

This PR removed the references to deprecated UIWebView, and used WKWebView (available on iOS8+) in place to keep the original behavior. 

As WKWebView is available on Mac Catalyst, the TARGET_OS_UIKITFORMAC flag is also removed.

An Example is created for this WebView change.
Screenshot:

![webview](https://user-images.githubusercontent.com/8836258/64892736-42993300-d643-11e9-8dfa-a686506de015.gif)
2019-09-13 17:41:09 -04: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
Robert Moore
51f63776ac
[BottomSheet] Use Starlark macros. (#8160)
Adds more macro usage to the BUILD file. This makes it easier to perform
weekly releases.

Part of #8150
2019-08-01 15:46:28 -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
Mark Aufflick
4354bfc284 Added test to avoid referencing UIWebView under UIKit for Mac (#7679)
`MDCBottomSheetPresentationController.m` contains a reference to UIWebView. This prevents compilation under UIKit for Mac where that class does not exist.

closes #7677
2019-06-26 07:21:18 -04:00
Andrew Overton
395290fed4
[BottomSheet] Add respondsToSelector check in BottomSheet accessibility escape (#7570)
This PR fixes a crash by adding a respondsToSelector check to the BottomSheet accessibility escape.

Closes #7569.
2019-06-13 09:58:33 -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
Yarden Eitan
efe61588a6
update (#7246)
We need to add @objc annotations to colorScheme and typographyScheme instances in our Swift examples, because we moved to Swift 4.2, the respondsToSelector won't find `setColorScheme:` and `setTypographyScheme:` setters otherwise.
2019-04-23 10:21:14 -04:00
featherless
699a621c7e
[BottomSheet] Annotate themer APIs with the recommended APIs. (#7216)
Part of https://github.com/material-components/material-components-ios/issues/7108
2019-04-22 19:55:40 +03:00
featherless
e2550dbb55
(automated) Regenerate all component readmes. (#7201)
This is an automated change. It was generated by running:

    ./scripts/generate_all_readmes
2019-04-22 13:29:48 +03:00
Andrew Overton
c56d5d76d3
Add @objc annotations to get examples to show up in Dragons (#7168)
This is a follow up PR for #7166 adds @objc annotations to Swift catalogMetadata() methods, because the Swift 4 compiler no longer attempts to infer what methods should be visible to Objective-C. As a result of this change in the compiler, no Swift examples were showing up in Dragons after #7166. See this article: https://useyourloaf.com/blog/objc-warnings-upgrading-to-swift-4/ for additional context.
2019-04-17 21:35:43 -04:00