-
Notifications
You must be signed in to change notification settings - Fork 401
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 TouchBehavior #1673
Add TouchBehavior #1673
Conversation
390693c
to
fe78e44
Compare
@Axemasta thanks for updating this PR. What action do you need now? Do you need a maintainer to review the current changes? Looking on my phone I see changes to popup related bits which might not be intended? |
The outstanding work as I am aware is:
The next steps are testing and ensuring it works and is ready to merge! I'm not sure what to do about this branch since its a rebase branch, do we abandon the old touch effect branch and merge this one (when ready)? If we decide to use the old branch, I can't rebase since i dont have push permissions and i'm unsure of how I can rebase it without doing a force push. |
What's the least amount of effort for you? I can rebase and force push if you need? |
fe78e44
to
98cb2df
Compare
You don't need to fret about rebasing, @Axemasta, we have branch protection rules in place that will take care of that automatically for you. To keep this PR scoped to the new TouchBevahior control, please remove the all of edits to files that are unrelated to the new TouchBehavior:
|
af7a135
to
2951f8d
Compare
@brminnick I have addressed all but two of these files in my latest commit, the files not address are:
|
I mentioned this in the discord yesterday, after updating the sample app to use a viewmodel I discovered the I discovered this from the following sources:
For the time being I have opted to set the binding context of the platform behavior so that the sample functions in the intended way. My question here is will this cause issues for consumers of the behavior? Is there any special handling we will need to do to ensure there aren't issues or would we be better reverting to the old api design, which uses attached properties to achieve the behavior? @pictos what do you think about this issue? |
@Axemasta Yeah, as you can see on #795 it's this way by design (as I mentioned in the discussion).
The user can set the BindingContext itself, and use the normal Binding expression. And I believe that we should align our implementation with the general recommendation, that's to set BindingContext on behaviors. |
Does this mean the toolkit should set the BindingContext in the behaviors? Or we apply it to our samples? |
The toolkit shouldn't apply the BindingContext to its behaviors. The reason Behaviors don't set the BindingContext is because they are meant to be reusable (for example you set a behavior on a style). With that, the user should decide if he wants to set the BindingContext or use the |
Thanks for the detail. Adding a behavior to a Style when you have properties like Commands that will need to be bound or assigned sounds like a dangerous thing to be able to do. I'm not criticizing anything here, just stating it feels a bit dangerous to allow it |
I agree, previously you couldn't do this because it was using an attached effect. The docs are going to have to be quite clear here that here is a specific way you setup binding & you definitely shouldn't apply to a style. People can still abuse it at their own risk, but the documented way should work fine! |
The .NET Maui docs on Behaviors are very explicit that behaviors do not inherit the BindingContext of their parent: https://learn.microsoft.com/en-us/dotnet/maui/fundamentals/behaviors?view=net-maui-8.0#create-a-net-maui-behavior |
Oh good spot! We should link to that on all behavior pages |
@Axemasta do you think it's fairly safe for me to get started on the docs PR for this? |
Yes I think so, the hover feature requires implementing and I'm starting to look at that. Api wise everything is there and aside from hover it behaves how it did in forms |
Current status of the pr, I have fixed hover which is now working on both platforms. Tests immediately all went green as a bonus (minus 1 test that had the wrong default plugged into it). All that remains dev wise is to fix the issue i'm seeing on android devices where a child view becomes invisible if the parent has the effect applied. I've narrowed it down to |
@Axemasta thanks for bringing this to the toolkit. |
Thanks its good to know it wasn't working properly in the XCT. I checked my port and the iOS native animations work but the android ones don't show so I've clearly ported the bug 😂. Currently the ripple animation is actually playing on Android, the issue is that the ripple view swallows any child views therefore causing the ui not to render correctly. I've actually found the root cause and I'm working on shipping a fix to position the ripple view behind any child views so the order of views it correct. The XamEffect library looks really cool, I've used the syncfusion ripple in the past and love how slick it makes your controls look. Its a small addition that makes a big difference to the look & feel of the app 😌 |
I hate to suggest big changes but is it a silly idea to suggest a rename to |
Wow! There is a LOT to this TouchBehavior API! I know this came from XCT and @Axemasta you have put in a lot of effort to bring it to the toolkit! I am just trying to comprehend how I can get some docs written. I think I will take the samples page and build on from there. These question(s) are purely to open a conversation:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Update Unit Tests
src/CommunityToolkit.Maui.UnitTests/Behaviors/ImageTouchBehaviorTests.cs
Outdated
Show resolved
Hide resolved
src/CommunityToolkit.Maui.UnitTests/Behaviors/ImageTouchBehaviorTests.cs
Outdated
Show resolved
Hide resolved
src/CommunityToolkit.Maui.UnitTests/Behaviors/ImageTouchBehaviorTests.cs
Outdated
Show resolved
Hide resolved
src/CommunityToolkit.Maui.UnitTests/Behaviors/ImageTouchBehaviorTests.cs
Outdated
Show resolved
Hide resolved
src/CommunityToolkit.Maui.UnitTests/Behaviors/ImageTouchBehaviorTests.cs
Outdated
Show resolved
Hide resolved
fyi I've just tried the 99.0.0-preview1678 nightly build (the first where TouchBehavior seems to appear in), and it seems to make my windows app crash on launch with an unspecified error and on android nothing really happens when adding a touchbehaviour to a control. |
@MitchBomcanhao please open an issue with a sample project that reproduces the error |
@pictos to get the windows app failing on launch, Just get a blank new app, add that nightly build to the project, and launch the app. it'll fail with the error shown below. It'll take me longer to figure out how to make a sample project added to github (which is a requirement to open an issue) than it will for you to try this.
|
I confirmed that TouchBehavior works as expected in
@MitchBomcanhao Could you open an Issue and provide a reproduction sample today? We are planning to release TouchBehavior in |
@brminnick I will not be able to get that done today as I'm about at the end of the working day... (and it is a long weekend in the UK). I came across this issue on two different projects (one a production app and another a brand new blank app where there's no other code modified other than updating maui, adding the toolkit and initialising it in mauiprogram.cs. perhaps there's some OS level issue where you might be running different windows versions? fyi I'm on windows 10 build 19045.4170 and VS 17.9.4 - that's pretty much all I got for you right now :/ |
I confirm the nightly NuGet Package of I also confirm the nightly NuGet Package of |
Are there any examples of using a CommandParameter for one of these touch events (I'm trying to use the new LongTap)? I can't find one in the samples, and no matter what I try, null gets passed to the command. I just need an example to see the proper syntax. |
You'll need to manually set Here's more information: https://stackoverflow.com/questions/78245724/both-touchbehavior-commandparameter-and-touchbehavior-longpresscommandparamet |
This is a rebase of the
touch-effect
branch, back ontop of main.The rebase wasn't pretty and there were lots of conflicts, I sided with main in every conflicted file but there were still some issues that had to be resolved by hand. Where any file was broken by the rebase, I have copied the code from
main
in to replace the contents.