11 Commits

Author SHA1 Message Date
Yarden Eitan
c9904413f7 [Button] Add opt-in new performant shadow support.
PiperOrigin-RevId: 369820180
2021-04-22 01:06:02 -07:00
Darren Mo
2d6db967af Add properties to configure the border color/width of MDCShapedView.
`MDCShapedView` has properties to configure the elevation and shape generator but no properties to configure the border color/width. In order to do so, one must cast the view’s layer to `MDCShapedShadowLayer` and set its border color/width. (There is also no property exposing the underlying `MDCShapedShadowLayer`.)

PiperOrigin-RevId: 351710014
2021-01-13 18:52:22 -08:00
Wenyu Zhang
bb04d0aab5 [Shapes] Use the path's boundingBox to determine the scale used when borderWidth is deducted from the path.
PiperOrigin-RevId: 324334338
2020-07-31 18:45:05 -07:00
Wenyu Zhang
aeacc8dcc6 [Shapes] Add a snapshot test for small path rendered in a large bounding box with same borderWidth and cornerRadius.
PiperOrigin-RevId: 323814069
2020-07-29 10:23:00 -07:00
Yarden Eitan
f4263fe70e [Shape] Update shapeLayer to the correct path to correctly be a mask for content.
PiperOrigin-RevId: 322911498
2020-07-23 18:33:38 -07:00
Jeff Verkoeyen
2db3fd1ced [Shapes] Fix divide by zero bug.
This bug was happening when an MDCShapedShadowLayer has an empty frame and a positive shapedBorderWidth value, and a path is assigned. The MDCShapedShadowLayer was attempting to calculate a value in relation to the bounds of the MDCShapedShadowLayer, which in turn was resulting in a divide by zero.

This change adds safeguards around the divisions to ensure that a division does not occur if the width or height are sufficiently close to zero.

PiperOrigin-RevId: 322768484
2020-07-23 05:37:21 -07:00
Jeff Verkoeyen
fb4f43d36c [Shapes] Add unit tests demonstrating a divide by zero error.
This error can happen when an MDCShapedShadowLayer has an empty frame and a positive shapedBorderWidth value, and a path is assigned. There is a divide by zero in the logic introduced in cl/322615641.

In a subsequent change I will fix the bug and update the test accordingly.

PiperOrigin-RevId: 322689400
2020-07-22 17:23:02 -07:00
Yarden Eitan
3f3816f014 [Shapes] Updates the shapeGenerator with a line width to inset the line rather than center it.
There is a visual difference when using lineWidth instead of borderWidth due to lineWidth drawing on the path, and borderWidth insetting from the path.
To resolve this, the path is made smaller by half the width of the line, thus to create a similar visual appearance as if borderWidth was set.

PiperOrigin-RevId: 322615641
2020-07-22 11:24:19 -07:00
Robert Moore
ac4b4eafcd
[Shapes] Add basic Snapshot tests. (#6919)
Adding simple Snapshot tests for shape generators and elevation.

Closes #6804
2019-03-20 12:48:01 -04:00
Yarden Eitan
10abd4524d
[Shapes] Move shapes from components/private to components/ - Part 3 (last part) (#6734)
This is the third and last part of the migration of moving the Shape libraries away from the private/ folder. Continuation to PR: #6664 and #6495

Tracking bug, progress and more details can be found here: #6494

This resolves #6494

Because Shapes and ShapeLibrary have been used in production and are an integral part of the shape scheme and theming. Moreover, with to stop the confusion of clients that the library should not be imported as it is under private, we want to migrate the Shape libs to be under components/ instead of components/private.

The migration will be a 7 step migration to not break clients internally.
**We have completed steps 1 to 6, This PR concludes step 7 and the entire migration**

1. move the folders to the new directory.
2. Make the old component's BUILD and Podspec targets depend on the new component (and nothing else).
3. Delete all implementation files from the old component.
4. Replace the contents of the old component's headers with import statements to the new component's header. If the new component has headers that match the old component's, then the new component's headers will need to be named uniquely for a period of time to allow clients to migrate over.
5. Once all clients have migrated from the old component, delete the old component. This is a breaking change.
6. If you had to create temporary header names in the new component, then in a separate release add the new headers that you want the new component to use. Move the content of the old headers into the new headers and replace the old headers with an import of the new headers. Migrate clients to the desired headers.
7. Once all clients have moved off of the old headers, delete the old headers.
2019-02-28 16:54:58 -05:00
Yarden Eitan
de5d200599
[Shapes] Move shapes from components/private to components/ (#6495)
This is the first part of the migration of moving the Shape libraries away from the private/ folder.

Tracking bug, progress and more details can be found here: #6494 

"Because Shapes and ShapeLibrary have been used in production and are an integral part of the shape scheme and theming. Moreover, with to stop the confusion of clients that the library should not be imported as it is under private, we want to migrate the Shape libs to be under components/ instead of components/private.

The migration will be a 7 step migration to not break clients internally.

1. move the folders to the new directory.
2. Make the old component's BUILD and Podspec targets depend on the new component (and nothing else).
3. Delete all implementation files from the old component.
4. Replace the contents of the old component's headers with import statements to the new component's header. If the new component has headers that match the old component's, then the new component's headers will need to be named uniquely for a period of time to allow clients to migrate over.
5. Once all clients have migrated from the old component, delete the old component. This is a breaking change.
6. If you had to create temporary header names in the new component, then in a separate release add the new headers that you want the new component to use. Move the content of the old headers into the new headers and replace the old headers with an import of the new headers. Migrate clients to the desired headers.
7. Once all clients have moved off of the old headers, delete the old headers.

Passes bazel build and pod build locally.
2019-01-28 17:51:27 -05:00