adospace / reactorui-maui

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

drag & drop question #91

Closed dstanchev closed 1 year ago

dstanchev commented 1 year ago

Hello Ado, how can I use drag & drop with reactor-maui? I can find DragGestureRecognizer but not DropGestureRecognizer, DropEventArgs , AllowDrop and DragOver/DragLeave . Is there any examples, cannot find any in sample apps. This is my test example and drop event is not triggered.

internal class MainPage : Component<MainPageState>
{

    public override VisualNode Render()
    {
        return new ContentPage
        {
            new Grid("*,*,Auto", "*")
            {
                // Drop location
                new BoxView()
                    .HeightRequest(60)
                    .HorizontalOptions(MC.LayoutOptions.Fill)
                    .VerticalOptions(MC.LayoutOptions.Start),

                // Dragged item
                new BoxView()
                    .WidthRequest(40)
                    .HeightRequest(40)
                    .HorizontalOptions(MC.LayoutOptions.Center)
                    .VerticalOptions(MC.LayoutOptions.Center)
                    .GridRow(1)
                    .OnDropCompleted(OnDrop)
                    .OnDragStarting(OnDragStart),

                new Label("items droped:" + State.Counter)
                    .GridRow(2)
                    .HorizontalTextAlignment(TextAlignment.Center)
                    .FontSize(18)
            }
        };
    }

    private void OnDragStart() { }

    private void OnDrop() => SetState(_ => _.Counter++);
}

Thank you for your attention.

adospace commented 1 year ago

Sorry for the late reply, I'll be able to look at this issue in a few days, thank you for your patience

adospace commented 1 year ago

I've added a showcase page for the drag & drop feature: https://github.com/adospace/reactorui-maui/blob/main/samples/MauiReactor.TestApp/Pages/DragDropTestPage.cs (Working in 1.0.132)