Unverified Commit e118e1a6 authored by Andrey Kabylin's avatar Andrey Kabylin Committed by GitHub

fix #24469 and #67354 (#69668)

parent 83ef26e4
...@@ -70,3 +70,4 @@ YeungKC <flutter@yeungkc.com> ...@@ -70,3 +70,4 @@ YeungKC <flutter@yeungkc.com>
Nobuhiro Tabuki <japanese.around30@gmail.com> Nobuhiro Tabuki <japanese.around30@gmail.com>
nt4f04uNd <nt4f04und@gmail.com> nt4f04uNd <nt4f04und@gmail.com>
Anurag Roy <anuragr9847@gmail.com> Anurag Roy <anuragr9847@gmail.com>
Andrey Kabylin <andrey@kabylin.ru>
...@@ -27,8 +27,6 @@ import 'transitions.dart'; ...@@ -27,8 +27,6 @@ import 'transitions.dart';
// dynamic routeObserver; // dynamic routeObserver;
// NavigatorState navigator; // NavigatorState navigator;
const Color _kTransparent = Color(0x00000000);
/// A route that displays widgets in the [Navigator]'s [Overlay]. /// A route that displays widgets in the [Navigator]'s [Overlay].
abstract class OverlayRoute<T> extends Route<T> { abstract class OverlayRoute<T> extends Route<T> {
/// Creates a route that knows how to interact with an [Overlay]. /// Creates a route that knows how to interact with an [Overlay].
...@@ -1475,10 +1473,10 @@ abstract class ModalRoute<T> extends TransitionRoute<T> with LocalHistoryRoute<T ...@@ -1475,10 +1473,10 @@ abstract class ModalRoute<T> extends TransitionRoute<T> with LocalHistoryRoute<T
Widget _buildModalBarrier(BuildContext context) { Widget _buildModalBarrier(BuildContext context) {
Widget barrier; Widget barrier;
if (barrierColor != null && barrierColor!.alpha != 0 && !offstage) { // changedInternalState is called if barrierColor or offstage updates if (barrierColor != null && barrierColor!.alpha != 0 && !offstage) { // changedInternalState is called if barrierColor or offstage updates
assert(barrierColor != _kTransparent); assert(barrierColor != barrierColor!.withOpacity(0.0));
final Animation<Color?> color = animation!.drive( final Animation<Color?> color = animation!.drive(
ColorTween( ColorTween(
begin: _kTransparent, begin: barrierColor!.withOpacity(0.0),
end: barrierColor, // changedInternalState is called if barrierColor updates end: barrierColor, // changedInternalState is called if barrierColor updates
).chain(CurveTween(curve: barrierCurve)), // changedInternalState is called if barrierCurve updates ).chain(CurveTween(curve: barrierCurve)), // changedInternalState is called if barrierCurve updates
); );
......
...@@ -1425,6 +1425,69 @@ void main() { ...@@ -1425,6 +1425,69 @@ void main() {
expect(modalBarrierAnimation.value, Colors.black); expect(modalBarrierAnimation.value, Colors.black);
}); });
testWidgets('white barrierColor', (WidgetTester tester) async {
await tester.pumpWidget(MaterialApp(
home: Material(
child: Builder(
builder: (BuildContext context) {
return Center(
child: ElevatedButton(
child: const Text('X'),
onPressed: () {
Navigator.of(context).push<void>(
_TestDialogRouteWithCustomBarrierCurve<void>(
child: const Text('Hello World'),
barrierColor: Colors.white,
)
);
},
),
);
}
),
),
));
final CurveTween _defaultBarrierTween = CurveTween(curve: Curves.ease);
int _getExpectedBarrierTweenAlphaValue(double t) {
return Color.getAlphaFromOpacity(_defaultBarrierTween.transform(t));
}
await tester.tap(find.text('X'));
await tester.pump();
final Finder animatedModalBarrier = find.byType(AnimatedModalBarrier);
expect(animatedModalBarrier, findsOneWidget);
Animation<Color?> modalBarrierAnimation;
modalBarrierAnimation = tester.widget<AnimatedModalBarrier>(animatedModalBarrier).color;
expect(modalBarrierAnimation.value, Colors.white.withOpacity(0));
await tester.pump(const Duration(milliseconds: 25));
modalBarrierAnimation = tester.widget<AnimatedModalBarrier>(animatedModalBarrier).color;
expect(
modalBarrierAnimation.value!.alpha,
closeTo(_getExpectedBarrierTweenAlphaValue(0.25), 1),
);
await tester.pump(const Duration(milliseconds: 25));
modalBarrierAnimation = tester.widget<AnimatedModalBarrier>(animatedModalBarrier).color;
expect(
modalBarrierAnimation.value!.alpha,
closeTo(_getExpectedBarrierTweenAlphaValue(0.50), 1),
);
await tester.pump(const Duration(milliseconds: 25));
modalBarrierAnimation = tester.widget<AnimatedModalBarrier>(animatedModalBarrier).color;
expect(
modalBarrierAnimation.value!.alpha,
closeTo(_getExpectedBarrierTweenAlphaValue(0.75), 1),
);
await tester.pumpAndSettle();
modalBarrierAnimation = tester.widget<AnimatedModalBarrier>(animatedModalBarrier).color;
expect(modalBarrierAnimation.value, Colors.white);
});
testWidgets('modal route semantics order', (WidgetTester tester) async { testWidgets('modal route semantics order', (WidgetTester tester) async {
// Regression test for https://github.com/flutter/flutter/issues/46625. // Regression test for https://github.com/flutter/flutter/issues/46625.
final SemanticsTester semantics = SemanticsTester(tester); final SemanticsTester semantics = SemanticsTester(tester);
...@@ -1781,6 +1844,7 @@ class _TestDialogRouteWithCustomBarrierCurve<T> extends PopupRoute<T> { ...@@ -1781,6 +1844,7 @@ class _TestDialogRouteWithCustomBarrierCurve<T> extends PopupRoute<T> {
_TestDialogRouteWithCustomBarrierCurve({ _TestDialogRouteWithCustomBarrierCurve({
required Widget child, required Widget child,
this.barrierLabel, this.barrierLabel,
this.barrierColor = Colors.black,
Curve? barrierCurve, Curve? barrierCurve,
}) : _barrierCurve = barrierCurve, }) : _barrierCurve = barrierCurve,
_child = child; _child = child;
...@@ -1794,7 +1858,7 @@ class _TestDialogRouteWithCustomBarrierCurve<T> extends PopupRoute<T> { ...@@ -1794,7 +1858,7 @@ class _TestDialogRouteWithCustomBarrierCurve<T> extends PopupRoute<T> {
final String? barrierLabel; final String? barrierLabel;
@override @override
Color get barrierColor => Colors.black; // easier value to test against final Color? barrierColor;
@override @override
Curve get barrierCurve { Curve get barrierCurve {
......
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