Commit d3022132 authored by Jason Simmons's avatar Jason Simmons Committed by GitHub

Gate the PhysicalModel shadows behind a flag (#9198)

Fixes https://github.com/flutter/flutter/issues/9186
parent 3000c8bb
......@@ -7,6 +7,7 @@ import 'package:flutter/rendering.dart';
import 'package:flutter/widgets.dart';
import 'constants.dart';
import 'shadows.dart';
import 'theme.dart';
/// Signature for the callback used by ink effects to obtain the rectangle for the effect.
......@@ -187,6 +188,9 @@ class Material extends StatefulWidget {
/// The default radius of an ink splash in logical pixels.
static const double defaultSplashRadius = 35.0;
// Temporary flag used to enable the PhysicalModel shadow implementation.
static bool debugEnablePhysicalModel = false;
}
class _MaterialState extends State<Material> with TickerProviderStateMixin {
......@@ -232,30 +236,41 @@ class _MaterialState extends State<Material> with TickerProviderStateMixin {
)
);
if (config.type == MaterialType.circle) {
contents = new PhysicalModel(
shape: BoxShape.circle,
elevation: config.elevation,
color: backgroundColor,
child: contents,
);
} else if (config.type == MaterialType.transparency) {
if (radius == null) {
contents = new ClipRect(child: contents);
if (Material.debugEnablePhysicalModel) {
if (config.type == MaterialType.circle) {
contents = new PhysicalModel(
shape: BoxShape.circle,
elevation: config.elevation,
color: backgroundColor,
child: contents,
);
} else if (config.type == MaterialType.transparency) {
if (radius == null) {
contents = new ClipRect(child: contents);
} else {
contents = new ClipRRect(
borderRadius: radius,
child: contents
);
}
} else {
contents = new PhysicalModel(
shape: BoxShape.rectangle,
borderRadius: radius ?? BorderRadius.zero,
elevation: config.elevation,
color: backgroundColor,
child: contents,
);
}
} else {
if (config.type == MaterialType.circle) {
contents = new ClipOval(child: contents);
} else if (kMaterialEdges[config.type] != null) {
contents = new ClipRRect(
borderRadius: radius,
child: contents
);
}
} else {
contents = new PhysicalModel(
shape: BoxShape.rectangle,
borderRadius: radius ?? BorderRadius.zero,
elevation: config.elevation,
color: backgroundColor,
child: contents,
);
}
if (config.type != MaterialType.transparency) {
......@@ -264,6 +279,8 @@ class _MaterialState extends State<Material> with TickerProviderStateMixin {
duration: kThemeChangeDuration,
decoration: new BoxDecoration(
borderRadius: radius,
boxShadow: config.elevation == 0 || Material.debugEnablePhysicalModel ?
null : kElevationToShadow[config.elevation],
shape: config.type == MaterialType.circle ? BoxShape.circle : BoxShape.rectangle
),
child: new Container(
......
......@@ -9,6 +9,8 @@ import 'package:flutter_test/flutter_test.dart';
import '../rendering/mock_canvas.dart';
void main() {
Material.debugEnablePhysicalModel = true;
testWidgets('Does the ink widget render a border radius', (WidgetTester tester) async {
final Color highlightColor = new Color(0xAAFF0000);
final Color splashColor = new Color(0xAA0000FF);
......
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