Пример #1
0
        private bool ValidateForm()
        {
            ResetErrors();

            if (_password.GetValue() != _retypedPassword.GetValue())
            {
                _retypedPassword.SetMessage("Passwords do not match", MessageType.Error);
                return(false);
            }

            return(true);
        }
Пример #2
0
        public async void OnRegisterClick()
        {
            if (!ValidateForm())
            {
                return;
            }

            // try to save te new user
            RegisterRequest request = new RegisterRequest()
            {
                fullName = _fullName.GetValue(),
                nickname = _nickname.GetValue(),
                email    = _email.GetValue(),
                password = _password.GetValue(),
            };

            RegisterResponse response;

            try
            {
                response = await Global.RestClient.Post <RegisterResponse>("/account/register", request);
            }
            catch (ResponseException e)
            {
                _title.SetMessage(e.Message, MessageType.Error);
                return;
            }

            ResetForm();

            _title.SetMessage($"Thanks {response.Nickname}!");

            //
            await Task.Delay(3000);

            ResetForm();

            OnSignInClick();
        }
Пример #3
0
        public async void OnSignInClick()
        {
            ResetErrors();

            SignInRequest request = new SignInRequest()
            {
                email    = _email.GetValue(),
                password = _password.GetValue()
            };

            Debug.Log(request.GetQueryString());

            SignInResponse response;

            try
            {
                response = await Global.RestClient.Post <SignInResponse>("/account/sign-in", request);

                Global.Me = response;
            }
            catch (ResponseException e)
            {
                _title.SetMessage(e.Message, MessageType.Error);
                return;
            }

            ResetForm();

            _title.SetMessage($"Wellcome {response.nickname}!");

            await Task.Delay(1000);

            ResetForm();

            gameObject.SetActive(false);
            GamePanel.SetActive(true);
        }
Пример #4
0
        public async Task CreateGeoLocationForm(float xPosition, float yPosition)
        {
            if (GeoLocationForm != null)
            {
                GeoLocationForm.parent?.Remove(GeoLocationForm);
                GeoLocationForm = null;
            }
            else
            {
                GeoLocationForm = new Stack().Size(200, 90).Padding(vertical: 8, horizontal: 8).Border(color: "#444", all: 1)
                                  .Background(color: "#666").X(xPosition).Y(yPosition).Absolute().ZIndex(1000);

                var title = new TextView {
                    Text = "Your Location", TextAlignment = Alignment.Middle
                };
                title.Width(100.Percent()).Padding(bottom: 5).Font(bold: true);
                var latField = new FormField <TextInput> {
                    LabelText = "Latitude"
                };
                var longField = new FormField <TextInput> {
                    LabelText = "Longitude"
                };
                latField.Control.Background(color: "#444").Padding(top: 5).Font(color: Colors.White, size: 10);
                longField.Control.Background(color: "#444").Padding(top: 5).Font(color: Colors.White, size: 10);

                if (EnvironmentSimulator.Location != null)
                {
                    latField.Control.Text(EnvironmentSimulator.Location.Latitude.ToString());
                    longField.Control.Text(EnvironmentSimulator.Location.Longitude.ToString());
                }

                var configButton = new Button
                {
                    Text            = "Set",
                    BackgroundColor = new GradientColor(GradientColor.Direction.Down).Add("#555", 50).EndWith("#444")
                };

                configButton.Tapped
                .Handle(() =>
                {
                    EnvironmentSimulator.Location = new GeoPosition
                    {
                        Latitude  = latField.GetValue <float>(),
                        Longitude = longField.GetValue <float>()
                    };

                    GeoLocationForm.parent?.Remove(GeoLocationForm);
                    GeoLocationForm = null;
                });

                await GeoLocationForm.Add(title);

                await GeoLocationForm.Add(latField);

                await GeoLocationForm.Add(longField);

                await GeoLocationForm.Add(configButton);

                await MainPhone.Add(GeoLocationForm);
            }
        }