Add optional background color to NavigationRailM3E and bump package versions to 0.3.4

This commit is contained in:
Emily Pauli 2025-10-26 11:59:57 +01:00
commit ac87434543
4 changed files with 12 additions and 7 deletions

View file

@ -1,6 +1,6 @@
name: m3e_collection name: m3e_collection
description: Aggregated exports of all Material 3 Expressive components for Flutter. description: Aggregated exports of all Material 3 Expressive components for Flutter.
version: 0.3.3 version: 0.3.4
repository: https://github.com/EmilyMoonstone/material_3_expressive/tree/main/packages/m3e_collection repository: https://github.com/EmilyMoonstone/material_3_expressive/tree/main/packages/m3e_collection
issue_tracker: https://github.com/EmilyMonestone/material_3_expressive/issues issue_tracker: https://github.com/EmilyMonestone/material_3_expressive/issues
@ -8,7 +8,7 @@ environment:
sdk: ">=3.5.0 <4.0.0" sdk: ">=3.5.0 <4.0.0"
dependencies: dependencies:
app_bar_m3e: ^0.1.1 app_bar_m3e: ^0.1.2
button_group_m3e: ^0.1.1 button_group_m3e: ^0.1.1
button_m3e: ^0.1.1 button_m3e: ^0.1.1
expressive_refresh: ^0.1.2 expressive_refresh: ^0.1.2
@ -20,7 +20,7 @@ dependencies:
m3e_design: ^0.2.1 m3e_design: ^0.2.1
material_new_shapes: ^1.0.0 material_new_shapes: ^1.0.0
navigation_bar_m3e: ^0.1.1 navigation_bar_m3e: ^0.1.1
navigation_rail_m3e: ^0.3.3 navigation_rail_m3e: ^0.3.4
progress_indicator_m3e: ^0.1.1 progress_indicator_m3e: ^0.1.1
slider_m3e: ^0.1.1 slider_m3e: ^0.1.1
split_button_m3e: ^0.2.1 split_button_m3e: ^0.2.1

View file

@ -30,6 +30,7 @@ class NavigationRailM3E extends StatefulWidget {
this.scrollable = true, this.scrollable = true,
this.trailing, this.trailing,
this.trailingAtBottom = true, this.trailingAtBottom = true,
this.background,
}); });
/// Presentation type for the rail (collapsed or expanded or alwaysCollapsed or alwaysExpanded). /// Presentation type for the rail (collapsed or expanded or alwaysCollapsed or alwaysExpanded).
@ -80,6 +81,10 @@ class NavigationRailM3E extends StatefulWidget {
/// If false, [trailing] appears directly after the sections. /// If false, [trailing] appears directly after the sections.
final bool trailingAtBottom; final bool trailingAtBottom;
/// Optional background color for the rail. If null, falls back to
/// [NavigationRailTokensAdapter.containerColor] from the current theme.
final Color? background;
@override @override
State<NavigationRailM3E> createState() => _NavigationRailM3EState(); State<NavigationRailM3E> createState() => _NavigationRailM3EState();
} }
@ -464,7 +469,8 @@ class _NavigationRailM3EState extends State<NavigationRailM3E>
duration: const Duration(milliseconds: 280), duration: const Duration(milliseconds: 280),
curve: Curves.easeOutCubic, curve: Curves.easeOutCubic,
width: width, width: width,
decoration: BoxDecoration(color: tokens.containerColor), decoration:
BoxDecoration(color: widget.background ?? tokens.containerColor),
child: LayoutBuilder( child: LayoutBuilder(
builder: (ctx, constraints) { builder: (ctx, constraints) {
final showLabels = _isExpanded && constraints.maxWidth >= 180; final showLabels = _isExpanded && constraints.maxWidth >= 180;

View file

@ -15,8 +15,7 @@ class NavigationRailTokensAdapter {
/// Background color of the rail container. /// Background color of the rail container.
Color get containerColor { Color get containerColor {
// Use surface container token if present, else fallback. // Use surface container token if present, else fallback.
return _maybe(() => context.m3e.colors.surfaceContainer) ?? return _maybe(() => context.m3e.colors.surface) ?? _cs.surface;
_cs.surfaceContainer;
} }
/// Background color of the active item indicator. /// Background color of the active item indicator.

View file

@ -1,6 +1,6 @@
name: navigation_rail_m3e name: navigation_rail_m3e
description: Material 3 Expressive navigation rail (collapsed & expanded) with modal/standard modes, badges, sections, and m3e_design token integration. description: Material 3 Expressive navigation rail (collapsed & expanded) with modal/standard modes, badges, sections, and m3e_design token integration.
version: 0.3.3 version: 0.3.4
homepage: https://github.com/EmilyMonestone/material_3_expressive homepage: https://github.com/EmilyMonestone/material_3_expressive
repository: https://github.com/EmilyMoonstone/material_3_expressive/tree/main/packages/navigation_rail_m3e repository: https://github.com/EmilyMoonstone/material_3_expressive/tree/main/packages/navigation_rail_m3e
issue_tracker: https://github.com/EmilyMonestone/material_3_expressive/issues issue_tracker: https://github.com/EmilyMonestone/material_3_expressive/issues