Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow Changing AppShell at runtime #16067

Closed
jrahma opened this issue Jul 10, 2023 · 10 comments
Closed

Allow Changing AppShell at runtime #16067

jrahma opened this issue Jul 10, 2023 · 10 comments
Labels
area-controls-shell Shell Navigation, Routes, Tabs, Flyout proposal/open s/needs-info Issue needs more info from the author

Comments

@jrahma
Copy link

jrahma commented Jul 10, 2023

Description

Please add an option to change the AppShell at runtime

Public API Changes

this is the AppShell:

<?xml version="1.0" encoding="utf-8" ?>
<Shell
    x:Class="Muffin.Mobile.AppShell"
    xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
    xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
    xmlns:local="clr-namespace:Muffin.Mobile"
    Shell.FlyoutBehavior="Disabled">
    <ShellContent
        Title="Home"
        ContentTemplate="{DataTemplate local:MainPage}"
        Route="MainPage" />

    <ShellContent
        Title="Home"
        ContentTemplate="{DataTemplate local:Signin}"
        Route="Signin" />

    <ShellContent
        Title="Home"
        ContentTemplate="{DataTemplate local:OnBoarding}"
        Route="OnBoarding" />
</Shell>

and in App.xaml.cs:

MainPage = new Mobile.AppShell()<MainPage>;

Or:

MainPage = new Mobile.AppShell()<Signin>;

Or

MainPage = new Mobile.AppShell()<OnBoarding>;

Intended Use-Case

Many apps needs to change the MainPage for different scenarios.

@Eilon Eilon added the area-controls-shell Shell Navigation, Routes, Tabs, Flyout label Jul 10, 2023
@Ghostbird
Copy link
Contributor

What's actually stopping you from doing it? Do you get an error? I'm doing it in my app, and it seems to work.

@mattleibow mattleibow added the s/needs-info Issue needs more info from the author label Jul 11, 2023
@ghost
Copy link

ghost commented Jul 11, 2023

Hi @jrahma. We have added the "s/needs-info" label to this issue, which indicates that we have an open question for you before we can take further action. This issue will be closed automatically in 7 days if we do not hear back from you by then - please feel free to re-open it if you come back to this issue after that time.

@jrahma
Copy link
Author

jrahma commented Jul 13, 2023

MainPage = new Mobile.AppShell()<MainPage>;

I tried this but did not work:

App.Current.MainPage = new Mobile.AppShell()<Signup>;

CS0119: 'Signup' is a type, which is not valid in the given context

@ghost ghost added s/needs-attention Issue has more information and needs another look and removed s/needs-info Issue needs more info from the author labels Jul 13, 2023
@Ghostbird
Copy link
Contributor

Ghostbird commented Jul 14, 2023

What do sharp brackets after a value mean? I don't know this syntax.

Did you mean new AppShell<Signup>()?

@jrahma
Copy link
Author

jrahma commented Jul 16, 2023

It means I have different pages that I want them to be my main without having ti use NavigationPage so when the user is already signed in then the AppShell's MainPage is called MainPage or or HomePage and if not then the AppShell's MainPage is called Signin

@Ghostbird
Copy link
Contributor

Don't you have a single AppShell? I don't think you want to change the app shell at all. It seems you just want to navigate.

@jrahma
Copy link
Author

jrahma commented Jul 21, 2023

Let me explain it.

I have the same pages that I need to open like MyProfile and it should be a main page when the user did not complete the profile so when the use is not signed in then the main page is Signin and when the user signed in with incomplete profile then the main page is MyProfile and then they profile is completed then the main page is MainPage

@Ghostbird
Copy link
Contributor

Ghostbird commented Jul 21, 2023

Yes, that sounds like you want to navigate. I think the article I linked will help you.

Note that in all your cases the app's MainPage doesn't change. The MainPage is always the AppShell.

@PureWeen PureWeen added s/needs-info Issue needs more info from the author and removed s/needs-attention Issue has more information and needs another look labels Dec 16, 2023
@ghost
Copy link

ghost commented Dec 16, 2023

Hi @jrahma. We have added the "s/needs-info" label to this issue, which indicates that we have an open question for you before we can take further action. This issue will be closed automatically in 7 days if we do not hear back from you by then - please feel free to re-open it if you come back to this issue after that time.

@ghost ghost added the s/no-recent-activity Issue has had no recent activity label Dec 20, 2023
@ghost
Copy link

ghost commented Dec 20, 2023

This issue has been automatically marked as stale because it has been marked as requiring author feedback but has not had any activity for 4 days. It will be closed if no further activity occurs within 3 days of this comment. If it is closed, feel free to comment when you are able to provide the additional information and we will re-investigate.

@ghost ghost closed this as completed Dec 25, 2023
@github-actions github-actions bot locked and limited conversation to collaborators Jan 24, 2024
@ghost ghost removed the s/no-recent-activity Issue has had no recent activity label Jan 24, 2024
This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-controls-shell Shell Navigation, Routes, Tabs, Flyout proposal/open s/needs-info Issue needs more info from the author
Projects
None yet
Development

No branches or pull requests

5 participants