using System.Collections.Generic;
using HouseProject.iOS.ViewControllers.User;
using Bss.Core.Extensions;
namespace HouseProject.iOS.ViewControllers
public partial class CustomNavigationController : UINavigationController
private IDictionary<Type, Screen> MapScreen = new Dictionary<Type, Screen>
{typeof(HomeViewController),Screen.Home},
{typeof(RegisterViewController),Screen.Register}
private readonly BWeakReference<SideMenuViewController> _bWeakMenu = new BWeakReference<SideMenuViewController>();
public CustomNavigationController(IntPtr handle) : base(handle)
public SideMenuViewController SideMenuController
get { return _bWeakMenu.Target; }
set { _bWeakMenu.Target = value; }
public override UIViewController[] ViewControllers
return base.ViewControllers;
base.ViewControllers = value;
CheckIfShouldSelect(value.Last()?.GetType());
public override UIViewController[] PopToViewController(UIViewController viewController, bool animated)
var vcs = base.PopToViewController(viewController, animated);
CheckIfShouldSelect(vcs.Last()?.GetType());
public override void PushViewController(UIViewController viewController, bool animated)
base.PushViewController(viewController, animated);
CheckIfShouldSelect(viewController?.GetType());
public override UIViewController PopViewController(bool animated)
var vc = base.PopViewController(animated);
CheckIfShouldSelect(vc?.GetType());
public override void SetViewControllers(UIViewController[] controllers, bool animated)
base.SetViewControllers(controllers, animated);
CheckIfShouldSelect(controllers.Last()?.GetType());
public bool IsTopViewController(Type type)
if (ViewControllers.IsNullOrEmpty()) return false;
return ViewControllers[ViewControllers.Length - 1].GetType() == type;
private void CheckIfShouldSelect(Type type)
if (type == null || !MapScreen.ContainsKey(type)) return;
SideMenuController?.SetActiveScreen(MapScreen[type]);