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