BurkusCat / Burkus.Mvvm.Maui

A simple MVVM framework for .NET MAUI. It provides: navigation, lifecycle events, parameter passing, native dialog abstractions, and testability.
MIT License
24 stars 5 forks source link

[Feature] Navigating to a Shell Page and Performing Async Operations in ShellContent #63

Open exendahal opened 1 week ago

exendahal commented 1 week ago

I have a Shell Page with several ShellContent items. Here is the code for the Shell Page:

<TabBar>
    <Tab Title="Explore">
        <Tab.Icon>
            <FontImageSource FontFamily="MaterialIcon" Glyph="&#xf56e;" />
        </Tab.Icon>
        <ShellContent ContentTemplate="{DataTemplate views:HomePageView}" />
    </Tab>
    <Tab Title="Cart">
        <Tab.Icon>
            <FontImageSource FontFamily="MaterialIcon" Glyph="&#xf110;" />
        </Tab.Icon>
        <ShellContent ContentTemplate="{DataTemplate views:CartView}" />
    </Tab>
    <Tab Title="Account">
        <Tab.Icon>
            <FontImageSource FontFamily="MaterialIcon" Glyph="&#xf004;" />
        </Tab.Icon>
        <ShellContent ContentTemplate="{DataTemplate views:ProfileView}" />
    </Tab>
</TabBar>

To navigate to the Shell Page, I use the following method:

 await navigationService.Push<AppShell>();

Requirement:

I need to perform some asynchronous operations in the OnNavigatedTo() method of each ShellContent. How can I achieve this functionality?

BurkusCat commented 6 days ago

My initial gut feel is that you shouldn't be using Shell at all with Burkus.Mvvm.Maui. This library should be used instead of Shell. So I think in your case you'd want to use a TabbedPage (instead of a TabBar) like so: https://github.com/BurkusCat/Burkus.Mvvm.Maui/blob/main/samples/DemoApp/Views/Tabs/DemoTabsPage.xaml

Are you able to try the sample app the in the repo (https://github.com/BurkusCat/Burkus.Mvvm.Maui?tab=readme-ov-file#documentation-) to see if it does what you what it to do when it comes to tabs?