Skip to content

Expose the currently available semantic scroll actions - #11286

Merged
goderbauer merged 4 commits into
flutter:masterfrom
goderbauer:scrollPos2
Jul 19, 2017
Merged

goderbauer merged 4 commits into
flutter:masterfrom
goderbauer:scrollPos2

Conversation

@goderbauer

@goderbauer goderbauer commented Jul 19, 2017 •

Copy link
Copy Markdown
Member

Fixes #1675.

@Hixie Hixie Jul 19, 2017 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nit: no braces

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Since this makes the earlier work pointless, maybe put all the earlier work into the else branch of this if block?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

It does not make the previous work pointless. We should only expose an action if there is a handler that can handle it (previous work) and if it is valid (the work in the if).

If there - for whatever reason - is no handler, we will blow up when executing the gesture....

@Hixie

Hixie commented Jul 19, 2017

Copy link
Copy Markdown
Contributor

This is great.

Test?


// If a set of validActions has been provided only expose those.
if (validActions != null)
actions = actions.where((SemanticsAction action) => validActions.contains(action)).toList();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

this is O(N^2). Since validActions is only used for this, maybe it should be a Set instead of a List?
Or maybe it should just be a pair of booleans ("can scroll backwards" and "can scroll forwards")? Then you could just check the booleans when adding the actions?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I wasn't too worried about that as validActions is guaranteed to be very small. Having said that, I refactored it to a Set, which gives us O(1) for contains. Happy to optimize further if this turns out to be an actual performance bottleneck.

@Hixie

Hixie commented Jul 19, 2017

Copy link
Copy Markdown
Contributor

LGTM

@goderbauer
goderbauer merged commit 1744e8e into flutter:master Jul 19, 2017
@goderbauer
goderbauer deleted the scrollPos2 branch July 19, 2017 19:21
@goderbauer goderbauer added the a: accessibility Accessibility, e.g. VoiceOver or TalkBack. (aka a11y) label Oct 17, 2017
@github-actions github-actions Bot locked as resolved and limited conversation to collaborators Aug 13, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

a: accessibility Accessibility, e.g. VoiceOver or TalkBack. (aka a11y)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Disable scroll actions that aren't relevant

3 participants