-
Notifications
You must be signed in to change notification settings - Fork 29.7k
Add CupertinoSlider haptic feedback
#167362
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
CupertinoSlider haptic feedback
658c201 to
5bb03da
Compare
|
thanks for working on this, are you doing to implement apples mechanism for the haptic mentioned in the issue where the strength of the haptic depends on how hard you slam the slider? |
|
Hi @MaherSafadii! Yes, I implemented different levels of haptics. Might need some adjustments, but overall it's there. flutter/packages/flutter/lib/src/cupertino/slider.dart Lines 253 to 257 in 7cfaac4
|
dkwingsmt
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.
Thanks for the change!
7cfaac4 to
40d0112
Compare
|
@dkwingsmt I have made the requested changes, please take a look. Thanks! |
dkwingsmt
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. Thank you!
|
@dkwingsmt I guess this needs one more approval to get merged? |
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.
LGTM with nits 👍. Thanks for adding this! I thought the "slam" might be harder to implement but this seems pretty good and simple.
| void _emitHapticFeedback(bool isFastDrag) { | ||
| switch (defaultTargetPlatform) { | ||
| case TargetPlatform.iOS: | ||
| if (isFastDrag) { | ||
| HapticFeedback.mediumImpact(); | ||
| } else { | ||
| HapticFeedback.selectionClick(); | ||
| } | ||
| case TargetPlatform.android: | ||
| case TargetPlatform.fuchsia: | ||
| case TargetPlatform.linux: | ||
| case TargetPlatform.macOS: | ||
| case TargetPlatform.windows: | ||
| break; | ||
| } | ||
| } |
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.
Nit: I just want to double check that we don't want haptic feedback on non-iOS platforms. I guess only iOS can do the proper selectionClick? CupertinoPicker does a similar platform check:
flutter/packages/flutter/lib/src/cupertino/picker.dart
Lines 252 to 265 in fe60a2b
| switch (defaultTargetPlatform) { | |
| case TargetPlatform.iOS: | |
| hasSuitableHapticHardware = true; | |
| case TargetPlatform.android: | |
| case TargetPlatform.fuchsia: | |
| case TargetPlatform.linux: | |
| case TargetPlatform.macOS: | |
| case TargetPlatform.windows: | |
| hasSuitableHapticHardware = false; | |
| } | |
| if (hasSuitableHapticHardware && index != _lastHapticIndex) { | |
| _lastHapticIndex = index; | |
| HapticFeedback.selectionClick(); | |
| } |
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.
I just followed what other Cupertino widgets like switch and picker do, so I think it would be a bit strange to enable haptics for this one particular Cupertino widget and not the others. I think this is ok for now and we can easily change this later.
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.
Sounds good, I agree.
b99e61e to
773719a
Compare
|
@justinmc I've added the docs and a test for non-iOS platforms. |
366d77e to
60ae03f
Compare
|
@justinmc friendly ping :) |
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.
LGTM 👍 . Thanks for adding the tests for the other platforms.
flutter/flutter@83082c1...992ad74 2025-05-10 [email protected] Roll Fuchsia Linux SDK from F2xwL6WosfD7ETcPm... to VIG5-P9wwXgQkCkeX... (flutter/flutter#168633) 2025-05-10 [email protected] delete stale references/includes to classes no longer used (flutter/flutter#168616) 2025-05-10 [email protected] Roll Skia from 645404ec2d60 to 0feee17aeaca (1 revision) (flutter/flutter#168624) 2025-05-10 [email protected] Roll Skia from 12dbc34d742e to 645404ec2d60 (1 revision) (flutter/flutter#168621) 2025-05-09 [email protected] Add Option to disable full selection on focus on TextField, TextFormField, and EditableText (flutter/flutter#163491) 2025-05-09 [email protected] Add `CupertinoSlider` haptic feedback (flutter/flutter#167362) 2025-05-09 [email protected] Roll Skia from 7f7555536e3c to 12dbc34d742e (1 revision) (flutter/flutter#168614) 2025-05-09 [email protected] Fix: Impeller playground's points should be draggable (flutter/flutter#168351) 2025-05-09 [email protected] Remove old link for java gradle incompatibility (flutter/flutter#168561) 2025-05-09 [email protected] Roll Skia from 0d16b74f74a5 to 7f7555536e3c (5 revisions) (flutter/flutter#168609) 2025-05-09 [email protected] add missing lockfiles not checked in from running generate_gradle_lockfiles.dart (flutter/flutter#168600) 2025-05-09 [email protected] [Impeller] libImpeller: Usability improvements for WASM and python bindings. (flutter/flutter#168397) 2025-05-09 [email protected] Fix ListTile overwriting parent IconButtonTheme for its children (#167727) (flutter/flutter#168480) 2025-05-09 [email protected] Roll Skia from efccaeb08b8d to 0d16b74f74a5 (6 revisions) (flutter/flutter#168569) 2025-05-09 [email protected] [web] more cleanup of unused APIs (flutter/flutter#168524) 2025-05-09 [email protected] Roll Fuchsia Linux SDK from mqhX1OP8ezmialgqA... to F2xwL6WosfD7ETcPm... (flutter/flutter#168587) 2025-05-09 [email protected] Roll Packages from ab44c26 to 7814fab (4 revisions) (flutter/flutter#168597) If this roll has caused a breakage, revert this CL and stop the roller using the controls here: https://autoroll.skia.org/r/flutter-packages Please CC [email protected],[email protected] on the revert to ensure that a human is aware of the problem. To file a bug in Packages: https://github.com/flutter/flutter/issues/new/choose To report a problem with the AutoRoller itself, please file a bug: https://issues.skia.org/issues/new?component=1389291&template=1850622 Documentation for the AutoRoller is here: https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
…r#9239) flutter/flutter@83082c1...992ad74 2025-05-10 [email protected] Roll Fuchsia Linux SDK from F2xwL6WosfD7ETcPm... to VIG5-P9wwXgQkCkeX... (flutter/flutter#168633) 2025-05-10 [email protected] delete stale references/includes to classes no longer used (flutter/flutter#168616) 2025-05-10 [email protected] Roll Skia from 645404ec2d60 to 0feee17aeaca (1 revision) (flutter/flutter#168624) 2025-05-10 [email protected] Roll Skia from 12dbc34d742e to 645404ec2d60 (1 revision) (flutter/flutter#168621) 2025-05-09 [email protected] Add Option to disable full selection on focus on TextField, TextFormField, and EditableText (flutter/flutter#163491) 2025-05-09 [email protected] Add `CupertinoSlider` haptic feedback (flutter/flutter#167362) 2025-05-09 [email protected] Roll Skia from 7f7555536e3c to 12dbc34d742e (1 revision) (flutter/flutter#168614) 2025-05-09 [email protected] Fix: Impeller playground's points should be draggable (flutter/flutter#168351) 2025-05-09 [email protected] Remove old link for java gradle incompatibility (flutter/flutter#168561) 2025-05-09 [email protected] Roll Skia from 0d16b74f74a5 to 7f7555536e3c (5 revisions) (flutter/flutter#168609) 2025-05-09 [email protected] add missing lockfiles not checked in from running generate_gradle_lockfiles.dart (flutter/flutter#168600) 2025-05-09 [email protected] [Impeller] libImpeller: Usability improvements for WASM and python bindings. (flutter/flutter#168397) 2025-05-09 [email protected] Fix ListTile overwriting parent IconButtonTheme for its children (#167727) (flutter/flutter#168480) 2025-05-09 [email protected] Roll Skia from efccaeb08b8d to 0d16b74f74a5 (6 revisions) (flutter/flutter#168569) 2025-05-09 [email protected] [web] more cleanup of unused APIs (flutter/flutter#168524) 2025-05-09 [email protected] Roll Fuchsia Linux SDK from mqhX1OP8ezmialgqA... to F2xwL6WosfD7ETcPm... (flutter/flutter#168587) 2025-05-09 [email protected] Roll Packages from ab44c26 to 7814fab (4 revisions) (flutter/flutter#168597) If this roll has caused a breakage, revert this CL and stop the roller using the controls here: https://autoroll.skia.org/r/flutter-packages Please CC [email protected],[email protected] on the revert to ensure that a human is aware of the problem. To file a bug in Packages: https://github.com/flutter/flutter/issues/new/choose To report a problem with the AutoRoller itself, please file a bug: https://issues.skia.org/issues/new?component=1389291&template=1850622 Documentation for the AutoRoller is here: https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
…r#9239) flutter/flutter@83082c1...992ad74 2025-05-10 [email protected] Roll Fuchsia Linux SDK from F2xwL6WosfD7ETcPm... to VIG5-P9wwXgQkCkeX... (flutter/flutter#168633) 2025-05-10 [email protected] delete stale references/includes to classes no longer used (flutter/flutter#168616) 2025-05-10 [email protected] Roll Skia from 645404ec2d60 to 0feee17aeaca (1 revision) (flutter/flutter#168624) 2025-05-10 [email protected] Roll Skia from 12dbc34d742e to 645404ec2d60 (1 revision) (flutter/flutter#168621) 2025-05-09 [email protected] Add Option to disable full selection on focus on TextField, TextFormField, and EditableText (flutter/flutter#163491) 2025-05-09 [email protected] Add `CupertinoSlider` haptic feedback (flutter/flutter#167362) 2025-05-09 [email protected] Roll Skia from 7f7555536e3c to 12dbc34d742e (1 revision) (flutter/flutter#168614) 2025-05-09 [email protected] Fix: Impeller playground's points should be draggable (flutter/flutter#168351) 2025-05-09 [email protected] Remove old link for java gradle incompatibility (flutter/flutter#168561) 2025-05-09 [email protected] Roll Skia from 0d16b74f74a5 to 7f7555536e3c (5 revisions) (flutter/flutter#168609) 2025-05-09 [email protected] add missing lockfiles not checked in from running generate_gradle_lockfiles.dart (flutter/flutter#168600) 2025-05-09 [email protected] [Impeller] libImpeller: Usability improvements for WASM and python bindings. (flutter/flutter#168397) 2025-05-09 [email protected] Fix ListTile overwriting parent IconButtonTheme for its children (#167727) (flutter/flutter#168480) 2025-05-09 [email protected] Roll Skia from efccaeb08b8d to 0d16b74f74a5 (6 revisions) (flutter/flutter#168569) 2025-05-09 [email protected] [web] more cleanup of unused APIs (flutter/flutter#168524) 2025-05-09 [email protected] Roll Fuchsia Linux SDK from mqhX1OP8ezmialgqA... to F2xwL6WosfD7ETcPm... (flutter/flutter#168587) 2025-05-09 [email protected] Roll Packages from ab44c26 to 7814fab (4 revisions) (flutter/flutter#168597) If this roll has caused a breakage, revert this CL and stop the roller using the controls here: https://autoroll.skia.org/r/flutter-packages Please CC [email protected],[email protected] on the revert to ensure that a human is aware of the problem. To file a bug in Packages: https://github.com/flutter/flutter/issues/new/choose To report a problem with the AutoRoller itself, please file a bug: https://issues.skia.org/issues/new?component=1389291&template=1850622 Documentation for the AutoRoller is here: https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
Fixes #165847
Pre-launch Checklist
///).