Skip to content

Add per thumb Range Slider semantics - #61439

Merged
fluttergithubbot merged 11 commits into
flutter:masterfrom
guidezpl:range-slider-semantics
Jul 23, 2020
Merged

fluttergithubbot merged 11 commits into
flutter:masterfrom
guidezpl:range-slider-semantics

Conversation

@guidezpl

@guidezpl guidezpl commented Jul 14, 2020 •

Copy link
Copy Markdown
Member

Description

Each RangeSlider thumb now has its own SemanticNode, each controllable like an individual slider, and which respects gesture rules like minThumbSeparation and inability to pass the other.

The semanticFormatterCallback passed to RangeSlider now formats both values individually instead of together (e.g. '10$' and '25$' instead of '15$').

In action: https://i.imgur.com/0ZEfYyF.mp4

Related Issues

Fixes #60715
#39510

Tests

A test to validate the a RangeSlider's semantics tree

Checklist

Before you create this PR confirm that it meets all requirements listed below by checking the relevant checkboxes ([x]). This will ensure a smooth and quick review process.

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • I signed the CLA.
  • I read and followed the Flutter Style Guide, including Features we expect every widget to implement.
  • I read the Tree Hygiene wiki page, which explains my responsibilities.
  • I updated/added relevant documentation (doc comments with ///).
  • All existing and new tests are passing.
  • The analyzer (flutter analyze --flutter-repo) does not report any problems on my PR.
  • I am willing to follow-up on review comments in a timely manner.

Breaking Change

Did any tests fail when you ran them? Please read Handling breaking changes.

@fluttergithubbot fluttergithubbot added p: material_ui material_ui package in flutter/packages framework flutter/packages/flutter repository. See also f: labels. labels Jul 14, 2020
@guidezpl
guidezpl requested a review from goderbauer July 14, 2020 11:17
config.increasedValue = semanticFormatterCallback(_state._lerp((value + _semanticActionUnit).clamp(0.0, 1.0) as double));
config.decreasedValue = semanticFormatterCallback(_state._lerp((value - _semanticActionUnit).clamp(0.0, 1.0) as double));
} else {
config.value = '${(value * 100).round()}%';

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.

Should percent be used here? If so, what about localization?

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.

This matches what Slider currently does. If they are to be localized, that would have to be a separate PR

);

// Split the semantics node area between the start and end nodes.
_startSemanticsNode.rect = Rect.fromPoints(node.rect.topLeft, node.rect.bottomCenter);

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.

Will these be reversed for RTL?

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.

Good catch, I'll reverse them for RTL


await tester.pumpAndSettle();

expect(

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I'd recommend writing the test with tester.getSemantics and matchesSemantics (example: https://github.com/flutter/flutter/pull/60329/files). That makes the test a little less brittle (we don't have to update the test when semantics above the Slider change.

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.

Cool, I'll look into that. It feels more resilient

Comment on lines +1571 to +1572
final Rect leftRect = Rect.fromPoints(node.rect.topLeft, node.rect.bottomCenter);
final Rect rightRect = Rect.fromPoints(node.rect.topCenter, node.rect.bottomRight);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This means, the accessibility focus rect (that green rect that Talkback draws) will always cover the first half of the slider for the first thump and the second half of the slider for the second thump - no matter the thumb position, right? Is that the expected behavior for a range slider? I would have expected the semantics nodes to be around the thumbs...

@guidezpl guidezpl Jul 15, 2020 •

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.

Correct, the thinking was that splitting the area in two makes the widget more accessible due to the larger targets (Slider's semantic node is around the whole slider, for instance). It also helps when the two thumbs are on top of one another

@goderbauer goderbauer left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM

@guidezpl

guidezpl commented Jul 20, 2020 •

Copy link
Copy Markdown
Member Author

Fixed and simplified the increase/decrease logic to avoid cases where the min distance between two close thumbs when using semantic actions was determined by the minThumbSeparation.

In order words, the thumbs now always get adjusted by the same increment (platform-determined for continuous sliders, user-specified for discrete sliders), or not at all.

@guidezpl
guidezpl requested a review from rami-a July 20, 2020 17:46
@fluttergithubbot
fluttergithubbot merged commit 629395f into flutter:master Jul 23, 2020
Pragya007 pushed a commit to Pragya007/flutter that referenced this pull request Aug 11, 2020
mingwandroid pushed a commit to mingwandroid/flutter that referenced this pull request Sep 6, 2020
@guidezpl
guidezpl deleted the range-slider-semantics branch January 5, 2021 00:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

framework flutter/packages/flutter repository. See also f: labels. p: material_ui material_ui package in flutter/packages

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Material] RangeSlider should have Semantics nodes for each thumb, rather than having one for the whole RangeSlider

6 participants