Exemple #1
0
        protected override bool IsValid()
        {
            if (!ValidationHelper.ValidateTextField(EntryRecepient.Text))
            {
                EntryRecepient.FocusField();
                Scroll();
                return(false);
            }
            else if (!ValidationHelper.ValidateTextField(ViewModel.LauncherFullPhoneNumber))
            {
                EntryLauncherPhoneNumber.Focus();
                Scroll();
                return(false);
            }
            else if (!ValidationHelper.ValidateTextField(ViewModel.RecipientFullPhoneNumber))
            {
                EntryRecipientPhoneNumber.Focus();
                Scroll();
                return(false);
            }
            else if (!ValidationHelper.ValidateTextField(ViewModel.FromLocationGPS))
            {
                EventHandler handleHandler = (s, e) => {
                    var picker = new LocationPickerPage(LocationPickerType.From);
                    picker.eventHandler = DidSelectLocationHandler;
                    Navigation.PushAsync(picker, true);
                };

                ShowErrorMessage(AppResources.LocationsNotSet, false, handleHandler);

                return(false);
            }
            else if (!ValidationHelper.ValidateTextField(ViewModel.ToLocationGPS))
            {
                EventHandler handleHandler = (s, e) => {
                    var picker = new LocationPickerPage(LocationPickerType.To);
                    picker.eventHandler = DidSelectLocationHandler;
                    Navigation.PushAsync(picker, true);
                };

                ShowErrorMessage(AppResources.LocationsNotSet, false, handleHandler);

                return(false);
            }
            else if (PhotoSource == null)
            {
                EventHandler handleHandler = (s, e) => {
                    OnTakePhoto(PhotoButton, null);
                };

                ShowErrorMessage(AppResources.SelectPackagePhoto, false, handleHandler);

                return(false);
            }
            else if (!ValidationHelper.ValidateTextField(EntryDeadline.Text))
            {
                EventHandler handleHandler = (s, e) => { 
 EntryDeadline.Focus(); 
 }; 

                ShowErrorMessage(AppResources.SelectDeadlineDate, false, handleHandler); 

                return(false);
            }
            else if (!ValidationHelper.ValidateNumber(EntryPayment.Text))
            {
                EntryPayment.Focus();

                return(false);
            }
            else if (!ValidationHelper.ValidateNumber(EntryCollateral.Text))
            {
                EntryCollateral.Focus();

                return(false);
            }
            else if (!ValidationHelper.ValidateTextField(EntryDescription.Text))
            {
                EntryDescription.Focus();
                Scroll();

                return(false);
            }


            return(true);
        }
Exemple #2
0
        public LaunchPackagePage(Package package)
        {
            InitializeComponent();

            AddressBookHelper.LoadCallSigns();

            BindingContext = package;

            //set launcher phone
            var profile = App.Locator.ProfileModel;
            var number  = profile.StoredPhoneNumber;

            PhoneNumberUtil phoneUtil = PhoneNumberUtil.Instance;

            try
            {
                PhoneNumber numberProto = phoneUtil.Parse(number, "");
                package.LauncherPhoneCode   = "+" + Convert.ToString(numberProto.CountryCode);
                package.LauncherPhoneNumber = number.Replace(package.LauncherPhoneCode, "");
            }
            catch (NumberParseException)
            {
                package.LauncherPhoneNumber = number;
            }

#if __IOS__
            if (App.Locator.DeviceService.IsIphoneX() == true)
            {
                TitleLabel.TranslationY = 35;
                BackButton.TranslationY = 10;
            }
            else
            {
                TitleLabel.TranslationY = 24;
            }
#elif __ANDROID__
            TitleLabel.TranslationY = 5;
            BackButton.TranslationY = -18;
            BackButton.TranslationX = -30;
            EntryLauncherPhoneNumber.TranslationY  = 3;
            EntryRecipientPhoneNumber.TranslationY = 3;
#endif

            var selectMyCountryCommand = new Command(() =>
            {
                var picker          = new CountryPickerPage();
                picker.eventHandler = DidSelectMyCountryHandler;
                Navigation.PushAsync(picker, true);
            });

            var selectRecipientCountryCommand = new Command(() =>
            {
                var picker          = new CountryPickerPage();
                picker.eventHandler = DidSelectRecipientCountryHandler;
                Navigation.PushAsync(picker, true);
            });

            var selectFromLocation = new Command(() =>
            {
                GooglePlace place = null;

                if (ViewModel.FromLocationGPS != null)
                {
                    string location = ViewModel.FromLocationGPS;

                    place           = new GooglePlace();
                    place.Address   = ViewModel.FromLocationAddress;
                    place.Latitude  = Convert.ToDouble(location.Split(',')[0]);
                    place.Longitude = Convert.ToDouble(location.Split(',')[1]);
                }

                var picker          = new LocationPickerPage(LocationPickerType.From, place);
                picker.eventHandler = DidSelectLocationHandler;
                Navigation.PushAsync(picker, true);
            });

            var selectToLocation = new Command(() =>
            {
                GooglePlace place = null;

                if (ViewModel.ToLocationGPS != null)
                {
                    string location = ViewModel.ToLocationGPS;

                    place           = new GooglePlace();
                    place.Address   = ViewModel.ToLocationAddress;
                    place.Latitude  = Convert.ToDouble(location.Split(',')[0]);
                    place.Longitude = Convert.ToDouble(location.Split(',')[1]);
                }

                var picker          = new LocationPickerPage(LocationPickerType.To, place);
                picker.eventHandler = DidSelectLocationHandler;
                Navigation.PushAsync(picker, true);
            });

            var openFullScreeenPhotoCommand = new Command(() =>
            {
                OpenPhotoFullScreen();
            });
            XamEffects.Commands.SetTap(PhotoImage, openFullScreeenPhotoCommand);

            XamEffects.Commands.SetTap(LauncherCountryCodeLabel, selectMyCountryCommand);
            XamEffects.Commands.SetTap(RecipientCountryCodeLabel, selectRecipientCountryCommand);
            XamEffects.Commands.SetTap(FromLocationLabel, selectFromLocation);
            //  XamEffects.Commands.SetTap(FromLocationFrame, selectFromLocation);
            XamEffects.Commands.SetTap(FromLocationImage, selectFromLocation);
            XamEffects.Commands.SetTap(ToLocationLabel, selectToLocation);
            // XamEffects.Commands.SetTap(ToLocationFrame, selectToLocation);
            XamEffects.Commands.SetTap(ToLocationImage, selectToLocation);

            EntryRecepient.MakeCustomOffset();
        }