Exemple #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);
        }