Skip to content

Conversation

@dkwingsmt
Copy link
Contributor

@dkwingsmt dkwingsmt commented Sep 9, 2024

This PR adds "sliding tap" to CupertinoAlertDialog and fixes #19786.

Much of the needed infrastructure has been implemented in #150219, but this time with a new challenge to support disabled buttons, i.e. the button should not show tap highlight when pressed (#107371).

  • Why? Because whether a button is disabled is assigned to CupertinoDialogAction, while the background is rendered by a private class that wraps the action widget and built by the dialog body. We need a way to pass the boolean "enabled" from the child to the parent when the action is pressed. After much experimentation, I think the best way is to propagate this boolean using the custom gesture callback.
  • An alternative way is to make the wrapper widget use an inherited widget, which allows the child CupertinoDialogAction to place a ValueGetter<bool> getEnabled to the parent as soon as it's mounted. However, this is pretty ugly...

This PR also fixes #107371, i.e. disabled CupertinoDialogAction no longer triggers the pressing highlight. However, while legacy buttons (custom button classes that are implemented by GestureDetector.onTap) still functions (their onPressed continues to work), disabled legacy buttons will still show pressing highlight, and there's no plan (actually, no way) to fix it.

All tests related to sliding taps in CupertinoActionSheet has been copied to CupertinoAlertDialog, with additional tests for disabled buttons.

Pre-launch Checklist

If you need help, consider asking for advice on the #hackers-new channel on Discord.

@github-actions github-actions bot added framework flutter/packages/flutter repository. See also f: labels. f: cupertino flutter/packages/flutter/cupertino repository labels Sep 9, 2024
@dkwingsmt dkwingsmt marked this pull request as ready for review September 9, 2024 23:25
@flutter-dashboard
Copy link

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 package:flutter.

Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing.

Changes reported for pull request #154853 at sha f1ec2b8

@override
bool didEnter({required bool fromPointerDown, required bool innerEnabled}) {
widget.onPressStateChange?.call(innerEnabled);
if (innerEnabled) {
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: maybe && over nested ifs?

State<CupertinoDialogAction> createState() => _CupertinoDialogActionState();
}

class _CupertinoDialogActionState extends State<CupertinoDialogAction>
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this going to be a leaf _SlideTarget? Since this is a public widget that takes a Key, I think it's possible for the if (_currentTargets.firstOrNull != foundTargets.firstOrNull) check in _updateDrag to be false if a CupertinoDialogAction gets reparented while a "sliding" gesture is in progress?

Copy link
Contributor Author

@dkwingsmt dkwingsmt Sep 14, 2024

Choose a reason for hiding this comment

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

Yeah it's technically possible. In fact, if the action buttons somehow moves (for example, if a button at the top expands by itself so that the highlighted button is moved out of the pointer position), the dialog will not re-perform hit tests without a pointer event and will not update.

However, in reality I can't imagine when this would happen, considering the dialog and action sheets tend to be pretty isolated.

Completely solving this requires the recognizer to use the same logic as MouseTracker, which additionally performs a hit test per frame - in fact, we should re-use the code from MouseTracker (or, better put, to conditionally enable hovering for touch events). However that might need some refactor for MouseTracker for a really rare edge case, and therefore I suggest we leave to a future PR, such as as part of #19786. What do you think?

Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe add a "TODO"?

which additionally performs a hit test per frame

I thought we are already doing that in the current implementation (in _updateDrag)? We are just not comparing the hit-testing paths in a per-entry fashion.

Copy link
Contributor Author

@dkwingsmt dkwingsmt Sep 16, 2024

Choose a reason for hiding this comment

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

Maybe add a "TODO"?

Sure!

I thought we are already doing that in the current implementation

_updateDrag is only triggered every time the pointer moves. But if the app is updated while the pointer stays still, then the pointer won't hit test the new layout. Really tricky situation.

@flutter-dashboard
Copy link

Golden file changes are available for triage from new commit, Click here to view.

For more guidance, visit Writing a golden file test for package:flutter.

Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing.

Changes reported for pull request #154853 at sha 75d4422

@dkwingsmt dkwingsmt added the autosubmit Merge PR when tree becomes green via auto submit App label Sep 17, 2024
@flutter-dashboard
Copy link

Golden file changes are available for triage from new commit, Click here to view.

For more guidance, visit Writing a golden file test for package:flutter.

Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing.

Changes reported for pull request #154853 at sha a6942d0

@auto-submit auto-submit bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Sep 17, 2024
@auto-submit
Copy link
Contributor

auto-submit bot commented Sep 17, 2024

auto label is removed for flutter/flutter/154853, due to - The status or check suite Google testing has failed. Please fix the issues identified (or deflake) before re-applying this label.

@dkwingsmt dkwingsmt added the autosubmit Merge PR when tree becomes green via auto submit App label Sep 17, 2024
@auto-submit auto-submit bot merged commit c57f99e into flutter:master Sep 17, 2024
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Sep 18, 2024
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Sep 18, 2024
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Sep 18, 2024
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Sep 18, 2024
@dkwingsmt dkwingsmt deleted the ad-tap-slide branch September 18, 2024 19:57
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Sep 18, 2024
auto-submit bot pushed a commit to flutter/packages that referenced this pull request Sep 19, 2024
Manual roll requested by [email protected]

flutter/flutter@c4c9f47...7fe8237

2024-09-18 [email protected] Roll Flutter Engine from 4bdcbf39c200 to 15e9e3153266 (1 revision) (flutter/flutter#155371)
2024-09-18 [email protected] Roll Flutter Engine from fdf38910bad4 to 4bdcbf39c200 (5 revisions) (flutter/flutter#155368)
2024-09-18 [email protected] Roll Packages from 4f2b9cd to c7406b3 (1 revision) (flutter/flutter#155362)
2024-09-18 [email protected] Roll Flutter Engine from 4f2d866aef32 to fdf38910bad4 (1 revision) (flutter/flutter#155339)
2024-09-18 [email protected] Roll Flutter Engine from 311ba971bb3a to 4f2d866aef32 (4 revisions) (flutter/flutter#155329)
2024-09-18 [email protected] Fix missing icon props in button `styleFrom`  methods (flutter/flutter#154821)
2024-09-17 [email protected] Roll Flutter Engine from 0ef18a3ef064 to 311ba971bb3a (8 revisions) (flutter/flutter#155325)
2024-09-17 [email protected] [CupertinoAlertDialog] Add tap-slide gesture (flutter/flutter#154853)
2024-09-17 [email protected] Uninstall /can fail/ (flutter/flutter#155314)
2024-09-17 [email protected] Roll Packages from df88c81 to 4f2b9cd (3 revisions) (flutter/flutter#155312)
2024-09-17 [email protected] Roll Flutter Engine from a1700b9ea2db to 0ef18a3ef064 (1 revision) (flutter/flutter#155311)
2024-09-17 [email protected] Roll Flutter Engine from 1376288f5c2a to a1700b9ea2db (2 revisions) (flutter/flutter#155290)
2024-09-17 [email protected] Delete packages/flutter_tools/lib/src/fuchsia directory (flutter/flutter#154880)
2024-09-17 [email protected] Adds ColorSwatch matcher (flutter/flutter#155272)

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],[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
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Dec 11, 2024
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Dec 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

autosubmit Merge PR when tree becomes green via auto submit App f: cupertino flutter/packages/flutter/cupertino repository framework flutter/packages/flutter repository. See also f: labels. will affect goldens Changes to golden files

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CupertinoDialogAction is tappable even if onPressed is null Implement correct iOS button press dynamics

2 participants