Commit d3f540d4 authored by Hans Muller's avatar Hans Muller Committed by GitHub

Fixed tabs fling velocity threshold (#5990)

parent d3efe7da
...@@ -37,10 +37,9 @@ const Duration _kTabBarScroll = const Duration(milliseconds: 200); ...@@ -37,10 +37,9 @@ const Duration _kTabBarScroll = const Duration(milliseconds: 200);
const Curve _kTabIndicatorLeadingCurve = Curves.easeOut; const Curve _kTabIndicatorLeadingCurve = Curves.easeOut;
const Curve _kTabIndicatorTrailingCurve = Curves.easeIn; const Curve _kTabIndicatorTrailingCurve = Curves.easeIn;
// The scrollOffset (velocity) provided to fling() is pixels/ms, and the // The additional factor of 5 is to further increase sensitivity to swipe
// tolerance velocity is pixels/sec. The additional factor of 5 is to further // gestures and was determined "experimentally".
// increase sensitivity to swipe gestures and was determined "experimentally". final double _kMinFlingVelocity = kPixelScrollTolerance.velocity / 5.0;
final double _kMinFlingVelocity = kPixelScrollTolerance.velocity / 5000.0;
class _TabBarParentData extends ContainerBoxParentDataMixin<RenderBox> { } class _TabBarParentData extends ContainerBoxParentDataMixin<RenderBox> { }
......
...@@ -171,7 +171,7 @@ void main() { ...@@ -171,7 +171,7 @@ void main() {
// Fling-scroll the TabBar to the left // Fling-scroll the TabBar to the left
expect(tester.getCenter(find.text('HHHHHH')).x, lessThan(700.0)); expect(tester.getCenter(find.text('HHHHHH')).x, lessThan(700.0));
await tester.fling(find.byKey(tabBarKey), const Offset(-20.0, 0.0), 1000.0); await tester.fling(find.byKey(tabBarKey), const Offset(-200.0, 0.0), 10000.0);
await tester.pump(); await tester.pump();
await tester.pump(const Duration(seconds: 1)); // finish the scroll animation await tester.pump(const Duration(seconds: 1)); // finish the scroll animation
expect(tester.getCenter(find.text('HHHHHH')).x, lessThan(500.0)); expect(tester.getCenter(find.text('HHHHHH')).x, lessThan(500.0));
...@@ -267,7 +267,7 @@ void main() { ...@@ -267,7 +267,7 @@ void main() {
// Fling to the left, switch from the 'LEFT' tab to the 'RIGHT' // Fling to the left, switch from the 'LEFT' tab to the 'RIGHT'
Point flingStart = tester.getCenter(find.text('LEFT CHILD')); Point flingStart = tester.getCenter(find.text('LEFT CHILD'));
await tester.flingFrom(flingStart, new Offset(-200.0, 0.0), 1000.0); await tester.flingFrom(flingStart, new Offset(-200.0, 0.0), 10000.0);
await tester.pump(); await tester.pump();
await tester.pump(const Duration(seconds: 1)); // finish the scroll animation await tester.pump(const Duration(seconds: 1)); // finish the scroll animation
expect(selection.value, equals('RIGHT')); expect(selection.value, equals('RIGHT'));
...@@ -276,7 +276,7 @@ void main() { ...@@ -276,7 +276,7 @@ void main() {
// Fling to the right, switch back to the 'LEFT' tab // Fling to the right, switch back to the 'LEFT' tab
flingStart = tester.getCenter(find.text('RIGHT CHILD')); flingStart = tester.getCenter(find.text('RIGHT CHILD'));
await tester.flingFrom(flingStart, new Offset(200.0, 0.0), 1000.0); await tester.flingFrom(flingStart, new Offset(200.0, 0.0), 10000.0);
await tester.pump(); await tester.pump();
await tester.pump(const Duration(seconds: 1)); // finish the scroll animation await tester.pump(const Duration(seconds: 1)); // finish the scroll animation
expect(selection.value, equals('LEFT')); expect(selection.value, equals('LEFT'));
...@@ -301,7 +301,7 @@ void main() { ...@@ -301,7 +301,7 @@ void main() {
// a change to the selected tab, everything should just settle back to // a change to the selected tab, everything should just settle back to
// to where it started. // to where it started.
Point flingStart = tester.getCenter(find.text('LEFT CHILD')); Point flingStart = tester.getCenter(find.text('LEFT CHILD'));
await tester.flingFrom(flingStart, new Offset(-200.0, 0.0), -1000.0); await tester.flingFrom(flingStart, new Offset(-200.0, 0.0), -10000.0);
await tester.pump(); await tester.pump();
await tester.pump(const Duration(seconds: 1)); // finish the scroll animation await tester.pump(const Duration(seconds: 1)); // finish the scroll animation
expect(selection.value, equals('LEFT')); expect(selection.value, equals('LEFT'));
......
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