Skip to content

Commit

Permalink
[Shape] Added theme attributes and styles for new shape appearances.
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 442925211
  • Loading branch information
pekingme authored and dsn5ft committed Apr 20, 2022
1 parent 3ca41be commit 6217aa8
Show file tree
Hide file tree
Showing 6 changed files with 111 additions and 39 deletions.
Expand Up @@ -181,12 +181,20 @@

<!-- TODO: Populate font families here -->

<!-- Shape styles. -->
<!-- Shape attributes. -->
<item name="shapeCornerFamily">@integer/m3_sys_shape_corner_full_family</item>
<item name="shapeAppearanceCornerExtraSmall">@style/ShapeAppearance.Material3.Corner.ExtraSmall</item>
<item name="shapeAppearanceCornerSmall">@style/ShapeAppearance.Material3.Corner.Small</item>
<item name="shapeAppearanceCornerMedium">@style/ShapeAppearance.Material3.Corner.Medium</item>
<item name="shapeAppearanceCornerLarge">@style/ShapeAppearance.Material3.Corner.Large</item>
<item name="shapeAppearanceCornerExtraLarge">@style/ShapeAppearance.Material3.Corner.ExtraLarge</item>

<!-- Deprecated shape styles. -->
<item name="shapeAppearanceSmallComponent">@style/ShapeAppearance.Material3.SmallComponent</item>
<item name="shapeAppearanceMediumComponent">@style/ShapeAppearance.Material3.MediumComponent</item>
<item name="shapeAppearanceLargeComponent">@style/ShapeAppearance.Material3.LargeComponent</item>

<!-- Motion-->
<!-- Motion attributes. -->
<item name="motionEasingStandardInterpolator">@interpolator/m3_sys_motion_easing_standard</item>
<item name="motionEasingStandardDecelerateInterpolator">@interpolator/m3_sys_motion_easing_standard_decelerate</item>
<item name="motionEasingStandardAccelerateInterpolator">@interpolator/m3_sys_motion_easing_standard_accelerate</item>
Expand Down Expand Up @@ -397,12 +405,20 @@

<!-- TODO: Populate font families here -->

<!-- Shape styles. -->
<!-- Shape attributes. -->
<item name="shapeCornerFamily">@integer/m3_sys_shape_corner_full_family</item>
<item name="shapeAppearanceCornerExtraSmall">@style/ShapeAppearance.Material3.Corner.ExtraSmall</item>
<item name="shapeAppearanceCornerSmall">@style/ShapeAppearance.Material3.Corner.Small</item>
<item name="shapeAppearanceCornerMedium">@style/ShapeAppearance.Material3.Corner.Medium</item>
<item name="shapeAppearanceCornerLarge">@style/ShapeAppearance.Material3.Corner.Large</item>
<item name="shapeAppearanceCornerExtraLarge">@style/ShapeAppearance.Material3.Corner.ExtraLarge</item>

<!-- Deprecated shape styles. -->
<item name="shapeAppearanceSmallComponent">@style/ShapeAppearance.Material3.SmallComponent</item>
<item name="shapeAppearanceMediumComponent">@style/ShapeAppearance.Material3.MediumComponent</item>
<item name="shapeAppearanceLargeComponent">@style/ShapeAppearance.Material3.LargeComponent</item>

<!-- Motion-->
<!-- Motion attributes. -->
<item name="motionEasingStandardInterpolator">@interpolator/m3_sys_motion_easing_standard</item>
<item name="motionEasingStandardDecelerateInterpolator">@interpolator/m3_sys_motion_easing_standard_decelerate</item>
<item name="motionEasingStandardAccelerateInterpolator">@interpolator/m3_sys_motion_easing_standard_accelerate</item>
Expand Down
Expand Up @@ -20,10 +20,18 @@
<public name="shapeAppearance" type="attr"/>
<public name="shapeAppearanceOverlay" type="attr"/>

<!-- Deprecated: Use shapeCorner* attributes. -->
<public name="shapeAppearanceSmallComponent" type="attr"/>
<public name="shapeAppearanceMediumComponent" type="attr"/>
<public name="shapeAppearanceLargeComponent" type="attr"/>

<public name="shapeCornerFamily" type="attr"/>
<public name="shapeAppearanceCornerExtraSmall" type="attr"/>
<public name="shapeAppearanceCornerSmall" type="attr"/>
<public name="shapeAppearanceCornerMedium" type="attr"/>
<public name="shapeAppearanceCornerLarge" type="attr"/>
<public name="shapeAppearanceCornerExtraLarge" type="attr"/>

<public name="cornerSize" type="attr"/>
<public name="cornerSizeTopLeft" type="attr"/>
<public name="cornerSizeTopRight" type="attr"/>
Expand All @@ -42,4 +50,18 @@
<public name="ShapeAppearance.Material3.SmallComponent" type="style"/>
<public name="ShapeAppearance.Material3.MediumComponent" type="style"/>
<public name="ShapeAppearance.Material3.LargeComponent" type="style"/>

<public name="ShapeAppearance.Material3.Corner.None" type="style"/>
<public name="ShapeAppearance.Material3.Corner.ExtraSmall" type="style"/>
<public name="ShapeAppearance.Material3.Corner.Small" type="style"/>
<public name="ShapeAppearance.Material3.Corner.Medium" type="style"/>
<public name="ShapeAppearance.Material3.Corner.Large" type="style"/>
<public name="ShapeAppearance.Material3.Corner.ExtraLarge" type="style"/>
<public name="ShapeAppearance.Material3.Corner.Full" type="style"/>

<public name="ShapeAppearanceOverlay.Material3.Corner.Top" type="style"/>
<public name="ShapeAppearanceOverlay.Material3.Corner.Bottom" type="style"/>
<public name="ShapeAppearanceOverlay.Material3.Corner.Left" type="style"/>
<public name="ShapeAppearanceOverlay.Material3.Corner.Right" type="style"/>

</resources>
17 changes: 17 additions & 0 deletions lib/java/com/google/android/material/shape/res/values/attrs.xml
Expand Up @@ -63,6 +63,23 @@
</attr>
</declare-styleable>

<!-- The corner family for all shape appearance styles. -->
<attr name="shapeCornerFamily" format="enum">
<enum name="rounded" value="0"/>
<enum name="cut" value="1"/>
</attr>
<!-- Shape appearance style reference with extra small corners. -->
<attr name="shapeAppearanceCornerExtraSmall" format="reference"/>
<!-- Shape appearance style reference with small corners. -->
<attr name="shapeAppearanceCornerSmall" format="reference"/>
<!-- Shape appearance style reference with medium corners. -->
<attr name="shapeAppearanceCornerMedium" format="reference"/>
<!-- Shape appearance style reference with large corners. -->
<attr name="shapeAppearanceCornerLarge" format="reference"/>
<!-- Shape appearance style reference with extra large corners. -->
<attr name="shapeAppearanceCornerExtraLarge" format="reference"/>

<!-- Deprecated: Use shapeAppearanceCorner* attributes. -->
<!-- Shape appearance style reference for small components. -->
<attr name="shapeAppearanceSmallComponent" format="reference"/>
<!-- Shape appearance style reference for medium components. -->
Expand Down
18 changes: 18 additions & 0 deletions lib/java/com/google/android/material/shape/res/values/styles.xml
Expand Up @@ -41,6 +41,24 @@
<style name="ShapeAppearance.Material3.Corner.ExtraLarge" parent="ShapeAppearance.M3.Sys.Shape.Corner.ExtraLarge"/>
<style name="ShapeAppearance.Material3.Corner.Full" parent="ShapeAppearance.M3.Sys.Shape.Corner.Full"/>

<style name="ShapeAppearanceOverlay.Material3.Corner.Top" parent="">
<item name="cornerSizeBottomLeft">0dp</item>
<item name="cornerSizeBottomRight">0dp</item>
</style>
<style name="ShapeAppearanceOverlay.Material3.Corner.Bottom" parent="">
<item name="cornerSizeTopLeft">0dp</item>
<item name="cornerSizeTopRight">0dp</item>
</style>
<style name="ShapeAppearanceOverlay.Material3.Corner.Left" parent="">
<item name="cornerSizeTopRight">0dp</item>
<item name="cornerSizeBottomRight">0dp</item>
</style>
<style name="ShapeAppearanceOverlay.Material3.Corner.Right" parent="">
<item name="cornerSizeTopLeft">0dp</item>
<item name="cornerSizeBottomLeft">0dp</item>
</style>

<!-- Deprecated: Consider using the ShapeAppearance styles above. -->
<style name="ShapeAppearance.Material3.SmallComponent" parent="">
<item name="cornerFamily">rounded</item>
<item name="cornerSize">4dp</item>
Expand Down
45 changes: 14 additions & 31 deletions lib/java/com/google/android/material/shape/res/values/tokens.xml
Expand Up @@ -20,55 +20,38 @@
<resources>
<!-- Generated from token set (md.sys.shape) in default context. -->
<style name="ShapeAppearance.M3.Sys.Shape.Corner.Full" parent="">
<item name="cornerFamily">rounded</item>
<item name="cornerFamily">?attr/shapeCornerFamily</item>
<item name="cornerSize">50%</item>
</style>
<integer name="m3_sys_shape_corner_full_family">0</integer>
<style name="ShapeAppearance.M3.Sys.Shape.Corner.None" parent="">
<item name="cornerFamily">rounded</item>
<item name="cornerFamily">?attr/shapeCornerFamily</item>
<item name="cornerSize">0dp</item>
</style>
<integer name="m3_sys_shape_corner_none_family">0</integer>
<style name="ShapeAppearance.M3.Sys.Shape.Corner.Large" parent="">
<item name="cornerFamily">rounded</item>
<item name="cornerFamily">?attr/shapeCornerFamily</item>
<item name="cornerSize">16dp</item>
</style>
<integer name="m3_sys_shape_corner_large_family">0</integer>
<style name="ShapeAppearance.M3.Sys.Shape.Corner.Small" parent="">
<item name="cornerFamily">rounded</item>
<item name="cornerFamily">?attr/shapeCornerFamily</item>
<item name="cornerSize">8dp</item>
</style>
<integer name="m3_sys_shape_corner_small_family">0</integer>
<style name="ShapeAppearance.M3.Sys.Shape.Corner.Medium" parent="">
<item name="cornerFamily">rounded</item>
<item name="cornerFamily">?attr/shapeCornerFamily</item>
<item name="cornerSize">12dp</item>
</style>
<style name="ShapeAppearance.M3.Sys.Shape.Corner.Large.End" parent="">
<item name="cornerFamily">rounded</item>
<item name="cornerSize">0dp</item>
<item name="cornerSizeTopRight">16dp</item>
<item name="cornerSizeBottomRight">16dp</item>
</style>
<style name="ShapeAppearance.M3.Sys.Shape.Corner.Large.Top" parent="">
<item name="cornerFamily">rounded</item>
<item name="cornerSize">0dp</item>
<item name="cornerSizeTopLeft">16dp</item>
<item name="cornerSizeTopRight">16dp</item>
</style>
<integer name="m3_sys_shape_corner_medium_family">0</integer>
<style name="ShapeAppearance.M3.Sys.Shape.Corner.ExtraLarge" parent="">
<item name="cornerFamily">rounded</item>
<item name="cornerFamily">?attr/shapeCornerFamily</item>
<item name="cornerSize">28dp</item>
</style>
<integer name="m3_sys_shape_corner_extra_large_family">0</integer>
<style name="ShapeAppearance.M3.Sys.Shape.Corner.ExtraSmall" parent="">
<item name="cornerFamily">rounded</item>
<item name="cornerFamily">?attr/shapeCornerFamily</item>
<item name="cornerSize">4dp</item>
</style>
<style name="ShapeAppearance.M3.Sys.Shape.Corner.ExtraLarge.Top" parent="">
<item name="cornerFamily">rounded</item>
<item name="cornerSize">0dp</item>
<item name="cornerSizeTopLeft">28dp</item>
<item name="cornerSizeTopRight">28dp</item>
</style>
<style name="ShapeAppearance.M3.Sys.Shape.Corner.ExtraSmall.Top" parent="">
<item name="cornerFamily">rounded</item>
<item name="cornerSize">0dp</item>
<item name="cornerSizeTopLeft">4dp</item>
<item name="cornerSizeTopRight">4dp</item>
</style>
<integer name="m3_sys_shape_corner_extra_small_family">0</integer>
</resources>
Expand Up @@ -193,12 +193,20 @@
<item name="textAppearanceLargePopupMenu">?attr/textAppearanceBodyLarge</item>
<item name="textAppearanceSmallPopupMenu">?attr/textAppearanceBodyLarge</item>

<!-- Shape styles. -->
<!-- Shape attributes. -->
<item name="shapeCornerFamily">@integer/m3_sys_shape_corner_full_family</item>
<item name="shapeAppearanceCornerExtraSmall">@style/ShapeAppearance.Material3.Corner.ExtraSmall</item>
<item name="shapeAppearanceCornerSmall">@style/ShapeAppearance.Material3.Corner.Small</item>
<item name="shapeAppearanceCornerMedium">@style/ShapeAppearance.Material3.Corner.Medium</item>
<item name="shapeAppearanceCornerLarge">@style/ShapeAppearance.Material3.Corner.Large</item>
<item name="shapeAppearanceCornerExtraLarge">@style/ShapeAppearance.Material3.Corner.ExtraLarge</item>

<!-- Deprecated shape styles. -->
<item name="shapeAppearanceSmallComponent">@style/ShapeAppearance.Material3.SmallComponent</item>
<item name="shapeAppearanceMediumComponent">@style/ShapeAppearance.Material3.MediumComponent</item>
<item name="shapeAppearanceLargeComponent">@style/ShapeAppearance.Material3.LargeComponent</item>

<!-- Motion-->
<!-- Motion attributes.-->
<item name="motionEasingStandardInterpolator">@interpolator/m3_sys_motion_easing_standard</item>
<item name="motionEasingStandardDecelerateInterpolator">@interpolator/m3_sys_motion_easing_standard_decelerate</item>
<item name="motionEasingStandardAccelerateInterpolator">@interpolator/m3_sys_motion_easing_standard_accelerate</item>
Expand Down Expand Up @@ -411,12 +419,20 @@
<item name="textAppearanceLargePopupMenu">?attr/textAppearanceBodyLarge</item>
<item name="textAppearanceSmallPopupMenu">?attr/textAppearanceBodyLarge</item>

<!-- Shape styles. -->
<!-- Shape attributes. -->
<item name="shapeCornerFamily">@integer/m3_sys_shape_corner_full_family</item>
<item name="shapeAppearanceCornerExtraSmall">@style/ShapeAppearance.Material3.Corner.ExtraSmall</item>
<item name="shapeAppearanceCornerSmall">@style/ShapeAppearance.Material3.Corner.Small</item>
<item name="shapeAppearanceCornerMedium">@style/ShapeAppearance.Material3.Corner.Medium</item>
<item name="shapeAppearanceCornerLarge">@style/ShapeAppearance.Material3.Corner.Large</item>
<item name="shapeAppearanceCornerExtraLarge">@style/ShapeAppearance.Material3.Corner.ExtraLarge</item>

<!-- Deprecated shape styles. -->
<item name="shapeAppearanceSmallComponent">@style/ShapeAppearance.Material3.SmallComponent</item>
<item name="shapeAppearanceMediumComponent">@style/ShapeAppearance.Material3.MediumComponent</item>
<item name="shapeAppearanceLargeComponent">@style/ShapeAppearance.Material3.LargeComponent</item>

<!-- Motion-->
<!-- Motion attributes. -->
<item name="motionEasingStandardInterpolator">@interpolator/m3_sys_motion_easing_standard</item>
<item name="motionEasingStandardDecelerateInterpolator">@interpolator/m3_sys_motion_easing_standard_decelerate</item>
<item name="motionEasingStandardAccelerateInterpolator">@interpolator/m3_sys_motion_easing_standard_accelerate</item>
Expand Down

0 comments on commit 6217aa8

Please sign in to comment.