Skip to content

Commit

Permalink
[NavigationRail] Integrate tokens and add shapeAppearance attribute
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 525551069
  • Loading branch information
imhappi authored and leticiarossi committed Apr 24, 2023
1 parent 3b43d41 commit 3b2b827
Show file tree
Hide file tree
Showing 7 changed files with 57 additions and 34 deletions.

This file was deleted.

Expand Up @@ -15,6 +15,6 @@
~ limitations under the License.
-->
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:color="?attr/colorOnSecondaryContainer" android:state_checked="true"/>
<item android:color="?attr/colorOnSurfaceVariant"/>
<item android:color="@macro/m3_comp_navigation_rail_active_icon_color" android:state_checked="true"/>
<item android:color="@macro/m3_comp_navigation_rail_inactive_icon_color"/>
</selector>
Expand Up @@ -15,6 +15,6 @@
~ limitations under the License.
-->
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:color="?attr/colorOnSurface" android:state_checked="true"/>
<item android:color="?attr/colorOnSurfaceVariant"/>
<item android:color="@macro/m3_comp_navigation_rail_active_label_text_color" android:state_checked="true"/>
<item android:color="@macro/m3_comp_navigation_rail_inactive_label_text_color"/>
</selector>
@@ -0,0 +1,30 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
~ Copyright 2021 The Android Open Source Project
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
~ You may obtain a copy of the License at
~
~ https://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->
<selector xmlns:android="http://schemas.android.com/apk/res/android">

<!-- Selected. -->
<item android:alpha="@dimen/m3_comp_navigation_rail_pressed_state_layer_opacity" android:color="@macro/m3_comp_navigation_rail_active_pressed_state_layer_color" android:state_pressed="true" android:state_selected="true"/>
<item android:alpha="@dimen/m3_comp_navigation_rail_focus_state_layer_opacity" android:color="@macro/m3_comp_navigation_rail_active_focus_state_layer_color" android:state_focused="true" android:state_selected="true"/>
<item android:alpha="@dimen/m3_comp_navigation_rail_hover_state_layer_opacity" android:color="@macro/m3_comp_navigation_rail_active_hover_state_layer_color" android:state_hovered="true" android:state_selected="true"/>

<!-- Unselected. -->
<item android:alpha="@dimen/m3_comp_navigation_rail_pressed_state_layer_opacity" android:color="@macro/m3_comp_navigation_rail_inactive_pressed_state_layer_color" android:state_pressed="true"/>
<item android:alpha="@dimen/m3_comp_navigation_rail_focus_state_layer_opacity" android:color="@macro/m3_comp_navigation_rail_inactive_focus_state_layer_color" android:state_focused="true"/>
<item android:alpha="@dimen/m3_comp_navigation_rail_hover_state_layer_opacity" android:color="@macro/m3_comp_navigation_rail_inactive_hover_state_layer_color" android:state_hovered="true"/>
<item android:color="@android:color/transparent"/>
</selector>

Expand Up @@ -45,6 +45,11 @@
<!-- Whether the navigation rail should apply any padding to its start to
account for any system window insets. -->
<attr name="paddingStartSystemWindowInsets"/>
<!-- Shape appearance style reference for NavigationRail. Attribute declaration is in the Shape package. -->
<attr name="shapeAppearance"/>
<!-- Shape appearance overlay style reference for NavigationRail. To be used to augment
attributes declared in the shapeAppearance. Attribute declaration is in the Shape package. -->
<attr name="shapeAppearanceOverlay"/>
</declare-styleable>

</resources>
Expand Up @@ -70,6 +70,7 @@
<item name="android:background">@macro/m3_comp_navigation_rail_container_color</item>
<item name="backgroundTint">@null</item>
<item name="elevation">@dimen/m3_navigation_rail_elevation</item>
<item name="shapeAppearance">@style/ShapeAppearance.M3.Comp.NavigationRail.Container.Shape</item>
<item name="itemActiveIndicatorStyle">@style/Widget.Material3.NavigationRailView.ActiveIndicator</item>
<item name="itemRippleColor">@color/m3_navigation_rail_ripple_color_selector</item>
<item name="itemIconSize">@dimen/m3_comp_navigation_rail_icon_size</item>
Expand Down
Expand Up @@ -22,16 +22,33 @@
<!-- Generated from token set (md.comp.navigation-rail) in context (platform=android, audience=3p). -->
<!-- Enabled - Container -->
<macro name="m3_comp_navigation_rail_container_color">?attr/colorSurface</macro>
<style name="ShapeAppearance.M3.Comp.NavigationRail.Container.Shape" parent="ShapeAppearance.M3.Sys.Shape.Corner.None"/>
<dimen name="m3_comp_navigation_rail_container_width">80dp</dimen>
<dimen name="m3_comp_navigation_rail_container_elevation">@dimen/m3_sys_elevation_level0</dimen>
<!-- Enabled - Label text -->
<macro name="m3_comp_navigation_rail_label_text_type">?attr/textAppearanceLabelMedium</macro>
<macro name="m3_comp_navigation_rail_active_label_text_color">?attr/colorOnSurface</macro>
<macro name="m3_comp_navigation_rail_inactive_label_text_color">?attr/colorOnSurfaceVariant</macro>
<!-- Enabled - Icon -->
<dimen name="m3_comp_navigation_rail_icon_size">24dp</dimen>
<macro name="m3_comp_navigation_rail_active_icon_color">?attr/colorOnSecondaryContainer</macro>
<macro name="m3_comp_navigation_rail_inactive_icon_color">?attr/colorOnSurfaceVariant</macro>
<!-- Enabled - Active indicator -->
<macro name="m3_comp_navigation_rail_active_indicator_color">?attr/colorSecondaryContainer</macro>
<dimen name="m3_comp_navigation_rail_active_indicator_height">32dp</dimen>
<style name="ShapeAppearance.M3.Comp.NavigationRail.ActiveIndicator.Shape" parent="ShapeAppearance.M3.Sys.Shape.Corner.Full"/>
<dimen name="m3_comp_navigation_rail_active_indicator_width">56dp</dimen>
<!-- Hovered - State layer -->
<macro name="m3_comp_navigation_rail_active_hover_state_layer_color">?attr/colorOnSurface</macro>
<macro name="m3_comp_navigation_rail_inactive_hover_state_layer_color">?attr/colorOnSurface</macro>
<dimen name="m3_comp_navigation_rail_hover_state_layer_opacity">@dimen/m3_sys_state_hover_state_layer_opacity</dimen>
<!-- Focused - State layer -->
<macro name="m3_comp_navigation_rail_active_focus_state_layer_color">?attr/colorOnSurface</macro>
<macro name="m3_comp_navigation_rail_inactive_focus_state_layer_color">?attr/colorOnSurface</macro>
<dimen name="m3_comp_navigation_rail_focus_state_layer_opacity">@dimen/m3_sys_state_focus_state_layer_opacity</dimen>
<!-- Pressed (rippple) - State layer -->
<macro name="m3_comp_navigation_rail_active_pressed_state_layer_color">?attr/colorOnSurface</macro>
<macro name="m3_comp_navigation_rail_inactive_pressed_state_layer_color">?attr/colorOnSurface</macro>
<dimen name="m3_comp_navigation_rail_pressed_state_layer_opacity">@dimen/m3_sys_state_pressed_state_layer_opacity</dimen>

</resources>

0 comments on commit 3b2b827

Please sign in to comment.