Home > front end >  Tabs showing on Login Page in Xamarin Forms app
Tabs showing on Login Page in Xamarin Forms app

Time:04-14

I have a Xamarin Forms app that uses Shell and the home page of the app happens to have tabs defined in the Shell -- see below:

<FlyoutItem Title="Home">
   <FlyoutItem.Icon>
       <FontImageSource
           FontFamily="MISHRP"
           Glyph="{StaticResource HomeIcon}"
           Color="White" />
   </FlyoutItem.Icon>
   <Tab Title="My Feed">
      <ShellContent Route="MyFeed" ContentTemplate="{DataTemplate views:MyFeedFeed}"/>
   </Tab>
   <Tab Title="Card">
      <ShellContent Route="PersonalCard" ContentTemplate="{DataTemplate views:PersonalCard}"/>
   </Tab>
   <Tab Title="Cart">
      <ShellContent Route="Cart" ContentTemplate="{DataTemplate views:Cart}"/>
   </Tab>
</FlyoutItem>

In the OnStart() method of App.xaml.cs, I check to see if the user is authenticated and if not, I send user to a separate Login page with the following code:

protected override async void OnStart()
{
    // Check to see if token has expired or missing
    var tokenExpiration = await SecureStorage.GetAsync("token_expiration");
    if(tokenExpiration == null)
        await Shell.Current.GoToAsync(nameof(LoginPage));

    // Some more logic here...
}

This works fine but when I get to the Login page, I see the tabs defined in Shell.

I already use Shell.NavBarIsVisible="False" on Login page which successfully hides the nav bar but NOT the tabs.

How do I make sure no tabs will be visible on Login page?

CodePudding user response:

All I had to do was add Shell.TabBarIsVisible="False" to the Login XAML. See below:

<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             x:Class="MyApp.Views.LoginPage"
             Shell.NavBarIsVisible="False"
             Shell.TabBarIsVisible="False">
  • Related