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
..

Shape Library

Our Shape Library consists of different convenience APIs and classes we use to build a shape. Specifically, the classes in this library sit on top of our core Shapes implementation, and that implementation should be understood and used before making use of the classes here.


Overview

The classes described below are convenience APIs on top of MDCRectangleShapeGenerator:

MDCCurvedCornerTreatment

Generates an MDCCornerTreatment that is curved and receives a size to define the size of the curve.

MDCCutCornerTreatment

Generates an MDCCornerTreatment that is a cut corner and receives a cut to define by how much to cut.

MDCRoundedCornerTreatment

Generates an MDCCornerTreatment that is rounded and receives a radius to define the radius of the rounding.

MDCTriangleEdgeTreatment

Generates an MDCEdgeTreatment that consists of a triangle of a settable size and style.

The classes described below are convenience shape generators that create an MDCRectangleShapeGenerator subclass that consist of preset corner and edge treatments:

MDCCurvedRectShapeGenerator

This generates a shape using MDCRectangleShapeGenerator with MDCCurvedCornerTreatment for its corners.

MDCPillShapeGenerator

This generates a shape using MDCRectangleShapeGenerator with MDCRoundedCornerTreatment for its corners.

MDCSlantedRectShapeGenerator

This generates a shape using MDCRectangleShapeGenerator and adds a slant to its corners using a simple offset to its corners.

Usage

You'll typically create an MDCRectangleShapeGenerator instance that you set your component with. Components that support the shape system will have a id<MDCShapeGenerating> shapeGenerator property as part of their API. By setting the shapeGenerator property with your MDCRectangleShapeGenerator, you will provide the defined shape to your component.

Swift

let card = MDCCard()
let shapeGenerator = MDCRectangleShapeGenerator()
let cutCornerTreatment = MDCCutCornerTreatment(cut: 4)
shapeGenerator.setCorners(cutCornerTreatment)
let triangleEdgeTreatment = MDCTriangleEdgeTreatment(size: 8, style: MDCTriangleEdgeStyleCut)
shapeGenerator.setEdges(triangleEdgeTreatment)
card.shapeGenerator = shapeGenerator

Objective-C

MDCCard *card = [[MDCCard alloc] init];
MDCRectangleShapeGenerator *shapeGenerator = [[MDCRectangleShapeGenerator alloc] init];
MDCCutCornerTreatment *cutCornerTreatment = [[MDCCutCornerTreatment alloc] initWithCut: 4];
[shapeGenerator setCorners:cutCornerTreatment];
MDCTriangleEdgeTreatment *triangleEdgeTreatment = [[MDCTriangleEdgeTreatment alloc] initWithSize: 8 style: MDCTriangleEdgeStyleCut];
[shapeGenerator setEdges:triangleEdgeTreatment];
card.shapeGenerator = shapeGenerator;