예제 #1
0
        public FillUserDataView(CreateUserData userData, string buttonName, bool isPasswordEnabled)
        {
            _fakeProfileImagePath = Path.Combine(AppProvider.IOManager.DocumentPath, "fakeProfileImage.jpeg");
            Model = userData;
            var layout = new StackLayout {
                BackgroundColor = Color.Transparent,
                Padding         = new Thickness(0, 0, 10, 0)
            };

            var topLayout = new StackLayout {
                Orientation = StackOrientation.Horizontal,
                Padding     = new Thickness(10, 0, 0, 0)
            };

            string imagePath   = string.IsNullOrEmpty(userData.ProfileImage) ? AppResources.DefaultUserImage : userData.ProfileImage;
            var    imageLayout = new StackLayout {
            };

            _profileImage = new Image {
                WidthRequest  = 100,
                HeightRequest = 100,
                Source        = ImageLoader.Instance.GetImage(imagePath, false)
            };

            imageLayout.Children.Add(_profileImage);

            var btnUpdatePicture = new Button {
                WidthRequest    = 100,
                FontSize        = 15,
                Text            = AppResources.SignUpChooseImage,
                BackgroundColor = Color.Transparent,
                TextColor       = AppResources.SignUpChooseImageButtonColor,
                BorderRadius    = 0,
                BorderWidth     = 2,
                BorderColor     = AppResources.SignUpChooseImageButtonColor
            };

                        #if __ANDROID__
            btnUpdatePicture.TextColor       = Color.White;
            btnUpdatePicture.BackgroundColor = AppResources.SignUpChooseImageButtonColor;
                        #endif

            btnUpdatePicture.Clicked += OnImageClicked;
            imageLayout.Children.Add(btnUpdatePicture);

            topLayout.Children.Add(imageLayout);

            var nameSurnameLayout = new StackLayout();
            nameSurnameLayout.Children.Add(GetEntry(Keyboard.Create(KeyboardFlags.CapitalizeSentence), AppResources.GetName(Model.Name), AppResources.LoginNameDefaultEntry, 20, false, out _nameEntry, 140, 10));
            nameSurnameLayout.Children.Add(GetEntry(Keyboard.Create(KeyboardFlags.CapitalizeSentence), AppResources.GetSurname(Model.Name), AppResources.LoginSurnameDefaultEntry, 15, false, out _surnameEntry, 140, 10));

            topLayout.Children.Add(nameSurnameLayout);

            layout.Children.Add(topLayout);

            layout.Children.Add(GetEntry(Keyboard.Email, Model.Email, AppResources.LoginEmailDefaultEntry, 10, false, out _emailEntry));

            if (isPasswordEnabled)
            {
                layout.Children.Add(GetEntry(Keyboard.Text, Model.Password, AppResources.LoginPasswordDefaultEntry, 10, true, out _passwordEntry));
            }

            layout.Children.Add(GetEntry(Keyboard.Create(KeyboardFlags.CapitalizeSentence), Model.Job, AppResources.LoginJobDefaultEntry, 15, false, out _jobEntry));
            layout.Children.Add(GetEntry(Keyboard.Telephone, Model.Phone, AppResources.LoginPhoneDefaultEntry, 10, false, out _phoneEntry));

            var applyBtn = new Button {
                BorderRadius    = 5,
                WidthRequest    = AppProvider.Screen.Width,
                FontSize        = 14,
                TextColor       = Color.White,
                BackgroundColor = AppResources.LoginButtonColor,
                Text            = buttonName
            };
            applyBtn.Clicked += OnApplyClicked;
            layout.Children.Add(new ContentView {
                Padding = new Thickness(LeftBorder, 10, LeftBorder, 0), HorizontalOptions = LayoutOptions.Center, Content = applyBtn
            });

            var fs = new FormattedString();

            string firstPart  = "Ao clicar em cadastrar, você confirma estar de acordo com nossos";
            string secondPart = " Termos de Uso ";
            string thirdPart  = "e também está de acordo com a nossa ";


            fs.Spans.Add(new Span {
                Text = firstPart, ForegroundColor = Color.Black, FontSize = 14
            });
            fs.Spans.Add(new Span {
                Text = secondPart, ForegroundColor = Color.Blue, FontSize = 14
            });
            fs.Spans.Add(new Span {
                Text = thirdPart, ForegroundColor = Color.Black, FontSize = 14
            });
            string fourthPart = " Política de Privacidade";

            var labelTerms = new Label {
                FormattedText = fs
            };
            TapGestureRecognizer tap = new TapGestureRecognizer();
            tap.Tapped += OnClicked;
            labelTerms.GestureRecognizers.Add(tap);

            var fs2 = new FormattedString();

            fs2.Spans.Add(new Span {
                Text = fourthPart, ForegroundColor = Color.Blue, FontSize = 14
            });

            var labelPrivaPol = new Label
            {
                FormattedText = fs2
            };

            TapGestureRecognizer tap2 = new TapGestureRecognizer();
            tap2.Tapped += OnClicked2;
            labelPrivaPol.GestureRecognizers.Add(tap2);



            layout.Children.Add(new ContentView {
                Content = labelTerms, Padding = new Thickness(10, 10, 10, 0)
            });
            layout.Children.Add(new ContentView {
                Content = labelPrivaPol, Padding = new Thickness(10, 0, 10, 0)
            });


            Content = new ScrollView {
                Content = layout
            };

            _requiredFields = new List <InputFieldView> {
                _jobEntry,
                _emailEntry,
                _nameEntry,
                _passwordEntry,
                //_phoneEntry,
                _surnameEntry
            };
        }