MajMcCloud / TelegramBotFramework

This is a context based application framework for the C# TelegramBot library.
https://www.t.me/tgbotbase
MIT License
149 stars 43 forks source link

How can i use NavigationController #38

Closed bretbas closed 1 year ago

bretbas commented 1 year ago

How can i use it? I set NavigationController property in my StartForm in Init event handler: NavigationController = new NavigationController(this); Then in some case i invoke transition:

var form1 = new SetFiltersForm();
await NavigationController.PushAsync(form1);

and nothing changes...

Because in PushAsync method we have a strange condition:

            if (Index < 2)
                return;
MajMcCloud commented 1 year ago

Please check the ReadMe as well for this purpose. Did you navigated to the Controller? Probably not, but you have to. Please check the ReadMe.

bretbas commented 1 year ago

But i have already read ReadMe. photo_2023-01-20_12-43-14

And i didn't understand, how can i use it when my StartForm have to start navigation

bretbas commented 1 year ago

Did you navigated to the Controller

Yes, i tried to navigate to the NavigationController in my Init event handler of StartForm. And i got a recursion

MajMcCloud commented 1 year ago

Navigation should only be done within the Load, Action or Render method. Cause there is stuff to get prepared before you can Navigate.

When having a StartForm just put the navigation to the NavigationController into the Load method, should be fine.

bretbas commented 1 year ago

I tried to set navigation in the Load and Render method, but i got recursion:

    public override async Task Load(MessageResult message)
    {
        NavigationController = new NavigationController(this);
        await NavigateTo(NavigationController);
    }
MajMcCloud commented 1 year ago

Please provide more source to get a better feeling of what you are trying to do. If its "private" stuff, you can send it to me via mail to contact@dahn.partners I will then just publish the "solution", nothing more.

bretbas commented 1 year ago

Everything is simple. I'm trying to find at least some normal documentation for your library, but I can't. And many things are not obvious.

As i said before, i have a StartForm. In StartForm, as you replied me, i tried to add Load method (i tried Render as well, but it didn't work with and with it). In Load method i setup my NavigationController like this:

    public override async Task Load(MessageResult message)
    {
        NavigationController = new NavigationController(this);
        await NavigateTo(NavigationController);
    }

but i got recursion.

bretbas commented 1 year ago

In your documentation written:

First, you need to create a NavigationController instance at the same position in code, where you want to start the navigation.

So, I want to use navigation in StartForm, that navigate to other form. How can i do that? Have you a little bit more explanation?

MajMcCloud commented 1 year ago

There is no explanation needed, if you read the docs. you have to Push a new form onto the controller stack during navigation.