feat(slider): add NakedSliderState.visualPercentageOf#79
Merged
Conversation
Map an arbitrary logical fraction (0 = min, 1 = max) to its physical alignment along the track (0 = left/top, 1 = right/bottom), accounting for orientation, text direction, and inversion. visualPercentageAt is keyed by thumb index, so consumers needing the visual position of a non-thumb point (e.g. the origin of a range fill) had to reimplement the flip chain. visualPercentageAt now delegates to the new method and its behavior is unchanged.
Contributor
LCOV of commit
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Adds
NakedSliderState.visualPercentageOf(double percentage)— maps a logical fraction (0=min,1=max) to its physical alignment along the track (0= left/top edge,1= right/bottom edge), accounting fororientation,textDirection, andinverted.visualPercentageAt(int index)now delegates to it. Its behavior is unchanged.Why
visualPercentageAtis keyed by a thumb index, so a consumer that needs the visual position of a point not tied to a thumb — for example the origin of a single-thumb range fill — has no way to ask for it and must reimplement the RTL/vertical/inverted flip chain itself. This lifts that logic onto the state that already ownsorientation/textDirection/inverted, so downstream code can call it instead of duplicating it.Changes
NakedSliderState.visualPercentageOf— new public methodvisualPercentageAtdelegates to it (no behavior change)visualPercentageAtdelegation invariantVerification
dart formatclean,dart analyzecleantest/src/naked_slider_test.dart)Purely additive and backward compatible.