-
Notifications
You must be signed in to change notification settings - Fork 29.7k
Implement tap to scroll to item in CupertinoPicker #153386
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement tap to scroll to item in CupertinoPicker #153386
Conversation
|
This pull request has been changed to a draft. The currently pending flutter-gold status will not be able to resolve until a new commit is pushed or the change is marked ready for review again. For more guidance, visit Writing a golden file test for Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing. |
MitchellGoodwin
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
| // If a controller is provided for this widget, it is | ||
| // expected to handle its own tap to scroll behavior. | ||
| onTappedChild: (widget.scrollController == null) | ||
| ? (int index) => _handleChildTap(index, controller) | ||
| : null, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why can't we support the user provided scroll controller?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From a separate thread: doing so on the user provided scroll controller might conflict with their own implementation.
I wonder if we have an example of such a conflict?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm increasingly believing there is a gesture conflict that is causing tests in date picker to fail.
Take this date picker test for example, along with the changes in this PR:
With tester.drag
testWidgets('TimerPicker minDate - maxDate with minuteInterval',
(WidgetTester tester) async {
DateTime date = DateTime.now();
final DateTime minimum = DateTime(2022, 6, 14, 3, 31);
final DateTime initial = DateTime(2022, 6, 14, 3, 40);
final DateTime maximum = DateTime(2022, 6, 14, 3, 49);
await tester.pumpWidget(
CupertinoApp(
home: Center(
child: SizedBox(
height: 400.0,
width: 400.0,
child: CupertinoDatePicker(
initialDateTime: initial,
minimumDate: minimum,
maximumDate: maximum,
minuteInterval: 5,
use24hFormat: true,
onDateTimeChanged: (DateTime newDate) {
date = newDate;
print('hiii');
},
),
),
),
),
);
// Drag picker minutes to min date
await tester.drag(find.text('40'), const Offset(0.0, 1000.0), touchSlopY: 0.0);
await tester.pumpAndSettle();
// Returns to min date.
expect(
date,
DateTime(2022, 6, 14, 3, 35),
);
});This test fails with the changes in this PR when tester.drag is used. However, it passes when tester.trackpadFling is used instead:
With tester.trackpadFling
testWidgets('TimerPicker minDate - maxDate with minuteInterval',
(WidgetTester tester) async {
DateTime date = DateTime.now();
final DateTime minimum = DateTime(2022, 6, 14, 3, 31);
final DateTime initial = DateTime(2022, 6, 14, 3, 40);
final DateTime maximum = DateTime(2022, 6, 14, 3, 49);
await tester.pumpWidget(
CupertinoApp(
home: Center(
child: SizedBox(
height: 400.0,
width: 400.0,
child: CupertinoDatePicker(
initialDateTime: initial,
minimumDate: minimum,
maximumDate: maximum,
minuteInterval: 5,
use24hFormat: true,
onDateTimeChanged: (DateTime newDate) {
date = newDate;
print('hiii');
},
),
),
),
),
);
// Drag picker minutes to min date
await tester.trackpadFling(find.text('40'), const Offset(0.0, 1000.0), 0.1);
await tester.pumpAndSettle();
// Returns to min date.
expect(
date,
DateTime(2022, 6, 14, 3, 35),
);
});
The documentation for tester.trackpadFling says:
A trackpad fling sends PointerPanZoom events instead of a sequence of touch events.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From a separate thread: The scrollable used by CupertinoPicker has default drag start behavior DragStartBehavior.start. The documentation for tester.drag says:
Breaking the drag into multiple moves is necessary for accurate execution of drag update calls with a DragStartBehavior variable set to DragStartBehavior.start. Without such a change, the dragUpdate callback from a drag recognizer will never be invoked.
But the tests in date_picker.dart only uses one drag move.
2fcbf75 to
44e6c1e
Compare
flutter/flutter@e7da16d...b8f89f7 2024-08-21 [email protected] docs: Update doc for scale behaviour of floating label (flutter/flutter#151835) 2024-08-21 [email protected] Disable Dropdown menu search during keyboard navigation (flutter/flutter#152378) 2024-08-21 [email protected] Add a `bin/flutter-dev` script, for running the `flutter` command-line tool from source (flutter/flutter#153599) 2024-08-21 [email protected] Roll Packages from 4d2d2e3 to 4e5d47e (6 revisions) (flutter/flutter#153848) 2024-08-21 [email protected] Remove unnecessary breaks in default clauses of switch statements (flutter/flutter#153843) 2024-08-21 [email protected] Create Postmortem-Platform-View-android-14-regression (flutter/flutter#149201) 2024-08-21 [email protected] Roll pub packages (flutter/flutter#153838) 2024-08-21 [email protected] Roll pub packages (flutter/flutter#153833) 2024-08-21 [email protected] Add tests for `SingleChildScrollView` examples (flutter/flutter#153548) 2024-08-21 [email protected] Roll Flutter Engine from b1220aa0ebf2 to b94e0097035d (3 revisions) (flutter/flutter#153817) 2024-08-21 [email protected] Roll Flutter Engine from aa1422391cf6 to b1220aa0ebf2 (1 revision) (flutter/flutter#153810) 2024-08-21 [email protected] Roll Flutter Engine from a6508d6557dc to aa1422391cf6 (2 revisions) (flutter/flutter#153808) 2024-08-21 [email protected] Roll Flutter Engine from 5cbf96d0a80f to a6508d6557dc (1 revision) (flutter/flutter#153806) 2024-08-21 [email protected] Roll Flutter Engine from 3d18f65c378a to 5cbf96d0a80f (3 revisions) (flutter/flutter#153804) 2024-08-21 [email protected] `_InteractiveViewerState` code cleanup (flutter/flutter#153645) 2024-08-20 [email protected] Roll Flutter Engine from b80c831e03f7 to 3d18f65c378a (1 revision) (flutter/flutter#153797) 2024-08-20 [email protected] Fix leaky test. (flutter/flutter#153798) 2024-08-20 [email protected] Fix leaky tests. (flutter/flutter#153786) 2024-08-20 [email protected] Roll Flutter Engine from 663176175b4c to b80c831e03f7 (1 revision) (flutter/flutter#153789) 2024-08-20 98614782+auto-submit[bot]@users.noreply.github.com Reverts "Update template/test `compileSdk`, `targetSdk`, `ndk` versions (#152487)" (flutter/flutter#153793) 2024-08-20 [email protected] Update template/test `compileSdk`, `targetSdk`, `ndk` versions (flutter/flutter#152487) 2024-08-20 [email protected] add autofocus to fix a11y issue with dialog (flutter/flutter#152637) 2024-08-20 [email protected] [Release] Update bots to expect new entitlements (flutter/flutter#153787) 2024-08-20 [email protected] Roll Flutter Engine from d6bc4dc6e59d to 663176175b4c (1 revision) (flutter/flutter#153785) 2024-08-20 [email protected] Roll pub packages (flutter/flutter#153740) 2024-08-20 [email protected] Implement tap to scroll to item in CupertinoPicker (flutter/flutter#153386) 2024-08-20 [email protected] Fix leaky test. (flutter/flutter#153780) 2024-08-20 [email protected] Roll Flutter Engine from e10b07598091 to d6bc4dc6e59d (2 revisions) (flutter/flutter#153781) If this roll has caused a breakage, revert this CL and stop the roller using the controls here: https://autoroll.skia.org/r/flutter-packages Please CC [email protected],[email protected],[email protected] on the revert to ensure that a human is aware of the problem. To file a bug in Packages: https://github.com/flutter/flutter/issues/new/choose To report a problem with the AutoRoller itself, please file a bug: https://issues.skia.org/issues/new?component=1389291&template=1850622 Documentation for the AutoRoller is here: https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
Finishes the work started by @Kavantix in flutter#110733. Fixes flutter#24089. Before: https://github.com/user-attachments/assets/7ca0d346-7538-44a0-b0b2-41cf96eee6eb After: https://github.com/user-attachments/assets/8da91188-28a0-4738-a216-e03946f00284 Native picker: https://github.com/user-attachments/assets/8662b3c0-0443-4f8d-818b-cabd97d37de8
Finishes the work started by @Kavantix in #110733.
Fixes Tapping items is not working in CupertinoPicker.
Before:
flutter.before.tap.picker.mov
After:
flutter.tap.picker.mov
Native picker:
native.tap.picker.mov
Pre-launch Checklist
///).If you need help, consider asking for advice on the #hackers-new channel on Discord.