private async void LiecenceImg_Clicked(object sender, EventArgs e)
        {
            var storageStatus = await CrossPermissions.Current.CheckPermissionStatusAsync(Permission.Storage);

            if (storageStatus != PermissionStatus.Granted)
            {
                var results = await CrossPermissions.Current.RequestPermissionsAsync(new[] { Permission.Storage });

                storageStatus = results[Permission.Storage];
            }
            if (storageStatus == PermissionStatus.Granted)
            {
                DriverLicImg = await CrossMedia.Current.PickPhotoAsync();

                if (DriverLicImg == null)
                {
                    return;
                }
                LiecenceImgSource.Source = ImageSource.FromStream(() =>
                {
                    return(DriverLicImg.GetStream());
                });
            }
            else
            {
                await DisplayAlert(AppResources.PermissionsDenied, AppResources.PermissionDetails, AppResources.Ok);

                //On iOS you may want to send your user to the settings screen.
                CrossPermissions.Current.OpenAppSettings();
            }
        }
        private async void Regbtn_Clicked(object sender, EventArgs e)
        {
            Active.IsRunning = true;
            StringContent user_id      = new StringContent(Settings.LastUsedDriverID.ToString());
            StringContent car_model_id = new StringContent(Settings.CarModelID);
            StringContent lat          = new StringContent(Settings.LastLat);
            StringContent lang         = new StringContent(Settings.LastLng);
            var           content      = new MultipartFormDataContent();

            content.Add(user_id, "user_id");
            content.Add(lat, "lat");
            content.Add(lang, "lang");
            content.Add(car_model_id, "car_model_id");
            content.Add(new StreamContent(ProfilePic.GetStream()), "personal_image", $"{ProfilePic.Path}");
            content.Add(new StreamContent(NationalImg1.GetStream()), "national_id_front", $"{NationalImg1.Path}");
            content.Add(new StreamContent(NationalImg2.GetStream()), "national_id_behind", $"{NationalImg2.Path}");
            content.Add(new StreamContent(DriverLicImg.GetStream()), "driving_license", $"{DriverLicImg.Path}");
            content.Add(new StreamContent(CarLicImg.GetStream()), "car_license", $"{CarLicImg.Path}");
            content.Add(new StreamContent(CarImg.GetStream()), "car_img", $"{CarImg.Path}");
            var httpClient = new HttpClient();

            try
            {
                var httpResponseMessage = await httpClient.PostAsync("http://wassel.alsalil.net/api/driverRegister", content);

                var serverResponse = httpResponseMessage.Content.ReadAsStringAsync().Result.ToString();
                var json           = JsonConvert.DeserializeObject <Response <string, string> >(serverResponse);
                if (json.success == false)
                {
                    Active.IsRunning = false;
                    await DisplayAlert(AppResources.Error, json.message, AppResources.Ok);
                }
                else
                {
                    Active.IsRunning = false;
                    await DisplayAlert(json.message, AppResources.RegisterSuccess, AppResources.Ok);

                    Device.BeginInvokeOnMainThread(() => App.Current.MainPage = new LoginPage());
                }
            }
            catch (Exception)
            {
                Active.IsRunning = false;
                await DisplayAlert(AppResources.ErrorMessage, AppResources.ErrorMessage, AppResources.Ok);
            }
        }
        private async void DriverLicImg_Clicked(object sender, EventArgs e)
        {
            await CrossMedia.Current.Initialize();

            if (!CrossMedia.Current.IsPickPhotoSupported)
            {
                await DisplayAlert("خطأ", "لم يتم إلتقاط صور", "موافق");

                return;
            }
            DriverLicImg = await CrossMedia.Current.PickPhotoAsync();

            if (DriverLicImg == null)
            {
                return;
            }

            DriverLicImgSource.Source = ImageSource.FromStream(() =>
            {
                return(DriverLicImg.GetStream());
            });
        }
        private async void DriverRegisterCommand(object sender, EventArgs e)
        {
            Active.IsRunning = true;
            var location = await Geolocation.GetLocationAsync();

            Settings.LastLat = location.Latitude.ToString();
            Settings.LastLng = location.Longitude.ToString();
            var device = DeviceInfo.Model;

            if (AllNeeded() == true)
            {
                GetFirbasetoken();
                UserService userService = new UserService();
                DriverUser  _driveruser = new DriverUser
                {
                    email          = EmailEntry.Text,
                    name           = NameEntry.Text,
                    phone          = PhoneEntry.Text,
                    password       = passwordEntry.Text,
                    confirmpass    = confirmpassEntry.Text,
                    country        = CountryEntry.Text,
                    city           = CityEntry.Text,
                    firebase_token = Settings.UserFirebaseToken,
                    nationality    = nationalityEntry.Text,
                    national       = Settings.Residentid.ToString(),
                    device_id      = Settings.LastSignalID,
                    age            = AgeEntry.Text,
                    carmodal       = Settings.CarModelID,
                    cartype        = Settings.cartype.ToString(),
                    //denominationnumber = denominationnumberimg,
                    //passportnumber = passportnumber.Text,
                    carnumber = CarNumberEntry.Text,
                    idnumber  = IdNumberEntry.Text,
                    type      = Settings.Type.ToString(),
                    load      = loadEntry.Text,
                    lat       = Settings.LastLat,
                    lng       = Settings.LastLng
                };

                StringContent name           = new StringContent(_driveruser.name);
                StringContent phone          = new StringContent(_driveruser.phone);
                StringContent email          = new StringContent(_driveruser.email);
                StringContent password       = new StringContent(_driveruser.password);
                StringContent confirmpass    = new StringContent(_driveruser.confirmpass);
                StringContent country        = new StringContent(_driveruser.country);
                StringContent city           = new StringContent(_driveruser.city);
                StringContent cartype        = new StringContent(_driveruser.cartype);
                StringContent carmodal       = new StringContent(_driveruser.carmodal);
                StringContent carnumber      = new StringContent(_driveruser.carnumber);
                StringContent device_id      = new StringContent(_driveruser.device_id);
                StringContent age            = new StringContent(_driveruser.age);
                StringContent idnumber       = new StringContent(_driveruser.idnumber);
                StringContent firebase_token = new StringContent(_driveruser.firebase_token);
                StringContent national       = new StringContent(_driveruser.national);
                StringContent nationality    = new StringContent(_driveruser.nationality);
                StringContent load           = new StringContent(_driveruser.load);
                StringContent type           = new StringContent(_driveruser.type);
                StringContent lat            = new StringContent(_driveruser.lat);
                StringContent lng            = new StringContent(_driveruser.lng);
                var           content        = new MultipartFormDataContent();

                content.Add(name, "name");
                content.Add(email, "email");
                content.Add(phone, "phone");
                content.Add(password, "password");
                content.Add(confirmpass, "confirmpass");
                content.Add(country, "country");
                content.Add(city, "city");
                content.Add(cartype, "cartype");
                content.Add(carmodal, "carmodal");
                content.Add(carnumber, "carnumber");
                content.Add(device_id, "device_id");
                content.Add(age, "age");
                content.Add(idnumber, "idnumber");
                content.Add(firebase_token, "firebase_token");
                content.Add(national, "national");
                content.Add(nationality, "nationality");
                content.Add(load, "load");
                content.Add(type, "type");
                content.Add(lat, "lat");
                content.Add(lng, "lng");
                content.Add(new StreamContent(DriverLicImg.GetStream()), "denominationnumber", $"{DriverLicImg.Path}");
                content.Add(new StreamContent(ProfilePic.GetStream()), "image", $"{ProfilePic.Path}");
                content.Add(new StreamContent(passportnumber.GetStream()), "passportnumber", $"{passportnumber.Path}");
                //content.Add(new StreamContent(_mediafile.GetStream()), "images", $"{_mediafile.Path}");
                HttpClient httpClient = new HttpClient();
                try
                {
                    var httpResponseMessage = await httpClient.PostAsync("https://waselksa.alsalil.net/api/register",
                                                                         content);

                    var serverResponse = httpResponseMessage.Content.ReadAsStringAsync().Result.ToString();
                    if (serverResponse == "false")
                    {
                        Active.IsRunning = false;
                        await DisplayAlert(AppResources.Error, AppResources.ErrorMessage, AppResources.Ok);
                    }
                    else
                    {
                        try
                        {
                            try
                            {
                                Active.IsRunning = false;
                                var JsonResponse = JsonConvert.DeserializeObject <Response <string, Models.DriverUser> >(serverResponse);
                                if (JsonResponse.success == true)
                                {
                                    Settings.LastUsedDriverID = JsonResponse.message.id;
                                    Settings.LastUsedEmail    = JsonResponse.message.email;
                                    Settings.LastUserStatus   = "0";
                                    Settings.ProfileUser      = "******";
                                    Settings.ProfileName      = JsonResponse.message.name;
                                    Settings.CarLat           = Convert.ToDouble(JsonResponse.message.lat);
                                    Settings.CarLng           = Convert.ToDouble(JsonResponse.message.lng);
                                    await PopupNavigation.Instance.PushAsync(new RegisterPopup(JsonResponse.data));

                                    Device.BeginInvokeOnMainThread(() => App.Current.MainPage = new MainTabbedPage());
                                }
                            }
                            catch
                            {
                                var JsonResponse = JsonConvert.DeserializeObject <RegisterResponse>(serverResponse);
                                if (JsonResponse.success == false)
                                {
                                    Active.IsRunning = false;
                                    await PopupNavigation.Instance.PushAsync(new RegisterPopup(JsonResponse.data));
                                }
                            }
                        }
                        catch (Exception)
                        {
                            Active.IsRunning = false;
                            await PopupNavigation.Instance.PushAsync(new ConnectionPopup());

                            return;
                        }
                    }
                }
                catch (Exception)
                {
                    await DisplayAlert(AppResources.Error, AppResources.ErrorMessage, AppResources.Ok);
                }
            }
        }