From d3ad4b9c9da7b9c178cea25a1800509196a3d7bc Mon Sep 17 00:00:00 2001 From: Emily Pauli Date: Sat, 25 Oct 2025 22:59:08 +0200 Subject: [PATCH] Refactor NavigationRailM3E theme to use expanded and collapsed height properties for items --- .../navigation_rail_m3e/lib/src/rail_item.dart | 4 +++- .../lib/src/rail_item_button_m3e.dart | 3 ++- .../lib/src/rail_theme.dart | 18 ++++++++++-------- 3 files changed, 15 insertions(+), 10 deletions(-) diff --git a/packages/navigation_rail_m3e/lib/src/rail_item.dart b/packages/navigation_rail_m3e/lib/src/rail_item.dart index 3875a5f..576be6f 100644 --- a/packages/navigation_rail_m3e/lib/src/rail_item.dart +++ b/packages/navigation_rail_m3e/lib/src/rail_item.dart @@ -36,7 +36,9 @@ class RailItem extends StatelessWidget { Widget build(BuildContext context) { final theme = Theme.of(context).extension() ?? const NavigationRailM3ETheme(); - final height = destination.short ? theme.itemShortHeight : theme.itemHeight; + final height = destination.short + ? theme.itemCollapsedHeight + : theme.itemExpandedHeight; final Widget button = RailItemButtonM3E( icon: destination.icon, diff --git a/packages/navigation_rail_m3e/lib/src/rail_item_button_m3e.dart b/packages/navigation_rail_m3e/lib/src/rail_item_button_m3e.dart index e91142d..9ab3e33 100644 --- a/packages/navigation_rail_m3e/lib/src/rail_item_button_m3e.dart +++ b/packages/navigation_rail_m3e/lib/src/rail_item_button_m3e.dart @@ -58,7 +58,8 @@ class RailItemButtonM3E extends StatelessWidget { const NavigationRailM3ETheme(); final tokens = NavigationRailTokensAdapter(context); - final double height = expanded ? theme.itemHeight : theme.itemHeight; + final double height = + expanded ? theme.itemCollapsedHeight : theme.itemCollapsedHeight; final bool selected = isSelected; // Colors and shape per state. diff --git a/packages/navigation_rail_m3e/lib/src/rail_theme.dart b/packages/navigation_rail_m3e/lib/src/rail_theme.dart index 6539f92..0f66f4e 100644 --- a/packages/navigation_rail_m3e/lib/src/rail_theme.dart +++ b/packages/navigation_rail_m3e/lib/src/rail_theme.dart @@ -9,8 +9,8 @@ class NavigationRailM3ETheme extends ThemeExtension { this.collapsedWidth = 96.0, this.expandedMinWidth = 220.0, this.expandedMaxWidth = 360.0, - this.itemHeight = 64.0, - this.itemShortHeight = 56.0, + this.itemExpandedHeight = 40.0, + this.itemCollapsedHeight = 56.0, this.iconSize = 24.0, this.indicatorLeading = 16.0, this.indicatorTrailing = 16.0, @@ -31,10 +31,10 @@ class NavigationRailM3ETheme extends ThemeExtension { final double expandedMaxWidth; /// Default height of an item. - final double itemHeight; + final double itemExpandedHeight; /// Short item height variant. - final double itemShortHeight; + final double itemCollapsedHeight; /// Default icon size used for items. final double iconSize; @@ -80,8 +80,8 @@ class NavigationRailM3ETheme extends ThemeExtension { collapsedWidth: collapsedWidth ?? this.collapsedWidth, expandedMinWidth: expandedMinWidth ?? this.expandedMinWidth, expandedMaxWidth: expandedMaxWidth ?? this.expandedMaxWidth, - itemHeight: itemHeight ?? this.itemHeight, - itemShortHeight: itemShortHeight ?? this.itemShortHeight, + itemExpandedHeight: itemHeight ?? this.itemExpandedHeight, + itemCollapsedHeight: itemShortHeight ?? this.itemCollapsedHeight, iconSize: iconSize ?? this.iconSize, indicatorLeading: indicatorLeading ?? this.indicatorLeading, indicatorTrailing: indicatorTrailing ?? this.indicatorTrailing, @@ -105,8 +105,10 @@ class NavigationRailM3ETheme extends ThemeExtension { lerpDouble(expandedMinWidth, other.expandedMinWidth, t)!, expandedMaxWidth: lerpDouble(expandedMaxWidth, other.expandedMaxWidth, t)!, - itemHeight: lerpDouble(itemHeight, other.itemHeight, t)!, - itemShortHeight: lerpDouble(itemShortHeight, other.itemShortHeight, t)!, + itemExpandedHeight: + lerpDouble(itemExpandedHeight, other.itemExpandedHeight, t)!, + itemCollapsedHeight: + lerpDouble(itemCollapsedHeight, other.itemCollapsedHeight, t)!, iconSize: lerpDouble(iconSize, other.iconSize, t)!, indicatorLeading: lerpDouble(indicatorLeading, other.indicatorLeading, t)!,