[Material] Remove opacity from dark theme overlay check (#66596)

* Remove opacity from check and add test
This commit is contained in:
MH Johnson
2020-09-25 10:41:27 -04:00
committed by GitHub
parent fd93576856
commit 7d89f21613
2 changed files with 22 additions and 1 deletions

View File

@@ -49,7 +49,7 @@ class ElevationOverlay {
if (elevation > 0.0 &&
theme.applyElevationOverlayColor &&
theme.brightness == Brightness.dark &&
color == theme.colorScheme.surface) {
color.withOpacity(1.0) == theme.colorScheme.surface.withOpacity(1.0)) {
return Color.alphaBlend(overlayColor(context, elevation), color);
}
return color;

View File

@@ -343,6 +343,27 @@ void main() {
expect(model.color, equals(Colors.cyan));
});
testWidgets('overlay will apply to materials with a non-opaque surface color', (WidgetTester tester) async {
const Color surfaceColor = Color(0xFF121212);
const Color surfaceColorWithOverlay = Color(0xC6353535);
await tester.pumpWidget(
Theme(
data: ThemeData(
applyElevationOverlayColor: true,
colorScheme: const ColorScheme.dark(surface: surfaceColor),
),
child: buildMaterial(
color: surfaceColor.withOpacity(.75),
elevation: 8.0,
),
),
);
final RenderPhysicalShape model = getModel(tester);
expect(model.color, equals(surfaceColorWithOverlay));
expect(model.color, isNot(equals(surfaceColor)));
});
});
group('Transparency clipping', () {