adjust UI
This commit is contained in:
93
Gallery.iOS/Renderers/AppShellRenderer.cs
Normal file
93
Gallery.iOS/Renderers/AppShellRenderer.cs
Normal file
@@ -0,0 +1,93 @@
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Threading.Tasks;
|
||||
using Gallery.iOS.Renderers;
|
||||
using Gallery.iOS.Renderers.AppShellSection;
|
||||
using Gallery.Services;
|
||||
using UIKit;
|
||||
using Xamarin.Forms;
|
||||
using Xamarin.Forms.Platform.iOS;
|
||||
|
||||
[assembly: ExportRenderer(typeof(Shell), typeof(AppShellRenderer))]
|
||||
namespace Gallery.iOS.Renderers
|
||||
{
|
||||
public class AppShellRenderer : ShellRenderer
|
||||
{
|
||||
|
||||
public override bool PrefersHomeIndicatorAutoHidden => Screen.GetHomeIndicatorAutoHidden(Element);
|
||||
|
||||
protected override IShellSectionRenderer CreateShellSectionRenderer(ShellSection shellSection)
|
||||
{
|
||||
var renderer = base.CreateShellSectionRenderer(shellSection); // new AppShellSectionRenderer(this);
|
||||
if (renderer is ShellSectionRenderer sr && Element is AppShell shell)
|
||||
{
|
||||
shell.SetNavigationBarHeight(sr.NavigationBar.Frame.Height);
|
||||
shell.SetStatusBarHeight(
|
||||
sr.NavigationBar.Frame.Height,
|
||||
UIApplication.SharedApplication.StatusBarFrame.Height);
|
||||
}
|
||||
return renderer;
|
||||
}
|
||||
|
||||
protected override IShellItemTransition CreateShellItemTransition()
|
||||
{
|
||||
return new AppShellItemTransition();
|
||||
}
|
||||
|
||||
protected override IShellTabBarAppearanceTracker CreateTabBarAppearanceTracker()
|
||||
{
|
||||
return new AppShellTabBarAppearanceTracker();
|
||||
}
|
||||
|
||||
protected override IShellNavBarAppearanceTracker CreateNavBarAppearanceTracker()
|
||||
{
|
||||
return new AppShellNavBarAppearanceTracker();
|
||||
}
|
||||
|
||||
protected override void UpdateBackgroundColor()
|
||||
{
|
||||
NativeView.BackgroundColor = Color.Transparent.ToUIColor();
|
||||
}
|
||||
}
|
||||
|
||||
public class AppShellItemTransition : IShellItemTransition
|
||||
{
|
||||
[SuppressMessage("Code Notifications", "XI0001:Notifies you with advices on how to use Apple APIs", Justification = "<Pending>")]
|
||||
public Task Transition(IShellItemRenderer oldRenderer, IShellItemRenderer newRenderer)
|
||||
{
|
||||
var task = new TaskCompletionSource<bool>();
|
||||
var oldView = oldRenderer.ViewController.View;
|
||||
var newView = newRenderer.ViewController.View;
|
||||
newView.Alpha = 0;
|
||||
|
||||
newView.Superview.InsertSubviewAbove(newView, oldView);
|
||||
|
||||
UIView.Animate(0.2, 0, UIViewAnimationOptions.BeginFromCurrentState, () => newView.Alpha = 1, () => task.TrySetResult(true));
|
||||
|
||||
return task.Task;
|
||||
}
|
||||
}
|
||||
|
||||
public class AppShellSectionRenderer : ShellSectionRenderer
|
||||
{
|
||||
public AppShellSectionRenderer(IShellContext context) : base(context)
|
||||
{
|
||||
}
|
||||
|
||||
protected override IShellSectionRootRenderer CreateShellSectionRootRenderer(ShellSection shellSection, IShellContext shellContext)
|
||||
{
|
||||
return new AppShellSectionRootRenderer(shellSection, shellContext);
|
||||
}
|
||||
}
|
||||
|
||||
public class AppShellSectionRootRenderer : ShellSectionRootRenderer
|
||||
{
|
||||
public AppShellSectionRootRenderer(ShellSection shellSection, IShellContext shellContext) : base(shellSection, shellContext)
|
||||
{
|
||||
}
|
||||
|
||||
protected override IShellSectionRootHeader CreateShellSectionRootHeader(IShellContext shellContext)
|
||||
{
|
||||
return new AppShellSectionRootHeader(shellContext);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user