Skip to content

Commit

Permalink
Ensure that textDirection is always passed to ShapeBorder.getOuterPath (
Browse files Browse the repository at this point in the history
  • Loading branch information
jonahwilliams authored Sep 7, 2018
1 parent 9a290c1 commit 3821c35
Show file tree
Hide file tree
Showing 12 changed files with 247 additions and 140 deletions.
6 changes: 5 additions & 1 deletion packages/flutter/lib/src/material/ink_highlight.dart
Original file line number Diff line number Diff line change
Expand Up @@ -39,16 +39,19 @@ class InkHighlight extends InteractiveInkFeature {
@required MaterialInkController controller,
@required RenderBox referenceBox,
@required Color color,
@required TextDirection textDirection,
BoxShape shape = BoxShape.rectangle,
BorderRadius borderRadius,
ShapeBorder customBorder,
RectCallback rectCallback,
VoidCallback onRemoved,
}) : assert(color != null),
assert(shape != null),
assert(textDirection != null),
_shape = shape,
_borderRadius = borderRadius ?? BorderRadius.zero,
_customBorder = customBorder,
_textDirection = textDirection,
_rectCallback = rectCallback,
super(controller: controller, referenceBox: referenceBox, color: color, onRemoved: onRemoved) {
_alphaController = new AnimationController(duration: _kHighlightFadeDuration, vsync: controller.vsync)
Expand All @@ -67,6 +70,7 @@ class InkHighlight extends InteractiveInkFeature {
final BorderRadius _borderRadius;
final ShapeBorder _customBorder;
final RectCallback _rectCallback;
final TextDirection _textDirection;

Animation<int> _alpha;
AnimationController _alphaController;
Expand Down Expand Up @@ -102,7 +106,7 @@ class InkHighlight extends InteractiveInkFeature {
assert(_shape != null);
canvas.save();
if (_customBorder != null) {
canvas.clipPath(_customBorder.getOuterPath(rect));
canvas.clipPath(_customBorder.getOuterPath(rect, textDirection: _textDirection));
}
switch (_shape) {
case BoxShape.circle:
Expand Down
8 changes: 7 additions & 1 deletion packages/flutter/lib/src/material/ink_ripple.dart
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ class _InkRippleFactory extends InteractiveInkFeatureFactory {
@required RenderBox referenceBox,
@required Offset position,
@required Color color,
@required TextDirection textDirection,
bool containedInkWell = false,
RectCallback rectCallback,
BorderRadius borderRadius,
Expand All @@ -63,6 +64,7 @@ class _InkRippleFactory extends InteractiveInkFeatureFactory {
customBorder: customBorder,
radius: radius,
onRemoved: onRemoved,
textDirection: textDirection,
);
}
}
Expand Down Expand Up @@ -114,6 +116,7 @@ class InkRipple extends InteractiveInkFeature {
@required RenderBox referenceBox,
@required Offset position,
@required Color color,
@required TextDirection textDirection,
bool containedInkWell = false,
RectCallback rectCallback,
BorderRadius borderRadius,
Expand All @@ -122,9 +125,11 @@ class InkRipple extends InteractiveInkFeature {
VoidCallback onRemoved,
}) : assert(color != null),
assert(position != null),
assert(textDirection != null),
_position = position,
_borderRadius = borderRadius ?? BorderRadius.zero,
_customBorder = customBorder,
_textDirection = textDirection,
_targetRadius = radius ?? _getTargetRadius(referenceBox, containedInkWell, rectCallback, position),
_clipCallback = _getClipCallback(referenceBox, containedInkWell, rectCallback),
super(controller: controller, referenceBox: referenceBox, color: color, onRemoved: onRemoved)
Expand Down Expand Up @@ -179,6 +184,7 @@ class InkRipple extends InteractiveInkFeature {
final ShapeBorder _customBorder;
final double _targetRadius;
final RectCallback _clipCallback;
final TextDirection _textDirection;

Animation<double> _radius;
AnimationController _radiusController;
Expand Down Expand Up @@ -245,7 +251,7 @@ class InkRipple extends InteractiveInkFeature {
if (_clipCallback != null) {
final Rect rect = _clipCallback();
if (_customBorder != null) {
canvas.clipPath(_customBorder.getOuterPath(rect));
canvas.clipPath(_customBorder.getOuterPath(rect, textDirection: _textDirection));
} else if (_borderRadius != BorderRadius.zero) {
canvas.clipRRect(new RRect.fromRectAndCorners(
rect,
Expand Down
10 changes: 8 additions & 2 deletions packages/flutter/lib/src/material/ink_splash.dart
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ class _InkSplashFactory extends InteractiveInkFeatureFactory {
@required RenderBox referenceBox,
@required Offset position,
@required Color color,
@required TextDirection textDirection,
bool containedInkWell = false,
RectCallback rectCallback,
BorderRadius borderRadius,
Expand All @@ -69,6 +70,7 @@ class _InkSplashFactory extends InteractiveInkFeatureFactory {
customBorder: customBorder,
radius: radius,
onRemoved: onRemoved,
textDirection: textDirection,
);
}
}
Expand Down Expand Up @@ -116,6 +118,7 @@ class InkSplash extends InteractiveInkFeature {
InkSplash({
@required MaterialInkController controller,
@required RenderBox referenceBox,
@required TextDirection textDirection,
Offset position,
Color color,
bool containedInkWell = false,
Expand All @@ -124,12 +127,14 @@ class InkSplash extends InteractiveInkFeature {
ShapeBorder customBorder,
double radius,
VoidCallback onRemoved,
}) : _position = position,
}) : assert(textDirection != null),
_position = position,
_borderRadius = borderRadius ?? BorderRadius.zero,
_customBorder = customBorder,
_targetRadius = radius ?? _getTargetRadius(referenceBox, containedInkWell, rectCallback, position),
_clipCallback = _getClipCallback(referenceBox, containedInkWell, rectCallback),
_repositionToReferenceBox = !containedInkWell,
_textDirection = textDirection,
super(controller: controller, referenceBox: referenceBox, color: color, onRemoved: onRemoved) {
assert(_borderRadius != null);
_radiusController = new AnimationController(duration: _kUnconfirmedSplashDuration, vsync: controller.vsync)
Expand All @@ -156,6 +161,7 @@ class InkSplash extends InteractiveInkFeature {
final double _targetRadius;
final RectCallback _clipCallback;
final bool _repositionToReferenceBox;
final TextDirection _textDirection;

Animation<double> _radius;
AnimationController _radiusController;
Expand Down Expand Up @@ -206,7 +212,7 @@ class InkSplash extends InteractiveInkFeature {
if (_clipCallback != null) {
final Rect rect = _clipCallback();
if (_customBorder != null) {
canvas.clipPath(_customBorder.getOuterPath(rect));
canvas.clipPath(_customBorder.getOuterPath(rect, textDirection: _textDirection));
} else if (_borderRadius != BorderRadius.zero) {
canvas.clipRRect(new RRect.fromRectAndCorners(
rect,
Expand Down
4 changes: 4 additions & 0 deletions packages/flutter/lib/src/material/ink_well.dart
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ abstract class InteractiveInkFeatureFactory {
@required RenderBox referenceBox,
@required Offset position,
@required Color color,
@required TextDirection textDirection,
bool containedInkWell = false,
RectCallback rectCallback,
BorderRadius borderRadius,
Expand Down Expand Up @@ -372,6 +373,7 @@ class InkResponse extends StatefulWidget {
@mustCallSuper
bool debugCheckContext(BuildContext context) {
assert(debugCheckHasMaterial(context));
assert(debugCheckHasDirectionality(context));
return true;
}

Expand Down Expand Up @@ -426,6 +428,7 @@ class _InkResponseState<T extends InkResponse> extends State<T> with AutomaticKe
customBorder: widget.customBorder,
rectCallback: widget.getRectCallback(referenceBox),
onRemoved: _handleInkHighlightRemoval,
textDirection: Directionality.of(context),
);
updateKeepAlive();
} else {
Expand Down Expand Up @@ -476,6 +479,7 @@ class _InkResponseState<T extends InkResponse> extends State<T> with AutomaticKe
borderRadius: borderRadius,
customBorder: customBorder,
onRemoved: onRemoved,
textDirection: Directionality.of(context),
);

return splash;
Expand Down
2 changes: 1 addition & 1 deletion packages/flutter/lib/src/material/outline_button.dart
Original file line number Diff line number Diff line change
Expand Up @@ -497,7 +497,7 @@ class _OutlineBorder extends ShapeBorder {
case BorderStyle.none:
break;
case BorderStyle.solid:
canvas.drawPath(shape.getOuterPath(rect), side.toPaint());
canvas.drawPath(shape.getOuterPath(rect, textDirection: textDirection), side.toPaint());
}
}

Expand Down
2 changes: 2 additions & 0 deletions packages/flutter/lib/src/material/text_field.dart
Original file line number Diff line number Diff line change
Expand Up @@ -473,6 +473,7 @@ class _TextFieldState extends State<TextField> with AutomaticKeepAliveClientMixi
// TODO(hansmuller): splash clip borderRadius should match the input decorator's border.
borderRadius: BorderRadius.zero,
onRemoved: handleRemoved,
textDirection: Directionality.of(context),
);

return splash;
Expand Down Expand Up @@ -539,6 +540,7 @@ class _TextFieldState extends State<TextField> with AutomaticKeepAliveClientMixi
Widget build(BuildContext context) {
super.build(context); // See AutomaticKeepAliveClientMixin.
assert(debugCheckHasMaterial(context));
assert(debugCheckHasDirectionality(context));
final ThemeData themeData = Theme.of(context);
final TextStyle style = widget.style ?? themeData.textTheme.subhead;
final Brightness keyboardAppearance = widget.keyboardAppearance ?? themeData.primaryColorBrightness;
Expand Down
Loading

0 comments on commit 3821c35

Please sign in to comment.