Unverified Commit cb8562e1 authored by Darren Austin's avatar Darren Austin Committed by GitHub

Make the InkResponse's focus highlight honor the radius parameter (#59117)

parent cd547c70
...@@ -41,6 +41,7 @@ class InkHighlight extends InteractiveInkFeature { ...@@ -41,6 +41,7 @@ class InkHighlight extends InteractiveInkFeature {
@required Color color, @required Color color,
@required TextDirection textDirection, @required TextDirection textDirection,
BoxShape shape = BoxShape.rectangle, BoxShape shape = BoxShape.rectangle,
double radius,
BorderRadius borderRadius, BorderRadius borderRadius,
ShapeBorder customBorder, ShapeBorder customBorder,
RectCallback rectCallback, RectCallback rectCallback,
...@@ -51,6 +52,7 @@ class InkHighlight extends InteractiveInkFeature { ...@@ -51,6 +52,7 @@ class InkHighlight extends InteractiveInkFeature {
assert(textDirection != null), assert(textDirection != null),
assert(fadeDuration != null), assert(fadeDuration != null),
_shape = shape, _shape = shape,
_radius = radius,
_borderRadius = borderRadius ?? BorderRadius.zero, _borderRadius = borderRadius ?? BorderRadius.zero,
_customBorder = customBorder, _customBorder = customBorder,
_textDirection = textDirection, _textDirection = textDirection,
...@@ -69,6 +71,7 @@ class InkHighlight extends InteractiveInkFeature { ...@@ -69,6 +71,7 @@ class InkHighlight extends InteractiveInkFeature {
} }
final BoxShape _shape; final BoxShape _shape;
final double _radius;
final BorderRadius _borderRadius; final BorderRadius _borderRadius;
final ShapeBorder _customBorder; final ShapeBorder _customBorder;
final RectCallback _rectCallback; final RectCallback _rectCallback;
...@@ -112,7 +115,7 @@ class InkHighlight extends InteractiveInkFeature { ...@@ -112,7 +115,7 @@ class InkHighlight extends InteractiveInkFeature {
} }
switch (_shape) { switch (_shape) {
case BoxShape.circle: case BoxShape.circle:
canvas.drawCircle(rect.center, Material.defaultSplashRadius, paint); canvas.drawCircle(rect.center, _radius ?? Material.defaultSplashRadius, paint);
break; break;
case BoxShape.rectangle: case BoxShape.rectangle:
if (_borderRadius != BorderRadius.zero) { if (_borderRadius != BorderRadius.zero) {
......
...@@ -840,6 +840,7 @@ class _InkResponseState extends State<_InkResponseStateWidget> ...@@ -840,6 +840,7 @@ class _InkResponseState extends State<_InkResponseStateWidget>
referenceBox: referenceBox, referenceBox: referenceBox,
color: getHighlightColorForType(type), color: getHighlightColorForType(type),
shape: widget.highlightShape, shape: widget.highlightShape,
radius: widget.radius,
borderRadius: widget.borderRadius, borderRadius: widget.borderRadius,
customBorder: widget.customBorder, customBorder: widget.customBorder,
rectCallback: widget.getRectCallback(referenceBox), rectCallback: widget.getRectCallback(referenceBox),
......
...@@ -313,6 +313,36 @@ void main() { ...@@ -313,6 +313,36 @@ void main() {
await gesture.up(); await gesture.up();
}); });
testWidgets('ink response uses radius for focus highlight', (WidgetTester tester) async {
FocusManager.instance.highlightStrategy = FocusHighlightStrategy.alwaysTraditional;
final FocusNode focusNode = FocusNode(debugLabel: 'Ink Focus');
await tester.pumpWidget(
Material(
child: Directionality(
textDirection: TextDirection.ltr,
child: Center(
child: Container(
width: 100,
height: 100,
child: InkResponse(
focusNode: focusNode,
radius: 20,
focusColor: const Color(0xff0000ff),
onTap: () { },
),
),
),
),
),
);
await tester.pumpAndSettle();
final RenderObject inkFeatures = tester.allRenderObjects.firstWhere((RenderObject object) => object.runtimeType.toString() == '_RenderInkFeatures');
expect(inkFeatures, paintsExactlyCountTimes(#drawCircle, 0));
focusNode.requestFocus();
await tester.pumpAndSettle();
expect(inkFeatures, paints..circle(radius: 20, color: const Color(0xff0000ff)));
});
testWidgets("ink response doesn't change color on focus when on touch device", (WidgetTester tester) async { testWidgets("ink response doesn't change color on focus when on touch device", (WidgetTester tester) async {
FocusManager.instance.highlightStrategy = FocusHighlightStrategy.alwaysTouch; FocusManager.instance.highlightStrategy = FocusHighlightStrategy.alwaysTouch;
final FocusNode focusNode = FocusNode(debugLabel: 'Ink Focus'); final FocusNode focusNode = FocusNode(debugLabel: 'Ink Focus');
......
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