Skip to content
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

feat!: The HasTappableComponents mixin is no longer needed #2450

Merged
merged 28 commits into from
Apr 2, 2023

Conversation

spydon
Copy link
Member

@spydon spydon commented Mar 30, 2023

Description

This PR is the second in a series of refactors that aim to simplify event handling in Flame. The approach is as follows:

  • Added the MultiTapDispatcher component, which contains the logic that used to be within the HasTappableComponents mixin. This component is internal; it mounts to a FlameGame directly, and ensures that it is a singleton.
  • Whenever any TapCallbacks component is added to a game, it automatically adds the MultiTapDispatcher component (unless there is already one), which in turn registers a tap gesture detector with GestureDetectorBuilder and rebuilds the game widget.

The end result is that now in order to make a component tappable you only need to add the TapCallbacks mixin to that component, everything else will be handled by the framework.

Consequently, the HasTappableComponents mixin is now empty and marked as deprecated.

Checklist

  • I have followed the Contributor Guide when preparing my PR.
  • I have updated/added tests for ALL new/updated/fixed functionality.
  • I have updated/added relevant documentation in docs and added dartdoc comments with ///.
  • I have updated/added relevant examples in examples or docs.

Breaking Change?

  • Yes, this PR is a breaking change.

Migration instructions

The HasTappableComponents mixin is now empty & deprecated. If your game used this mixin overriding its methods onTapDown, onTapUp, etc -- then they will no longer work. If you want to receive tap events at the top level of the game, then simply add a TapCallbacks component to the top level of the game.

Related Issues

WIP for #1733

@spydon spydon changed the title feat!: HasTappableComponents mixin is no longer needed feat!: The HasTappableComponents mixin is no longer needed Mar 30, 2023
@spydon spydon requested review from st-pasha and a team March 30, 2023 17:54
Copy link
Member

@erickzanardo erickzanardo left a comment

Choose a reason for hiding this comment

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

Great job 🔥! Overall LGTM, just left a couple of simple comments!

doc/flame/inputs/tap_events.md Outdated Show resolved Hide resolved
doc/flame/inputs/tap_events.md Outdated Show resolved Hide resolved
packages/flame/example/lib/main.dart Outdated Show resolved Hide resolved
Copy link
Member

@erickzanardo erickzanardo left a comment

Choose a reason for hiding this comment

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

LGTM awesome job!!!

@spydon spydon enabled auto-merge (squash) April 2, 2023 16:30
@spydon spydon merged commit b5bdf4e into main Apr 2, 2023
@spydon spydon deleted the spydon/deprecate-hastappablecomponents branch April 2, 2023 16:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants