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

[Proposal] TouchEffect #86

Closed
4 of 10 tasks
brminnick opened this issue Sep 26, 2021 · 81 comments
Closed
4 of 10 tasks

[Proposal] TouchEffect #86

brminnick opened this issue Sep 26, 2021 · 81 comments
Assignees
Labels
approved This Proposal has been approved and is ready to be added to the Toolkit champion A member of the .NET MAUI Toolkit core team has chosen to champion this feature in-progress proposal A fully fleshed out proposal describing a new feature in syntactic and semantic detail

Comments

@brminnick
Copy link
Collaborator

brminnick commented Sep 26, 2021

TouchEffect

  • Proposed
  • Prototype
  • Implementation
    • iOS Support
    • Android Support
    • macOS Support
    • Windows Support
  • Unit Tests: Not Started
  • Sample: Not Started
  • Documentation: Not Started

Summary

Adds additional touch events to any VisualElement

Detailed Design

TouchEffect.shared.cs

public class TouchEffect : RoutingEffect
{
  public event EventHandler<TouchStatusChangedEventArgs> StatusChanged;
  public event EventHandler<TouchStateChangedEventArgs> StateChanged;
  public event EventHandler<TouchInteractionStatusChangedEventArgs> InteractionStatusChanged;
  public event EventHandler<HoverStatusChangedEventArgs> HoverStatusChanged;
  public event EventHandler<HoverStateChangedEventArgs> HoverStateChanged;
  public event EventHandler<TouchCompletedEventArgs> Completed;
  public event EventHandler<LongPressCompletedEventArgs> LongPressCompleted;
  
  public static readonly BindableProperty IsAvailableProperty;
  public static readonly BindableProperty ShouldMakeChildrenInputTransparentProperty;
  public static readonly BindableProperty CommandProperty;
  public static readonly BindableProperty LongPressCommandProperty;
  public static readonly BindableProperty CommandParameterProperty;
  public static readonly BindableProperty LongPressCommandParameterProperty;
  public static readonly BindableProperty LongPressDurationProperty;
  public static readonly BindableProperty StatusProperty;
  public static readonly BindableProperty StateProperty;
  public static readonly BindableProperty InteractionStatusProperty;
  public static readonly BindableProperty HoverStatusProperty;
  public static readonly BindableProperty HoverStateProperty;
  public static readonly BindableProperty NormalBackgroundColorProperty;
  public static readonly BindableProperty HoveredBackgroundColorProperty;
  public static readonly BindableProperty PressedBackgroundColorProperty;
  public static readonly BindableProperty NormalOpacityProperty;
  public static readonly BindableProperty HoveredOpacityProperty;
  public static readonly BindableProperty PressedOpacityProperty;
  public static readonly BindableProperty NormalScaleProperty;
  public static readonly BindableProperty HoveredScaleProperty;
  public static readonly BindableProperty PressedScaleProperty;
  public static readonly BindableProperty NormalTranslationXProperty;
  public static readonly BindableProperty HoveredTranslationXProperty;
  public static readonly BindableProperty PressedTranslationXProperty;
  public static readonly BindableProperty NormalTranslationYProperty;
  public static readonly BindableProperty HoveredTranslationYProperty;
  public static readonly BindableProperty PressedTranslationYProperty;
  public static readonly BindableProperty NormalRotationProperty;
  public static readonly BindableProperty HoveredRotationProperty;
  public static readonly BindableProperty PressedRotationProperty;
  public static readonly BindableProperty NormalRotationXProperty;
  public static readonly BindableProperty HoveredRotationXProperty;
  public static readonly BindableProperty PressedRotationXProperty;
  public static readonly BindableProperty NormalRotationYProperty;
  public static readonly BindableProperty HoveredRotationYProperty;
  public static readonly BindableProperty PressedRotationYProperty;
  public static readonly BindableProperty AnimationDurationProperty;
  public static readonly BindableProperty AnimationEasingProperty;
  public static readonly BindableProperty PressedAnimationDurationProperty;
  public static readonly BindableProperty PressedAnimationEasingProperty;
  public static readonly BindableProperty NormalAnimationDurationProperty;
  public static readonly BindableProperty NormalAnimationEasingProperty;
  public static readonly BindableProperty HoveredAnimationEasingProperty;
  public static readonly BindableProperty PulseCountProperty;
  public static readonly BindableProperty IsToggledProperty;
  public static readonly BindableProperty DisallowTouchThresholdProperty;
  public static readonly BindableProperty NativeAnimationProperty;
  public static readonly BindableProperty NativeAnimationColorProperty;
  public static readonly BindableProperty NativeAnimationRadiusProperty;
  public static readonly BindableProperty NativeAnimationShadowRadiusProperty;
  public static readonly BindableProperty NormalBackgroundImageSourceProperty;
  public static readonly BindableProperty HoveredBackgroundImageSourceProperty;
  public static readonly BindableProperty PressedBackgroundImageSourceProperty;
  public static readonly BindableProperty BackgroundImageAspectProperty;
  public static readonly BindableProperty NormalBackgroundImageAspectProperty;
  public static readonly BindableProperty HoveredBackgroundImageAspectProperty;
  public static readonly BindableProperty PressedBackgroundImageAspectProperty;
  public static readonly BindableProperty ShouldSetImageOnAnimationEndProperty;
}

Usage Syntax

<Button TouchEffect.PressedScale="3">
</Button>

C# Usage

var button = new Button();
TouchEffect.SetPressedScale(button, 3);
@brminnick brminnick added new proposal A fully fleshed out proposal describing a new feature in syntactic and semantic detail labels Sep 26, 2021
@brminnick brminnick added this to the v1.0.0 milestone Sep 26, 2021
@brminnick brminnick removed this from the v1.0.0 milestone Apr 15, 2022
@ghost ghost added champion A member of the .NET MAUI Toolkit core team has chosen to champion this feature and removed new labels May 5, 2022
@mmendoza-apa

This comment was marked as off-topic.

@pictos

This comment was marked as outdated.

@naweed

This comment was marked as outdated.

@pictos
Copy link
Member

pictos commented Jun 13, 2022

@naweed we don't have a date to share

@JohnHDev
Copy link

@pictos can I confirm if/when this is done it will be a Behaviour, not an effect, right?
We have started investigating what is needed to migrate to .NET Maui and we have dependencies that we either want to remove or migrate as well. We have a long press effect we don't want to migrate (unless we have to), we would rather go down the supported route with the replacement for TouchEffect.

@bijington
Copy link
Contributor

@JohnHDev yes that is correct. Much like the IconTintColor and SelectAllTextBehavior implementations we will be moving from the old Effects API over to using Behaviors.

I don't know if @pictos but if not would you fancy the challenge of adding this in?

@beeradmoore

This comment was marked as off-topic.

@smardine

This comment was marked as off-topic.

@mantasdaskev

This comment was marked as off-topic.

@pictos

This comment was marked as outdated.

@smardine

This comment was marked as off-topic.

@KSemenenko
Copy link
Member

Here is the most important point, in the experience of XF, that the ListView and CollectionView gestures did not allow to process all the other gestures.

And of course multiple gesture handlers are also needed

@LennoxP90

This comment was marked as off-topic.

@jonakirke94

This comment was marked as off-topic.

@LennoxP90

This comment was marked as off-topic.

@pictos pictos added the needs discussion Discuss it on the next Monthly standup label Nov 3, 2022
@KieranMaclagan

This comment was marked as off-topic.

@KSemenenko
Copy link
Member

@pictos @brminnick is there any design decision about using behavior or effect?
I found old pr xamarin/Xamarin.Forms#9740 for it.

Maybe we can make decision about it and I can start implementation?

@pictos
Copy link
Member

pictos commented Nov 15, 2022

@KSemenenko this is in WIP mode, I'm working this. Thanks

@ghost ghost added the approved This Proposal has been approved and is ready to be added to the Toolkit label Dec 1, 2022
@VladislavAntonyuk
Copy link
Collaborator

@criss02-cs MauiCompat target framework is net6.0.
most likely touch effect will be a part of the next release (with .net 8)

@mirceamuresanse
Copy link

Checking the code for the Touch Behavior in the touch-effect branch we noticed that the implementation is missing handling a move event and exposing it to the users.
Are there any plans to implement the move event?
This is critical for us, as we already use the Xamarin CommunityToolkit, where the TouchEffect is already handling the move event.

@kphillpotts
Copy link
Contributor

At this point this proposal does not specify the move events. It's a terrific addition no doubt to have this to maintain parity with Xamarin CommunityToolkit. I think it is best to get this version out as soon as we can and then we can put in the move events shortly after.

If it is critical for you in the meantime you could port the XCT move across in a PR so we can get it in as soon as possible.

@criss02-cs
Copy link

approximately when will we have the opportunity to have this functionality?

@fredericoregateiro
Copy link

I do believe that some functionality is better than none.
To see some functionality from time to time is way better than years with nothing.

@Axemasta
Copy link
Contributor

Axemasta commented Nov 1, 2023

The TouchEffect in XCT in my opinion was a core feature that realistically should have been part of the main framework. It was the best part of XCT and all my Maui apps have been REALLY suffering in its absence.

The MauiCompat library doesn't seem to work in any of my net7 / 8 maui apps. I can see there is a planned release for this effect in net8 & can see the touch-effect branch looks quite good. I've hit the point where I simply couldn't wait for an MCT release so I have the XCT code ported to Maui here.

I'm not putting this on NuGet, for anyone wanting to use it my suggestion is build it locally and either host it in a private nuget feed (such as azure devops) or reference locally.

Really looking forward to this being released properly!

@gsgou
Copy link

gsgou commented Dec 1, 2023

@kphillpotts is there any rough estimation or planning when to expect this feature coming in?

@fredericoregateiro
Copy link

I was watching .net conf and see this video on maui
https://youtu.be/4saU9BNY6l4?t=677&si=8MkaeOaxJ8Edq7nk

They talk about point gestures and that they can be used to detect things like long press, also the docs https://learn.microsoft.com/en-us/dotnet/maui/fundamentals/gestures/pointer?view=net-maui-8.0&tabs=windows

I didn't have the time to check this out, have anyone worked with these?

@unamed000
Copy link

I was watching .net conf and see this video on maui https://youtu.be/4saU9BNY6l4?t=677&si=8MkaeOaxJ8Edq7nk

They talk about point gestures and that they can be used to detect things like long press, also the docs https://learn.microsoft.com/en-us/dotnet/maui/fundamentals/gestures/pointer?view=net-maui-8.0&tabs=windows

I didn't have the time to check this out, have anyone worked with these?

I don't think thing the Pointer gesture is enough, it doesn't have event that will be fired when user just hold on and didn't move their finger. So how can we detect something like that?

@fredericoregateiro
Copy link

@unamed000
I didn't have time to try but in WPF i've made something similar with the down and up touch events, and we could use the PointerPressed and PointerReleased in MAUI.
So the idea is to start a timer on the PointerPressed event and check the passed time on the PointerReleased event.

It could work on all platforms with just one implementation.

@maexsp
Copy link

maexsp commented Jan 18, 2024

@fredericoregateiro Actually I use the following package for TouchEffects unless its implemented in the CommunityToolkit. API is compatible to the old XF implementation and works fine for Android and iOS. Quite fresh nuget package but quality is ok. https://www.nuget.org/packages/TouchEffect.Maui

@Axemasta
Copy link
Contributor

Quite fresh nuget package but quality is ok. https://www.nuget.org/packages/TouchEffect.Maui

This looks familiar... too familiar. Not that I put my maui port up for fame and glory, but when this library is clearly just my repo slightly reworded, with no credit or the crucial context that this library is a stopgap for the MCT feature, feels a little wild west...

Coincidentally I just updated my port to NET 8 & Fixed an iOS bug to do with input transparency (something I did after this repo was copied). We now have loads of wish.com maui touch effects floating around, we are in dire need of the official thing. Is there any word on the state of the current feature? I am super happy to jump in and help get this feature over the line so we can end the compat library wars!

@jfversluis
Copy link
Member

@Axemasta 😔 yeah this is not great. Might be good to maybe get this out of the way, awesome you're willing to help out. Did you join our Discord server by any chance? That might be good to get some coordination going?

@felipebaltazar
Copy link

Quite fresh nuget package but quality is ok. https://www.nuget.org/packages/TouchEffect.Maui

This looks familiar... too familiar. Not that I put my maui port up for fame and glory, but when this library is clearly just my repo slightly reworded, with no credit or the crucial context that this library is a stopgap for the MCT feature, feels a little wild west...

Coincidentally I just updated my port to NET 8 & Fixed an iOS bug to do with input transparency (something I did after this repo was copied). We now have loads of wish.com maui touch effects floating around, we are in dire need of the official thing. Is there any word on the state of the current feature? I am super happy to jump in and help get this feature over the line so we can end the compat library wars!

@Axemasta First of all I want to apologize, you are right my package is entirely your code and I don't have any mention to you...
I don't think that any explanation will be enough here, but I started forking from the original TouchEffect and i didn't notice that I didn't fork from your repository (and I don't put any mention in the readme, shame)

I don't used your Nuget because it's deprecated and you have mentioned that you have no intention to maintain other platforms, so I started my version to solve this for the app migrations that I'm doing... I want to talk to you in order to resolve this, maybe removing my package and contributing to your original code.. or anything that you have in mind...
Please text me: felipe.dasilvabaltazar@gmail.com

Sorry again

@IeuanWalker
Copy link
Contributor

I was watching .net conf and see this video on maui https://youtu.be/4saU9BNY6l4?t=677&si=8MkaeOaxJ8Edq7nk

They talk about point gestures and that they can be used to detect things like long press, also the docs https://learn.microsoft.com/en-us/dotnet/maui/fundamentals/gestures/pointer?view=net-maui-8.0&tabs=windows

I didn't have the time to check this out, have anyone worked with these?

I don't think thing the Pointer gesture is enough, it doesn't have event that will be fired when user just hold on and didn't move their finger. So how can we detect something like that?

If u just want pressed, released and clicked events, you could try my control out - https://github.com/IeuanWalker/Maui.StateButton

@gsgou
Copy link

gsgou commented Feb 1, 2024

@felipebaltazar any plans for a PR to @Axemasta 's project for Windows support?
https://github.com/Axemasta/Maui.TouchEffect/pulls

Do you have in your repo any plans for a Windows branch?
https://github.com/felipebaltazar/TouchEffect.Maui/branches/all

@alexskrms
Copy link

Any news about this feature coming to .NET MAUI Community Toolkit? I need it for my application.

@jfversluis
Copy link
Member

Still being worked on, stay tuned!

@somapatrik

This comment has been minimized.

@GeorgeCarr44
Copy link

@unamed000
I didn't have time to try but in WPF i've made something similar with the down and up touch events, and we could use the PointerPressed and PointerReleased in MAUI.
So the idea is to start a timer on the PointerPressed event and check the passed time on the PointerReleased event.

It could work on all platforms with just one implementation.

Your going to have issues with this implementation if the clickable element in within a scroll view and the user scrolls on the clickable element

@apoorvadixit-ttc
Copy link

Still being worked on, stay tuned!

@jfversluis is there a short-term alternative for .NET 8/MAUI?

@bijington
Copy link
Contributor

Still being worked on, stay tuned!

@jfversluis is there a short-term alternative for .NET 8/MAUI?

No I think you will just have to wait and watch this PR #1673

@jfversluis
Copy link
Member

Or of course implement it yourself. Any plugin or project is someone else writing code you could've written yourself.

Otherwise, done when it's done 😄 and we hear you, we see a lot of people want this. So we're working on it.

@Axemasta
Copy link
Contributor

Axemasta commented Mar 1, 2024

@apoorvadixit-ttc

is there a short-term alternative for .NET 8/MAUI?

If you scroll up you'll see my links, I ported the XCT implementation to Maui and have it available as a "build, fork or drop into your projects yourself & use at your own risk" type deal. I'm currently using that library in my own apps and its been rock solid so far.

Currently working on the MCT PR to get this feature into the toolkit for 2 reasons. 1 its not my project, I just did a port and want the credit to go to the toolkit guys & Andrei who originally wrote it + donated to xct. 2 I dont want sole maintenance responsibility, it would be better when a team of people can manage it that way we know its super solid

@apoorvadixit-ttc
Copy link

@apoorvadixit-ttc

is there a short-term alternative for .NET 8/MAUI?

If you scroll up you'll see my links, I ported the XCT implementation to Maui and have it available as a "build, fork or drop into your projects yourself & use at your own risk" type deal. I'm currently using that library in my own apps and its been rock solid so far.

Currently working on the MCT PR to get this feature into the toolkit for 2 reasons. 1 its not my project, I just did a port and want the credit to go to the toolkit guys & Andrei who originally wrote it + donated to xct. 2 I dont want sole maintenance responsibility, it would be better when a team of people can manage it that way we know its super solid

Noted sir. I have tested it in a sample .NET 8/MAUI project and it seems to do what I was doing in the Xamarin CT, so thank you.
Hopefully we will see a new version of MAUI toolkit soon.

@bijington
Copy link
Contributor

@Axemasta we really appreciate this effort that you are putting in and I'm sure everyone would agree that you certainly deserve the credit for it!

@jfversluis
Copy link
Member

All done, released as part of v8.0.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved This Proposal has been approved and is ready to be added to the Toolkit champion A member of the .NET MAUI Toolkit core team has chosen to champion this feature in-progress proposal A fully fleshed out proposal describing a new feature in syntactic and semantic detail
Projects
Status: Completed
Development

Successfully merging a pull request may close this issue.