Skip to content

Conversation

@alex-medinsh
Copy link
Contributor

@alex-medinsh alex-medinsh commented Apr 17, 2025

Fixes #165847

Pre-launch Checklist

  • I read the [Contributor Guide] and followed the process outlined there for submitting PRs.
  • I read the [Tree Hygiene] wiki page, which explains my responsibilities.
  • I read and followed the [Flutter Style Guide], including [Features we expect every widget to implement].
  • I signed the [CLA].
  • I listed at least one issue that this PR fixes in the description above.
  • I updated/added relevant documentation (doc comments with ///).
  • 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.
  • All existing and new tests are passing.

@github-actions github-actions bot added framework flutter/packages/flutter repository. See also f: labels. f: cupertino flutter/packages/flutter/cupertino repository labels Apr 17, 2025
@alex-medinsh alex-medinsh changed the title added slider haptic feedback Add CupertinoSlider haptic feedback Apr 17, 2025
@MaherSafadii
Copy link

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?

@alex-medinsh
Copy link
Contributor Author

alex-medinsh commented Apr 17, 2025

Hi @MaherSafadii! Yes, I implemented different levels of haptics. Might need some adjustments, but overall it's there.

if (isLargeDelta) {
HapticFeedback.mediumImpact();
} else {
HapticFeedback.selectionClick();
}

@alex-medinsh alex-medinsh marked this pull request as ready for review April 17, 2025 18:59
@dkwingsmt dkwingsmt self-requested a review April 23, 2025 18:14
Copy link
Contributor

@dkwingsmt dkwingsmt left a 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!

@alex-medinsh
Copy link
Contributor Author

@dkwingsmt I have made the requested changes, please take a look. Thanks!

Copy link
Contributor

@dkwingsmt dkwingsmt left a comment

Choose a reason for hiding this comment

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

LGTM. Thank you!

@alex-medinsh
Copy link
Contributor Author

@dkwingsmt I guess this needs one more approval to get merged?

Copy link
Contributor

@justinmc justinmc left a 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.

Comment on lines 257 to 275
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;
}
}
Copy link
Contributor

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:

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();
}

Copy link
Contributor Author

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.

Copy link
Contributor

Choose a reason for hiding this comment

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

Sounds good, I agree.

@alex-medinsh
Copy link
Contributor Author

@justinmc I've added the docs and a test for non-iOS platforms.

@alex-medinsh
Copy link
Contributor Author

@justinmc friendly ping :)

Copy link
Contributor

@justinmc justinmc left a 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.

@justinmc justinmc added the autosubmit Merge PR when tree becomes green via auto submit App label May 9, 2025
@auto-submit auto-submit bot added this pull request to the merge queue May 9, 2025
Merged via the queue into flutter:master with commit 7592aea May 9, 2025
76 checks passed
@flutter-dashboard flutter-dashboard bot removed the autosubmit Merge PR when tree becomes green via auto submit App label May 9, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request May 10, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request May 10, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request May 11, 2025
auto-submit bot pushed a commit to flutter/packages that referenced this pull request May 11, 2025
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
FMorschel pushed a commit to FMorschel/packages that referenced this pull request Jun 9, 2025
…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
Ortes pushed a commit to Ortes/packages that referenced this pull request Jun 25, 2025
…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
@alex-medinsh alex-medinsh deleted the slider-haptics branch July 2, 2025 08:01
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Aug 14, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Aug 14, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Aug 15, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Aug 15, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Aug 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

f: cupertino flutter/packages/flutter/cupertino repository framework flutter/packages/flutter repository. See also f: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CupertinoSlider should provide haptic feedback

4 participants