--- /dev/null
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.Text;
+using Xamarin.Forms.CustomAttributes;
+using Xamarin.Forms.Internals;
+
+
+#if UITEST
+using Xamarin.UITest;
+using NUnit.Framework;
+using Xamarin.Forms.Core.UITests;
+#endif
+
+namespace Xamarin.Forms.Controls.Issues
+{
+ [Preserve(AllMembers = true)]
+ [Issue(IssueTracker.Github, 6362, "[iOS] Shell GoToAsync doesn't update selected tab to bold",
+ PlatformAffected.iOS)]
+#if UITEST
+ [NUnit.Framework.Category(UITestCategories.Shell)]
+#endif
+ public class Issue6362 : TestShell
+ {
+ protected override void Init()
+ {
+ Shell.SetFlyoutBehavior(this, FlyoutBehavior.Disabled);
+ AddTopTab(
+ new ContentPage()
+ {
+ Content = new StackLayout()
+ {
+ Children =
+ {
+ new Label()
+ {
+ Text = "Click between tabs and make sure the tab colors change"
+ },
+ new Button()
+ {
+ Text = "Go to tab 2 and make sure tab colors change",
+ Command = new Command(()=>
+ {
+ GoToAsync(@"\\\Second");
+ })
+ }
+ }
+ }
+ },
+ "First");
+
+ AddTopTab("Second");
+ }
+ }
+}
return;
}
- Items[0].Items[0].Items.Add(new ShellContent()
+ var content = new ShellContent()
{
Title = title ?? page.Title,
Content = page
- });
+ };
+
+ Items[0].Items[0].Items.Add(content);
+
+ if (!String.IsNullOrWhiteSpace(content.Title))
+ content.Route = content.Title;
}
public ContentPage AddBottomTab(string title)
headerCell.Label.Text = shellContent.Title;
headerCell.Label.SetNeedsDisplay();
+ headerCell.SelectedColor = _selectedColor.ToUIColor();
+ headerCell.UnSelectedColor = _unselectedColor.ToUIColor();
+
if (selectedItems.Length > 0 && selectedItems[0].Row == indexPath.Row)
- headerCell.Label.TextColor = _selectedColor.ToUIColor();
+ headerCell.Selected = true;
else
- headerCell.Label.TextColor = _unselectedColor.ToUIColor();
+ headerCell.Selected = false;
return headerCell;
}
public override void ItemDeselected(UICollectionView collectionView, NSIndexPath indexPath)
{
- var cell = (ShellSectionHeaderCell)CollectionView.CellForItem(indexPath);
- cell.Label.TextColor = _unselectedColor.ToUIColor();
}
public override void ItemSelected(UICollectionView collectionView, NSIndexPath indexPath)
{
var row = indexPath.Row;
-
var item = ShellSection.Items[row];
-
if (item != ShellSection.CurrentItem)
ShellSection.SetValueFromRenderer(ShellSection.CurrentItemProperty, item);
-
- var cell = (ShellSectionHeaderCell)CollectionView.CellForItem(indexPath);
- cell.Label.TextColor = _selectedColor.ToUIColor();
}
public override nint NumberOfSections(UICollectionView collectionView)
public class ShellSectionHeaderCell : UICollectionViewCell
{
+ public UIColor SelectedColor { get; set; }
+ public UIColor UnSelectedColor { get; set; }
+
+ public override bool Selected
+ {
+ get => base.Selected;
+ set
+ {
+ base.Selected = value;
+ Label.TextColor = value ? SelectedColor : UnSelectedColor;
+ }
+ }
+
[Export("initWithFrame:")]
public ShellSectionHeaderCell(CGRect frame) : base(frame)
{