adospace / reactorui-maui

MauiReactor is a MVU UI framework built on top of .NET MAUI
MIT License
586 stars 49 forks source link

NotSupportedException when using non-reactorui controls #70

Closed JaneySprings closed 1 year ago

JaneySprings commented 1 year ago

Hello. Thank you for this library!

I'm trying to use CommunityToolkit views with Reactor.Maui:

class MainPage : Component<MainPageState> {
    public override VisualNode Render() {
        return new ContentPage {
            new ScrollView {
                new VerticalStackLayout {
                    new Button(State.Counter == 0 ? "Click me" : $"Clicked {State.Counter} times!")
                        .OnClicked(()=>SetState(s => s.Counter++))
                        .HCenter(),
                    new AvatarView {
                        Text = "ZS"
                    }
                }
                .VCenter()
                .Spacing(25)
                .Padding(20, 0)
            }
        };
    }
}

But I have a following exception:

Screenshot 2023-05-01 at 12 53 37

Its also happens when using MAUI controls:

Screenshot 2023-05-01 at 12 57 15

Maybe I need to write some kind of wrapper for these classes? For example:

class ReactorUIAvatarView: CommunityToolkit.AvatarView {
    override...
}
JaneySprings commented 1 year ago

Yep. I tried this:

public class MyControl: View<CommunityToolkit.Maui.Views.AvatarView> {
}

Works fine.

BTW: Thank you for this awesome library!

adospace commented 1 year ago

Yeah, you can't directly put Maui controls under mauireactor elements, you need a wrapper. MauiReactor includes a convenient source generator, please gett a look at this guide: https://adospace.gitbook.io/mauireactor/components/wrap-3rd-party-controls

Said that, I'm probably going to provide a package with all the wrappers for common libraries like the Community toolkit

JaneySprings commented 1 year ago

I think you just need to add this link to the readme. Common libraries are updated very often and you may not keep up with it.

adospace commented 1 year ago

The link to the documentation is present in the readme