Skip to content
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

Fix scrolling issues in CupertinoPicker #3678

Merged
merged 2 commits into from
Jul 27, 2024

Conversation

ndonkoHenri
Copy link
Contributor

@ndonkoHenri ndonkoHenri commented Jul 20, 2024

Fixes #3649

Notes

  • I don't have Windows, so can't tell if it will eventually fix the issue on that platform. Needs testing on Windows.
  • CupertinoTimerPicker was reported to have thesame issue, but it has no scrollController, hence the SO solution can't be applicable.

Test Code

https://flet.dev/docs/controls/cupertinopicker

Summary by Sourcery

This pull request addresses and fixes the scrolling issues in the CupertinoPicker component by introducing a FixedExtentScrollController and adding logic to manage scroll events, ensuring correct item selection and smooth scrolling behavior.

  • Bug Fixes:
    • Resolved scrolling issues in CupertinoPicker by implementing a FixedExtentScrollController and managing scroll events to ensure proper item selection.

Copy link
Contributor

sourcery-ai bot commented Jul 20, 2024

Reviewer's Guide by Sourcery

This pull request addresses the scrolling issues in CupertinoPicker by introducing a FixedExtentScrollController and adding logic to manage scroll events. The changes include initializing the scroll controller with the selected index, adding a listener to handle scroll direction, and updating the build method to use the scroll controller.

File-Level Changes

Files Changes
packages/flet/lib/src/controls/cupertino_picker.dart Introduced a FixedExtentScrollController to manage the scroll position and added logic to handle scroll events to fix the scrolling issues in CupertinoPicker.

Tips
  • Trigger a new Sourcery review by commenting @sourcery-ai review on the pull request.
  • Continue your discussion with Sourcery by replying directly to review comments.
  • You can change your review settings at any time by accessing your dashboard:
    • Enable or disable the Sourcery-generated pull request summary or reviewer's guide;
    • Change the review language;
  • You can always contact us if you have any questions or feedback.

Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @ndonkoHenri - I've reviewed your changes and they look great!

Here's what I looked at during the review
  • 🟡 General issues: 1 issue found
  • 🟢 Security: all looks good
  • 🟢 Testing: all looks good
  • 🟢 Complexity: all looks good
  • 🟢 Documentation: all looks good

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment to tell me if it was helpful.

@@ -63,14 +102,12 @@ class _CupertinoPickerControlState extends State<CupertinoPickerControl> {
useMagnifier: useMagnifier,
looping: looping,
onSelectedItemChanged: (int index) {
_index = index;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion: Consider using setState when updating _index.

To ensure the UI updates correctly, consider wrapping the assignment of _index in a setState call.

Suggested change
_index = index;
setState(() {
_index = index;
});

@FeodorFitsner FeodorFitsner merged commit 3b1bd16 into main Jul 27, 2024
2 checks passed
@ndonkoHenri ndonkoHenri deleted the fix-cupertino-timer-picker-on-windows branch July 27, 2024 01:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

CupertinoPicker control doesn't work as expected
2 participants