Unverified Commit 0d3d8d4b authored by Jonah Williams's avatar Jonah Williams Committed by GitHub

[framework] respect debugDisableShadows in slider thumbs (#105467)

parent 9f735613
......@@ -2366,7 +2366,19 @@ class RoundSliderThumbShape extends SliderComponentShape {
final double evaluatedElevation = elevationTween.evaluate(activationAnimation);
final Path path = Path()
..addArc(Rect.fromCenter(center: center, width: 2 * radius, height: 2 * radius), 0, math.pi * 2);
canvas.drawShadow(path, Colors.black, evaluatedElevation, true);
bool paintShadows = true;
assert(() {
if (debugDisableShadows) {
_debugDrawShadow(canvas, path, evaluatedElevation);
paintShadows = false;
}
return true;
}());
if (paintShadows) {
canvas.drawShadow(path, Colors.black, evaluatedElevation, true);
}
canvas.drawCircle(
center,
......@@ -2475,7 +2487,19 @@ class RoundRangeSliderThumbShape extends RangeSliderThumbShape {
final double evaluatedElevation = isPressed! ? elevationTween.evaluate(activationAnimation) : elevation;
final Path shadowPath = Path()
..addArc(Rect.fromCenter(center: center, width: 2 * radius, height: 2 * radius), 0, math.pi * 2);
canvas.drawShadow(shadowPath, Colors.black, evaluatedElevation, true);
bool paintShadows = true;
assert(() {
if (debugDisableShadows) {
_debugDrawShadow(canvas, shadowPath, evaluatedElevation);
paintShadows = false;
}
return true;
}());
if (paintShadows) {
canvas.drawShadow(shadowPath, Colors.black, evaluatedElevation, true);
}
canvas.drawCircle(
center,
......@@ -3359,3 +3383,15 @@ class RangeLabels {
return '${objectRuntimeType(this, 'RangeLabels')}($start, $end)';
}
}
void _debugDrawShadow(Canvas canvas, Path path, double elevation) {
if (elevation > 0.0) {
canvas.drawPath(
path,
Paint()
..color = Colors.black
..style = PaintingStyle.stroke
..strokeWidth = elevation * 2.0,
);
}
}
......@@ -1276,8 +1276,10 @@ void main() {
expect(
valueIndicatorBox,
paints
..path(color: Colors.black) // shadow
..path(color: Colors.black) // shadow
..path(color: sliderTheme.valueIndicatorColor)
..paragraph(),
..paragraph()
);
await gesture.up();
// Wait for value indicator animation to finish.
......@@ -1360,7 +1362,7 @@ void main() {
);
// Represents the Raised Button and Range Slider.
expect(valueIndicatorBox, paintsExactlyCountTimes(#drawPath, 4));
expect(valueIndicatorBox, paintsExactlyCountTimes(#drawPath, 6));
expect(valueIndicatorBox, paintsExactlyCountTimes(#drawParagraph, 3));
await tester.tap(find.text('Next'));
......@@ -1370,11 +1372,11 @@ void main() {
expect(
valueIndicatorBox,
isNot(
paints
..path(color: fillColor)
..paragraph()
..path(color: fillColor)
..paragraph(),
paints
..path(color: fillColor)
..paragraph()
..path(color: fillColor)
..paragraph(),
),
);
......@@ -1519,6 +1521,8 @@ void main() {
expect(
valueIndicatorBox,
paints
..path(color: Colors.black) // shadow
..path(color: Colors.black) // shadow
..path(color: sliderTheme.valueIndicatorColor)
..paragraph(),
);
......@@ -1594,6 +1598,8 @@ void main() {
expect(
valueIndicatorBox,
paints
..path(color: Colors.black) // shadow
..path(color: Colors.black) // shadow
..path(color: sliderTheme.valueIndicatorColor)
..paragraph(),
);
......
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