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