Navigation Menu

Skip to content

Commit

Permalink
[Badge] Integrating tokens
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 512186562
  • Loading branch information
imhappi authored and paulfthomas committed Feb 27, 2023
1 parent 2ddcfe4 commit 68c844c
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 6 deletions.
Expand Up @@ -32,8 +32,8 @@
<dimen name="mtrl_badge_toolbar_action_menu_item_vertical_offset">12dp</dimen>

<!-- M3 Dimens -->
<dimen name="m3_badge_size">6dp</dimen>
<dimen name="m3_badge_with_text_size">16dp</dimen>
<dimen name="m3_badge_size">@dimen/m3_comp_badge_size</dimen>
<dimen name="m3_badge_with_text_size">@dimen/m3_comp_badge_large_size</dimen>

<dimen name="m3_badge_vertical_offset">1.5dp</dimen>
<dimen name="m3_badge_horizontal_offset">1.5dp</dimen>
Expand Down
15 changes: 11 additions & 4 deletions lib/java/com/google/android/material/badge/res/values/styles.xml
Expand Up @@ -27,8 +27,8 @@
<item name="badgeGravity">TOP_END</item>
<item name="offsetAlignmentMode">legacy</item>
<item name="badgeTextAppearance">@style/TextAppearance.MaterialComponents.Badge</item>
<item name="badgeShapeAppearance">@style/ShapeAppearance.Material3.Corner.Full</item>
<item name="badgeWithTextShapeAppearance">@style/ShapeAppearance.Material3.Corner.Full</item>
<item name="badgeShapeAppearance">@style/ShapeAppearance.MaterialComponents.Badge</item>
<item name="badgeWithTextShapeAppearance">@style/ShapeAppearance.MaterialComponents.Badge</item>
</style>

<style name="Base.TextAppearance.MaterialComponents.Badge" parent="TextAppearance.AppCompat">
Expand All @@ -44,23 +44,30 @@

<style name="TextAppearance.MaterialComponents.Badge" parent="Base.TextAppearance.MaterialComponents.Badge"/>

<style name="ShapeAppearance.MaterialComponents.Badge">
<item name="cornerFamily">?attr/shapeCornerFamily</item>
<item name="cornerSize">50%</item>
</style>

<!-- M3 Badge -->
<style name="Widget.Material3.Badge" parent="Widget.MaterialComponents.Badge">
<item name="backgroundColor">@macro/m3_comp_badge_color</item>
<item name="badgeTextColor">?attr/colorOnError</item>
<item name="badgeTextColor">@macro/m3_comp_badge_large_label_text_color</item>
<item name="offsetAlignmentMode">edge</item>
<!-- Badge "dot" without text -->
<item name="horizontalOffset">@dimen/m3_badge_offset</item>
<item name="verticalOffset">@dimen/m3_badge_offset</item>
<item name="badgeWidth">@dimen/m3_badge_size</item>
<item name="badgeHeight">@dimen/m3_badge_size</item>
<item name="badgeShapeAppearance">@style/ShapeAppearance.M3.Comp.Badge.Shape</item>

<!-- Badge with text -->
<item name="badgeWithTextWidth">@dimen/m3_badge_with_text_size</item>
<item name="badgeWithTextHeight">@dimen/m3_badge_with_text_size</item>
<item name="horizontalOffsetWithText">@dimen/m3_badge_with_text_offset</item>
<item name="verticalOffsetWithText">@dimen/m3_badge_with_text_offset</item>
<item name="badgeTextAppearance">?attr/textAppearanceLabelSmall</item>
<item name="badgeTextAppearance">@macro/m3_comp_badge_large_label_text_type</item>
<item name="badgeWithTextShapeAppearance">@style/ShapeAppearance.M3.Comp.Badge.Shape</item>
</style>

</resources>
Expand Up @@ -22,5 +22,12 @@
<!-- Generated from token set (md.comp.badge) in context (platform=android, audience=3p). -->
<!-- Enabled - Container -->
<macro name="m3_comp_badge_color">?attr/colorError</macro>
<style name="ShapeAppearance.M3.Comp.Badge.Shape" parent="ShapeAppearance.M3.Sys.Shape.Corner.Full"/>
<dimen name="m3_comp_badge_size">6dp</dimen>
<style name="ShapeAppearance.M3.Comp.Badge.Large.Shape" parent="ShapeAppearance.M3.Sys.Shape.Corner.Full"/>
<dimen name="m3_comp_badge_large_size">16dp</dimen>
<!-- Enabled - Label text -->
<macro name="m3_comp_badge_large_label_text_color">?attr/colorOnError</macro>
<macro name="m3_comp_badge_large_label_text_type">?attr/textAppearanceLabelSmall</macro>

</resources>

0 comments on commit 68c844c

Please sign in to comment.