using System.Diagnostics.CodeAnalysis; using Pixiview.iOS.Renderers; using Pixiview.UI; using Pixiview.Utils; using UIKit; using Xamarin.Forms; using Xamarin.Forms.Platform.iOS; [assembly: ExportRenderer(typeof(AdaptedPage), typeof(AdaptedPageRenderer))] namespace Pixiview.iOS.Renderers { public class AdaptedPageRenderer : PageRenderer { public override void ViewDidLoad() { base.ViewDidLoad(); if (Element is AdaptedPage page) { page.OnLoad(); } } public override void ViewDidAppear(bool animated) { base.ViewDidAppear(animated); var style = ConvertStyle(StatusBar.GetStatusBarStyle(Element)); if (UIApplication.SharedApplication.StatusBarStyle != style) { SetStatusBarStyle(style); } } private void SetStatusBarStyle(UIStatusBarStyle style) { if (style == UIStatusBarStyle.BlackOpaque) { UIApplication.SharedApplication.SetStatusBarHidden(true, UIStatusBarAnimation.Fade); } else { UIApplication.SharedApplication.SetStatusBarStyle(style, true); UIApplication.SharedApplication.SetStatusBarHidden(false, UIStatusBarAnimation.Fade); } SetNeedsStatusBarAppearanceUpdate(); } [SuppressMessage("Code Notifications", "XI0002:Notifies you from using newer Apple APIs when targeting an older OS version", Justification = "")] [SuppressMessage("Style", "IDE0066:Convert switch statement to expression", Justification = "")] private UIStatusBarStyle ConvertStyle(StatusBarStyles style) { switch (style) { case StatusBarStyles.DarkText: return UIStatusBarStyle.DarkContent; case StatusBarStyles.WhiteText: return UIStatusBarStyle.LightContent; case StatusBarStyles.Hidden: return UIStatusBarStyle.BlackOpaque; case StatusBarStyles.Default: default: return UIStatusBarStyle.Default; } } } }