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();
        }
Esempio n. 2
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();
        }
Esempio n. 3
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"];
        }
        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"];
        }
        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);
                }
            }));
        }
Esempio n. 6
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>();
        }
Esempio n. 9
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++;
            }
        }