unoplatform / uno

Open-source platform for building cross-platform native Mobile, Web, Desktop and Embedded apps quickly. Create rich, C#/XAML, single-codebase apps from any IDE. Hot Reload included! 90m+ NuGet Downloads!!
https://platform.uno
Apache License 2.0
8.89k stars 720 forks source link

[WASM] Implement `PointerDevice` #2469

Open paulovila opened 4 years ago

paulovila commented 4 years ago

Current behavior

WASM is not able to run code related to the PointerDevice , see: https://github.com/paulovila/MaterialDesignInXamlToolkit/blob/AddUnoSupport/MainDemo.Uno/MainDemo.Uno.Shared/Ripple.cs This project is trying to support Material design styles in Uno platform

mono.js:1       The member event PointerEventHandler UIElement.PointerWheelChanged is not implemented in Uno.
mono.js:1 fail: Windows.UI.Xaml.Media.Animation.PointerUpThemeAnimation[0]
mono.js:1       The member PointerUpThemeAnimation.PointerUpThemeAnimation() is not implemented in Uno.
mono.js:1 fail: Windows.UI.Xaml.VisualTransition[0]
mono.js:1       The member Duration VisualTransition.GeneratedDuration is not implemented in Uno.
mono.js:1 fail: Windows.UI.Xaml.Media.Animation.RepositionThemeAnimation[0]
mono.js:1       The member RepositionThemeAnimation.RepositionThemeAnimation() is not implemented in Uno.
mono.js:1 fail: Windows.UI.Xaml.Controls.Primitives.ToggleSwitchTemplateSettings[0]
mono.js:1       The member KnobCurrentToOnOffset is not implemented in Uno.
mono.js:1 fail: Windows.UI.Xaml.Controls.Primitives.ToggleSwitchTemplateSettings[0]
mono.js:1       The member KnobOnToOffOffset is not implemented in Uno.
mono.js:1 fail: Windows.UI.Xaml.Controls.Primitives.ToggleSwitchTemplateSettings[0]
mono.js:1       The member KnobOffToOnOffset is not implemented in Uno.
mono.js:1 fail: Windows.UI.Xaml.Media.Animation.PointerUpThemeAnimation[0]
mono.js:1       The member void Begin() is not implemented in Uno.

Expected behavior

It should generate events so that the click animation works properly

How to reproduce it (as minimally and precisely as possible)

Checkout https://github.com/paulovila/MaterialDesignInXamlToolkit/tree/AddUnoSupport and open https://github.com/paulovila/MaterialDesignInXamlToolkit/blob/AddUnoSupport/MaterialDesignToolkit.Uwp.sln Affected platform(s):

jeromelaban commented 4 years ago

@dr1rrb Seems like it's Wheels that is not implemented there. Is it in 2.1 ?

@paulovila could you try with the latest dev bits as well ?

paulovila commented 4 years ago

Thanks @jeromelaban these are the package references,

    <PackageReference Include="Uno.UI" Version="2.1.0-dev.679" />
    <PackageReference Include="Uno.UI.RemoteControl" Version="2.1.0-dev.679" Condition="'$(Configuration)'=='Debug'" />
    <PackageReference Include="Uno.Wasm.Bootstrap" Version="1.0.10" />
    <DotNetCliToolReference Include="Uno.Wasm.Bootstrap.Cli" Version="1.0.10" />

the WASM console shows:

fail: Windows.UI.Xaml.UIElement[0]
mono.js:1       The member event PointerEventHandler UIElement.PointerWheelChanged is not implemented in Uno.
mono.js:1 fail: Windows.UI.Xaml.Media.Animation.PointerUpThemeAnimation[0]
mono.js:1       The member PointerUpThemeAnimation.PointerUpThemeAnimation() is not implemented in Uno.
mono.js:1 fail: Windows.UI.Xaml.VisualTransition[0]
mono.js:1       The member Duration VisualTransition.GeneratedDuration is not implemented in Uno.
mono.js:1 fail: Windows.UI.Xaml.Media.Animation.RepositionThemeAnimation[0]
mono.js:1       The member RepositionThemeAnimation.RepositionThemeAnimation() is not implemented in Uno.
mono.js:1 fail: Windows.UI.Xaml.Controls.Primitives.ToggleSwitchTemplateSettings[0]
mono.js:1       The member KnobCurrentToOnOffset is not implemented in Uno.
mono.js:1 fail: Windows.UI.Xaml.Controls.Primitives.ToggleSwitchTemplateSettings[0]
mono.js:1       The member KnobCurrentToOffOffset is not implemented in Uno.
mono.js:1 fail: Windows.UI.Xaml.Controls.Primitives.ToggleSwitchTemplateSettings[0]
mono.js:1       The member KnobOnToOffOffset is not implemented in Uno.
mono.js:1 fail: Windows.UI.Xaml.Controls.Primitives.ToggleSwitchTemplateSettings[0]
mono.js:1       The member KnobOffToOnOffset is not implemented in Uno.
2mono.js:1 The Bindable attribute is missing and the type [Windows.Foundation.Point] is not known by the MetadataProvider. Reflection was used instead of the binding engine and generated static metadata. Add the Bindable attribute to prevent this message and performance issues.
mono.js:1 fail: Windows.UI.Xaml.Media.Animation.PointerUpThemeAnimation[0]
mono.js:1       The member void Begin() is not implemented in Uno.
mono.js:1 GC_MINOR: (Nursery full) time 38.02ms, stw 38.59ms promoted 2619K major size: 9280K in use: 8458K los size: 1024K in use: 80K
mono.js:1 fail: Windows.UI.Xaml.Media.Animation.PointerUpThemeAnimation[0]
mono.js:1       The member void Deactivate() is not implemented in Uno.
dr1rrb commented 4 years ago

No Wheels are still not supported by pointers.

Note that wheel are however supported by the ScrollViewer on Android and WASM.

paulovila commented 4 years ago

I don't know if the wheel is needed as much as it is the basic mouse position and clicking position

dr1rrb commented 4 years ago

Actually I think the issue is not linked to the PointerWheelChanged event. As it's not implemented it won't be fired, but it should not raise any exception.

I think the issue is more linked to the PointerUpThemeAnimation and especially the last lines of the trace, where we try to invoke methods on it:

mono.js:1 fail: Windows.UI.Xaml.Media.Animation.PointerUpThemeAnimation[0]
mono.js:1       The member void *** Begin() *** is not implemented in Uno.
mono.js:1 GC_MINOR: (Nursery full) time 38.02ms, stw 38.59ms promoted 2619K major size: 9280K in use: 8458K los size: 1024K in use: 80K
mono.js:1 fail: Windows.UI.Xaml.Media.Animation.PointerUpThemeAnimation[0]
mono.js:1       The member void *** Deactivate() *** is not implemented in Uno.

I found that you have few of them in your xaml (for instance here and here ).

You should try to comment them out to see if it resolves your issue.

paulovila commented 4 years ago

Even if I remove that in WASM says:

: Windows.UI.Xaml.UIElement[0]
      The member event PointerEventHandler UIElement.PointerWheelChanged is not implemented in Uno.
: Windows.UI.Xaml.VisualTransition[0]
      The member Duration VisualTransition.GeneratedDuration is not implemented in Uno.
: Windows.UI.Xaml.Media.Animation.RepositionThemeAnimation[0]
      The member RepositionThemeAnimation.RepositionThemeAnimation() is not implemented in Uno.
: Windows.UI.Xaml.Controls.Primitives.ToggleSwitchTemplateSettings[0]
      The member KnobCurrentToOnOffset is not implemented in Uno.
: Windows.UI.Xaml.Controls.Primitives.ToggleSwitchTemplateSettings[0]
      The member KnobCurrentToOffOffset is not implemented in Uno.
: Windows.UI.Xaml.Controls.Primitives.ToggleSwitchTemplateSettings[0]
      The member KnobOnToOffOffset is not implemented in Uno.
: Windows.UI.Xaml.Controls.Primitives.ToggleSwitchTemplateSettings[0]
      The member KnobOffToOnOffset is not implemented in Uno.

It would be good to have this implemented because it would have a huge impact in porting projects like Material Design in XALM