Remove experimental flag for shell and change a few apis (#6086) fixes #2415

* api changes for shell official

* Update Xamarin.Forms.Core/Shell/Shell.cs

Co-Authored-By: PureWeen <shane94@hotmail.com>

* Update Xamarin.Forms.Core/Shell/ShellItemCollection.cs

Co-Authored-By: PureWeen <shane94@hotmail.com>

* Update Xamarin.Forms.Core/Shell/ShellSection.cs

Co-Authored-By: PureWeen <shane94@hotmail.com>

* Update Xamarin.Forms.Core/Shell/ShellItem.cs

Co-Authored-By: PureWeen <shane94@hotmail.com>

* fix compile errors

* fix ui test

* fix ui test

* removed some more properties

* remove a couple more
This commit is contained in:
Shane Neuville 2019-05-09 14:18:04 -07:00 коммит произвёл Rui Marinho
Родитель 5210d5c1e6
Коммит 03e9a9fe43
19 изменённых файлов: 105 добавлений и 147 удалений

Просмотреть файл

@ -574,7 +574,7 @@ namespace Xamarin.Forms.Controls
protected virtual bool Isolate => true; protected virtual bool Isolate => true;
#endif #endif
protected TestShell() : base(false) protected TestShell() : base()
{ {
#if APP #if APP
Init(); Init();

Просмотреть файл

@ -6,27 +6,27 @@
x:Class="Xamarin.Forms.Controls.XamStore.StoreShell"> x:Class="Xamarin.Forms.Controls.XamStore.StoreShell">
<Shell.Resources> <Shell.Resources>
<Style x:Key="BaseStyle" TargetType="Element"> <Style x:Key="BaseStyle" TargetType="Element">
<Setter Property="Shell.ShellBackgroundColor" Value="#455A64" /> <Setter Property="Shell.BackgroundColor" Value="#455A64" />
<Setter Property="Shell.ShellForegroundColor" Value="White" /> <Setter Property="Shell.ForegroundColor" Value="White" />
<Setter Property="Shell.ShellTitleColor" Value="White" /> <Setter Property="Shell.TitleColor" Value="White" />
<Setter Property="Shell.ShellDisabledColor" Value="#B4FFFFFF" /> <Setter Property="Shell.DisabledColor" Value="#B4FFFFFF" />
<Setter Property="Shell.ShellUnselectedColor" Value="#95FFFFFF" /> <Setter Property="Shell.UnselectedColor" Value="#95FFFFFF" />
</Style> </Style>
<Style TargetType="ShellItem" BasedOn="{StaticResource BaseStyle}" /> <Style TargetType="ShellItem" BasedOn="{StaticResource BaseStyle}" />
<Style x:Key="GreenShell" TargetType="Element" BasedOn="{StaticResource BaseStyle}"> <Style x:Key="GreenShell" TargetType="Element" BasedOn="{StaticResource BaseStyle}">
<Setter Property="Shell.ShellBackgroundColor" Value="#689F39" /> <Setter Property="Shell.BackgroundColor" Value="#689F39" />
</Style> </Style>
<Style x:Key="MusicShell" TargetType="Element" BasedOn="{StaticResource BaseStyle}"> <Style x:Key="MusicShell" TargetType="Element" BasedOn="{StaticResource BaseStyle}">
<Setter Property="Shell.ShellBackgroundColor" Value="#EF6C00" /> <Setter Property="Shell.BackgroundColor" Value="#EF6C00" />
</Style> </Style>
<Style x:Key="MoviesShell" TargetType="Element" BasedOn="{StaticResource BaseStyle}"> <Style x:Key="MoviesShell" TargetType="Element" BasedOn="{StaticResource BaseStyle}">
<Setter Property="Shell.ShellBackgroundColor" Value="#ED3B3B" /> <Setter Property="Shell.BackgroundColor" Value="#ED3B3B" />
</Style> </Style>
<Style x:Key="BooksShell" TargetType="Element" BasedOn="{StaticResource BaseStyle}"> <Style x:Key="BooksShell" TargetType="Element" BasedOn="{StaticResource BaseStyle}">
<Setter Property="Shell.ShellBackgroundColor" Value="#039BE6" /> <Setter Property="Shell.BackgroundColor" Value="#039BE6" />
</Style> </Style>
<Style x:Key="NewsShell" TargetType="Element" BasedOn="{StaticResource BaseStyle}"> <Style x:Key="NewsShell" TargetType="Element" BasedOn="{StaticResource BaseStyle}">
<Setter Property="Shell.ShellBackgroundColor" Value="#546DFE" /> <Setter Property="Shell.BackgroundColor" Value="#546DFE" />
</Style> </Style>
</Shell.Resources> </Shell.Resources>

Просмотреть файл

@ -1,4 +1,4 @@
<?xml version="1.0" encoding="UTF-8" ?> <?xml version="1.0" encoding="UTF-8" ?>
<?xaml-comp compile="true" ?> <?xaml-comp compile="true" ?>
<ResourceDictionary xmlns="http://xamarin.com/schemas/2014/forms" <ResourceDictionary xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:converters="clr-namespace:ConferenceVision.Converters" xmlns:converters="clr-namespace:ConferenceVision.Converters"
@ -60,11 +60,11 @@
<!-- Shell Styles --> <!-- Shell Styles -->
<Style x:Key="BaseStyle" TargetType="Element"> <Style x:Key="BaseStyle" TargetType="Element">
<Setter Property="Shell.ShellBackgroundColor" Value="#11313F" /> <Setter Property="Shell.BackgroundColor" Value="#11313F" />
<Setter Property="Shell.FlyoutBackgroundColor" Value="#11313F" /> <Setter Property="Shell.FlyoutBackgroundColor" Value="#11313F" />
<Setter Property="Shell.ShellForegroundColor" Value="White" /> <Setter Property="Shell.ForegroundColor" Value="White" />
<Setter Property="Shell.ShellTitleColor" Value="White" /> <Setter Property="Shell.TitleColor" Value="White" />
<Setter Property="Shell.ShellDisabledColor" Value="#B4FFFFFF" /> <Setter Property="Shell.DisabledColor" Value="#B4FFFFFF" />
<Setter Property="Shell.ShellUnselectedColor" Value="#95FFFFFF" /> <Setter Property="Shell.UnselectedColor" Value="#95FFFFFF" />
</Style> </Style>
</ResourceDictionary> </ResourceDictionary>

Просмотреть файл

@ -20,7 +20,7 @@ namespace Xamarin.Forms.Controls.XamStore
public BasePage(string title, Color tint) public BasePage(string title, Color tint)
{ {
Title = title; Title = title;
Shell.SetShellForegroundColor(this, tint); Shell.SetForegroundColor(this, tint);
var grid = new Grid() var grid = new Grid()
{ {
Padding = 20, Padding = 20,
@ -223,7 +223,7 @@ namespace Xamarin.Forms.Controls.XamStore
grid.Children.Add(MakeButton("Go Back with Text", grid.Children.Add(MakeButton("Go Back with Text",
async () => { async () => {
var page = (Page)Activator.CreateInstance(GetType()); var page = (Page)Activator.CreateInstance(GetType());
Shell.SetShellForegroundColor(page, Color.Pink); Shell.SetForegroundColor(page, Color.Pink);
Shell.SetBackButtonBehavior(page, new BackButtonBehavior() Shell.SetBackButtonBehavior(page, new BackButtonBehavior()
{ {
//IconOverride = "calculator.png", //IconOverride = "calculator.png",

Просмотреть файл

@ -532,8 +532,6 @@ namespace Xamarin.Forms.Core.UnitTests
[SetUp] [SetUp]
public override void Setup() public override void Setup()
{ {
Device.SetFlags(new List<string> { ExperimentalFlags.ShellExperimental });
base.Setup(); base.Setup();
Device.PlatformServices = new MockPlatformServices(); Device.PlatformServices = new MockPlatformServices();
} }

Просмотреть файл

@ -12,7 +12,6 @@ namespace Xamarin.Forms.Core.UnitTests
[SetUp] [SetUp]
public override void Setup() public override void Setup()
{ {
Device.SetFlags(new[] { Shell.ShellExperimental });
base.Setup(); base.Setup();
} }

Просмотреть файл

@ -48,7 +48,7 @@ namespace Xamarin.Forms.Core.UnitTests
NavigationProxy proxy = page.NavigationProxy.Inner as NavigationProxy; NavigationProxy proxy = page.NavigationProxy.Inner as NavigationProxy;
Assert.IsNotNull(proxy); Assert.IsNotNull(proxy);
NavigationProxy shellProxy = proxy.Inner as ShellSection.NavigationImpl; var shellProxy = proxy.Inner;
Assert.IsNotNull(shellProxy); Assert.IsNotNull(shellProxy);
} }

Просмотреть файл

@ -12,7 +12,6 @@ namespace Xamarin.Forms.Core.UnitTests
[SetUp] [SetUp]
public override void Setup() public override void Setup()
{ {
Device.SetFlags(new List<string> { ExperimentalFlags.ShellExperimental });
base.Setup(); base.Setup();
var mockDeviceInfo = new TestDeviceInfo(); var mockDeviceInfo = new TestDeviceInfo();
Device.Info = mockDeviceInfo; Device.Info = mockDeviceInfo;

Просмотреть файл

@ -10,7 +10,6 @@ namespace Xamarin.Forms
internal static class ExperimentalFlags internal static class ExperimentalFlags
{ {
internal const string CollectionViewExperimental = "CollectionView_Experimental"; internal const string CollectionViewExperimental = "CollectionView_Experimental";
internal const string ShellExperimental = "Shell_Experimental";
[EditorBrowsable(EditorBrowsableState.Never)] [EditorBrowsable(EditorBrowsableState.Never)]
public static void VerifyFlagEnabled( public static void VerifyFlagEnabled(

Просмотреть файл

@ -115,13 +115,13 @@ using Xamarin.Forms.StyleSheets;
//shell //shell
[assembly: StyleProperty("-xf-flyout-background", typeof(Shell), nameof(Shell.FlyoutBackgroundColorProperty))] [assembly: StyleProperty("-xf-flyout-background", typeof(Shell), nameof(Shell.FlyoutBackgroundColorProperty))]
[assembly: StyleProperty("-xf-shell-background", typeof(Element), nameof(Shell.ShellBackgroundColorProperty), PropertyOwnerType = typeof(Shell))] [assembly: StyleProperty("-xf-shell-background", typeof(Element), nameof(Shell.BackgroundColorProperty), PropertyOwnerType = typeof(Shell))]
[assembly: StyleProperty("-xf-shell-disabled", typeof(Element), nameof(Shell.ShellDisabledColorProperty), PropertyOwnerType = typeof(Shell))] [assembly: StyleProperty("-xf-shell-disabled", typeof(Element), nameof(Shell.DisabledColorProperty), PropertyOwnerType = typeof(Shell))]
[assembly: StyleProperty("-xf-shell-foreground", typeof(Element), nameof(Shell.ShellForegroundColorProperty), PropertyOwnerType = typeof(Shell))] [assembly: StyleProperty("-xf-shell-foreground", typeof(Element), nameof(Shell.ForegroundColorProperty), PropertyOwnerType = typeof(Shell))]
[assembly: StyleProperty("-xf-shell-tabbar-background", typeof(Element), nameof(Shell.ShellTabBarBackgroundColorProperty), PropertyOwnerType = typeof(Shell))] [assembly: StyleProperty("-xf-shell-tabbar-background", typeof(Element), nameof(Shell.TabBarBackgroundColorProperty), PropertyOwnerType = typeof(Shell))]
[assembly: StyleProperty("-xf-shell-tabbar-disabled", typeof(Element), nameof(Shell.ShellTabBarDisabledColorProperty), PropertyOwnerType = typeof(Shell))] [assembly: StyleProperty("-xf-shell-tabbar-disabled", typeof(Element), nameof(Shell.TabBarDisabledColorProperty), PropertyOwnerType = typeof(Shell))]
[assembly: StyleProperty("-xf-shell-tabbar-foreground", typeof(Element), nameof(Shell.ShellTabBarForegroundColorProperty), PropertyOwnerType = typeof(Shell))] [assembly: StyleProperty("-xf-shell-tabbar-foreground", typeof(Element), nameof(Shell.TabBarForegroundColorProperty), PropertyOwnerType = typeof(Shell))]
[assembly: StyleProperty("-xf-shell-tabbar-title", typeof(Element), nameof(Shell.ShellTabBarTitleColorProperty), PropertyOwnerType = typeof(Shell))] [assembly: StyleProperty("-xf-shell-tabbar-title", typeof(Element), nameof(Shell.TabBarTitleColorProperty), PropertyOwnerType = typeof(Shell))]
[assembly: StyleProperty("-xf-shell-tabbar-unselected", typeof(Element), nameof(Shell.ShellTabBarUnselectedColorProperty), PropertyOwnerType = typeof(Shell))] [assembly: StyleProperty("-xf-shell-tabbar-unselected", typeof(Element), nameof(Shell.TabBarUnselectedColorProperty), PropertyOwnerType = typeof(Shell))]
[assembly: StyleProperty("-xf-shell-title", typeof(Element), nameof(Shell.ShellTitleColorProperty), PropertyOwnerType = typeof(Shell))] [assembly: StyleProperty("-xf-shell-title", typeof(Element), nameof(Shell.TitleColorProperty), PropertyOwnerType = typeof(Shell))]
[assembly: StyleProperty("-xf-shell-unselected", typeof(Element), nameof(Shell.ShellUnselectedColorProperty), PropertyOwnerType = typeof(Shell))] [assembly: StyleProperty("-xf-shell-unselected", typeof(Element), nameof(Shell.UnselectedColorProperty), PropertyOwnerType = typeof(Shell))]

Просмотреть файл

@ -1,13 +1,8 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Collections.Specialized; using System.Collections.Specialized;
using System.ComponentModel;
using System.Diagnostics;
using System.Linq; using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Text; using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks; using System.Threading.Tasks;
using Xamarin.Forms.Internals; using Xamarin.Forms.Internals;
@ -83,77 +78,77 @@ namespace Xamarin.Forms
} }
} }
public static readonly BindableProperty ShellBackgroundColorProperty = public static readonly new BindableProperty BackgroundColorProperty =
BindableProperty.CreateAttached("ShellBackgroundColor", typeof(Color), typeof(Shell), Color.Default, BindableProperty.CreateAttached("BackgroundColor", typeof(Color), typeof(Shell), Color.Default,
propertyChanged: OnShellColorValueChanged); propertyChanged: OnColorValueChanged);
public static readonly BindableProperty ShellDisabledColorProperty = public static readonly BindableProperty DisabledColorProperty =
BindableProperty.CreateAttached("ShellDisabledColor", typeof(Color), typeof(Shell), Color.Default, BindableProperty.CreateAttached("DisabledColor", typeof(Color), typeof(Shell), Color.Default,
propertyChanged: OnShellColorValueChanged); propertyChanged: OnColorValueChanged);
public static readonly BindableProperty ShellForegroundColorProperty = public static readonly BindableProperty ForegroundColorProperty =
BindableProperty.CreateAttached("ShellForegroundColor", typeof(Color), typeof(Shell), Color.Default, BindableProperty.CreateAttached("ForegroundColor", typeof(Color), typeof(Shell), Color.Default,
propertyChanged: OnShellColorValueChanged); propertyChanged: OnColorValueChanged);
public static readonly BindableProperty ShellTabBarBackgroundColorProperty = public static readonly BindableProperty TabBarBackgroundColorProperty =
BindableProperty.CreateAttached("ShellTabBarBackgroundColor", typeof(Color), typeof(Shell), Color.Default, BindableProperty.CreateAttached("TabBarBackgroundColor", typeof(Color), typeof(Shell), Color.Default,
propertyChanged: OnShellColorValueChanged); propertyChanged: OnColorValueChanged);
public static readonly BindableProperty ShellTabBarDisabledColorProperty = public static readonly BindableProperty TabBarDisabledColorProperty =
BindableProperty.CreateAttached("ShellTabBarDisabledColor", typeof(Color), typeof(Shell), Color.Default, BindableProperty.CreateAttached("TabBarDisabledColor", typeof(Color), typeof(Shell), Color.Default,
propertyChanged: OnShellColorValueChanged); propertyChanged: OnColorValueChanged);
public static readonly BindableProperty ShellTabBarForegroundColorProperty = public static readonly BindableProperty TabBarForegroundColorProperty =
BindableProperty.CreateAttached("ShellTabBarForegroundColor", typeof(Color), typeof(Shell), Color.Default, BindableProperty.CreateAttached("TabBarForegroundColor", typeof(Color), typeof(Shell), Color.Default,
propertyChanged: OnShellColorValueChanged); propertyChanged: OnColorValueChanged);
public static readonly BindableProperty ShellTabBarTitleColorProperty = public static readonly BindableProperty TabBarTitleColorProperty =
BindableProperty.CreateAttached("ShellTabBarTitleColor", typeof(Color), typeof(Shell), Color.Default, BindableProperty.CreateAttached("TabBarTitleColor", typeof(Color), typeof(Shell), Color.Default,
propertyChanged: OnShellColorValueChanged); propertyChanged: OnColorValueChanged);
public static readonly BindableProperty ShellTabBarUnselectedColorProperty = public static readonly BindableProperty TabBarUnselectedColorProperty =
BindableProperty.CreateAttached("ShellTabBarUnselectedColor", typeof(Color), typeof(Shell), Color.Default, BindableProperty.CreateAttached("TabBarUnselectedColor", typeof(Color), typeof(Shell), Color.Default,
propertyChanged: OnShellColorValueChanged); propertyChanged: OnColorValueChanged);
public static readonly BindableProperty ShellTitleColorProperty = public static readonly BindableProperty TitleColorProperty =
BindableProperty.CreateAttached("ShellTitleColor", typeof(Color), typeof(Shell), Color.Default, BindableProperty.CreateAttached("TitleColor", typeof(Color), typeof(Shell), Color.Default,
propertyChanged: OnShellColorValueChanged); propertyChanged: OnColorValueChanged);
public static readonly BindableProperty ShellUnselectedColorProperty = public static readonly BindableProperty UnselectedColorProperty =
BindableProperty.CreateAttached("ShellUnselectedColor", typeof(Color), typeof(Shell), Color.Default, BindableProperty.CreateAttached("UnselectedColor", typeof(Color), typeof(Shell), Color.Default,
propertyChanged: OnShellColorValueChanged); propertyChanged: OnColorValueChanged);
public static Color GetShellBackgroundColor(BindableObject obj) => (Color)obj.GetValue(ShellBackgroundColorProperty); public static Color GetBackgroundColor(BindableObject obj) => (Color)obj.GetValue(BackgroundColorProperty);
public static void SetShellBackgroundColor(BindableObject obj, Color value) => obj.SetValue(ShellBackgroundColorProperty, value); public static void SetBackgroundColor(BindableObject obj, Color value) => obj.SetValue(BackgroundColorProperty, value);
public static Color GetShellDisabledColor(BindableObject obj) => (Color)obj.GetValue(ShellDisabledColorProperty); public static Color GetDisabledColor(BindableObject obj) => (Color)obj.GetValue(DisabledColorProperty);
public static void SetShellDisabledColor(BindableObject obj, Color value) => obj.SetValue(ShellDisabledColorProperty, value); public static void SetDisabledColor(BindableObject obj, Color value) => obj.SetValue(DisabledColorProperty, value);
public static Color GetShellForegroundColor(BindableObject obj) => (Color)obj.GetValue(ShellForegroundColorProperty); public static Color GetForegroundColor(BindableObject obj) => (Color)obj.GetValue(ForegroundColorProperty);
public static void SetShellForegroundColor(BindableObject obj, Color value) => obj.SetValue(ShellForegroundColorProperty, value); public static void SetForegroundColor(BindableObject obj, Color value) => obj.SetValue(ForegroundColorProperty, value);
public static Color GetShellTabBarBackgroundColor(BindableObject obj) => (Color)obj.GetValue(ShellTabBarBackgroundColorProperty); public static Color GetTabBarBackgroundColor(BindableObject obj) => (Color)obj.GetValue(TabBarBackgroundColorProperty);
public static void SetShellTabBarBackgroundColor(BindableObject obj, Color value) => obj.SetValue(ShellTabBarBackgroundColorProperty, value); public static void SetTabBarBackgroundColor(BindableObject obj, Color value) => obj.SetValue(TabBarBackgroundColorProperty, value);
public static Color GetShellTabBarDisabledColor(BindableObject obj) => (Color)obj.GetValue(ShellTabBarDisabledColorProperty); public static Color GetTabBarDisabledColor(BindableObject obj) => (Color)obj.GetValue(TabBarDisabledColorProperty);
public static void SetShellTabBarDisabledColor(BindableObject obj, Color value) => obj.SetValue(ShellTabBarDisabledColorProperty, value); public static void SetTabBarDisabledColor(BindableObject obj, Color value) => obj.SetValue(TabBarDisabledColorProperty, value);
public static Color GetShellTabBarForegroundColor(BindableObject obj) => (Color)obj.GetValue(ShellTabBarForegroundColorProperty); public static Color GetTabBarForegroundColor(BindableObject obj) => (Color)obj.GetValue(TabBarForegroundColorProperty);
public static void SetShellTabBarForegroundColor(BindableObject obj, Color value) => obj.SetValue(ShellTabBarForegroundColorProperty, value); public static void SetTabBarForegroundColor(BindableObject obj, Color value) => obj.SetValue(TabBarForegroundColorProperty, value);
public static Color GetShellTabBarTitleColor(BindableObject obj) => (Color)obj.GetValue(ShellTabBarTitleColorProperty); public static Color GetTabBarTitleColor(BindableObject obj) => (Color)obj.GetValue(TabBarTitleColorProperty);
public static void SetShellTabBarTitleColor(BindableObject obj, Color value) => obj.SetValue(ShellTabBarTitleColorProperty, value); public static void SetTabBarTitleColor(BindableObject obj, Color value) => obj.SetValue(TabBarTitleColorProperty, value);
public static Color GetShellTabBarUnselectedColor(BindableObject obj) => (Color)obj.GetValue(ShellTabBarUnselectedColorProperty); public static Color GetTabBarUnselectedColor(BindableObject obj) => (Color)obj.GetValue(TabBarUnselectedColorProperty);
public static void SetShellTabBarUnselectedColor(BindableObject obj, Color value) => obj.SetValue(ShellTabBarUnselectedColorProperty, value); public static void SetTabBarUnselectedColor(BindableObject obj, Color value) => obj.SetValue(TabBarUnselectedColorProperty, value);
public static Color GetShellTitleColor(BindableObject obj) => (Color)obj.GetValue(ShellTitleColorProperty); public static Color GetTitleColor(BindableObject obj) => (Color)obj.GetValue(TitleColorProperty);
public static void SetShellTitleColor(BindableObject obj, Color value) => obj.SetValue(ShellTitleColorProperty, value); public static void SetTitleColor(BindableObject obj, Color value) => obj.SetValue(TitleColorProperty, value);
public static Color GetShellUnselectedColor(BindableObject obj) => (Color)obj.GetValue(ShellUnselectedColorProperty); public static Color GetUnselectedColor(BindableObject obj) => (Color)obj.GetValue(UnselectedColorProperty);
public static void SetShellUnselectedColor(BindableObject obj, Color value) => obj.SetValue(ShellUnselectedColorProperty, value); public static void SetUnselectedColor(BindableObject obj, Color value) => obj.SetValue(UnselectedColorProperty, value);
static void OnShellColorValueChanged(BindableObject bindable, object oldValue, object newValue) static void OnColorValueChanged(BindableObject bindable, object oldValue, object newValue)
{ {
var item = (Element)bindable; var item = (Element)bindable;
var source = item; var source = item;
@ -194,7 +189,7 @@ namespace Xamarin.Forms
void IShellController.AddAppearanceObserver(IAppearanceObserver observer, Element pivot) void IShellController.AddAppearanceObserver(IAppearanceObserver observer, Element pivot)
{ {
_appearanceObservers.Add((observer, pivot)); _appearanceObservers.Add((observer, pivot));
observer.OnAppearanceChanged(GetShellAppearanceForPivot(pivot)); observer.OnAppearanceChanged(GetAppearanceForPivot(pivot));
} }
void IShellController.AddFlyoutBehaviorObserver(IFlyoutBehaviorObserver observer) void IShellController.AddFlyoutBehaviorObserver(IFlyoutBehaviorObserver observer)
@ -242,7 +237,7 @@ namespace Xamarin.Forms
{ {
if (leaf == target) if (leaf == target)
{ {
observer.OnAppearanceChanged(GetShellAppearanceForPivot(pivot)); observer.OnAppearanceChanged(GetAppearanceForPivot(pivot));
break; break;
} }
leaf = leaf.Parent; leaf = leaf.Parent;
@ -571,30 +566,14 @@ namespace Xamarin.Forms
ShellNavigatedEventArgs _accumulatedEvent; ShellNavigatedEventArgs _accumulatedEvent;
bool _accumulateNavigatedEvents; bool _accumulateNavigatedEvents;
View _flyoutHeaderView; View _flyoutHeaderView;
bool _checkExperimentalFlag = true;
public Shell() : this(true) public Shell()
{
}
internal Shell(bool checkFlag)
{ {
Navigation = new NavigationImpl(this); Navigation = new NavigationImpl(this);
_checkExperimentalFlag = checkFlag;
VerifyShellFlagEnabled(constructorHint: nameof(Shell));
((INotifyCollectionChanged)Items).CollectionChanged += (s, e) => SendStructureChanged(); ((INotifyCollectionChanged)Items).CollectionChanged += (s, e) => SendStructureChanged();
Route = Routing.GenerateImplicitRoute("shell"); Route = Routing.GenerateImplicitRoute("shell");
} }
internal const string ShellExperimental = ExperimentalFlags.ShellExperimental;
[EditorBrowsable(EditorBrowsableState.Never)]
internal void VerifyShellFlagEnabled(string constructorHint = null, [CallerMemberName] string memberName = "")
{
if (_checkExperimentalFlag)
ExperimentalFlags.VerifyFlagEnabled("Shell", ShellExperimental, constructorHint, memberName);
}
public event EventHandler<ShellNavigatedEventArgs> Navigated; public event EventHandler<ShellNavigatedEventArgs> Navigated;
public event EventHandler<ShellNavigatingEventArgs> Navigating; public event EventHandler<ShellNavigatingEventArgs> Navigating;
@ -649,8 +628,7 @@ namespace Xamarin.Forms
set => SetValue(FlyoutIsPresentedProperty, value); set => SetValue(FlyoutIsPresentedProperty, value);
} }
public ShellItemCollection Items => (ShellItemCollection)GetValue(ItemsProperty); public IList<ShellItem> Items => (IList<ShellItem>)GetValue(ItemsProperty);
public ShellItemCollection Flyout => Items;
public DataTemplate ItemTemplate public DataTemplate ItemTemplate
{ {
@ -969,7 +947,7 @@ namespace Xamarin.Forms
return FlyoutBehavior; return FlyoutBehavior;
} }
ShellAppearance GetShellAppearanceForPivot(Element pivot) ShellAppearance GetAppearanceForPivot(Element pivot)
{ {
// this algorithm is pretty simple // this algorithm is pretty simple
// 1) Get the "CurrentPage" by walking down from the pivot // 1) Get the "CurrentPage" by walking down from the pivot
@ -1090,7 +1068,7 @@ namespace Xamarin.Forms
PropertyPropagationExtensions.PropagatePropertyChanged(propertyName, this, new[] { FlyoutHeaderView }); PropertyPropagationExtensions.PropagatePropertyChanged(propertyName, this, new[] { FlyoutHeaderView });
} }
public class NavigationImpl : NavigationProxy class NavigationImpl : NavigationProxy
{ {
readonly Shell _shell; readonly Shell _shell;

Просмотреть файл

@ -8,16 +8,16 @@ namespace Xamarin.Forms
{ {
static readonly BindableProperty[] s_ingestArray = new[] static readonly BindableProperty[] s_ingestArray = new[]
{ {
Shell.ShellBackgroundColorProperty, Shell.BackgroundColorProperty,
Shell.ShellDisabledColorProperty, Shell.DisabledColorProperty,
Shell.ShellForegroundColorProperty, Shell.ForegroundColorProperty,
Shell.ShellTabBarBackgroundColorProperty, Shell.TabBarBackgroundColorProperty,
Shell.ShellTabBarDisabledColorProperty, Shell.TabBarDisabledColorProperty,
Shell.ShellTabBarForegroundColorProperty, Shell.TabBarForegroundColorProperty,
Shell.ShellTabBarTitleColorProperty, Shell.TabBarTitleColorProperty,
Shell.ShellTabBarUnselectedColorProperty, Shell.TabBarUnselectedColorProperty,
Shell.ShellTitleColorProperty, Shell.TitleColorProperty,
Shell.ShellUnselectedColorProperty Shell.UnselectedColorProperty
}; };
Color?[] _colorArray = new Color?[s_ingestArray.Length]; Color?[] _colorArray = new Color?[s_ingestArray.Length];

Просмотреть файл

@ -5,7 +5,7 @@ using System.Collections.Specialized;
namespace Xamarin.Forms namespace Xamarin.Forms
{ {
public sealed class ShellContentCollection : IList<ShellContent>, INotifyCollectionChanged internal sealed class ShellContentCollection : IList<ShellContent>, INotifyCollectionChanged
{ {
ObservableCollection<ShellContent> _inner = new ObservableCollection<ShellContent>(); ObservableCollection<ShellContent> _inner = new ObservableCollection<ShellContent>();

Просмотреть файл

@ -15,8 +15,6 @@ namespace Xamarin.Forms
{ {
Shell.SetFlyoutBehavior(this, FlyoutBehavior.Flyout); Shell.SetFlyoutBehavior(this, FlyoutBehavior.Flyout);
} }
public ShellSectionCollection Tabs => Items;
} }
[EditorBrowsable(EditorBrowsableState.Always)] [EditorBrowsable(EditorBrowsableState.Always)]
@ -26,8 +24,6 @@ namespace Xamarin.Forms
{ {
Shell.SetFlyoutBehavior(this, FlyoutBehavior.Disabled); Shell.SetFlyoutBehavior(this, FlyoutBehavior.Disabled);
} }
public ShellSectionCollection Tabs => Items;
} }
@ -112,7 +108,7 @@ namespace Xamarin.Forms
set { SetValue(CurrentItemProperty, value); } set { SetValue(CurrentItemProperty, value); }
} }
public ShellSectionCollection Items => (ShellSectionCollection)GetValue(ItemsProperty); public IList<ShellSection> Items => (IList<ShellSection>)GetValue(ItemsProperty);
internal override ReadOnlyCollection<Element> LogicalChildrenInternal => _logicalChildren ?? (_logicalChildren = new ReadOnlyCollection<Element>(_children)); internal override ReadOnlyCollection<Element> LogicalChildrenInternal => _logicalChildren ?? (_logicalChildren = new ReadOnlyCollection<Element>(_children));
@ -233,4 +229,4 @@ namespace Xamarin.Forms
SendStructureChanged(); SendStructureChanged();
} }
} }
} }

Просмотреть файл

@ -4,7 +4,7 @@ using System.Collections.Specialized;
namespace Xamarin.Forms namespace Xamarin.Forms
{ {
public sealed class ShellItemCollection : IEnumerable<ShellItem>, IList<ShellItem>, INotifyCollectionChanged internal sealed class ShellItemCollection : IList<ShellItem>, INotifyCollectionChanged
{ {
event NotifyCollectionChangedEventHandler INotifyCollectionChanged.CollectionChanged event NotifyCollectionChangedEventHandler INotifyCollectionChanged.CollectionChanged
{ {

Просмотреть файл

@ -2,7 +2,6 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Collections.ObjectModel; using System.Collections.ObjectModel;
using System.Collections.Specialized; using System.Collections.Specialized;
using System.Diagnostics;
using System.Linq; using System.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;
using Xamarin.Forms.Internals; using Xamarin.Forms.Internals;
@ -13,7 +12,6 @@ namespace Xamarin.Forms
[EditorBrowsable(EditorBrowsableState.Always)] [EditorBrowsable(EditorBrowsableState.Always)]
public class Tab : ShellSection public class Tab : ShellSection
{ {
public ShellContentCollection Content => Items;
} }
[ContentProperty(nameof(Items))] [ContentProperty(nameof(Items))]
@ -166,7 +164,7 @@ namespace Xamarin.Forms
set { SetValue(CurrentItemProperty, value); } set { SetValue(CurrentItemProperty, value); }
} }
public ShellContentCollection Items => (ShellContentCollection)GetValue(ItemsProperty); public IList<ShellContent> Items => (IList<ShellContent>)GetValue(ItemsProperty);
public IReadOnlyList<Page> Stack => _navStack; public IReadOnlyList<Page> Stack => _navStack;
@ -556,7 +554,7 @@ namespace Xamarin.Forms
} }
} }
public class NavigationImpl : NavigationProxy class NavigationImpl : NavigationProxy
{ {
readonly ShellSection _owner; readonly ShellSection _owner;
@ -575,4 +573,4 @@ namespace Xamarin.Forms
protected override void OnRemovePage(Page page) => _owner.OnRemovePage(page); protected override void OnRemovePage(Page page) => _owner.OnRemovePage(page);
} }
} }
} }

Просмотреть файл

@ -4,7 +4,7 @@ using System.Collections.Specialized;
namespace Xamarin.Forms namespace Xamarin.Forms
{ {
public sealed class ShellSectionCollection : IList<ShellSection>, INotifyCollectionChanged internal sealed class ShellSectionCollection : IList<ShellSection>, INotifyCollectionChanged
{ {
event NotifyCollectionChangedEventHandler INotifyCollectionChanged.CollectionChanged event NotifyCollectionChangedEventHandler INotifyCollectionChanged.CollectionChanged
{ {

Просмотреть файл

@ -16,21 +16,17 @@ namespace Xamarin.Forms.Xaml.UnitTests
[TestFixture] class Tests [TestFixture] class Tests
{ {
IReadOnlyList<string> _flags;
[SetUp] [SetUp]
public void Setup() public void Setup()
{ {
Device.PlatformServices = new MockPlatformServices(); Device.PlatformServices = new MockPlatformServices();
_flags = Device.Flags;
Device.SetFlags(new List<string>() { ExperimentalFlags.ShellExperimental});
} }
[TearDown] [TearDown]
public void TearDown() public void TearDown()
{ {
Device.PlatformServices = null; Device.PlatformServices = null;
Device.SetFlags(_flags);
} }
[Test] [Test]

Просмотреть файл

@ -28,21 +28,16 @@ namespace Xamarin.Forms.Xaml.UnitTests
[TestFixture] class Tests [TestFixture] class Tests
{ {
IReadOnlyList<string> _flags;
[SetUp] [SetUp]
public void Setup() public void Setup()
{ {
Device.PlatformServices = new MockPlatformServices(); Device.PlatformServices = new MockPlatformServices();
_flags = Device.Flags;
Device.SetFlags(new List<string>() { ExperimentalFlags.ShellExperimental });
} }
[TearDown] [TearDown]
public void TearDown() public void TearDown()
{ {
Device.PlatformServices = null; Device.PlatformServices = null;
Device.SetFlags(_flags);
} }
[Test] [Test]