void addNewTab(string title, string icon, ContentPage page, bool createNewTabBar = false)
{
var shell = Application.Current.MainPage as AppShell;
if (shell == null) return;
if (createNewTabBar || shell.Items.Count == 0)
{
// Создаем новый TabBar с одной вкладкой
shell.Items.Clear();
var tabBars = new TabBar();
shell.Items.Add(tabBars);
}
if (shell.Items[0] is TabBar tabBar)
{
var newTab = new Tab
{
Title = title,
Icon = icon,
Items = { new ShellContent { ContentTemplate = new DataTemplate(() => page) } }
};
tabBar.Items.Add(newTab);
}
}