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

Add Support for onTapDown #533

Open
6 tasks
tilucasoli opened this issue Nov 28, 2024 · 4 comments · May be fixed by #534
Open
6 tasks

Add Support for onTapDown #533

tilucasoli opened this issue Nov 28, 2024 · 4 comments · May be fixed by #534

Comments

@tilucasoli
Copy link
Collaborator

tilucasoli commented Nov 28, 2024

Description:

Mix supports $on.press for styling Widgets, but the style is applied only after the press action is completed (onTapUp). Developers have expressed the need for styling during the onTapDown event.

User Stories:

  1. As a developer using Mix,
    I want to style widgets specifically during the onTapDown event,
    so that I can provide immediate visual feedback, such as color changes or scaling, when a button is pressed.

Acceptance Criteria:

  • Add support for the onTapDown event in widget and expose it in the styling API.
  • The widget should only rebuild if it is listening to the state.
  • Ensure that onTapDown styles are applied immediately when the user presses the widget and reset when the press is released or canceled.
  • Include unit and integration tests to validate the functionality of onTapDown event styling.
  • Write documentation explaining how to use the onTapDown styling feature.
    • Add examples demonstrating use cases such as changing widget color or scaling on press.

Resources:

Example of API

$on.press.event((e) {
  switch (e) {
    case MixPressEvent.onTapDown:
      return Style(
        $box.color.red(),
      );
    case MixPressEvent.onTapUp:
      return Style();
  }
});
@tilucasoli tilucasoli linked a pull request Nov 28, 2024 that will close this issue
4 tasks
@lvsecoto
Copy link

If we have a StyledMaterial,then we have ripple effect

StyledMaterial(
   child: InkWell(
     onTap() {
     },
   ),
);

@tilucasoli
Copy link
Collaborator Author

If we have a StyledMaterial,then we have ripple effect

StyledMaterial(
   child: InkWell(
     onTap() {
     },
   ),
);

@lvsecoto, We will create a specific issue to track the solution for InkWell. While support for onTapDown is related, it is not the same issue.

@tilucasoli
Copy link
Collaborator Author

An alternative is to create a utility for tap that is triggered whenever any onTap method is called. The API would look like:

$on.tap((e) {
  switch (e) {
    case OnTapEvent.onTapDown:
      return Style(
        $box.color.red(),
      );
    case OnTapEvent.onTapUp:
      return Style();
  }
});
  • The enum OnTapEvent should contains a case for every onTap method.
  • The tap utility should receive a as parameter Function(OnTapEvent)

@tilucasoli
Copy link
Collaborator Author

The press state must remain active while the button is held; it shouldn't replace the state for a longPress.

@tilucasoli tilucasoli linked a pull request Dec 3, 2024 that will close this issue
4 tasks
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 a pull request may close this issue.

2 participants