adospace / reactorui-maui

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

TabbedPage display empty #88

Closed chaoyebugao closed 1 year ago

chaoyebugao commented 1 year ago

Problem:

I want a TabbedPage with login and register tabs. But nothing show up In Windows Machine when I navigated to it. I don't know what's wrong.

Steps to reproduce:

  1. Add new project with MauiReactor base app
  2. Add new LoginTabbedPage add navigate code to it
  3. Start project with Windows Machine and click MainPage's button, navigate to it

Relative Codes:

// MainPage button click method
private void HandleClick()
{
    SetState(s => s.Counter++);

    //var navTask = Navigation.PushAsync<LoginPage>();
    //navTask.ContinueWith(t =>
    //{
    //});

    var navTask = Navigation.PushAsync<LoginTabbedPage>();
    navTask.ContinueWith(t =>
    {
    });
}
// This page no content show up
internal class LoginTabbedPage : Component
{
    public override VisualNode Render()
    {
        return new TabbedPage()
        {
            //new LoginPage(),
            //new RegisterPage(),

            new ContentPage()
            {
                new Label("Label 1"),
            },
            new ContentPage()
            {
                new Label("Label 2"),
            },
        };
    }
}

Solution Codes:

MauiReactorTabbedDemo.zip

Versions:

windows 11 - 22H2 Visual Studio 2022 - 17.6.2

BTW:

There is some wrong generated code with MauiReactor base app template tool:

// Generated with new project
// app.SetWindowsSpecificAssetsDirectory("Assets");
// Actual method
app.SetWindowsSpecificAssectDirectory("Assets");
adospace commented 1 year ago

Hi, the MauiReactorTabbedDemo.zip is empty. Regarding the last question if you upgrade to latest version of MauiReactor you'll find the correct name of the method that is : SetWindowsSpecificAssetsDirectory (previous one had a typo)

chaoyebugao commented 1 year ago

Hi, the MauiReactorTabbedDemo.zip is empty. Regarding the last question if you upgrade to latest version of MauiReactor you'll find the correct name of the method that is : SetWindowsSpecificAssetsDirectory (previous one had a typo)

I added a repo git here: https://github.com/chaoyebugao/MauiReactorTabbedDemo.git

I've downloaded and opened the zip file. It's not empty, huh, weird~ image

adospace commented 1 year ago

Ok, yes, I see the project now in the zip (don't ask me why :) ).

The issue is that you have to set the title of the child pages to see them (it's a MAUI thing I guess):

return new TabbedPage()
{
    //new LoginPage(),
    //new RegisterPage(),

    new ContentPage("Page1")
    {
        new Label("Label 1"),
    },
    new ContentPage("Page 2")
    {
        new Label("Label 2"),
    },
};

said that please note that Microsoft doesn't recommend putting a tabbed page inside a navigation page: image

it's not recommended but it works.

Another possible solution would be creating your TabbedView as I did here: https://github.com/adospace/reactorui-maui/blob/main/samples/MauiReactor.TestApp/Pages/LandscapePage.cs

PS: Always update to the latest version of MauiReactor

chaoyebugao commented 1 year ago

Huh~ Thanks for the tip. I've updated nugets and It worked! Thanks a lot~