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