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>
Nobuhiro Tabuki <japanese.around30@gmail.com>
nt4f04uNd <nt4f04und@gmail.com>
Anurag Roy <anuragr9847@gmail.com>
Andrey Kabylin <andrey@kabylin.ru>
......@@ -27,8 +27,6 @@ import 'transitions.dart';
// dynamic routeObserver;
// NavigatorState navigator;
const Color _kTransparent = Color(0x00000000);
/// A route that displays widgets in the [Navigator]'s [Overlay].
abstract class OverlayRoute<T> extends Route<T> {
/// 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
Widget _buildModalBarrier(BuildContext context) {
Widget barrier;
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(
ColorTween(
begin: _kTransparent,
begin: barrierColor!.withOpacity(0.0),
end: barrierColor, // changedInternalState is called if barrierColor updates
).chain(CurveTween(curve: barrierCurve)), // changedInternalState is called if barrierCurve updates
);
......
......@@ -1425,6 +1425,69 @@ void main() {
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 {
// Regression test for https://github.com/flutter/flutter/issues/46625.
final SemanticsTester semantics = SemanticsTester(tester);
......@@ -1781,6 +1844,7 @@ class _TestDialogRouteWithCustomBarrierCurve<T> extends PopupRoute<T> {
_TestDialogRouteWithCustomBarrierCurve({
required Widget child,
this.barrierLabel,
this.barrierColor = Colors.black,
Curve? barrierCurve,
}) : _barrierCurve = barrierCurve,
_child = child;
......@@ -1794,7 +1858,7 @@ class _TestDialogRouteWithCustomBarrierCurve<T> extends PopupRoute<T> {
final String? barrierLabel;
@override
Color get barrierColor => Colors.black; // easier value to test against
final Color? barrierColor;
@override
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