Fix default opacity assignments for unselected and selected icons in NavigationRail (#55902)

This commit is contained in:
Anthony 2020-04-29 12:39:03 -04:00 committed by GitHub
parent 4dd3435b78
commit 1b6711277e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 6 deletions

View File

@ -441,20 +441,20 @@ class _NavigationRailState extends State<NavigationRail> with TickerProviderStat
final double minWidth = widget.minWidth ?? _minRailWidth;
final double minExtendedWidth = widget.minExtendedWidth ?? _minExtendedRailWidth;
final Color baseSelectedColor = theme.colorScheme.primary;
final Color baseColor = theme.colorScheme.onSurface.withOpacity(0.64);
final Color baseUnselectedColor = theme.colorScheme.onSurface.withOpacity(0.64);
final IconThemeData defaultUnselectedIconTheme = widget.unselectedIconTheme ?? navigationRailTheme.unselectedIconTheme;
final IconThemeData unselectedIconTheme = IconThemeData(
size: defaultUnselectedIconTheme?.size ?? 24.0,
color: defaultUnselectedIconTheme?.color ?? theme.colorScheme.onSurface,
opacity: defaultUnselectedIconTheme?.opacity ?? 1.0,
opacity: defaultUnselectedIconTheme?.opacity ?? 0.64,
);
final IconThemeData defaultSelectedIconTheme = widget.selectedIconTheme ?? navigationRailTheme.selectedIconTheme;
final IconThemeData selectedIconTheme = IconThemeData(
size: defaultSelectedIconTheme?.size ?? 24.0,
color: defaultSelectedIconTheme?.color ?? theme.colorScheme.primary,
opacity: defaultSelectedIconTheme?.opacity ?? 0.64,
opacity: defaultSelectedIconTheme?.opacity ?? 1.0,
);
final TextStyle unselectedLabelTextStyle = theme.textTheme.bodyText1.copyWith(color: baseColor).merge(widget.unselectedLabelTextStyle ?? navigationRailTheme.unselectedLabelTextStyle);
final TextStyle unselectedLabelTextStyle = theme.textTheme.bodyText1.copyWith(color: baseUnselectedColor).merge(widget.unselectedLabelTextStyle ?? navigationRailTheme.unselectedLabelTextStyle);
final TextStyle selectedLabelTextStyle = theme.textTheme.bodyText1.copyWith(color: baseSelectedColor).merge(widget.selectedLabelTextStyle ?? navigationRailTheme.selectedLabelTextStyle);
final double groupAlignment = widget.groupAlignment ?? navigationRailTheme.groupAlignment ?? -1.0;
final NavigationRailLabelType labelType = widget.labelType ?? navigationRailTheme.labelType ?? NavigationRailLabelType.none;

View File

@ -29,10 +29,10 @@ void main() {
expect(_railMaterial(tester).elevation, 0);
expect(_selectedIconTheme(tester).size, 24.0);
expect(_selectedIconTheme(tester).color, ThemeData().colorScheme.primary);
expect(_selectedIconTheme(tester).opacity, 0.64);
expect(_selectedIconTheme(tester).opacity, 1.0);
expect(_unselectedIconTheme(tester).size, 24.0);
expect(_unselectedIconTheme(tester).color, ThemeData().colorScheme.onSurface);
expect(_unselectedIconTheme(tester).opacity, 1.0);
expect(_unselectedIconTheme(tester).opacity, 0.64);
expect(_selectedLabelStyle(tester).fontSize, 14.0);
expect(_unselectedLabelStyle(tester).fontSize, 14.0);
expect(_destinationsAlign(tester).alignment, Alignment.topCenter);