Example #1
0
        private void getDriverName(ref string driver_name, string duid)
        {
            string driver_path = "users/" + duid + "/personal_info";
            var    driver      = FireDatabase.read(driver_path).Result;

            driver_name = driver["name_first"] + " " + driver["name_last"];
        }
        public RideListPage(DateTime date_of_rides)
        {
            InitializeComponent();

            // Grabs the list of all rides IDs on a specific date from the database
            string path_of_rides = "users/" + FireAuth.auth.User.LocalId + "/ride_info/ride_history/" + date_of_rides.ToString("M-y") + "/" + date_of_rides.ToString("M-d-yy");

            rides    = FireDatabase.read(path_of_rides).Result;
            numRides = rides.Values.Count;

            this.date_of_rides = date_of_rides;

            // Adds a back button
            var backButtonGesture = new TapGestureRecognizer();

            backButtonGesture.Tapped += (s, e) =>
            {
                Navigation.PopModalAsync();
            };
            back_arrow_button.GestureRecognizers.Add(backButtonGesture);

            // Sets the ride date text
            ride_date.Text = date_of_rides.ToString("MM-dd-yyyy");


            // Creates a new stack of rides
            ride_stack             = new RideStack();
            scroll_view.Content    = ride_stack;
            ride_stack.ChildAdded += method;

            SetupInitialView();
        }
Example #3
0
        public RideListPage(DateTime date_of_rides)
        {
            InitializeComponent();

            //GET LIST OF RIDE IDS HERE
            string path_of_rides = "users/" + FireAuth.auth.User.LocalId + "/ride_info/ride_history/" + date_of_rides.ToString("M-y") + "/" + date_of_rides.ToString("M-d-yy");

            this.rides    = FireDatabase.read(path_of_rides).Result;
            this.numRides = rides.Values.Count;

            this.date_of_rides = date_of_rides;

            //Back button functionality
            var backButtonGesture = new TapGestureRecognizer();

            backButtonGesture.Tapped += (s, e) =>
            {
                Navigation.PopModalAsync();
            };
            back_arrow_button.GestureRecognizers.Add(backButtonGesture);

            ride_date.Text = date_of_rides.ToString("MM-dd-yyyy");


            ride_stack             = new RideStack();
            scroll_view.Content    = ride_stack;
            ride_stack.ChildAdded += method;



            SetupInitialView();
        }
Example #4
0
        public InitPage()
        {
            InitializeComponent();
            UIInstance.nav = Navigation;
            FireDatabase.initDatabase();
            Instances.Init();
            var assembly = typeof(FireCore).GetTypeInfo().Assembly;

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

            using (var reader = new System.IO.StreamReader(stream))
            {
                text += reader.ReadToEnd();
            }
            //HtmlWebViewSource source = new HtmlWebViewSource();
            //source.Html = text;
            //splash_screen.Source = source;
            //DependencyService.Get<IListenForRideProposal>().Listen();
            //FireAuth.LoginWithEmailAndPassword("*****@*****.**", "Password_10");
            FireAuth.LoginWithEmailAndPassword("*****@*****.**", "Bwooorkm1");
            //FireAuth.LoginWithEmailAndPassword("*****@*****.**", "Password_10");
            //var test = assembly.GetManifestResourceStream("DroverXamarin.iOS.animation.html");
            //Console.WriteLine("Stream: "+test+" isNull? "+(test==null).ToString()+" assembly: "+assembly);
            //foreach (var res in assembly.GetManifestResourceNames())
            //	Console.WriteLine("found resource: " + res);
        }
        public InitPage()
        {
            // Setup the firebase database, show an animation that the app is loading, and push the main page asynchronously as a modal
            InitializeComponent();
            UIInstance.nav = Navigation;
            FireDatabase.initDatabase();
            Instances.Init();
            var assembly = typeof(FireCore).GetTypeInfo().Assembly;

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

            using (var reader = new System.IO.StreamReader(stream))
            {
                text += reader.ReadToEnd();
            }
            //HtmlWebViewSource source = new HtmlWebViewSource();
            //source.Html = text;
            //splash_screen.Source = source;
            //DependencyService.Get<IListenForRideProposal>().Listen();
            //FireAuth.LoginWithEmailAndPassword("*****@*****.**", "Password_10");
            Xamarin.Forms.Device.BeginInvokeOnMainThread(() =>
            {
                UIInstance.nav.PushModalAsync(new LaunchPage());
            });
            //FireAuth.LoginWithEmailAndPassword("*****@*****.**", "Password_10");
            //var test = assembly.GetManifestResourceStream("DroverXamarin.iOS.animation.html");
            //Console.WriteLine("Stream: "+test+" isNull? "+(test==null).ToString()+" assembly: "+assembly);
            //foreach (var res in assembly.GetManifestResourceNames())
            //	Console.WriteLine("found resource: " + res);
        }
        private void getDriverName(ref string driver_name, string duid)
        {
            // Gets the driver name for the current ride from the database
            string driver_path = "users/" + duid + "/personal_info";
            var    driver      = FireDatabase.read(driver_path).Result;

            driver_name = driver["name_first"] + " " + driver["name_last"];
        }
Example #7
0
        public static Task LoginWithEmailAndPassword(string email, string password)
        {
            return(Task.Factory.StartNew(() =>
            {
                try
                {
                    var authProvider = new FirebaseAuthProvider(new FirebaseConfig(FireCore.FIREBASE_KEY));
                    auth = authProvider.SignInWithEmailAndPasswordAsync(email, password).Result;



                    Console.WriteLine("First Token: " + auth.FirebaseToken);
                    expirationTime = Time.CurrentTimeMillis() + (auth.ExpiresIn * 1000);
                    Settings.RefreshToken = auth.RefreshToken;
                    Settings.LastUserID = auth.User.LocalId;
                    Settings.LastAuthToken = auth.FirebaseToken;
                    //RenewAuthToken(auth.RefreshToken);
                    if (!Settings.ApnsToken.Equals(string.Empty))
                    {
                        FireDatabase.write("users/" + auth.User.LocalId + "/device_info/apns_token", Settings.ApnsToken);
                    }

                    Xamarin.Forms.Device.BeginInvokeOnMainThread(() =>
                    {
                        UIInstance.nav.PushModalAsync(new MainPage());
                    });
                }
                catch (Exception e)
                {
                    auth = null;
                    Console.WriteLine("Bad Login Info! ");
                    Console.WriteLine(e.StackTrace);
                    Console.WriteLine(e.GetBaseException());
                    Xamarin.Forms.Device.BeginInvokeOnMainThread(() =>
                    {
                        UIInstance.app.MainPage.DisplayAlert("ERROR", "Unable to log you in. Check password or internet connection.", "OK");
                    });
                }

                /*
                 * var firebase = new FirebaseClient("https://droverrideshare-69d73.firebaseio.com/");
                 * var dinos = firebase
                 *      .Child("city-lookups");
                 * var query = QueryExtensions.WithAuth(dinos, auth.FirebaseToken).OnceAsync<Object>().Result;
                 *
                 * foreach (var item in query)
                 * {
                 *      Console.WriteLine(item.Key + ", " + item.Object);
                 * }
                 */
            }));
        }
Example #8
0
        public static Task SignUpWithEmailAndPassword(string email, string password, string first_name, string last_name, long phone)
        {
            return(Task.Factory.StartNew(() =>
            {
                try
                {
                    var authProvider = new FirebaseAuthProvider(new FirebaseConfig(FireCore.FIREBASE_KEY));
                    auth = authProvider.CreateUserWithEmailAndPasswordAsync(email, password).Result;


                    expirationTime = Time.CurrentTimeMillis() + (auth.ExpiresIn * 1000);
                    Settings.RefreshToken = auth.RefreshToken;
                    Settings.LastUserID = auth.User.LocalId;
                    Settings.LastAuthToken = auth.FirebaseToken;

                    /*FireDatabase.write("users/"+auth.User.LocalId ,"temp");*/
                    FireDatabase.write("users/" + auth.User.LocalId + "/is_driver", true);
                    FireDatabase.write("users/" + auth.User.LocalId + "/personal_info/name_first", first_name);
                    FireDatabase.write("users/" + auth.User.LocalId + "/personal_info/name_last", last_name);
                    FireDatabase.write("users/" + auth.User.LocalId + "/personal_info/phone", phone);
                    Xamarin.Forms.Device.BeginInvokeOnMainThread(() =>
                    {
                        UIInstance.nav.PushModalAsync(new MainPage());
                    });
                }
                catch (Exception e)
                {
                    auth = null;
                    Console.WriteLine(e);
                    Console.WriteLine("Bad Login Info!");
                    Xamarin.Forms.Device.BeginInvokeOnMainThread(() =>
                    {
                        UIInstance.app.MainPage.DisplayAlert("ERROR", "Unable to Create Account. Check your email and internet.", "OK");
                    });
                }

                /*
                 * var firebase = new FirebaseClient("https://droverrideshare-69d73.firebaseio.com/");
                 * var dinos = firebase
                 *      .Child("city-lookups");
                 * var query = QueryExtensions.WithAuth(dinos, auth.FirebaseToken).OnceAsync<Object>().Result;
                 *
                 * foreach (var item in query)
                 * {
                 *      Console.WriteLine(item.Key + ", " + item.Object);
                 * }
                 */
            }));
        }
 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);
     }
 }
Example #10
0
 public static Task InitFireAuth()
 {
     return(Task.Factory.StartNew(() =>
     {
         //CHECK TO SEE IF WE HAVE A VALID ACCOUNT ON THIS DEVICE
         if (!Settings.RefreshToken.Equals(string.Empty))
         {
             //CHECK TO SEE IF OUR AUTH TOKEN NEEDS RENEWING
             if (isTokenExpired())
             //ATTEMPT TO RENEW OUR AUTH TOKEN
             {
                 bool success = RenewAuthToken(Settings.RefreshToken).Result;
                 if (success)
                 {
                     //IF TOKEN WAS RENEWED. GO ONTO MAIN PAGE.
                     Xamarin.Forms.Device.BeginInvokeOnMainThread(() =>
                     {
                         //UIInstance.app.MainPage.Navigation.PushModalAsync(new MainPage());
                     });
                     return;
                 }
                 //ELSE. CONTINUE TO PUSH THE LAUNCH PAGE.
             }
             //SEND US TO THE MAIN PAGE. WE ARE ALREADY LOGGED IN.
             else
             {
                 if (!Settings.ApnsToken.Equals(string.Empty))
                 {
                     FireDatabase.write("users/" + auth.User.LocalId + "/device_info/apns_token", Settings.ApnsToken);
                 }
                 Xamarin.Forms.Device.BeginInvokeOnMainThread(() =>
                 {
                     UIInstance.app.MainPage.Navigation.PushModalAsync(new MainPage());
                 });
                 return;
             }
         }
         //SEND US TO THE LOGIN PAGE. WE ARE LOGGED OUT.
         Xamarin.Forms.Device.BeginInvokeOnMainThread(() =>
         {
             UIInstance.app.MainPage.Navigation.PushModalAsync(new LaunchPage());
         });
     }));
 }
Example #11
0
        public static Task <Boolean> RenewAuthToken(string refreshToken)
        {
            return(Task <Boolean> .Factory.StartNew(() =>
            {
                string responseData = "N/A";
                HttpClient client = new HttpClient();

                try
                {
                    var tokenPost = $"{{\"grant_type\":\"refresh_token\",\"refresh_token\":\"{refreshToken}\"}}";
                    var response = client.PostAsync(new Uri("https://securetoken.googleapis.com/v1/token?key=" + FireCore.FIREBASE_KEY), new StringContent(tokenPost, Encoding.UTF8, "application/json")).Result;
                    responseData = response.Content.ReadAsStringAsync().Result;
                    response.EnsureSuccessStatusCode();
                    FirebaseAuthLink test = JsonConvert.DeserializeObject <FirebaseAuthLink>(responseData);
                    Console.WriteLine("REFRESH TOKEN FROM: " + test.RefreshToken);
                    var auth2 = JsonConvert.DeserializeObject <Dictionary <string, Object> >(responseData);

                    //auth.FirebaseToken = auth2["access_token"].ToString();
                    Settings.LastAuthToken = auth2["access_token"].ToString();
                    //auth.RefreshToken = auth2["refresh_token"].ToString();
                    Settings.RefreshToken = auth2["refresh_token"].ToString();
                    var u = new User();
                    u.LocalId = Settings.LastUserID;
                    string stringData = $"{{\"localId\":\"{Settings.LastUserID}\", \"idToken\":\"{Settings.LastAuthToken}\"}}";

                    FirebaseAuthLink tempAuth = JsonConvert.DeserializeObject <FirebaseAuthLink>(stringData);
                    tempAuth.User = u;
                    auth = tempAuth;
                    expirationTime = Time.CurrentTimeMillis() + (long.Parse(auth2["expires_in"].ToString()) * 1000);
                    if (!Settings.ApnsToken.Equals(string.Empty))
                    {
                        FireDatabase.write("users/" + auth.User.LocalId + "/device_info/apns_token", Settings.ApnsToken);
                    }
                    return true;
                }
                catch (Exception ex)
                {
                    Console.WriteLine("ERROR");
                    Console.WriteLine(ex);
                    return false;
                }
            }));
        }
        private Task updateDriverLocation()
        {
            return(Task.Factory.StartNew(() =>
            {
                Task.Delay(6000);

                while (Settings.InRide)
                {
                    try
                    {
                        Console.WriteLine("Hello");
                        var tracker = FireDatabase.read("rides/" + Settings.LastRideID + "/latest_tracker").Result;
                        makeDriverPin(new Position((double)tracker["lat"], (double)tracker["lng"]));
                    }
                    catch (Exception e)
                    {
                    }
                    Task.Delay(1000);
                }
            }));
        }
Example #13
0
        private Task updateDriverLocation()
        {
            // Immediately starts a loop for every 6 seconds that updates the drivers location asynchronously
            return(Task.Factory.StartNew(() =>
            {
                Task.Delay(6000);

                while (Settings.InRide)
                {
                    try
                    {
                        Console.WriteLine("Hello");
                        var tracker = FireDatabase.read("rides/" + Settings.LastRideID + "/latest_tracker").Result;
                        makeDriverPin(new Position((double)tracker["lat"], (double)tracker["lng"]));
                    }
                    catch (Exception e)
                    {
                    }
                    Task.Delay(1000);
                }
            }));
        }
        public void method(object sender, ElementEventArgs args)
        {
            if (args.Element is RideListEntry && ((RideListEntry)args.Element).Children.Count == 1)
            {
                // Start an asynchronous task
                Task.Run(async() =>
                {
                    // Grab the ride ID from the ride object
                    int index   = ride_stack.Children.IndexOf((RideListEntry)args.Element) / 2;
                    var ride_id = (string)rides.ElementAt(index).Value;

                    string ridePath = "rides/" + ride_id;
                    var ride_dict   = FireDatabase.read(ridePath).Result;


                    // Grab all the information about the current ride from the database
                    string driver_name      = "name";
                    var duid                = (string)ride_dict["duid"];
                    string dropOff_location = "Location";

                    getDriverName(ref driver_name, duid);

                    var tracker_dict = ((JObject)(ride_dict["tracker"])).Values <object>();

                    double total_dist = 0;

                    for (int i = 0; i < tracker_dict.Count() - 1; i++)
                    {
                        var tracker1 = (JObject)((JContainer)tracker_dict.ElementAt(i)).First();
                        var tracker2 = (JObject)((JContainer)tracker_dict.ElementAt(i + 1)).First();

                        var lat1 = tracker1["lat"];
                        var lng1 = tracker1["lng"];
                        var lat2 = tracker2["lat"];
                        var lng2 = tracker2["lng"];

                        if (i + 1 == tracker_dict.Count() - 1)
                        {
                            dropOff_location = lat2 + "," + lng2;
                        }

                        total_dist += calcDistBetweenPoints((double)lat1, (double)lng1, (double)lat2, (double)lng2);
                    }
                    total_dist *= 0.621371;

                    var start_time  = ConvertUnixTimeStamp((long)ride_dict["start_time"]);
                    var finish_time = ConvertUnixTimeStamp((long)ride_dict["finish_time"]);
                    var time        = start_time.Subtract(finish_time).Duration();

                    var ride_time        = time.ToString();
                    string ride_distance = Math.Round(total_dist, 2).ToString() + " miles";
                    string ride_cost     = "$" + (Math.Round((time.TotalMinutes * perMinuteRate) + (total_dist * perMileRate) + safetyCharge + baseRate, 2)).ToString();

                    Device.BeginInvokeOnMainThread(() =>
                    {
                        ride_stack.Children[ride_stack.Children.IndexOf((View)args.Element)] = new RideListEntry(driver_name, dropOff_location, ride_time, ride_distance, ride_cost);
                    });
                    await Task.Delay(100);
                });
            }
        }
        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>();
        }
Example #16
0
        public void monthChanged(DateTime new_date)
        {
            date_grid.Children.Clear();

            date_grid.Children.Add(new Label {
                Text = "S", HorizontalTextAlignment = TextAlignment.Center, VerticalTextAlignment = TextAlignment.Center
            }, 0, 0);
            date_grid.Children.Add(new Label {
                Text = "M", HorizontalTextAlignment = TextAlignment.Center, VerticalTextAlignment = TextAlignment.Center
            }, 1, 0);
            date_grid.Children.Add(new Label {
                Text = "T", HorizontalTextAlignment = TextAlignment.Center, VerticalTextAlignment = TextAlignment.Center
            }, 2, 0);
            date_grid.Children.Add(new Label {
                Text = "W", HorizontalTextAlignment = TextAlignment.Center, VerticalTextAlignment = TextAlignment.Center
            }, 3, 0);
            date_grid.Children.Add(new Label {
                Text = "R", HorizontalTextAlignment = TextAlignment.Center, VerticalTextAlignment = TextAlignment.Center
            }, 4, 0);
            date_grid.Children.Add(new Label {
                Text = "F", HorizontalTextAlignment = TextAlignment.Center, VerticalTextAlignment = TextAlignment.Center
            }, 5, 0);
            date_grid.Children.Add(new Label {
                Text = "S", HorizontalTextAlignment = TextAlignment.Center, VerticalTextAlignment = TextAlignment.Center
            }, 6, 0);

            date_label.Text = new_date.ToString("MMMM yyyy");


            while (new_date.Day != 1)
            {
                new_date = new_date.AddDays(-1);
            }

            String dayOfFirst = new_date.DayOfWeek.ToString();
            int    row        = 1;
            int    col        = 0;

            switch (dayOfFirst)
            {
            case "Sunday":
                col = 0;
                break;

            case "Monday":
                col = 1;
                break;

            case "Tuesday":
                col = 2;
                break;

            case "Wednesday":
                col = 3;
                break;

            case "Thursday":
                col = 4;
                break;

            case "Friday":
                col = 5;
                break;

            case "Saturday":
                col = 6;
                break;
            }

            string path  = "users/" + FireAuth.auth.User.LocalId + "/ride_info/ride_history/" + new_date.ToString("M-y");
            var    rides = FireDatabase.read(path).Result;


            for (int i = 0; i < DateTime.DaysInMonth(new_date.Year, new_date.Month); i++)
            {
                if (col == 7)
                {
                    row++;
                    col = 0;
                }

                var nextDay = new Label {
                    Text = (i + 1).ToString(), HorizontalTextAlignment = TextAlignment.Center, VerticalTextAlignment = TextAlignment.Center
                };


                int numDays             = i;
                var day_clicked_gesture = new TapGestureRecognizer();
                day_clicked_gesture.Tapped += (s, e) =>
                {
                    Console.WriteLine("TEST");
                    nextDay.BackgroundColor = Color.Gray;
                    if (rides.ContainsKey(new_date.ToString("M-") + nextDay.Text + new_date.ToString("-y")))
                    {
                        DateTime date_clicked_on = new DateTime();
                        date_clicked_on = new_date.AddDays(numDays);
                        Console.WriteLine("TEST3");
                        Navigation.PushModalAsync(new RideListPage(date_clicked_on));
                    }
                    nextDay.BackgroundColor = Color.Transparent;
                };

                nextDay.GestureRecognizers.Add(day_clicked_gesture);

                date_grid.Children.Add(nextDay, col, row);

                if (rides != null)
                {
                    //Add ride markers for neccessary days
                    if (rides.ContainsKey(new_date.ToString("M-") + nextDay.Text + new_date.ToString("-y")))
                    {
                        addRideMarker(nextDay, col, row);
                    }
                }

                col++;
            }
        }