adospace / reactorui-maui

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

Menu not showing up #242

Closed Jolvera2001 closed 1 week ago

Jolvera2001 commented 1 week ago

Hi @adospace, I've been really enjoying Reactorui and I'm hoping to make a few small projects with it soon! This is a really great UI framework with a lot of potential so keep up the good work!

I had an issue creating menus within a desktop application. Here is my code:

using MauiReactor;

namespace AudioPlayer.Pages;

class MainPage : Component
{
    public override VisualNode Render()
        => Window(
            ContentPage(
                MenuBarItem(
                    MenuFlyout(
                        MenuFlyoutItem().Text("Some Item")
                    )
                ).Text("Test 1"),   
                Label("Hello World!")
                .HCenter()
                .Padding(20)
            )
        ).Title("Audio Player");
}

Let me know if I'm doing something wrong or if there's some issue with this.

adospace commented 1 week ago

Not at PC right now, but looking at MAUI documentation, you just need MenuBarItem →MenuFlyoutItem/MenuFlyoutSubItem, why are you using the MenuFlyout? Also the window object is not strictly required.

https://learn.microsoft.com/en-us/dotnet/maui/user-interface/menu-bar?view=net-maui-8.0

Jolvera2001 commented 1 week ago

So I simplified it and got this. The menu doesn't show up still, but let me know if I'm still not doing something correctly. I know in the Maui documentation is shows ContentPage -> ContentPage.MenuBarItems and then -> MenuBarItem -> ...

Not sure if the ContentPage.MenuBarItems is just implicitly done since in the Reactorui documentation it shows the flow of MenuBarItem -> MenuFlyoutItem/MenuFlyoutSubItem -> ...

using MauiReactor;

namespace AudioPlayer.Pages;

class MainPage : Component
{
    public override VisualNode Render()
        => ContentPage(
            MenuBarItem(
                MenuFlyoutItem(
                    MenuFlyoutSubItem().Text("Yes")
                ).Text("Flyout Item 1")
            ).Text("Item 1")
        );
}

Also as a heads up, I am using VSCode and its hot reload function for this if it makes any difference.

adospace commented 1 week ago

hum, seems working to me: image

Are you sure you're hosting the ContentPage inside a NavigationPage or Shell? image

Jolvera2001 commented 1 week ago

That's something I missed completely, entirely my fault honestly. I wasn't using a Navigation Page or Shell within the project. I'll make sure to read the documentation instead of skimming it from now on though so thank you! It's working as intended now

adospace commented 1 week ago

no problem, you're welcome