namespace inutralia.Views
{
    using System;
    using Xamarin.Forms;

    public partial class RootPage : MasterDetailPage
    {
        public RootPage()
        {
            InitializeComponent();
        }

        public void Navigate<T>() where T : ContentPage
        {
            NavigationPage p = Detail as NavigationPage;
            if (p?.Navigation?.NavigationStack?[0]?.GetType() != typeof(T))
                Detail = new NavigationPage(Activator.CreateInstance(typeof(T)) as Page);

            IsPresented = false;
        }

        public new void Navigation<T>() where T : TabbedPage
        {
            NavigationPage p = Detail as NavigationPage;
            if (p?.Navigation?.NavigationStack?[0]?.GetType() != typeof(T))
                Detail = new NavigationPage(Activator.CreateInstance(typeof(T)) as Page);

            IsPresented = false;
        }
    }
}
