31 Commits

Author SHA1 Message Date
Nobody
8bb590a78d Add explicit imports for CoreGraphics in files which use it.
PiperOrigin-RevId: 642400931
2024-06-11 14:52:59 -07:00
Nobody
a18d1afbc0 Fixed up imports for Ripple
PiperOrigin-RevId: 478024434
2022-09-30 10:26:28 -07:00
Jeff Verkoeyen
b3fa42005b Optimizing imports
PiperOrigin-RevId: 356966407
2021-02-11 07:12:37 -08:00
Yarden Eitan
a68702e3a4 [Ripple] Add delegate method to RippleTouchController existing in InkTouchController.
This delegate method allows clients to have one ripple touch controller control multiple ripple views. Also gives them more flexibility on the creation and reusing of ripple views.

PiperOrigin-RevId: 317614179
2020-06-22 02:18:07 -07:00
Yarden Eitan
5462d27375 [Ripple] Add a convenience API for finding the ripple view in the view's subviews.
If a ripple view is not found, a new instance of a ripple view is created.

PiperOrigin-RevId: 317610319
2020-06-22 01:40:27 -07:00
Yarden Eitan
f425b8995b [Ripple] Update alpha value of Ripple to 0.12 instead of 0.16
PiperOrigin-RevId: 316850177
2020-06-17 02:23:19 -07:00
Yarden Eitan
ef53fab9ca [Ripple] Align ripple starting size with spec guidance.
PiperOrigin-RevId: 316633026
2020-06-16 01:03:50 -07:00
Eric Lee
608694e260 [Material][Availability] Migrates Ripple to MDCAvailability.
PiperOrigin-RevId: 301671613
2020-03-18 14:42:27 -07:00
featherless
9d60c22e29
[Ripple] Add usesSuperviewShadowLayerAsMask flag. (#8822)
Follow-up to https://github.com/material-components/material-components-ios/pull/8808

Part of https://github.com/material-components/material-components-ios/issues/6913

From the docs:

tl;dr: If you are adding ripples to views with custom `layer.shadowPath` values, please disable
`usesSuperviewShadowLayerAsMask` and assign an explicit layer mask to the ripple view if needed
instead. usesSuperviewShadowLayerAsMask will eventually be disabled by default and then deleted.

MDCRippleView currently implements a convenience behavior that will inherit its parent view's
`layer.shadowPath` as the mask of the ripple view itself. This works for the general case where the
ripple view's frame equals the bounds of its super view, but behaves unexpectedly for any other
frame of the ripple view.

Due to the brittleness of this behavior, a new migration property, `usesSuperviewShadowLayerAsMask`,
has been added that will allow you to disable this behavior in favor of a more explicit
determination of the ripple's layer mask.

Example usage:

<!--<div class="material-code-render" markdown="1">-->
#### Swift
```swift
// During initialization:
rippleView.usesSuperviewShadowLayerAsMask = false
// Simple example of applying a mask to the ripple view using the ripple view's bounds:
let rippleViewMask = CAShapeLayer()
rippleViewMask.path = UIBezierPath(rect: rippleView.bounds).cgPath
rippleView.layer.mask = rippleViewMask
```
#### Objective-C
```objc
// During initialization:
rippleView.usesSuperviewShadowLayerAsMask = NO;
// Simple example of applying a mask to the ripple view using the ripple view's bounds:
CAShapeLayer *rippleViewMask = [[CAShapeLayer alloc] init];
rippleViewMask.path = [UIBezierPath bezierPathWithRect:rippleView.bounds].CGPath;
rippleView.layer.mask = rippleViewMask;
```
<!--</div>-->
2019-11-27 16:07:09 -05:00
featherless
9123dc603e
[Ripple] Add tests demonstrating unexpected layer.mask behavior. (#8808)
These tests demonstrate how a ripple view added as a subview can end up with an incorrect layer mask if the ripple view's frame does not match the bounds of the parent view and the parent view's layer has a shadowPath. All of the tests intentionally pass, with the final test demonstrating the incorrect behavior.

In a follow-up change, I will be adding a behavioral flag to turn off this unexpected behavior in favor of a more explicit approach to configuring the ripple view's layer mask.

Part of https://github.com/material-components/material-components-ios/issues/6913
2019-11-14 13:29:01 -05:00
Michael Schneider
3b4c9d170a [Ripple] Improve MDCRippleTouchController (#8631)
Changes:
- Create new initializer that allows to defer adding `MDCRippleView` to the a provided view
- Add `MDCRippleView` on first touch down if YES was passed in as deferred parameter
- Lazy getter for `rippleView`
- As `rippleView` property is not supposed to be overwritten always use `_rippleView` instance variable within touch controller
- Cache all delegate methods for faster lookup if a delegate responds to a selector

Determined improvements:
- Reduce memory overhead and safes a couple of cycles due to creation of `MDCRippleView` lazily
- Reduce overhead for adding / removing `MDCRippleView` to view hierarchies
- Reduce overhead of having the `MDCRippleView` that most of the time is hidden within view hierarchies as it will only get's added and immediately removed if needed
2019-11-04 15:26:45 -05:00
Robert Moore
48d3d591bf [Ripple] Use Starlark macros. (#8183)
Updates the BUILD file to use more Starlark macros. Also drops the `includes`
update from the private target and fixes the imports in unit tests.

Part of #8150
2019-08-02 08:48:41 -07:00
Robert Moore
66435f1b68
[Color] Create umbrella header. (#8091)
All components should have a top-level umbrella header for their includes.
This allows easier refactoring of classes and files within the component.
Creating an umbrella for Color and using it outside the component.

Part of #8086
2019-07-25 15:41:26 -04:00
Cody Weaver
8f6338e0b2
[Ripple] Add traitCollectionDidChange block (#8062)
Adds a traitCollectionDidChangeBlock to MDCRippleView and its subclass, called when its trait collection changes.

Closes #8043
2019-07-23 22:18:52 -07:00
Yarden Eitan
5cdb7f95f7
[Ripple] Add dynamic color support for ripple. (#7968)
Adds dynamic color support for Ripple and tests using snapshot tests that the dark mode color is correctly applied.

Closes #7867

(this is an un-revert of dfbecc6547 now that https://github.com/material-components/material-components-ios/pull/7949 landed)
2019-07-19 07:50:52 -07:00
Wenyu Zhang
dfbecc6547 Revert "[Ripple] Add dynamic color support for ripple. (#7877)"
This reverts commit edb5f11af1a830e004fdffef536c4b6306b4eb4b.
2019-07-17 12:36:38 -04:00
Wenyu Zhang
593470a471 [Snackbar] Fix a common typo. 2019-07-16 13:40:42 -04:00
Yarden Eitan
edb5f11af1
[Ripple] Add dynamic color support for ripple. (#7877)
This relies on #7861 .

Adds dynamic color support for Ripple and tests using snapshot tests that the dark mode color is correctly applied.

Closes #7867
2019-07-11 22:13:46 -04:00
Cody Weaver
6deed96003
[Ripple] Add snapshot test for maximumRadius API. #7538
In #7357 the `maximumRadius` API was added to Ripple along with unit test. This adds a snapshot test to make sure that we do not regress this behavior visually in the future.
2019-06-05 10:10:34 -04:00
Cody Weaver
22a4f2b72f
[Ripple] Add max ripple radius property (#7357)
Add maxRippleRadius property to MDCRippleView. This allows clients to set the maximum size a ripple should expand if rippleStyle is set to MDCRippleStyleUnbounded. This property is part of the Ink component and in order to make transitions easier for clients from Ink to Ripple this property is necessary. Additionally this allows icon button to be supported as a button with only an icon has a different ripple than a button without an icon or with an icon and text.

Closes #7338
2019-05-09 11:10:33 -07:00
Cody Weaver
d42a3819c4
[Ripple] Make rippleRadius a property (#7350)
This change modifies the rippleRadius ivar to make it a property. This exposes it in the private header of the MDCRippleLayer.h so that later if we need to modify the rippleRadius to support min/max values we can. This change also allows us to test this property.
2019-05-09 10:10:15 -07:00
Cody Weaver
8dc59e15a1
[Ripple] Remove setting frame based on superview (#7333)
In order for MDCRipple to support customizable ripple size the superview needs to be able to adjust the ripple view's frame. By setting the frame to the superview's frame it overrides whatever the superview sets within its layoutSubviews method. This removes that override to allow for a more customizable ripple.

Closes #7329
2019-05-03 09:54:54 -07:00
Yarden Eitan
2cfe205750 [Ripple] Reduce runloop time as speed is already very fast (#7283)
post PR for lowering run loop time comment.
2019-04-27 17:53:45 +03:00
Yarden Eitan
a8a9cfa534
[Ripple] Additional snapshot test for an edge case (#7279)
This snapshot test is added to test the behavior when the rippleHighlighted is set to YES and the ripple is then dissolved because there is no check in the implementation to only dissolve when rippleHighlighted is set to NO.

This is a pre-snapshot test to successfully test PR: #7274
2019-04-26 16:46:28 -04:00
Yarden Eitan
f7f792b513
[Ripple] Added additional unit and snapshot tests (#6992)
Adding unit tests and snapshot tests to provide better coverage for the Ripple component.
2019-03-27 11:03:25 -04:00
Yarden Eitan
60c3eea9ce
[Ripple] Adds additional API of adding the Ripple to a view and its position in the view hierarchy. (#6983)
Add support of adding Ripple anywhere in the view hierarchy using the rippleTouchController's delegate and added an initializer that doesn't add the ripple as a subview straight away.

This PR provides these changes to the RippleTouchController class:
1. Adds a `init` initializer and turns `initWithView` to a convenience initializer. This allows users to add the view that owns the tap gesture and have the ripple as its subview to be added at a later time.
2. Provided a new method to the RippleTouchControllerDelegate that is optional and if conformed to allows users to decide where in the view hierarchy the ripple view should be added.

Both changes above allow the MDCRippleTouchController to better support the API of the MDCInkTouchController when migration comes. Also this change won't break existing clients who already use the RippleTouchController.

Unit tests provided for the added API.

Closes b/128908674
2019-03-25 15:16:11 -04:00
Andrew Overton
3b1d82a526
Revert "[Cocoapods] Fix snapshot testing after Cocoapods 1.6.0 update (#6611)" (#6619)
This reverts commit fb21536d9f685485793de87f25ad2d4cd43e081e.
2019-02-14 19:22:03 -05:00
Andrew Overton
fb21536d9f
[Cocoapods] Fix snapshot testing after Cocoapods 1.6.0 update (#6611)
Snapshot tests stopped running after https://github.com/material-components/material-components-ios/pull/6580. I think this PR fixes it.

Cocoapods 1.6.0 creates a selected "white lego" test target for each unit test `test_spec` in a podspec. However, it did not do so for our snapshot tests. Instead, it created a single unselectable  `MaterialComponentSnapshotTests` build target with the red and white target icon.

I moved the snapshot testing related files like `MaterialSnapshot.h` to a regular `subspec`, as opposed to a `test_spec`. After this change, Cocoapods 1.6.0 created selected "white lego" snapshot testing targets, just like with the unit tests. I guess it's bad to have test_specs within subspecs that don't have any source files?

EDIT: What I described above was only the beginning. I had to do a lot more to get everything working. Because Cocoapods 1.6.0 makes each `test_spec` into its own test target I had to create additional Swift dummy files to evade the [-lswiftSwiftOnoneSupport](https://github.com/material-components/material-components-ios/blob/develop/components/Cards/tests/snapshot/Dummy.swift#L17) linker error that Rami discovered when first adding Snapshot testing. I also had to add these Swift files to BUILD files. We might be able to get rid of these if we only depend on `iOSSnapshotTestCase/Core` (which is the same thing as `iOSSnapshotTestCase` but without Swift support) and commit to writing only Obj-C snapshot tests.

I also had to add two Objective-C dummy source files at the top level of the `MaterialComponentsSnapshotTests` podspec, and to the `private/Snapshot` BUILD file. I don't know why these source files were required. I arrived at this after much trial and error, which is not ideal. I want to try to get rid of them if possible, but I think they should go in for now, just so we can get this stuff working again.

Lastly, I had to disable bitcode everywhere. For some reason, the fact that `iOSSnapshotTestCase` explicitly disables bitcode is now a problem for us, where it wasn't before. From what I read on various blog posts, if an app target's dependency explicitly disables bitcode, an app target cannot enable it. Again, I don't know why this is only now a problem. This change on my part is the result of reading linker error messages and taking their advice. Right now I'm just disabling it everywhere in the `post_install`. We might be able to get away with only disabling it in MDCDragons and MDCDragons and just committing that to version control. I plan to look into that after this gets merged in.

I'm hoping that some of the changes in this PR can be undone at a later date, preferably soon. There is a chance that only depending on `iOSSnapshotTestCase/Core` and removing our snapshot tests from the Dragons and Catalog schemes and putting them in their own app target _could_ go a long way towards doing this.

Closes #6609
2019-02-14 14:07:40 -05:00
Yarden Eitan
02161e4a76
[Ripple] Fix ripple layout issues with autolayout (#6588)
This fixes a long standing issue in our Ink/Ripple implementation where with auto layout the ink view doesn't fit itself correctly when there is a re-layout, as an example during an orientation change.

There were a few things needed to be fixed/added to be able to make the Ripple work correctly:

1. every time MDCRippleView lays out its view, the MDCRippleLayer sublayers need to receive the new bounds and need to lay out the ripple based on the new bounds.
2. The MDCRippleView should at all times be the size of it's superView.
2. When an MDCRippleLayer exists and needs to be laid out again, it needs to recalculate the ripple layer's position and path. This can happen as an example during a ripple animation when an orientation change occurs. This can also happen when there is a ripple overlay that isn't transient is on a surface and there is an orientation change.
3. Lastly, moving the MDCRippleLayer animations away from `removeOnCompletion = NO;` to having the final visual values be set prior to the animation, solves an issue where a `setNeedsLayout` reverts certain animations (an animation over layer.position) back to their original values and causes the ripple to be incorrectly centered.

Resolves #4533 
Resolves #4603 

Below are provided gifs showing the fix.
Before:
![beforeripplelayout](https://user-images.githubusercontent.com/4066863/52529447-c3640b00-2cbf-11e9-929b-cb69be6d3b27.gif)

After:
![afterripplelayout](https://user-images.githubusercontent.com/4066863/52529450-cb23af80-2cbf-11e9-828b-2dfd5cb2bc96.gif)
2019-02-11 17:22:26 -05:00
Robert Moore
47cb0eb08f
[Ripple] Fix flaky unit test. (#6315)
The Ripple unit test was attempting to grab `CACurrentMediaTime()` but that
resulted in a flaky test if there was any delay between the method invocation
and when the time was recorded. Instead, we should probably just inspect the
timing between when the touch began and the expected start of the ripple end
animation.

Closes #6313
2019-01-15 08:41:04 -05:00
Yarden Eitan
1753e12717
[Ripple] Ripple implementation + example + unit tests (#6174)
This PR includes the ripple implementation that is up to date with Material design and motion guidelines.

A ripple by definition is a visual form of feedback for touch events providing users a clear signal that an element is being touched. The ripple effect is a core functionality for components such as buttons, cells, cards, etc.

This will eventually succeed the outdated Ink component, and is currently being added under MaterialComponentsBeta.

There are unit tests and an example included to this PR.

The full design doc can be found here: go/ripple-ios-revisited
2019-01-02 19:31:03 -05:00