TimLariviere / Fabulous-new

Fabulous v2 - Work in progress
https://timothelariviere.com/Fabulous-new/
Other
41 stars 3 forks source link

[Xamarin.Forms] Add wrappers for all controls #53

Closed TimLariviere closed 2 years ago

TimLariviere commented 2 years ago

Would be great to have a control gallery apps to both test out the wrappers and have a sample on how to use them.

Pages:

Layouts:

Controls:

Collections:

Cells:

MenuItems:

GestureRecognizers:

TimLariviere commented 2 years ago

The controls with (?) means I'm not sure if we should wrap them, most of them are rely on DataTemplate

edgarfgp commented 2 years ago

I think would be good to Wrap TemplatedView. So we can have something like https://github.com/jsuarezruiz/TemplateUI . What do you think ?

edgarfgp commented 2 years ago

How do you plan to organise the effort of wrapping this controls ? . We could create the gallery app and then start adding one control per PR + add to the gallery + some screenshot πŸ˜€

edgarfgp commented 2 years ago

I was investigating the possibility to add support for VisualStateManager (https://docs.microsoft.com/en-us/xamarin/xamarin-forms/user-interface/visual-state-manager as a way to control control states and avoid having to create custom renderers.

We already use VisualStateManager in v1 See here https://github.com/fsprojects/Fabulous/blob/8bbb610a2bbfe239e175b8e25ac950d55ebc94f5/Fabulous.XamarinForms/samples/AllControls/AllControls/Samples/Controls/RadioButton.fs#L60 . SoI was wondering if could add some sort of support for it as a extension method πŸ˜€

Unlike #10 I think this is not blocked with the V2 architecture . But I might be wrong

edgarfgp commented 2 years ago

I'm happy to help adding any widgets necessary πŸ˜€

TimLariviere commented 2 years ago

I think would be good to Wrap TemplatedView. So we can have something like https://github.com/jsuarezruiz/TemplateUI . What do you think ?

That would be interesting. Maybe we can keep it for the end so we can better think how to do it?

How do you plan to organise the effort of wrapping this controls ? . We could create the gallery app and then start adding one control per PR + add to the gallery + some screenshot πŸ˜€

Right now, I'm working on making AttributeDefinitions pure so unused attributes will be removed from the compiled code (smaller IPA/APK). It might have a big impact on how widgets are declared. Could you wait a few days before adding new widgets please?

But ideally, we should do like you said:

The important part is to make sure we don't forget any properties.

I was investigating the possibility to add support for VisualStateManager

That would be very interesting too, I don't see any blocker with v2. Not exactly sure how to handle target names though. But if you want to write a POC, I would be happy to discuss it :) Most likely, it will be part of a later release though.

edgarfgp commented 2 years ago

Could you wait a few days before adding new widgets please?

Sure πŸ˜€.

edgarfgp commented 2 years ago

@TimLariviere I have started to implement the Carrousel based on the new virtualized collections . But I notice that on my app I will need to support cell types based on the data. As far I can see CarrouselView only has ItemTemplate and EmptyViewTemplate. . So Was wondering if have any thought on the implementation . ?

Edit: I realised that I can achieve the result that I want by organising the data using a DU to model the types of data while still uses the same item template πŸ˜„

TimLariviere commented 2 years ago

@edgarfgp Internally, Fabulous will change the cell type based on the root control passed in the ItemTemplate like you found. :)

CarouselView(items) (fun item ->
    if item.Name = "Hello" then
        Label("Hello World")
    else
        Button("Click me", Clicked)
)

Here, it will instantiate a Label cell when item.Name = "Hello" and a Button cell for everything else.

edgarfgp commented 2 years ago

@TimLariviere Should we include Behaviour, Triggers and Effects to the list ?

TimLariviere commented 2 years ago

Triggers are closely related to Style, so I think we need to properly think of VisualStateManagers and Styles before. For Behaviors and Effects, absolutely. We can add them.

For Effect, I remember creating a basic one in v1

View.Label(
    effects = [ View.Effect("EffectName") ]
)

Maybe we can add the same one to v2?

TimLariviere commented 2 years ago

Though Effect is not a BindableObject, so no ViewNode no diffing :/

edgarfgp commented 2 years ago

@TimLariviere BoxView can be marked as Done . It was completed as part of https://github.com/TimLariviere/Fabulous-new/pull/73

edgarfgp commented 2 years ago

Grid and StackLayout do not need any update . They are already complete

Grid : https://docs.microsoft.com/en-us/dotnet/api/xamarin.forms.grid?view=xamarin-forms StackLayout : https://docs.microsoft.com/en-us/dotnet/api/xamarin.forms.stacklayout?view=xamarin-forms

TimLariviere commented 2 years ago

Almost 50% done πŸ₯³

edgarfgp commented 2 years ago

@TimLariviere BoxView can be marked as Done . It was completed as part of #73

Same applies for ProgressBar πŸ˜€

edgarfgp commented 2 years ago

@TimLariviere RelativeLayout can set the children position based on the on other views . Could we use ViewRef for this ?

public static Constraint RelativeToView(View view, Func<RelativeLayout, View, double> measure)
{
    var result = new Constraint { _measureFunc = layout => measure(layout, view), RelativeTo = new[] { view } };

    return result;
}

I had a look at V1 and it does not seem to support for this RelativeToView either . I could only see RelativeToParent

edgarfgp commented 2 years ago

@TimLariviere Seems like CarrouselPage has been deprecated in favour of CarrouselView . Not sure if it worth to make a wrapper for this ? .

From Docs :

Important The CarouselPage has been superseded by the CarouselView, which provides a scrollable layout where users can swipe to move through a collection of items. For more information about the CarouselView, see Xamarin.Forms CarouselView.

TimLariviere commented 2 years ago

Oh alright. If it's deprecated then no need to write a wrapper for it

edgarfgp commented 2 years ago

@TimLariviere Regarding OpenGLView > I think most people mow a days uses SkiaSharp . So We could avoid wrapping it and also remove the dependency of OpenTK.Graphics on V2 and implement this in case we have request to do it in the future .

edgarfgp commented 2 years ago

Looks like Maui is not biding it also. https://github.com/dotnet/maui/wiki/Status. I guess the With Shape, Geometries it is ok for now

TimLariviere commented 2 years ago

Yes. I read a few years ago that iOS even dropped support for OpenGL in favor of Metal. Will update the list

edgarfgp commented 2 years ago

126 #129 Should be the last ones to complete the 56 items πŸ˜€.

There are still somethings are not wrapped . Like Effects, Behaviours, VisualStateManagers, TemplatedView , TemplatedPages, StyleWidgets. Would be good to create a separate issue for all them so we can attempt then in the future.

TimLariviere commented 2 years ago

Awesome work @edgarfgp! This brings us very close to a first release for v2 πŸ₯³

Will start to bring everything we did into the main repo