Unverified Commit c4cb0ecf authored by Todd Volkert's avatar Todd Volkert Committed by GitHub

Updates to debugDisableShadows (#17577)

1. Make CupertinoSwitch use BoxShadow.toPaint() so that it respects
   the `debugDisableShadows` flag.
2. Increase blue radius on debug banner
3. Only stroke "synthetic shadow" borders if elevation is positive.
parent 8be2682e
df3f713cc47fc4e919d1c5cf52c0543424c26c09
298b585e6eb2bf51b12cd0ea9261a1b7a83c9a29
......@@ -6,8 +6,6 @@ import 'package:flutter/painting.dart';
import 'colors.dart';
final MaskFilter _kShadowMaskFilter = new MaskFilter.blur(BlurStyle.normal, BoxShadow.convertRadiusToSigma(1.0));
/// Paints an iOS-style slider thumb.
///
/// Used by [CupertinoSwitch] and [CupertinoSlider].
......@@ -16,7 +14,10 @@ class CupertinoThumbPainter {
CupertinoThumbPainter({
this.color: CupertinoColors.white,
this.shadowColor: const Color(0x2C000000),
});
}) : _shadowPaint = new BoxShadow(
color: shadowColor,
blurRadius: 1.0,
).toPaint();
/// The color of the interior of the thumb.
final Color color;
......@@ -24,6 +25,9 @@ class CupertinoThumbPainter {
/// The color of the shadow case by the thumb.
final Color shadowColor;
/// The paint used to draw the shadow case by the thumb.
final Paint _shadowPaint;
/// Half the default diameter of the thumb.
static const double radius = 14.0;
......@@ -35,17 +39,13 @@ class CupertinoThumbPainter {
/// Consider using [radius] and [extension] when deciding how large a
/// rectangle to use for the thumb.
void paint(Canvas canvas, Rect rect) {
final RRect rrect = new RRect.fromRectAndRadius(rect, new Radius.circular(rect.shortestSide / 2.0));
final Paint paint = new Paint()
..color = shadowColor
..maskFilter = _kShadowMaskFilter;
canvas.drawRRect(rrect, paint);
canvas.drawRRect(rrect.shift(const Offset(0.0, 3.0)), paint);
paint
..color = color
..maskFilter = null;
canvas.drawRRect(rrect, paint);
final RRect rrect = new RRect.fromRectAndRadius(
rect,
new Radius.circular(rect.shortestSide / 2.0),
);
canvas.drawRRect(rrect, _shadowPaint);
canvas.drawRRect(rrect.shift(const Offset(0.0, 3.0)), _shadowPaint);
canvas.drawRRect(rrect, new Paint()..color = color);
}
}
......@@ -1600,13 +1600,15 @@ class RenderPhysicalModel extends _RenderPhysicalModelBase<RRect> {
bool paintShadows = true;
assert(() {
if (debugDisableShadows) {
context.canvas.drawRRect(
offsetRRect,
new Paint()
..color = shadowColor
..style = PaintingStyle.stroke
..strokeWidth = elevation * 2.0,
);
if (elevation > 0.0) {
context.canvas.drawRRect(
offsetRRect,
new Paint()
..color = shadowColor
..style = PaintingStyle.stroke
..strokeWidth = elevation * 2.0,
);
}
paintShadows = false;
}
return true;
......@@ -1721,13 +1723,15 @@ class RenderPhysicalShape extends _RenderPhysicalModelBase<Path> {
bool paintShadows = true;
assert(() {
if (debugDisableShadows) {
context.canvas.drawPath(
offsetPath,
new Paint()
..color = shadowColor
..style = PaintingStyle.stroke
..strokeWidth = elevation * 2.0,
);
if (elevation > 0.0) {
context.canvas.drawPath(
offsetPath,
new Paint()
..color = shadowColor
..style = PaintingStyle.stroke
..strokeWidth = elevation * 2.0,
);
}
paintShadows = false;
}
return true;
......
......@@ -110,7 +110,7 @@ class BannerPainter extends CustomPainter {
static const BoxShadow _shadow = const BoxShadow(
color: const Color(0x7F000000),
blurRadius: 4.0,
blurRadius: 6.0,
);
bool _prepared = false;
......
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