Ejemplo n.º 1
0
        RootElement InitializeRoot()
        {
            var root    = new RootElement();
            var section = new Section();

            var bindings = this.CreateInlineBindingTarget <CreateAccountViewModel>();

            // Used DialogCenter + paddingTop = 1dip because DialogTop caused a thiner separation line
            var email = new EntryElement(null, this.Services().Localize["CreateAccountEmailPlaceHolder"], null, "DialogCenter")
            {
                IsEmail = true
            };

            email.Bind(bindings, vm => vm.Data.Email);

            var name = new TaxiHailEntryElement(null, this.Services().Localize["CreateAccountFullNamePlaceHolder"], null, "DialogCenter", InputTypes.TextFlagCapWords);

            name.Bind(bindings, vm => vm.Data.Name);

            var layoutCell      = "DialogCenter";
            var phoneEditorCell = "PhoneEditor";

            if (ViewModel.HasSocialInfo && !ViewModel.Settings.IsPayBackRegistrationFieldRequired.HasValue)
            {
                layoutCell      = "DialogBottom";
                phoneEditorCell = "PhoneEditorBottom";
            }

            var phoneNumber = (bindings.BindingContextOwner.BindingContext.DataContext as CreateAccountViewModel).PhoneNumber;
            var phone       = new PhoneEditorElement(null, phoneNumber, phoneEditorCell);

            var password = new TaxiHailEntryElement(null, this.Services().Localize["CreateAccountPasswordPlaceHolder"], null, layoutCell)
            {
                Password = true
            };

            password.Bind(bindings, vm => vm.Data.Password);

            if (!ViewModel.Settings.IsPayBackRegistrationFieldRequired.HasValue)
            {
                layoutCell = "DialogBottom";
            }

            var passwordConfirm = new TaxiHailEntryElement(null, this.Services().Localize["CreateAccountPasswordConfirmationPlaceHolder"], null, layoutCell)
            {
                Password = true
            };

            passwordConfirm.Bind(bindings, vm => vm.ConfirmPassword);

            var payback = new TaxiHailEntryElement(null, this.Services().Localize["CreateAccountPayBackPlaceHolder"], null, "DialogBottom")
            {
                Numeric = true
            };

            payback.Bind(bindings, vm => vm.Data.PayBack);


            section.Add(new Element[] { email, name, phone });

            if (!ViewModel.HasSocialInfo)
            {
                section.Add(new Element[] { password, passwordConfirm });
            }

            if (ViewModel.Settings.IsPayBackRegistrationFieldRequired.HasValue)
            {
                section.Add(new Element[] { payback });
            }

            root.LayoutName = "fake_rounded";

            root.Add(section);

            return(root);
        }
        private void BuildTableView()
        {
            const int entryElementHeight = 40;

            var bindings = this.CreateInlineBindingTarget <CreateAccountViewModel>();

            var fullNameEntryElement = new TaxiHailEntryElement(string.Empty, Localize.GetValue("CreateAccountFullNamePlaceHolder"),
                                                                ViewModel.Data.Name,
                                                                false,
                                                                UITextAutocapitalizationType.Words).Bind(bindings, vm => vm.Data.Name);

            var emailEntryElement = new TaxiHailEntryElement(string.Empty, Localize.GetValue("CreateAccountEmailPlaceHolder"), ViewModel.Data.Email)
            {
                KeyboardType = UIKeyboardType.EmailAddress
            }.Bind(bindings, vm => vm.Data.Email);

            emailEntryElement.IsInputEnabled = !ViewModel.HasSocialInfo;

            var phoneNumberInfo    = (bindings.BindingContextOwner.BindingContext.DataContext as CreateAccountViewModel).PhoneNumber;
            var phoneEditorElement = new PhoneEditorElement(string.Empty, phoneNumberInfo, NavigationController, Localize.GetValue("CreateAccountPhonePlaceHolder"));

            var section = new Section()
            {
                emailEntryElement,
                fullNameEntryElement,
                phoneEditorElement
            };

            if (!ViewModel.HasSocialInfo)
            {
                constraintTableViewHeight.Constant += entryElementHeight * 2;

                section.AddAll(new List <Element>
                {
                    new TaxiHailEntryElement(string.Empty, Localize.GetValue("CreateAccountPasswordPlaceHolder"), ViewModel.Data.Password, true)
                    .Bind(bindings, vm => vm.Data.Password),
                    new TaxiHailEntryElement(string.Empty, Localize.GetValue("CreateAccountPasswordConfirmationPlaceHolder"), ViewModel.ConfirmPassword, true)
                    .Bind(bindings, vm => vm.ConfirmPassword)
                });
            }

            if (ViewModel.Settings.IsPayBackRegistrationFieldRequired.HasValue)
            {
                constraintTableViewHeight.Constant += entryElementHeight;

                section.Add(new TaxiHailEntryElement(string.Empty, Localize.GetValue("CreateAccountPayBackPlaceHolder"),
                                                     ViewModel.Data.Name,
                                                     false)
                {
                    KeyboardType = UIKeyboardType.NumberPad
                }
                            .Bind(bindings, vm => vm.Data.PayBack));
            }

            var root = new RootElement()
            {
                section
            };

            tableView.BackgroundColor = UIColor.Clear;
            tableView.AddSubview(new TaxiHailDialogViewController(root, true).TableView);
        }