Repository navigation
Add per thumb Range Slider semantics - #61439
Conversation
| 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()}%'; |
There was a problem hiding this comment.
Should percent be used here? If so, what about localization?
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
Will these be reversed for RTL?
There was a problem hiding this comment.
Good catch, I'll reverse them for RTL
|
|
||
| await tester.pumpAndSettle(); | ||
|
|
||
| expect( |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Cool, I'll look into that. It feels more resilient
| final Rect leftRect = Rect.fromPoints(node.rect.topLeft, node.rect.bottomCenter); | ||
| final Rect rightRect = Rect.fromPoints(node.rect.topCenter, node.rect.bottomRight); |
There was a problem hiding this comment.
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...
There was a problem hiding this comment.
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
|
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 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. |
Description
Each
RangeSliderthumb now has its ownSemanticNode, each controllable like an individual slider, and which respects gesture rules likeminThumbSeparationand inability to pass the other.The
semanticFormatterCallbackpassed toRangeSlidernow 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.///).flutter analyze --flutter-repo) does not report any problems on my PR.Breaking Change
Did any tests fail when you ran them? Please read Handling breaking changes.