public void confirmPickup()
        {
            //SET PICKUP LOCATION
            if (inRide == false)
            {
                showSearch(true);
                confirm_location_button.IsVisible = false;
                cancel_pickup_button.IsVisible    = false;
                var pin = map.getPin("Pick Up Location");
                Console.WriteLine("Latitude: " + pin.Position.Latitude + "   Longitude: " + pin.Position.Longitude);
                //rider_ui.IsVisible = true;
                inRide = true;
                GenericSocket.GET_DROVER(pin.Position.Latitude, pin.Position.Longitude);
                cancel_driver_search_button.IsVisible = true;
                //
            }

            //SET DROPOFF LOCATION
            else
            {
                if (map.getPin("Drop-Off Location") != null)
                {
                    confirm_location_button.IsVisible = false;
                    cancel_pickup_button.IsVisible    = false;
                    var pin   = map.getPin("Pick Up Location");
                    var pin_2 = map.getPin("Drop-Off Location");
                    rider_ui.IsVisible    = true;
                    set_pickup_label.Text = "Set Pickup Location";
                    centerMapOnTwoPins(pin, pin_2);
                    GenericSocket.CHANGE_DROP_OFF_LOCATION(pin_2.Position.Latitude, pin_2.Position.Longitude);
                }
            }
            confirm_location_button.IsVisible = false;
            cancel_pickup_button.IsVisible    = false;
        }
 void Handle_DriverSwitch_Toggled(object sender, Xamarin.Forms.ToggledEventArgs e)
 {
     Console.WriteLine("TOGGLED THE DRIVER SWITCH!");
     if (driver_switch.IsToggled)
     {
         GenericSocket.REQUEST_DRIVER_MODE();
         DependencyService.Get <IRegisterDriverMode>().Register();
         //set_pickup_button.Is
     }
     else
     {
         DependencyService.Get <IRegisterDriverMode>().UnRegister();
         FireDatabase.write("users/" + FireAuth.auth.User.LocalId + "/stage_1_driving", null);
     }
 }
        public MainPage()
        {
            BindingContext = this;
            InitializeComponent();
            instance = this;
            //Set the map to the Current Location
            setPositionToCurrentLocation();

            BindingContext = this;

            //SET UP SERACHING WEB VIEW
            var assembly = typeof(FireCore).GetTypeInfo().Assembly;

            Stream stream = assembly.GetManifestResourceStream("DroverXamarin.iOS.SEARCHING.html");
            string text   = "";

            using (var reader = new System.IO.StreamReader(stream))
            {
                text += reader.ReadToEnd();
            }
            HtmlWebViewSource source = new HtmlWebViewSource();

            source.Html          = text;
            searching_web.Source = source;


            //------------------------------Gesture Recognizer Section --------------------------

            //Three bars image tap functionality
            var drawer_button_gesture_recognizer = new TapGestureRecognizer();

            drawer_button_gesture_recognizer.Tapped += (s, e) => {
                onButtonClicked(s, e);
            };
            drawer_button.GestureRecognizers.Add(drawer_button_gesture_recognizer);


            //Quarter page filler box tap functionality
            var view_box_gesture_recognizer = new TapGestureRecognizer();

            view_box_gesture_recognizer.Tapped += (s, e) => {
                onButtonClicked(s, e);
            };
            view_box.GestureRecognizers.Add(view_box_gesture_recognizer);

            //Payment option tap functionality
            var paymentGesture = new TapGestureRecognizer();

            paymentGesture.Tapped += (s, e) =>
            {
                Navigation.PushModalAsync(new PaymentPage());
            };
            payment_button.GestureRecognizers.Add(paymentGesture);
            payment_picture.GestureRecognizers.Add(paymentGesture);

            //About option tap functionality
            var aboutGesture = new TapGestureRecognizer();

            aboutGesture.Tapped += (s, e) => {
                Navigation.PushModalAsync(new AboutPage());
            };
            about_button.GestureRecognizers.Add(aboutGesture);
            about_picture.GestureRecognizers.Add(aboutGesture);

            //Sign out option tab functionality
            var signOutGesture = new TapGestureRecognizer();

            signOutGesture.Tapped += (s, e) =>
            {
                signOutButtonClicked(s, e);
            };
            sign_out_button.GestureRecognizers.Add(signOutGesture);
            sign_out_picture.GestureRecognizers.Add(signOutGesture);

            //Help option tap functionality
            var helpGesture = new TapGestureRecognizer();

            helpGesture.Tapped += (s, e) =>
            {
                Navigation.PushModalAsync(new HelpPage());
            };
            help_button.GestureRecognizers.Add(helpGesture);
            help_picture.GestureRecognizers.Add(helpGesture);

            //History option tap functionality
            var historyGesture = new TapGestureRecognizer();

            historyGesture.Tapped += (s, e) =>
            {
                Navigation.PushModalAsync(new CalendarPage());
            };
            history_button.GestureRecognizers.Add(historyGesture);
            history_picture.GestureRecognizers.Add(historyGesture);

            //Search button tap functionality
            var searchGesture = new TapGestureRecognizer();

            searchGesture.Tapped += (s, e) =>
            {
                input_location_box.IsVisible          = true;
                input_location_blackout_box.IsVisible = true;
                entered_pickup_location.Focus();
            };
            search_button.GestureRecognizers.Add(searchGesture);

            //Input location blackout box tap functionality
            var blackoutBoxGesture = new TapGestureRecognizer();

            blackoutBoxGesture.Tapped += (s, e) =>
            {
                input_location_box.IsVisible          = false;
                input_location_blackout_box.IsVisible = false;
            };
            input_location_blackout_box.GestureRecognizers.Add(blackoutBoxGesture);

            //Profile Pic tap functionality
            var profilePicGesture = new TapGestureRecognizer();

            profilePicGesture.Tapped += (s, e) =>
            {
                switchPopMenu();                        //PROFILE PICTURE STUFF
            };
            profile_pic.GestureRecognizers.Add(profilePicGesture);

            //Compass Image tap functionality
            var compassGesture = new TapGestureRecognizer();

            compassGesture.Tapped += (s, e) =>
            {
                setPositionToCurrentLocation();
            };
            compass_image.GestureRecognizers.Add(compassGesture);
            compass_frame.GestureRecognizers.Add(compassGesture);

            //Set Pickup Location tap functionality
            var setPickupGesture = new TapGestureRecognizer();

            setPickupGesture.Tapped += (s, e) =>
            {
                //FireDatabase.write("test/test+test", "test+test");
                getPinPosition();
            };
            set_pickup_button.GestureRecognizers.Add(setPickupGesture);

            //Confirm Pickup tap functionality
            var confirmPickupGesture = new TapGestureRecognizer();

            confirmPickupGesture.Tapped += (s, e) =>
            {
                confirmPickup();
            };
            confirm_location_button.GestureRecognizers.Add(confirmPickupGesture);

            //Cancel Pickup tap functionality
            var cancelPickupGesture = new TapGestureRecognizer();

            cancelPickupGesture.Tapped += (s, e) =>
            {
                cancelPickup();
            };
            cancel_pickup_button.GestureRecognizers.Add(cancelPickupGesture);

            //Cancel Search tap functionality
            var cancelSearchGesture = new TapGestureRecognizer();

            cancelSearchGesture.Tapped += (s, e) =>
            {
                input_location_box.IsVisible          = false;
                input_location_blackout_box.IsVisible = false;
                entered_pickup_location.Text          = "";
            };
            cancel_location_search_button.GestureRecognizers.Add(cancelSearchGesture);

            //Confirm Search tap functionality
            var confirmSearchGesture = new TapGestureRecognizer();

            confirmSearchGesture.Tapped += (s, e) =>
            {
                confirmSearch(entered_pickup_location.Text);
            };
            search_for_location_button.GestureRecognizers.Add(confirmSearchGesture);

            //Dropoff location search tap functionality
            var dropoffSearchGesture = new TapGestureRecognizer();

            dropoffSearchGesture.Tapped += (s, e) =>
            {
                setDropoffLocation();
            };
            dropoff_location_search.GestureRecognizers.Add(dropoffSearchGesture);

            var confirmDropOff = new TapGestureRecognizer();

            confirmDropOff.Tapped += (s, e) =>
            {
                GenericSocket.CONFIRM_DROP_OFF(Settings.LastRideID);
            };

            var confirmArrival = new TapGestureRecognizer();

            confirmArrival.Tapped += (s, e) =>
            {
                GenericSocket.CONFIRM_ARRIVAL(Settings.LastRideID);
            };

            //PROFILE PICTURE STUFF
            var cancelPictureGesture = new TapGestureRecognizer();

            cancelPictureGesture.Tapped += (s, e) =>
            {
                switchPopMenu();
            };
            cancel_button.GestureRecognizers.Add(cancelPictureGesture);
            profile_pic_blackout_box.GestureRecognizers.Add(cancelPictureGesture);

            var takePicGesture = new TapGestureRecognizer();

            takePicGesture.Tapped += (s, e) =>
            {
                CameraCallback callback = new CameraCallback(processImage);
                DependencyService.Get <ICameraSystem>().TakePicture(callback);
            };
            take_pic_button.GestureRecognizers.Add(takePicGesture);

            var choosePicGesture = new TapGestureRecognizer();

            choosePicGesture.Tapped += (s, e) =>
            {
                CameraCallback callback = new CameraCallback(processImage);
                DependencyService.Get <ICameraSystem>().GetMediaPicture(callback);
            };
            choose_pic_button.GestureRecognizers.Add(choosePicGesture);

            var cancelDriverSearchGesture = new TapGestureRecognizer();

            cancelDriverSearchGesture.Tapped += (s, e) =>
            {
                cancelDriverSearch();
            };
            cancel_driver_search_button.GestureRecognizers.Add(cancelDriverSearchGesture);


            profile_pic_pin = new CircleImage {
                Source = Settings.GetImageFromDisk().Source
            };
            profile_pic.Source            = Settings.GetImageFromDisk().Source;
            profile_pic_pin.WidthRequest  = App.ScreenWidth * 0.12;
            profile_pic_pin.HeightRequest = App.ScreenWidth * 0.12;
            double pic_x = App.ScreenWidth * 0.4415;
            double pic_y = App.ScreenHeight * getPicYPosition();

            parentLayout.Children.Add(profile_pic_pin, Constraint.Constant(pic_x), Constraint.Constant(pic_y));

            //-----------------------End Gesture Recognizer Section----------------------------



            string path = "users/" + FireAuth.auth.User.LocalId + "/personal_info";

            //Set the User's name in the slide out menu
            var user_info = FireDatabase.read(path).Result;

            if (user_info != null && user_info.ContainsKey("name_first") && user_info.ContainsKey("name_last"))
            {
                user_name_label.Text = user_info["name_first"].ToString() + " " + user_info["name_last"].ToString();
            }

            //Set the User's phone number in the slide out menu
            if (user_info != null && user_info.ContainsKey("phone"))
            {
                user_phone_label.Text = String.Format("{0:(###) ###-####}", long.Parse(user_info["phone"].ToString()));
            }


            path = "users/" + FireAuth.auth.User.LocalId;
            var is_driver = FireDatabase.read(path).Result;

            Console.WriteLine("UPCOMING!");
            Console.WriteLine("IS DRIVER: " + is_driver.Values);
            if (is_driver.ContainsKey("is_driver") && is_driver["is_driver"].Equals(true))
            {
                driver_switch.IsVisible = true;
            }
            parentLayout.RaiseChild(map_pin);
            parentLayout.RaiseChild(input_location_blackout_box);
            parentLayout.RaiseChild(input_location_box);

            map.CustomPins = new System.Collections.ObjectModel.ObservableCollection <CustomPin>();
        }