Merge branch '4.5.0' into 4.6.0

This commit is contained in:
Samantha Houts 2020-04-06 20:03:19 -07:00
Родитель 4222c2e099 e5496de45a
Коммит c8b99fb391
4 изменённых файлов: 115 добавлений и 6 удалений

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

@ -138,6 +138,7 @@
<Compile Include="CustomRenderers\RoundedLabelRenderer.cs" />
<Compile Include="ApiLabelRenderer.cs" />
<Compile Include="CustomRenderers\CustomSearchBarRenderer.cs" />
<Compile Include="_9767CustomRenderer.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Xamarin.Forms.Controls\Xamarin.Forms.Controls.csproj">

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

@ -0,0 +1,50 @@
using CoreAnimation;
using CoreGraphics;
using UIKit;
using Xamarin.Forms;
using Xamarin.Forms.ControlGallery.iOS;
using Xamarin.Forms.Controls.Issues;
using Xamarin.Forms.Platform.iOS;
[assembly: ExportRenderer(typeof(Issue9767NavigationPage), typeof(_9767CustomRenderer))]
namespace Xamarin.Forms.ControlGallery.iOS
{
public class _9767CustomRenderer : NavigationRenderer
{
public _9767CustomRenderer() : base()
{
}
public override void ViewWillAppear(bool animated)
{
base.ViewWillAppear(animated);
UpdateColors();
UpdateGradientView();
}
void UpdateColors()
{
UINavigationBar.Appearance.BarTintColor = UIColor.FromPatternImage(UIImage.FromFile("coffee.png"));
UINavigationBar.Appearance.TintColor = UIColor.Yellow;
UINavigationBar.Appearance.SetTitleTextAttributes(new UITextAttributes { TextColor = UIColor.Blue });
}
void UpdateGradientView()
{
var gradientLayer = new CAGradientLayer
{
Bounds = NavigationBar.Bounds,
Colors = new CGColor[] { Color.Blue.ToCGColor(), Color.Purple.ToCGColor() },
EndPoint = new CGPoint(0.0, 0.5),
StartPoint = new CGPoint(1.0, 0.5)
};
UIGraphics.BeginImageContext(gradientLayer.Bounds.Size);
gradientLayer.RenderInContext(UIGraphics.GetCurrentContext());
UIImage image = UIGraphics.GetImageFromCurrentImageContext();
UIGraphics.EndImageContext();
NavigationBar.SetBackgroundImage(image, UIBarMetrics.Default);
}
}
}

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

@ -68,10 +68,21 @@ namespace Xamarin.Forms.Controls.Issues
BarTextColor = Color.Default;
};
var navigateButton = new Button
{
Text = "Navigate"
};
navigateButton.Clicked += (sender, args) =>
{
Navigation.PushAsync(new Issue9767NavigationPage(new Issue9767()));
};
layout.Children.Add(updateBarBackgroundButton);
layout.Children.Add(updateBarTextButton);
layout.Children.Add(resetBarBackgroundButton);
layout.Children.Add(resetBarTextButton);
layout.Children.Add(navigateButton);
page.Content = layout;
@ -80,7 +91,7 @@ namespace Xamarin.Forms.Controls.Issues
protected override void Init()
{
}
Color GetRandomColor()
@ -102,4 +113,18 @@ namespace Xamarin.Forms.Controls.Issues
return (Color)result;
}
}
}
[Preserve(AllMembers = true)]
public class Issue9767NavigationPage : NavigationPage
{
public Issue9767NavigationPage()
{
}
public Issue9767NavigationPage(Page root) : base(root)
{
}
}
}

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

@ -148,6 +148,14 @@ namespace Xamarin.Forms.Platform.iOS
base.ViewWillAppear(animated);
SetStatusBarStyle();
if (Forms.IsiOS13OrNewer)
{
UpdateTint();
UpdateBarBackgroundColor();
UpdateBarTextColor();
UpdateHideNavigationBarSeparator();
}
}
public override void ViewDidDisappear(bool animated)
@ -226,11 +234,16 @@ namespace Xamarin.Forms.Platform.iOS
navPage.RemovePageRequested += OnRemovedPageRequested;
navPage.InsertPageBeforeRequested += OnInsertPageBeforeRequested;
UpdateTint();
UpdateBarBackgroundColor();
UpdateBarTextColor();
if (!Forms.IsiOS13OrNewer)
{
UpdateTint();
UpdateBarBackgroundColor();
UpdateBarTextColor();
UpdateHideNavigationBarSeparator();
}
UpdateUseLargeTitles();
UpdateHideNavigationBarSeparator();
if (Forms.RespondsToSetNeedsUpdateOfHomeIndicatorAutoHidden)
SetNeedsUpdateOfHomeIndicatorAutoHidden();
@ -678,6 +691,9 @@ namespace Xamarin.Forms.Platform.iOS
NavigationBar.CompactAppearance = navigationBarAppearance;
NavigationBar.StandardAppearance = navigationBarAppearance;
NavigationBar.ScrollEdgeAppearance = navigationBarAppearance;
var parentingViewController = (ParentingViewController)ViewControllers.Last();
parentingViewController?.UpdateNavigationBarBackgroundImage();
}
else
#endif
@ -1081,6 +1097,7 @@ namespace Xamarin.Forms.Platform.iOS
public override void ViewWillAppear(bool animated)
{
UpdateNavigationBarBackgroundImage();
UpdateNavigationBarVisibility(animated);
NavigationRenderer n;
@ -1155,6 +1172,22 @@ namespace Xamarin.Forms.Platform.iOS
UpdateIconColor();
}
internal void UpdateNavigationBarBackgroundImage()
{
if (!Forms.IsiOS13OrNewer)
return;
if (!_navigation.TryGetTarget(out NavigationRenderer navigationRenderer))
return;
#if __XCODE11__
var backgroundImage = navigationRenderer.NavigationBar.GetBackgroundImage(UIBarMetrics.Default);
navigationRenderer.NavigationBar.CompactAppearance.BackgroundImage = backgroundImage;
navigationRenderer.NavigationBar.StandardAppearance.BackgroundImage = backgroundImage;
navigationRenderer.NavigationBar.ScrollEdgeAppearance.BackgroundImage = backgroundImage;
#endif
}
internal void UpdateLeftBarButtonItem(Page pageBeingRemoved = null)
{