tbaggett / xfgloss

New styling properties for standard Xamarin.Forms controls
Other
160 stars 25 forks source link

Low-level touch events label:enhancement #33

Open MappingSteve opened 6 years ago

MappingSteve commented 6 years ago

Xamarin has never had adequate touch support.
When we [MappingIndustries / LiveCaddie] switched from native (java) to Xamarin development, we developed our own common API and implemented it on iOS and Android.

Now switching from Xamarin.Android + Xamarin.iOS to Xamarin.Forms, I find that we are gradually adding classes like "TouchButton", which is Button + native renderer that maps (on Android) OnTouchEvent(Android.Views.MotionEvent e) and OnInterceptTouchEvent to methods in code behind.

Attached properties look like a great way to do this, and support a broader range of controls without the repetition that I am doing right now.

I posted some preliminary cross-platform code in a Xamarin forum a couple of years ago. Eventually would like to contribute a better solution, and this seems like a good project + technique to add to.

Realistically, I won't be able to collaborate in the next few months, but if I had experience implementing attached properties I might start to migrate the code we have into that format.

Mentioning this in case other people have interest in this topic, and to see whether you think this is a good fit with xfgloss.

Edit I just saw https://michaelridland.com/xamarin/xaml-attached-properties-tricks-in-xamarin-forms/ which shows how easy it is to attach a gesture via attached property, so that might get me started on attaching a cross-platform representation of Android OnTouchEvent.

EDIT 2 For my company, most of our advanced touch needs seem to be met by making a "TouchAwareContentView" which implements our ITouch interface [via platform Renderers], having as its child the custom control that needed advanced touch, and passing it in to custom child constructor as an ITouch. For example, to add touch to an OpenGL view. Or a Pan Gesture Behavior that knows where the original Down location was. A bit of code behind where we need it, but will get us through the next six months. So will revisit "doing it right" sometime in 2019.

-- ToolmakerSteve

tbaggett commented 6 years ago

Hi @MappingSteve / ToolmakerSteve,

Sorry for the slow reply. My father was ill through most of the summer before passing away at the end of August. I'm willing to review what you've done to look at integrating it into the XFGloss project. Please let me know if you're still interested in pursuing this. Thanks!