mirror of
https://github.com/flutter/flutter
synced 2024-10-14 04:02:56 +00:00
Ensure that textDirection is always passed to ShapeBorder.getOuterPath (#21532)
This commit is contained in:
parent
9a290c174a
commit
3821c35d04
|
@ -39,6 +39,7 @@ class InkHighlight extends InteractiveInkFeature {
|
||||||
@required MaterialInkController controller,
|
@required MaterialInkController controller,
|
||||||
@required RenderBox referenceBox,
|
@required RenderBox referenceBox,
|
||||||
@required Color color,
|
@required Color color,
|
||||||
|
@required TextDirection textDirection,
|
||||||
BoxShape shape = BoxShape.rectangle,
|
BoxShape shape = BoxShape.rectangle,
|
||||||
BorderRadius borderRadius,
|
BorderRadius borderRadius,
|
||||||
ShapeBorder customBorder,
|
ShapeBorder customBorder,
|
||||||
|
@ -46,9 +47,11 @@ class InkHighlight extends InteractiveInkFeature {
|
||||||
VoidCallback onRemoved,
|
VoidCallback onRemoved,
|
||||||
}) : assert(color != null),
|
}) : assert(color != null),
|
||||||
assert(shape != null),
|
assert(shape != null),
|
||||||
|
assert(textDirection != null),
|
||||||
_shape = shape,
|
_shape = shape,
|
||||||
_borderRadius = borderRadius ?? BorderRadius.zero,
|
_borderRadius = borderRadius ?? BorderRadius.zero,
|
||||||
_customBorder = customBorder,
|
_customBorder = customBorder,
|
||||||
|
_textDirection = textDirection,
|
||||||
_rectCallback = rectCallback,
|
_rectCallback = rectCallback,
|
||||||
super(controller: controller, referenceBox: referenceBox, color: color, onRemoved: onRemoved) {
|
super(controller: controller, referenceBox: referenceBox, color: color, onRemoved: onRemoved) {
|
||||||
_alphaController = new AnimationController(duration: _kHighlightFadeDuration, vsync: controller.vsync)
|
_alphaController = new AnimationController(duration: _kHighlightFadeDuration, vsync: controller.vsync)
|
||||||
|
@ -67,6 +70,7 @@ class InkHighlight extends InteractiveInkFeature {
|
||||||
final BorderRadius _borderRadius;
|
final BorderRadius _borderRadius;
|
||||||
final ShapeBorder _customBorder;
|
final ShapeBorder _customBorder;
|
||||||
final RectCallback _rectCallback;
|
final RectCallback _rectCallback;
|
||||||
|
final TextDirection _textDirection;
|
||||||
|
|
||||||
Animation<int> _alpha;
|
Animation<int> _alpha;
|
||||||
AnimationController _alphaController;
|
AnimationController _alphaController;
|
||||||
|
@ -102,7 +106,7 @@ class InkHighlight extends InteractiveInkFeature {
|
||||||
assert(_shape != null);
|
assert(_shape != null);
|
||||||
canvas.save();
|
canvas.save();
|
||||||
if (_customBorder != null) {
|
if (_customBorder != null) {
|
||||||
canvas.clipPath(_customBorder.getOuterPath(rect));
|
canvas.clipPath(_customBorder.getOuterPath(rect, textDirection: _textDirection));
|
||||||
}
|
}
|
||||||
switch (_shape) {
|
switch (_shape) {
|
||||||
case BoxShape.circle:
|
case BoxShape.circle:
|
||||||
|
|
|
@ -45,6 +45,7 @@ class _InkRippleFactory extends InteractiveInkFeatureFactory {
|
||||||
@required RenderBox referenceBox,
|
@required RenderBox referenceBox,
|
||||||
@required Offset position,
|
@required Offset position,
|
||||||
@required Color color,
|
@required Color color,
|
||||||
|
@required TextDirection textDirection,
|
||||||
bool containedInkWell = false,
|
bool containedInkWell = false,
|
||||||
RectCallback rectCallback,
|
RectCallback rectCallback,
|
||||||
BorderRadius borderRadius,
|
BorderRadius borderRadius,
|
||||||
|
@ -63,6 +64,7 @@ class _InkRippleFactory extends InteractiveInkFeatureFactory {
|
||||||
customBorder: customBorder,
|
customBorder: customBorder,
|
||||||
radius: radius,
|
radius: radius,
|
||||||
onRemoved: onRemoved,
|
onRemoved: onRemoved,
|
||||||
|
textDirection: textDirection,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -114,6 +116,7 @@ class InkRipple extends InteractiveInkFeature {
|
||||||
@required RenderBox referenceBox,
|
@required RenderBox referenceBox,
|
||||||
@required Offset position,
|
@required Offset position,
|
||||||
@required Color color,
|
@required Color color,
|
||||||
|
@required TextDirection textDirection,
|
||||||
bool containedInkWell = false,
|
bool containedInkWell = false,
|
||||||
RectCallback rectCallback,
|
RectCallback rectCallback,
|
||||||
BorderRadius borderRadius,
|
BorderRadius borderRadius,
|
||||||
|
@ -122,9 +125,11 @@ class InkRipple extends InteractiveInkFeature {
|
||||||
VoidCallback onRemoved,
|
VoidCallback onRemoved,
|
||||||
}) : assert(color != null),
|
}) : assert(color != null),
|
||||||
assert(position != null),
|
assert(position != null),
|
||||||
|
assert(textDirection != null),
|
||||||
_position = position,
|
_position = position,
|
||||||
_borderRadius = borderRadius ?? BorderRadius.zero,
|
_borderRadius = borderRadius ?? BorderRadius.zero,
|
||||||
_customBorder = customBorder,
|
_customBorder = customBorder,
|
||||||
|
_textDirection = textDirection,
|
||||||
_targetRadius = radius ?? _getTargetRadius(referenceBox, containedInkWell, rectCallback, position),
|
_targetRadius = radius ?? _getTargetRadius(referenceBox, containedInkWell, rectCallback, position),
|
||||||
_clipCallback = _getClipCallback(referenceBox, containedInkWell, rectCallback),
|
_clipCallback = _getClipCallback(referenceBox, containedInkWell, rectCallback),
|
||||||
super(controller: controller, referenceBox: referenceBox, color: color, onRemoved: onRemoved)
|
super(controller: controller, referenceBox: referenceBox, color: color, onRemoved: onRemoved)
|
||||||
|
@ -179,6 +184,7 @@ class InkRipple extends InteractiveInkFeature {
|
||||||
final ShapeBorder _customBorder;
|
final ShapeBorder _customBorder;
|
||||||
final double _targetRadius;
|
final double _targetRadius;
|
||||||
final RectCallback _clipCallback;
|
final RectCallback _clipCallback;
|
||||||
|
final TextDirection _textDirection;
|
||||||
|
|
||||||
Animation<double> _radius;
|
Animation<double> _radius;
|
||||||
AnimationController _radiusController;
|
AnimationController _radiusController;
|
||||||
|
@ -245,7 +251,7 @@ class InkRipple extends InteractiveInkFeature {
|
||||||
if (_clipCallback != null) {
|
if (_clipCallback != null) {
|
||||||
final Rect rect = _clipCallback();
|
final Rect rect = _clipCallback();
|
||||||
if (_customBorder != null) {
|
if (_customBorder != null) {
|
||||||
canvas.clipPath(_customBorder.getOuterPath(rect));
|
canvas.clipPath(_customBorder.getOuterPath(rect, textDirection: _textDirection));
|
||||||
} else if (_borderRadius != BorderRadius.zero) {
|
} else if (_borderRadius != BorderRadius.zero) {
|
||||||
canvas.clipRRect(new RRect.fromRectAndCorners(
|
canvas.clipRRect(new RRect.fromRectAndCorners(
|
||||||
rect,
|
rect,
|
||||||
|
|
|
@ -51,6 +51,7 @@ class _InkSplashFactory extends InteractiveInkFeatureFactory {
|
||||||
@required RenderBox referenceBox,
|
@required RenderBox referenceBox,
|
||||||
@required Offset position,
|
@required Offset position,
|
||||||
@required Color color,
|
@required Color color,
|
||||||
|
@required TextDirection textDirection,
|
||||||
bool containedInkWell = false,
|
bool containedInkWell = false,
|
||||||
RectCallback rectCallback,
|
RectCallback rectCallback,
|
||||||
BorderRadius borderRadius,
|
BorderRadius borderRadius,
|
||||||
|
@ -69,6 +70,7 @@ class _InkSplashFactory extends InteractiveInkFeatureFactory {
|
||||||
customBorder: customBorder,
|
customBorder: customBorder,
|
||||||
radius: radius,
|
radius: radius,
|
||||||
onRemoved: onRemoved,
|
onRemoved: onRemoved,
|
||||||
|
textDirection: textDirection,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -116,6 +118,7 @@ class InkSplash extends InteractiveInkFeature {
|
||||||
InkSplash({
|
InkSplash({
|
||||||
@required MaterialInkController controller,
|
@required MaterialInkController controller,
|
||||||
@required RenderBox referenceBox,
|
@required RenderBox referenceBox,
|
||||||
|
@required TextDirection textDirection,
|
||||||
Offset position,
|
Offset position,
|
||||||
Color color,
|
Color color,
|
||||||
bool containedInkWell = false,
|
bool containedInkWell = false,
|
||||||
|
@ -124,12 +127,14 @@ class InkSplash extends InteractiveInkFeature {
|
||||||
ShapeBorder customBorder,
|
ShapeBorder customBorder,
|
||||||
double radius,
|
double radius,
|
||||||
VoidCallback onRemoved,
|
VoidCallback onRemoved,
|
||||||
}) : _position = position,
|
}) : assert(textDirection != null),
|
||||||
|
_position = position,
|
||||||
_borderRadius = borderRadius ?? BorderRadius.zero,
|
_borderRadius = borderRadius ?? BorderRadius.zero,
|
||||||
_customBorder = customBorder,
|
_customBorder = customBorder,
|
||||||
_targetRadius = radius ?? _getTargetRadius(referenceBox, containedInkWell, rectCallback, position),
|
_targetRadius = radius ?? _getTargetRadius(referenceBox, containedInkWell, rectCallback, position),
|
||||||
_clipCallback = _getClipCallback(referenceBox, containedInkWell, rectCallback),
|
_clipCallback = _getClipCallback(referenceBox, containedInkWell, rectCallback),
|
||||||
_repositionToReferenceBox = !containedInkWell,
|
_repositionToReferenceBox = !containedInkWell,
|
||||||
|
_textDirection = textDirection,
|
||||||
super(controller: controller, referenceBox: referenceBox, color: color, onRemoved: onRemoved) {
|
super(controller: controller, referenceBox: referenceBox, color: color, onRemoved: onRemoved) {
|
||||||
assert(_borderRadius != null);
|
assert(_borderRadius != null);
|
||||||
_radiusController = new AnimationController(duration: _kUnconfirmedSplashDuration, vsync: controller.vsync)
|
_radiusController = new AnimationController(duration: _kUnconfirmedSplashDuration, vsync: controller.vsync)
|
||||||
|
@ -156,6 +161,7 @@ class InkSplash extends InteractiveInkFeature {
|
||||||
final double _targetRadius;
|
final double _targetRadius;
|
||||||
final RectCallback _clipCallback;
|
final RectCallback _clipCallback;
|
||||||
final bool _repositionToReferenceBox;
|
final bool _repositionToReferenceBox;
|
||||||
|
final TextDirection _textDirection;
|
||||||
|
|
||||||
Animation<double> _radius;
|
Animation<double> _radius;
|
||||||
AnimationController _radiusController;
|
AnimationController _radiusController;
|
||||||
|
@ -206,7 +212,7 @@ class InkSplash extends InteractiveInkFeature {
|
||||||
if (_clipCallback != null) {
|
if (_clipCallback != null) {
|
||||||
final Rect rect = _clipCallback();
|
final Rect rect = _clipCallback();
|
||||||
if (_customBorder != null) {
|
if (_customBorder != null) {
|
||||||
canvas.clipPath(_customBorder.getOuterPath(rect));
|
canvas.clipPath(_customBorder.getOuterPath(rect, textDirection: _textDirection));
|
||||||
} else if (_borderRadius != BorderRadius.zero) {
|
} else if (_borderRadius != BorderRadius.zero) {
|
||||||
canvas.clipRRect(new RRect.fromRectAndCorners(
|
canvas.clipRRect(new RRect.fromRectAndCorners(
|
||||||
rect,
|
rect,
|
||||||
|
|
|
@ -92,6 +92,7 @@ abstract class InteractiveInkFeatureFactory {
|
||||||
@required RenderBox referenceBox,
|
@required RenderBox referenceBox,
|
||||||
@required Offset position,
|
@required Offset position,
|
||||||
@required Color color,
|
@required Color color,
|
||||||
|
@required TextDirection textDirection,
|
||||||
bool containedInkWell = false,
|
bool containedInkWell = false,
|
||||||
RectCallback rectCallback,
|
RectCallback rectCallback,
|
||||||
BorderRadius borderRadius,
|
BorderRadius borderRadius,
|
||||||
|
@ -372,6 +373,7 @@ class InkResponse extends StatefulWidget {
|
||||||
@mustCallSuper
|
@mustCallSuper
|
||||||
bool debugCheckContext(BuildContext context) {
|
bool debugCheckContext(BuildContext context) {
|
||||||
assert(debugCheckHasMaterial(context));
|
assert(debugCheckHasMaterial(context));
|
||||||
|
assert(debugCheckHasDirectionality(context));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -426,6 +428,7 @@ class _InkResponseState<T extends InkResponse> extends State<T> with AutomaticKe
|
||||||
customBorder: widget.customBorder,
|
customBorder: widget.customBorder,
|
||||||
rectCallback: widget.getRectCallback(referenceBox),
|
rectCallback: widget.getRectCallback(referenceBox),
|
||||||
onRemoved: _handleInkHighlightRemoval,
|
onRemoved: _handleInkHighlightRemoval,
|
||||||
|
textDirection: Directionality.of(context),
|
||||||
);
|
);
|
||||||
updateKeepAlive();
|
updateKeepAlive();
|
||||||
} else {
|
} else {
|
||||||
|
@ -476,6 +479,7 @@ class _InkResponseState<T extends InkResponse> extends State<T> with AutomaticKe
|
||||||
borderRadius: borderRadius,
|
borderRadius: borderRadius,
|
||||||
customBorder: customBorder,
|
customBorder: customBorder,
|
||||||
onRemoved: onRemoved,
|
onRemoved: onRemoved,
|
||||||
|
textDirection: Directionality.of(context),
|
||||||
);
|
);
|
||||||
|
|
||||||
return splash;
|
return splash;
|
||||||
|
|
|
@ -497,7 +497,7 @@ class _OutlineBorder extends ShapeBorder {
|
||||||
case BorderStyle.none:
|
case BorderStyle.none:
|
||||||
break;
|
break;
|
||||||
case BorderStyle.solid:
|
case BorderStyle.solid:
|
||||||
canvas.drawPath(shape.getOuterPath(rect), side.toPaint());
|
canvas.drawPath(shape.getOuterPath(rect, textDirection: textDirection), side.toPaint());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -473,6 +473,7 @@ class _TextFieldState extends State<TextField> with AutomaticKeepAliveClientMixi
|
||||||
// TODO(hansmuller): splash clip borderRadius should match the input decorator's border.
|
// TODO(hansmuller): splash clip borderRadius should match the input decorator's border.
|
||||||
borderRadius: BorderRadius.zero,
|
borderRadius: BorderRadius.zero,
|
||||||
onRemoved: handleRemoved,
|
onRemoved: handleRemoved,
|
||||||
|
textDirection: Directionality.of(context),
|
||||||
);
|
);
|
||||||
|
|
||||||
return splash;
|
return splash;
|
||||||
|
@ -539,6 +540,7 @@ class _TextFieldState extends State<TextField> with AutomaticKeepAliveClientMixi
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
super.build(context); // See AutomaticKeepAliveClientMixin.
|
super.build(context); // See AutomaticKeepAliveClientMixin.
|
||||||
assert(debugCheckHasMaterial(context));
|
assert(debugCheckHasMaterial(context));
|
||||||
|
assert(debugCheckHasDirectionality(context));
|
||||||
final ThemeData themeData = Theme.of(context);
|
final ThemeData themeData = Theme.of(context);
|
||||||
final TextStyle style = widget.style ?? themeData.textTheme.subhead;
|
final TextStyle style = widget.style ?? themeData.textTheme.subhead;
|
||||||
final Brightness keyboardAppearance = widget.keyboardAppearance ?? themeData.primaryColorBrightness;
|
final Brightness keyboardAppearance = widget.keyboardAppearance ?? themeData.primaryColorBrightness;
|
||||||
|
|
|
@ -15,16 +15,19 @@ void main() {
|
||||||
final BorderRadius borderRadius = new BorderRadius.circular(6.0);
|
final BorderRadius borderRadius = new BorderRadius.circular(6.0);
|
||||||
|
|
||||||
await tester.pumpWidget(
|
await tester.pumpWidget(
|
||||||
new Material(
|
new Directionality(
|
||||||
child: new Center(
|
textDirection: TextDirection.ltr,
|
||||||
child: new Container(
|
child: new Material(
|
||||||
width: 200.0,
|
child: new Center(
|
||||||
height: 60.0,
|
child: new Container(
|
||||||
child: new InkWell(
|
width: 200.0,
|
||||||
borderRadius: borderRadius,
|
height: 60.0,
|
||||||
highlightColor: highlightColor,
|
child: new InkWell(
|
||||||
splashColor: splashColor,
|
borderRadius: borderRadius,
|
||||||
onTap: () { },
|
highlightColor: highlightColor,
|
||||||
|
splashColor: splashColor,
|
||||||
|
onTap: () { },
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
@ -61,18 +64,21 @@ void main() {
|
||||||
final BorderRadius borderRadius = new BorderRadius.circular(6.0);
|
final BorderRadius borderRadius = new BorderRadius.circular(6.0);
|
||||||
|
|
||||||
await tester.pumpWidget(
|
await tester.pumpWidget(
|
||||||
new Material(
|
new Directionality(
|
||||||
child: new Center(
|
textDirection: TextDirection.ltr,
|
||||||
child: new Container(
|
child: new Material(
|
||||||
width: 100.0,
|
child: new Center(
|
||||||
height: 100.0,
|
child: new Container(
|
||||||
child: new InkWell(
|
width: 100.0,
|
||||||
borderRadius: borderRadius,
|
height: 100.0,
|
||||||
highlightColor: highlightColor,
|
child: new InkWell(
|
||||||
splashColor: splashColor,
|
borderRadius: borderRadius,
|
||||||
onTap: () { },
|
highlightColor: highlightColor,
|
||||||
radius: 100.0,
|
splashColor: splashColor,
|
||||||
splashFactory: InkRipple.splashFactory,
|
onTap: () { },
|
||||||
|
radius: 100.0,
|
||||||
|
splashFactory: InkRipple.splashFactory,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
@ -138,15 +144,18 @@ void main() {
|
||||||
|
|
||||||
testWidgets('Does the Ink widget render anything', (WidgetTester tester) async {
|
testWidgets('Does the Ink widget render anything', (WidgetTester tester) async {
|
||||||
await tester.pumpWidget(
|
await tester.pumpWidget(
|
||||||
new Material(
|
new Directionality(
|
||||||
child: new Center(
|
textDirection: TextDirection.ltr,
|
||||||
child: new Ink(
|
child: new Material(
|
||||||
color: Colors.blue,
|
child: new Center(
|
||||||
width: 200.0,
|
child: new Ink(
|
||||||
height: 200.0,
|
color: Colors.blue,
|
||||||
child: new InkWell(
|
width: 200.0,
|
||||||
splashColor: Colors.green,
|
height: 200.0,
|
||||||
onTap: () { },
|
child: new InkWell(
|
||||||
|
splashColor: Colors.green,
|
||||||
|
onTap: () { },
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
@ -167,15 +176,18 @@ void main() {
|
||||||
);
|
);
|
||||||
|
|
||||||
await tester.pumpWidget(
|
await tester.pumpWidget(
|
||||||
new Material(
|
new Directionality(
|
||||||
child: new Center(
|
textDirection: TextDirection.ltr,
|
||||||
child: new Ink(
|
child: new Material(
|
||||||
color: Colors.red,
|
child: new Center(
|
||||||
width: 200.0,
|
child: new Ink(
|
||||||
height: 200.0,
|
color: Colors.red,
|
||||||
child: new InkWell(
|
width: 200.0,
|
||||||
splashColor: Colors.green,
|
height: 200.0,
|
||||||
onTap: () { },
|
child: new InkWell(
|
||||||
|
splashColor: Colors.green,
|
||||||
|
onTap: () { },
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
@ -192,11 +204,14 @@ void main() {
|
||||||
);
|
);
|
||||||
|
|
||||||
await tester.pumpWidget(
|
await tester.pumpWidget(
|
||||||
new Material(
|
new Directionality(
|
||||||
child: new Center(
|
textDirection: TextDirection.ltr,
|
||||||
child: new InkWell( // this is at a different depth in the tree so it's now a new InkWell
|
child: new Material(
|
||||||
splashColor: Colors.green,
|
child: new Center(
|
||||||
onTap: () { },
|
child: new InkWell( // this is at a different depth in the tree so it's now a new InkWell
|
||||||
|
splashColor: Colors.green,
|
||||||
|
onTap: () { },
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
@ -213,15 +228,18 @@ void main() {
|
||||||
testWidgets('Cancel an InkRipple that was disposed when its animation ended', (WidgetTester tester) async {
|
testWidgets('Cancel an InkRipple that was disposed when its animation ended', (WidgetTester tester) async {
|
||||||
// Regression test for https://github.com/flutter/flutter/issues/14391
|
// Regression test for https://github.com/flutter/flutter/issues/14391
|
||||||
await tester.pumpWidget(
|
await tester.pumpWidget(
|
||||||
new Material(
|
new Directionality(
|
||||||
child: new Center(
|
textDirection: TextDirection.ltr,
|
||||||
child: new Container(
|
child: new Material(
|
||||||
width: 100.0,
|
child: new Center(
|
||||||
height: 100.0,
|
child: new Container(
|
||||||
child: new InkWell(
|
width: 100.0,
|
||||||
onTap: () { },
|
height: 100.0,
|
||||||
radius: 100.0,
|
child: new InkWell(
|
||||||
splashFactory: InkRipple.splashFactory,
|
onTap: () { },
|
||||||
|
radius: 100.0,
|
||||||
|
splashFactory: InkRipple.splashFactory,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
@ -246,17 +264,20 @@ void main() {
|
||||||
|
|
||||||
// Regression test for https://github.com/flutter/flutter/issues/14391
|
// Regression test for https://github.com/flutter/flutter/issues/14391
|
||||||
await tester.pumpWidget(
|
await tester.pumpWidget(
|
||||||
new Material(
|
new Directionality(
|
||||||
child: new Center(
|
textDirection: TextDirection.ltr,
|
||||||
child: new Container(
|
child: new Material(
|
||||||
width: 100.0,
|
child: new Center(
|
||||||
height: 100.0,
|
child: new Container(
|
||||||
child: new InkWell(
|
width: 100.0,
|
||||||
splashColor: splashColor,
|
height: 100.0,
|
||||||
highlightColor: highlightColor,
|
child: new InkWell(
|
||||||
onTap: () { },
|
splashColor: splashColor,
|
||||||
radius: 100.0,
|
highlightColor: highlightColor,
|
||||||
splashFactory: InkRipple.splashFactory,
|
onTap: () { },
|
||||||
|
radius: 100.0,
|
||||||
|
splashFactory: InkRipple.splashFactory,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|
29
packages/flutter/test/material/ink_splash_test.dart
Normal file
29
packages/flutter/test/material/ink_splash_test.dart
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
// Copyright 2018 The Chromium Authors. All rights reserved.
|
||||||
|
// Use of this source code is governed by a BSD-style license that can be
|
||||||
|
// found in the LICENSE file.
|
||||||
|
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter_test/flutter_test.dart';
|
||||||
|
|
||||||
|
void main() {
|
||||||
|
// Regression test for https://github.com/flutter/flutter/issues/21506.
|
||||||
|
testWidgets('InkSplash receives textDirection', (WidgetTester tester) async {
|
||||||
|
await tester.pumpWidget(new MaterialApp(
|
||||||
|
home: new Scaffold(
|
||||||
|
appBar: new AppBar(title: const Text('Button Border Test')),
|
||||||
|
body: new Center(
|
||||||
|
child: new RaisedButton(
|
||||||
|
child: const Text('Test'),
|
||||||
|
onPressed: () {},
|
||||||
|
shape: new Border.all(
|
||||||
|
color: Colors.blue,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
)));
|
||||||
|
await tester.tap(find.text('Test'));
|
||||||
|
// start ink animation which asserts for a textDirection.
|
||||||
|
await tester.pumpAndSettle(const Duration(milliseconds: 30));
|
||||||
|
expect(tester.takeException(), isNull);
|
||||||
|
});
|
||||||
|
}
|
|
@ -14,27 +14,32 @@ void main() {
|
||||||
testWidgets('InkWell gestures control test', (WidgetTester tester) async {
|
testWidgets('InkWell gestures control test', (WidgetTester tester) async {
|
||||||
final List<String> log = <String>[];
|
final List<String> log = <String>[];
|
||||||
|
|
||||||
await tester.pumpWidget(new Material(
|
await tester.pumpWidget(
|
||||||
child: new Center(
|
new Directionality(
|
||||||
child: new InkWell(
|
textDirection: TextDirection.ltr,
|
||||||
onTap: () {
|
child: new Material(
|
||||||
log.add('tap');
|
child: new Center(
|
||||||
},
|
child: new InkWell(
|
||||||
onDoubleTap: () {
|
onTap: () {
|
||||||
log.add('double-tap');
|
log.add('tap');
|
||||||
},
|
},
|
||||||
onLongPress: () {
|
onDoubleTap: () {
|
||||||
log.add('long-press');
|
log.add('double-tap');
|
||||||
},
|
},
|
||||||
onTapDown: (TapDownDetails details) {
|
onLongPress: () {
|
||||||
log.add('tap-down');
|
log.add('long-press');
|
||||||
},
|
},
|
||||||
onTapCancel: () {
|
onTapDown: (TapDownDetails details) {
|
||||||
log.add('tap-cancel');
|
log.add('tap-down');
|
||||||
},
|
},
|
||||||
),
|
onTapCancel: () {
|
||||||
),
|
log.add('tap-cancel');
|
||||||
));
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
await tester.tap(find.byType(InkWell), pointer: 1);
|
await tester.tap(find.byType(InkWell), pointer: 1);
|
||||||
|
|
||||||
|
@ -72,9 +77,12 @@ void main() {
|
||||||
|
|
||||||
testWidgets('long-press and tap on disabled should not throw', (WidgetTester tester) async {
|
testWidgets('long-press and tap on disabled should not throw', (WidgetTester tester) async {
|
||||||
await tester.pumpWidget(const Material(
|
await tester.pumpWidget(const Material(
|
||||||
child: Center(
|
child: Directionality(
|
||||||
child: InkWell(),
|
textDirection: TextDirection.ltr,
|
||||||
),
|
child: Center(
|
||||||
|
child: InkWell(),
|
||||||
|
),
|
||||||
|
)
|
||||||
));
|
));
|
||||||
await tester.tap(find.byType(InkWell), pointer: 1);
|
await tester.tap(find.byType(InkWell), pointer: 1);
|
||||||
await tester.pump(const Duration(seconds: 1));
|
await tester.pump(const Duration(seconds: 1));
|
||||||
|
@ -95,10 +103,13 @@ void main() {
|
||||||
|
|
||||||
testWidgets('enabled (default)', (WidgetTester tester) async {
|
testWidgets('enabled (default)', (WidgetTester tester) async {
|
||||||
await tester.pumpWidget(new Material(
|
await tester.pumpWidget(new Material(
|
||||||
child: new Center(
|
child: new Directionality(
|
||||||
child: new InkWell(
|
textDirection: TextDirection.ltr,
|
||||||
onTap: () {},
|
child: new Center(
|
||||||
onLongPress: () {},
|
child: new InkWell(
|
||||||
|
onTap: () {},
|
||||||
|
onLongPress: () {},
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
));
|
));
|
||||||
|
@ -120,13 +131,16 @@ void main() {
|
||||||
|
|
||||||
testWidgets('disabled', (WidgetTester tester) async {
|
testWidgets('disabled', (WidgetTester tester) async {
|
||||||
await tester.pumpWidget(new Material(
|
await tester.pumpWidget(new Material(
|
||||||
child: new Center(
|
child: new Directionality(
|
||||||
child: new InkWell(
|
textDirection: TextDirection.ltr,
|
||||||
onTap: () {},
|
child: new Center(
|
||||||
onLongPress: () {},
|
child: new InkWell(
|
||||||
enableFeedback: false,
|
onTap: () {},
|
||||||
|
onLongPress: () {},
|
||||||
|
enableFeedback: false,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
)
|
||||||
));
|
));
|
||||||
await tester.tap(find.byType(InkWell), pointer: 1);
|
await tester.tap(find.byType(InkWell), pointer: 1);
|
||||||
await tester.pump(const Duration(seconds: 1));
|
await tester.pump(const Duration(seconds: 1));
|
||||||
|
|
|
@ -9,14 +9,19 @@ void main() {
|
||||||
testWidgets('materialTapTargetSize.padded expands hit test area', (WidgetTester tester) async {
|
testWidgets('materialTapTargetSize.padded expands hit test area', (WidgetTester tester) async {
|
||||||
int pressed = 0;
|
int pressed = 0;
|
||||||
|
|
||||||
await tester.pumpWidget(new RawMaterialButton(
|
await tester.pumpWidget(
|
||||||
onPressed: () {
|
new Directionality(
|
||||||
pressed++;
|
textDirection: TextDirection.ltr,
|
||||||
},
|
child: new RawMaterialButton(
|
||||||
constraints: new BoxConstraints.tight(const Size(10.0, 10.0)),
|
onPressed: () {
|
||||||
materialTapTargetSize: MaterialTapTargetSize.padded,
|
pressed++;
|
||||||
child: const Text('+', textDirection: TextDirection.ltr),
|
},
|
||||||
));
|
constraints: new BoxConstraints.tight(const Size(10.0, 10.0)),
|
||||||
|
materialTapTargetSize: MaterialTapTargetSize.padded,
|
||||||
|
child: const Text('+'),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
await tester.tapAt(const Offset(40.0, 400.0));
|
await tester.tapAt(const Offset(40.0, 400.0));
|
||||||
|
|
||||||
|
@ -26,12 +31,15 @@ void main() {
|
||||||
testWidgets('materialTapTargetSize.padded expands semantics area', (WidgetTester tester) async {
|
testWidgets('materialTapTargetSize.padded expands semantics area', (WidgetTester tester) async {
|
||||||
final SemanticsTester semantics = new SemanticsTester(tester);
|
final SemanticsTester semantics = new SemanticsTester(tester);
|
||||||
await tester.pumpWidget(
|
await tester.pumpWidget(
|
||||||
new Center(
|
new Directionality(
|
||||||
child: new RawMaterialButton(
|
textDirection: TextDirection.ltr,
|
||||||
onPressed: () {},
|
child: new Center(
|
||||||
constraints: new BoxConstraints.tight(const Size(10.0, 10.0)),
|
child: new RawMaterialButton(
|
||||||
materialTapTargetSize: MaterialTapTargetSize.padded,
|
onPressed: () {},
|
||||||
child: const Text('+', textDirection: TextDirection.ltr),
|
constraints: new BoxConstraints.tight(const Size(10.0, 10.0)),
|
||||||
|
materialTapTargetSize: MaterialTapTargetSize.padded,
|
||||||
|
child: const Text('+'),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
@ -66,14 +74,17 @@ void main() {
|
||||||
const Color fillColor = Color(0xFFEF5350);
|
const Color fillColor = Color(0xFFEF5350);
|
||||||
|
|
||||||
await tester.pumpWidget(
|
await tester.pumpWidget(
|
||||||
new Center(
|
new Directionality(
|
||||||
child: new RawMaterialButton(
|
textDirection: TextDirection.ltr,
|
||||||
materialTapTargetSize: MaterialTapTargetSize.padded,
|
child: new Center(
|
||||||
onPressed: () {},
|
child: new RawMaterialButton(
|
||||||
fillColor: fillColor,
|
materialTapTargetSize: MaterialTapTargetSize.padded,
|
||||||
highlightColor: highlightColor,
|
onPressed: () {},
|
||||||
splashColor: splashColor,
|
fillColor: fillColor,
|
||||||
child: const SizedBox(),
|
highlightColor: highlightColor,
|
||||||
|
splashColor: splashColor,
|
||||||
|
child: const SizedBox(),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
@ -95,14 +106,17 @@ void main() {
|
||||||
const Color fillColor = Color(0xFFEF5350);
|
const Color fillColor = Color(0xFFEF5350);
|
||||||
|
|
||||||
await tester.pumpWidget(
|
await tester.pumpWidget(
|
||||||
new Center(
|
new Directionality(
|
||||||
child: new RawMaterialButton(
|
textDirection: TextDirection.ltr,
|
||||||
materialTapTargetSize: MaterialTapTargetSize.padded,
|
child: new Center(
|
||||||
onPressed: () {},
|
child: new RawMaterialButton(
|
||||||
fillColor: fillColor,
|
materialTapTargetSize: MaterialTapTargetSize.padded,
|
||||||
highlightColor: highlightColor,
|
onPressed: () {},
|
||||||
splashColor: splashColor,
|
fillColor: fillColor,
|
||||||
child: const SizedBox(),
|
highlightColor: highlightColor,
|
||||||
|
splashColor: splashColor,
|
||||||
|
child: const SizedBox(),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
|
@ -22,6 +22,7 @@ class TestInkSplash extends InkSplash {
|
||||||
ShapeBorder customBorder,
|
ShapeBorder customBorder,
|
||||||
double radius,
|
double radius,
|
||||||
VoidCallback onRemoved,
|
VoidCallback onRemoved,
|
||||||
|
TextDirection textDirection
|
||||||
}) : super(
|
}) : super(
|
||||||
controller: controller,
|
controller: controller,
|
||||||
referenceBox: referenceBox,
|
referenceBox: referenceBox,
|
||||||
|
@ -33,6 +34,7 @@ class TestInkSplash extends InkSplash {
|
||||||
customBorder: customBorder,
|
customBorder: customBorder,
|
||||||
radius: radius,
|
radius: radius,
|
||||||
onRemoved: onRemoved,
|
onRemoved: onRemoved,
|
||||||
|
textDirection: textDirection,
|
||||||
);
|
);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
@ -63,6 +65,7 @@ class TestInkSplashFactory extends InteractiveInkFeatureFactory {
|
||||||
ShapeBorder customBorder,
|
ShapeBorder customBorder,
|
||||||
double radius,
|
double radius,
|
||||||
VoidCallback onRemoved,
|
VoidCallback onRemoved,
|
||||||
|
TextDirection textDirection,
|
||||||
}) {
|
}) {
|
||||||
return new TestInkSplash(
|
return new TestInkSplash(
|
||||||
controller: controller,
|
controller: controller,
|
||||||
|
@ -75,6 +78,7 @@ class TestInkSplashFactory extends InteractiveInkFeatureFactory {
|
||||||
customBorder: customBorder,
|
customBorder: customBorder,
|
||||||
radius: radius,
|
radius: radius,
|
||||||
onRemoved: onRemoved,
|
onRemoved: onRemoved,
|
||||||
|
textDirection: textDirection,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,12 +8,15 @@ import 'package:flutter_test/flutter_test.dart';
|
||||||
void main() {
|
void main() {
|
||||||
testWidgets('runApp inside onPressed does not throw', (WidgetTester tester) async {
|
testWidgets('runApp inside onPressed does not throw', (WidgetTester tester) async {
|
||||||
await tester.pumpWidget(
|
await tester.pumpWidget(
|
||||||
new Material(
|
new Directionality(
|
||||||
child: new RaisedButton(
|
textDirection: TextDirection.ltr,
|
||||||
onPressed: () {
|
child: new Material(
|
||||||
runApp(const Center(child: Text('Done', textDirection: TextDirection.ltr)));
|
child: new RaisedButton(
|
||||||
},
|
onPressed: () {
|
||||||
child: const Text('GO', textDirection: TextDirection.ltr)
|
runApp(const Center(child: Text('Done', textDirection: TextDirection.ltr,)));
|
||||||
|
},
|
||||||
|
child: const Text('GO')
|
||||||
|
)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
Loading…
Reference in a new issue