Unverified Commit 2867b31f authored by Matheus Kirchesch's avatar Matheus Kirchesch Committed by GitHub

Fixed [NavigationRailDestination]'s label opacity while disabled not being...

Fixed [NavigationRailDestination]'s label opacity while disabled not being coherent with the icon (#132345)

Fixing the opacity of the NavigationRailDestination widget label while
it is disabled, right now it doesn't get affected by the disabled
attribute, which doesn't match the icon that gets affected

* https://github.com/flutter/flutter/issues/132344

I believe this PR should be marked as [test-exempt]

## Pre-launch Checklist

- [x] I read the [Contributor Guide] and followed the process outlined
there for submitting PRs.
- [x] I read the [Tree Hygiene] wiki page, which explains my
responsibilities.
- [x] I read and followed the [Flutter Style Guide], including [Features
we expect every widget to implement].
- [x] I signed the [CLA].
- [x] I listed at least one issue that this PR fixes in the description
above.
- [x] I updated/added relevant documentation (doc comments with `///`).
- [x] I added new tests to check the change I am making, or this PR is
[test-exempt].
- [x] All existing and new tests are passing.
parent 6ddb3b04
......@@ -594,7 +594,9 @@ class _RailDestination extends StatelessWidget {
child: icon,
);
final Widget styledLabel = DefaultTextStyle(
style: labelTextStyle,
style: disabled
? labelTextStyle.copyWith(color: theme.colorScheme.onSurface.withOpacity(0.38))
: labelTextStyle,
child: label,
);
......
......@@ -3290,6 +3290,47 @@ void main() {
tester.pumpAndSettle();
});
testWidgetsWithLeakTracking("Destination's label with the right opacity while disabled", (WidgetTester tester) async {
await _pumpNavigationRail(
tester,
navigationRail: NavigationRail(
selectedIndex: 0,
destinations: const <NavigationRailDestination>[
NavigationRailDestination(
icon: Icon(Icons.favorite_border),
selectedIcon: Icon(Icons.favorite),
label: Text('Abc'),
),
NavigationRailDestination(
icon: Icon(Icons.bookmark_border),
selectedIcon: Icon(Icons.bookmark),
label: Text('Bcd'),
disabled: true,
),
],
onDestinationSelected: (int index) {},
labelType: NavigationRailLabelType.all,
),
);
await tester.pumpAndSettle();
double? defaultTextStyleOpacity(String text) {
return tester.widget<DefaultTextStyle>(
find.ancestor(
of: find.text(text),
matching: find.byType(DefaultTextStyle),
).first,
).style.color?.opacity;
}
final double? abcLabelOpacity = defaultTextStyleOpacity('Abc');
final double? bcdLabelOpacity = defaultTextStyleOpacity('Bcd');
expect(abcLabelOpacity, 1.0);
expect(bcdLabelOpacity, closeTo(0.38, 0.01));
});
group('Material 2', () {
// These tests are only relevant for Material 2. Once Material 2
// support is deprecated and the APIs are removed, these tests
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment