UI adjustment
This commit is contained in:
@ -1,5 +1,7 @@
|
||||
using System.Threading.Tasks;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Threading.Tasks;
|
||||
using Pixiview.iOS.Renderers;
|
||||
using Pixiview.iOS.Renderers.AppShellSection;
|
||||
using Pixiview.Utils;
|
||||
using UIKit;
|
||||
using Xamarin.Forms;
|
||||
@ -14,7 +16,7 @@ namespace Pixiview.iOS.Renderers
|
||||
|
||||
protected override IShellSectionRenderer CreateShellSectionRenderer(ShellSection shellSection)
|
||||
{
|
||||
var renderer = base.CreateShellSectionRenderer(shellSection);
|
||||
var renderer = new AppShellSectionRenderer(this);
|
||||
if (renderer is ShellSectionRenderer sr && Element is AppShell shell)
|
||||
{
|
||||
shell.SetNavigationBarHeight(
|
||||
@ -24,15 +26,36 @@ namespace Pixiview.iOS.Renderers
|
||||
return renderer;
|
||||
}
|
||||
|
||||
[SuppressMessage("Code Notifications", "XI0002:Notifies you from using newer Apple APIs when targeting an older OS version", Justification = "<Pending>")]
|
||||
protected override IShellItemRenderer CreateShellItemRenderer(ShellItem item)
|
||||
{
|
||||
var renderer = base.CreateShellItemRenderer(item);
|
||||
if (UIDevice.CurrentDevice.CheckSystemVersion(13, 0))
|
||||
{
|
||||
if (renderer.ViewController is UITabBarController controller)
|
||||
{
|
||||
var tabBar = controller.TabBar;
|
||||
tabBar.TintColor = UIColor.SecondaryLabelColor.ColorWithAlpha(1);
|
||||
tabBar.UnselectedItemTintColor = UIColor.SecondaryLabelColor;
|
||||
}
|
||||
}
|
||||
return renderer;
|
||||
}
|
||||
|
||||
protected override IShellItemTransition CreateShellItemTransition()
|
||||
{
|
||||
return new AppShellItemTransition();
|
||||
}
|
||||
|
||||
protected override IShellTabBarAppearanceTracker CreateTabBarAppearanceTracker()
|
||||
{
|
||||
return new AppShellTabBarAppearanceTracker();
|
||||
}
|
||||
}
|
||||
|
||||
public class AppShellItemTransition : IShellItemTransition
|
||||
{
|
||||
[System.Diagnostics.CodeAnalysis.SuppressMessage("Code Notifications", "XI0001:Notifies you with advices on how to use Apple APIs", Justification = "<Pending>")]
|
||||
[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>();
|
||||
@ -47,4 +70,90 @@ namespace Pixiview.iOS.Renderers
|
||||
return task.Task;
|
||||
}
|
||||
}
|
||||
|
||||
public class AppShellTabBarAppearanceTracker : IShellTabBarAppearanceTracker
|
||||
{
|
||||
UIColor _defaultBarTint;
|
||||
UIColor _defaultTint;
|
||||
UIColor _defaultUnselectedTint;
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
}
|
||||
|
||||
public void ResetAppearance(UITabBarController controller)
|
||||
{
|
||||
if (_defaultTint == null)
|
||||
return;
|
||||
|
||||
var tabBar = controller.TabBar;
|
||||
tabBar.BarTintColor = _defaultBarTint;
|
||||
tabBar.TintColor = _defaultTint;
|
||||
tabBar.UnselectedItemTintColor = _defaultUnselectedTint;
|
||||
}
|
||||
|
||||
public void SetAppearance(UITabBarController controller, ShellAppearance appearance)
|
||||
{
|
||||
IShellAppearanceElement appearanceElement = appearance;
|
||||
//var backgroundColor = appearanceElement.EffectiveTabBarBackgroundColor;
|
||||
var unselectedColor = appearanceElement.EffectiveTabBarUnselectedColor;
|
||||
var titleColor = appearanceElement.EffectiveTabBarTitleColor;
|
||||
|
||||
var tabBar = controller.TabBar;
|
||||
//bool operatingSystemSupportsUnselectedTint = Forms.IsiOS10OrNewer;
|
||||
|
||||
if (_defaultTint == null)
|
||||
{
|
||||
_defaultBarTint = tabBar.BarTintColor;
|
||||
_defaultTint = tabBar.TintColor;
|
||||
|
||||
//if (operatingSystemSupportsUnselectedTint)
|
||||
{
|
||||
_defaultUnselectedTint = tabBar.UnselectedItemTintColor;
|
||||
}
|
||||
}
|
||||
|
||||
//if (!backgroundColor.IsDefault)
|
||||
// tabBar.BarTintColor = backgroundColor.ToUIColor();
|
||||
if (!UIDevice.CurrentDevice.CheckSystemVersion(13, 0))
|
||||
{
|
||||
if (!titleColor.IsDefault)
|
||||
tabBar.TintColor = titleColor.ToUIColor();
|
||||
|
||||
//if (operatingSystemSupportsUnselectedTint)
|
||||
{
|
||||
if (!unselectedColor.IsDefault)
|
||||
tabBar.UnselectedItemTintColor = unselectedColor.ToUIColor();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void UpdateLayout(UITabBarController controller)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
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