using System;
using System.Collections.Generic;
using Xamarin.Forms;
using MobileApp.Views;

namespace MobileApp
{
    public class NavigationDrawer : MasterDetailPage  // Navigation Drawer using MasterDetailPage
    {

        public NavigationDrawer()
        {

            string[] myPageNames = { "Home", "Countries", "Destinations", "About", "Contact" };


            ListView listView = new ListView
            {
                ItemsSource = myPageNames,
            };
            
            
            this.Master = new ContentPage
            {
                Title = "Menu",
                Content = listView,
                IconImageSource = "hamburger.png",

            };

            listView.ItemTapped += (sender, e) =>
            {
                ContentPage gotoPage;
                switch (e.Item.ToString())
                {
                    case "Home":
                        gotoPage = new Views.Home();
                        break;
                    case "Countries":
                        gotoPage = new Views.Countries();
                        break;
                    case "Destinations":
                        gotoPage = new Views.Destinations();
                        break;
                    case "About":
                        gotoPage = new Views.About();
                        break;
                    case "Contact":
                        gotoPage = new Views.Contact();
                        break;
                    default:
                        gotoPage = new Views.Home();
                        break;
                }
                Detail = new NavigationPage(gotoPage);
                ((ListView)sender).SelectedItem = null;
                this.IsPresented = false;
            };

            Detail = new NavigationPage(new Views.Home());

            //// For Windows Phone, provide a way to get back to the master page.
            //if (Device.OS == TargetPlatform.WinPhone)
            //{
            //    (this.Detail as ContentPage).Content.GestureRecognizers.Add(
            //        new TapGestureRecognizer((view) =>
            //        {
            //            this.IsPresented = true;
            //        }));
            //}
        }
    }

}