xamarin / Xamarin.Forms

Xamarin.Forms is no longer supported. Migrate your apps to .NET MAUI.
https://aka.ms/xamarin-upgrade
Other
5.62k stars 1.87k forks source link

How to limit the number of tabs to show at the bottom tab bar in shell in Android and iOS #15764

Closed Priyabaghelgithub closed 1 year ago

Priyabaghelgithub commented 1 year ago
<!-- <FlyoutItem FlyoutDisplayOptions="AsMultipleItems"
        <Tab Title="Browse" Icon="tab_feed.png">
            <ShellContent ContentTemplate="{DataTemplate local:ItemsPage}" />
        </Tab>
        <Tab Title="About" Icon="tab_about.png">
            <ShellContent ContentTemplate="{DataTemplate local:AboutPage}" />
        </Tab> 
<Tab Title="Browse1" Icon="tab_feed.png">
            <ShellContent ContentTemplate="{DataTemplate local:ItemsPage}" />
        </Tab>
        <Tab Title="About2" Icon="tab_about.png">
            <ShellContent ContentTemplate="{DataTemplate local:AboutPage}" />
        </Tab> 
<Tab Title="Browse3" Icon="tab_feed.png">
            <ShellContent ContentTemplate="{DataTemplate local:ItemsPage}" />
        </Tab>
        <Tab Title="About4" Icon="tab_about.png">
            <ShellContent ContentTemplate="{DataTemplate local:AboutPage}" />
        </Tab> 
<FlyoutItem /> 
 -->

want 8 tabs in the flyout menu only inside this and just want to 4tabs in the bottom tab bar how I limit the bottom tabbar to show only 4tabs in shell How to hide "More" option that include additional tabs in bottom she'll tabbar in Xamarin form for both Android and iOs

InShot_20230610_191127296_1

Gerald Versluis #James Mogamento

@jfversluis @jamesmontemagno

jfversluis commented 1 year ago

If you don't want them in the tab bar then you probably shouldn't add them as a tab. Please refer to the documentation of Shell on how to use the different options: https://learn.microsoft.com/xamarin/xamarin-forms/app-fundamentals/shell/

Priyabaghelgithub commented 1 year ago

@jfversluis Can you suggest how to hide/Remove the "More" option from tha shell tab bar in iOS using shell renderer

`public class CustomShellRenderer : ShellRenderer

{

protected override IShellTabBarAppearanceTracker CreateTabBarAppearanceTracker() { return new CustomTabBarAppearanceTracker();

}

}

public class CustomTabBarAppearanceTracker : IShellTabBarAppearanceTracker

{ public void SetAppearance(UITabBarController controller, ShellAppearance appearance)

{ try

{
            var count = controller.ViewControllers;

var len = controller.ViewControllers.Length;

 if (controller != null && controller.ViewControllers != null && controller.ViewControllers.Length > 4)

  {
                var items = controller.ViewControllers;

          var itemsToRemove = items.Skip(4).ToArray();

    foreach (var item in itemsToRemove)

   {

   var tabBarItem = item.TabBarItem;

           tabBarItem.Enabled = false;

   }

    }

 }

catch (Exception ex)

   {

 Console.WriteLine("Ios ERROR" + ex.ToString());

   }

}

public void Dispose() { }

  public void ResetAppearance(UITabBarController controller) { }

public void UpdateLayout(UITabBarController controller) { }

} ` I have implemented this but ViewController.TabBarItem is taking null here

Priyabaghelgithub commented 1 year ago

@jfversluis @jamesmontemagno
How do I hide the tabs more than 4 tabs in shell tabbar but keep them all item(8) in the flyout?

Priyabaghelgithub commented 1 year ago

@jfversluis suggest how to hide/remove the more option from bottom she'll tab bar in iOS