-
Notifications
You must be signed in to change notification settings - Fork 29.7k
Fix Slider thumb doesn't align with divisions, thumb padding, and rounded corners
#149594
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
Conversation
b53e452 to
ffb98aa
Compare
|
Golden file changes have been found for this pull request. Click here to view and triage (e.g. because this is an intentional change). If you are still iterating on this change and are not ready to resolve the images on the Flutter Gold dashboard, consider marking this PR as a draft pull request above. You will still be able to view image results on the dashboard, commenting will be silenced, and the check will not try to resolve itself until marked ready for review. For more guidance, visit Writing a golden file test for Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing. Changes reported for pull request #149594 at sha ffb98aae854a5674a394a9b0978c7ba8b5ea33cd |
|
Pinging to my inbox so it's in my queue. 👍 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we use is a lot in the slider code like this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe instead of is, RoundedRectSliderTrackShape and others can contains a getter for this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Excellent idea! Added isRounded getter. Please let me know what do you think.
ffb98aa to
8dfa9b4
Compare
|
Golden file changes are available for triage from new commit, Click here to view. For more guidance, visit Writing a golden file test for Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing. |
Piinks
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! Thanks for your patience @TahaTesser 🙏
|
Golden file changes are available for triage from new commit, Click here to view. For more guidance, visit Writing a golden file test for Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing. |
fe6c6f3 to
98a3c58
Compare
|
Golden file changes are available for triage from new commit, Click here to view. For more guidance, visit Writing a golden file test for Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing. |
|
@Piinks |
cff1bd9 to
687c31d
Compare
|
Golden file changes are available for triage from new commit, Click here to view. For more guidance, visit Writing a golden file test for Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing. |
justinmc
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The goldens changes look like they're only due to slight changes in the rounded corners of the track (seems expected).
In the Google tests I see a bunch of visual diff tests related to the position of the thumb and sometimes its label (seems expected), but also I see breakages of classes that extends SliderTrackShape.
| /// Whether the track shape is rounded. | ||
| /// | ||
| /// This is used to determine the correct position of the thumb in relation to the track. | ||
| bool get isRounded; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is is possible to give a default value here? This will break anyone that extends SliderTrackShape.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you!
687c31d to
b8f446c
Compare
|
Golden file changes are available for triage from new commit, Click here to view. For more guidance, visit Writing a golden file test for Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing. |
|
Golden file changes are available for triage from new commit, Click here to view. For more guidance, visit Writing a golden file test for Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing. |
|
It looks like there are still breakages of classes that use abstract class Foo {
bool get isRounded => false;
}
// Error, missing implementation of isRounded (even though Foo has an implementation).
class Bar implements Foo {
}
// No error.
class Baz extends Foo {
}Some options to move forward here:
|
|
Hmm, maybe we can add a g3 fix in frob to add the getter for folks that have |
2095138 to
05ee675
Compare
|
Thanks @justinmc!
I noticed | updated the PR to return default Please let me know what do you think. |
|
Golden file changes are available for triage from new commit, Click here to view. For more guidance, visit Writing a golden file test for Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing. |
…g, and rounded corners (flutter/flutter#149594)
…g, and rounded corners (flutter/flutter#149594)
…g, and rounded corners (flutter/flutter#149594)
…g, and rounded corners (flutter/flutter#149594)
…g, and rounded corners (flutter/flutter#149594)
…g, and rounded corners (flutter/flutter#149594)
…g, and rounded corners (flutter/flutter#149594)
…g, and rounded corners (flutter/flutter#149594)
…g, and rounded corners (flutter/flutter#149594)
…g, and rounded corners (flutter/flutter#149594)
…g, and rounded corners (flutter/flutter#149594)
…g, and rounded corners (flutter/flutter#149594)
…g, and rounded corners (flutter/flutter#149594)
…g, and rounded corners (flutter/flutter#149594)
…g, and rounded corners (flutter/flutter#149594)
…g, and rounded corners (flutter/flutter#149594)
…g, and rounded corners (flutter/flutter#149594)
…g, and rounded corners (flutter/flutter#149594)
…g, and rounded corners (flutter/flutter#149594)
…g, and rounded corners (flutter/flutter#149594)
|
Hi, |
|
@hauvudinh24! |
…and rounded corners (#159792) Fixes [`RangeSlider` thumb's center doesn't align with division's center, thumb padding, and rounded corners don't work as expected](#159586) This makes a similar fix as the one for `Slider` in #149594. This fix is essential to bring updated Material Design for `RangeSlider`. ### Code sample <details> <summary>expand to view the code sample</summary> ```dart import 'package:flutter/material.dart'; void main() => runApp(const MyApp()); class MyApp extends StatefulWidget { const MyApp({super.key}); @OverRide State<MyApp> createState() => _MyAppState(); } class _MyAppState extends State<MyApp> { double _discreetSliderValue = 0.6; RangeValues _discreteRangeSliderValues = const RangeValues(0.2, 1.0); @OverRide Widget build(BuildContext context) { return MaterialApp( debugShowCheckedModeBanner: false, theme: ThemeData( sliderTheme: const SliderThemeData( trackHeight: 32, thumbColor: Colors.green, activeTrackColor: Colors.deepPurple, inactiveTrackColor: Colors.amber, ), ), home: Scaffold( body: Center( child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ Text( 'Discrete Slider', style: Theme.of(context).textTheme.titleMedium, ), Slider( value: _discreetSliderValue, divisions: 5, onChanged: (double newValue) { setState(() { _discreetSliderValue = newValue; }); }), Text( 'Discrete Range Slider', style: Theme.of(context).textTheme.titleMedium, ), RangeSlider( values: _discreteRangeSliderValues, divisions: 5, onChanged: (RangeValues newValues) { setState(() { _discreteRangeSliderValues = newValues; }); }, ), ], ), ), ), ); } } ``` </details> ### Before <img width="701" alt="Screenshot 2024-12-02 at 18 57 03" src="https://github.com/user-attachments/assets/62d85476-87fd-48e9-aaa9-42d7629d4808"> ### After <img width="701" alt="Screenshot 2024-12-02 at 18 57 21" src="https://github.com/user-attachments/assets/36f136d1-a759-4b11-b0a9-8cb6b54b8573"> ## Pre-launch Checklist - [x] I read the [Contributor Guide] and followed the process outlined there for submitting PRs. - [x] I read the [Tree Hygiene] wiki page, which explains my responsibilities. - [x] I read and followed the [Flutter Style Guide], including [Features we expect every widget to implement]. - [x] I signed the [CLA]. - [x] I listed at least one issue that this PR fixes in the description above. - [x] I updated/added relevant documentation (doc comments with `///`). - [x] I added new tests to check the change I am making, or this PR is [test-exempt]. - [ ] I followed the [breaking change policy] and added [Data Driven Fixes] where supported. - [x] All existing and new tests are passing. If you need help, consider asking for advice on the #hackers-new channel on [Discord]. <!-- Links --> [Contributor Guide]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#overview [Tree Hygiene]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md [test-exempt]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#tests [Flutter Style Guide]: https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md [Features we expect every widget to implement]: https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md#features-we-expect-every-widget-to-implement [CLA]: https://cla.developers.google.com/ [flutter/tests]: https://github.com/flutter/tests [breaking change policy]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#handling-breaking-changes [Discord]: https://github.com/flutter/flutter/blob/main/docs/contributing/Chat.md [Data Driven Fixes]: https://github.com/flutter/flutter/blob/main/docs/contributing/Data-driven-Fixes.md
fixes [Slider] Thumb's center doesn't align with division's center
fixes Slider thumb doesn't respect round slider track shape
fixes
RoundedRectSliderTrackShapecorners are not rendered correctly(Verified these behaviors with Android components implementation)
Code sample
expand to view the code sample
Description
This PR fixes several core
Slidersissues which are apparent in #147783. As a result, fixing the these bugs will unblock it.1. Fixes the thumb doesn't align with
Sliderdivisions.2. Fixes
RoundedRectSliderTrackShapecorners are not rendered correctly.3. Fixes round track shape corners when the thumb is at the start or end of the round track shape.
Pre-launch Checklist
///).If you need help, consider asking for advice on the #hackers-new channel on Discord.