void Init()
        {
            App.StartCheckInternet(NoInternetLabel, this);

            NoInternetLabel.TextColor       = Color.White;
            NoInternetLabel.BackgroundColor = Constants.ErrorColor;

            EntryEmail.TextColor        = Constants.MainTextColor;
            EntryEmail.PlaceholderColor = Constants.PlaceHolderColor;
            EntryEmail.Completed       += (s, e) => EntryPassword.Focus();
            EntryEmail.FontSize         = Constants.TextM;

            EntryPassword.TextColor        = Constants.MainTextColor;
            EntryPassword.PlaceholderColor = Constants.PlaceHolderColor;
            EntryPassword.Completed       += (s, e) => LoginButton_Clicked(s, e);
            EntryPassword.FontSize         = Constants.TextM;

            ForgottenPassword.TextColor = Constants.OrangeTextColor;
            ForgottenPassword.FontSize  = Constants.TextS;

            LoginButton.FontSize  = Constants.TextM;
            LoginButton.TextColor = Constants.ButtonTextColor;

            RegisterLabel.FontSize  = Constants.TextS;
            RegisterLabel.TextColor = Constants.ButtonTextColor;

            RegisterLink.TextColor = Constants.OrangeTextColor;

            LoginButtonBackgroundColor.FillColor = Constants.ActiveOrangeColor;

            //Auto login
            Token loadedToken = App.TokenDatabase.GetToken();

            autoLogin(loadedToken);
        }
Exemplo n.º 2
0
        void init()
        {
            App.StartCheckInternet(NoInternetLabel, this);

            // Error label style
            NoInternetLabel.TextColor       = Color.White;
            NoInternetLabel.BackgroundColor = Constants.ErrorColor;

            // Email entry style
            EntryEmail.TextColor        = Constants.MainTextColor;
            EntryEmail.PlaceholderColor = Constants.PlaceHolderColor;
            EntryEmail.Completed       += (s, e) => EntryPassword.Focus();
            EntryEmail.FontSize         = Constants.TextM;

            // Password entry style
            EntryPassword.TextColor        = Constants.MainTextColor;
            EntryPassword.PlaceholderColor = Constants.PlaceHolderColor;
            //EntryPassword.Completed += (s, e) => LoginButton_Clicked(s, e);
            EntryPassword.FontSize = Constants.TextM;

            // Login label style
            LoginLabel.TextColor = Color.White;
            LoginLabel.FontSize  = Constants.TextS;

            // Login link style
            LoginLink.TextColor = Constants.OrangeTextColor;
            LoginLink.FontSize  = Constants.TextS;

            // Register button style
            RegisterButton.FontSize  = Constants.TextM;
            RegisterButton.TextColor = Constants.ButtonTextColor;

            RegisterButtonBackgroundColor.FillColor = Constants.ActiveOrangeColor;
        }
 private void OnWrongPasswordEntered(TypePasswordViewModel arg1, string arg2)
 {
     Device.BeginInvokeOnMainThread(async() =>
     {
         await System.Threading.Tasks.Task.Delay(250);
         EntryPassword.Focus();
     });
 }
Exemplo n.º 4
0
        public MainPage()
        {
            InitializeComponent();

            Task.Delay(2000).ContinueWith((arg) =>
            {
                Debug.WriteLine(EntryUserName.GetAbsoluteLocation().ToString());
                Debug.WriteLine(EntryPassword.GetAbsoluteLocation().ToString());
            });
        }
        private void Init()
        {
            BackgroundColor           = Constants.BackgroundColor;
            LblUsername.TextColor     = Constants.MainTextColor;
            LblPassword.TextColor     = Constants.MainTextColor;
            ActivitySpinner.IsVisible = false;
            LoginIcon.HeightRequest   = Constants.LogicIconHeight;

            EntryUsername.Completed += (s, e) => EntryPassword.Focus();
            EntryPassword.Completed += SignInProcedure;
        }
Exemplo n.º 6
0
        void Init()
        {
            BackgroundColor           = Constants.BackgroundColor;
            lblUsername.TextColor     = Constants.MainTextColor;
            lblPassword.TextColor     = Constants.MainTextColor;
            ActivitySpinner.IsVisible = false;
            LogInIcon.HeightRequest   = Constants.LoginIconHeight;

            EntryUsername.Completed += (s, e) => EntryPassword.Focus();
            EntryPassword.Completed += (s, e) => Btn_SignInAsync(s, e);
        }
        protected override void OnAppearing()
        {
            base.OnAppearing();

            // https://github.com/xamarin/Xamarin.Forms/issues/2094
            Device.BeginInvokeOnMainThread(async() =>
            {
                await System.Threading.Tasks.Task.Delay(250);
                EntryPassword.Focus();
            });

            MessagingCenter.Subscribe <TypePasswordViewModel, string>(viewModel, Messages.WRONGPASSWORD, OnWrongPasswordEntered);
        }
Exemplo n.º 8
0
 public Login()
 {
     InitializeComponent();
     FlowDirection         = (CyberMentor.Helper.AppSettings.LastUserGravity == "Arabic") ? FlowDirection.RightToLeft : FlowDirection.LeftToRight;
     EntryEmail.Completed += (Object sender, EventArgs e) =>
     {
         EntryPassword.Focus();
     };
     EntryPassword.Completed += (Object sender, EventArgs e) =>
     {
         Loginbtn.Focus();
     };
 }
        public LoginPage()
        {
            _navigationPage = DependencyService.Get <INavigationService>();
            _messageService = DependencyService.Get <IMessageService>();

            InitializeComponent();

            this.BindingContext = new ViewModel.LoginViewModel();

            EntryUsername.Completed += (s, e) => EntryPassword.Focus();
            EntryPassword.Completed += (s, e) => {
                var current = this.BindingContext as ViewModel.LoginViewModel;
                current.LoginCommand.Execute(null);
            };
        }
Exemplo n.º 10
0
        public Login()
        {
            InitializeComponent();
            loginModel = new LoginModel();
            MessagingCenter.Subscribe <LoginModel, string>(this, "Login Alert", (sender, username) =>
            {
                DisplayAlert("Title", username, "Oke");
            });
            this.BindingContext = loginModel;

            EntryUsername.Completed += (object sender, EventArgs e) =>
            {
                EntryPassword.Focus();
            };

            EntryPassword.Completed += (object sender, EventArgs e) =>
            {
                loginModel.SubmitCommand.Execute(null);
            };
        }
Exemplo n.º 11
0
 public LoginPage()
 {
     InitializeComponent();
     OneSignal.Current.IdsAvailable(IdsAvailable);
     FlowDirection         = (WaselDriver.Helper.Settings.LastUserGravity == "Arabic") ? FlowDirection.RightToLeft : FlowDirection.LeftToRight;
     userService           = new UserServices();
     EntryPhone.Completed += (Object sender, EventArgs e) =>
     {
         EntryEmail.Focus();
     };
     EntryEmail.Completed += (Object sender, EventArgs e) =>
     {
         EntryPassword.Focus();
     };
     Settings.LastUsedEmail   = EntryEmail.Text;
     EntryPassword.Completed += (Object sender, EventArgs e) =>
     {
         Loginbtn.Focus();
     };
     Settings.LastUsedEmail = EntryEmail.Text;
 }
Exemplo n.º 12
0
 void UserNameCompleted(object sender, System.EventArgs e)
 {
     EntryPassword.Focus();
 }
Exemplo n.º 13
0
        async void Login_Clicked(object sender, EventArgs e)
        {
            if (EntryUser.Text == null)
            {
                //await this.DisplayAlert(null, "กรุณาระบุชื่อผู้ใช้งาน", null, "ตกลง");
                EntryUser.PlaceholderColor = Color.FromHex("#ffb3ba");
                EntryUser.Placeholder      = "กรุณาระบุชื่อผู้ใช้งาน";
                EntryUser.Focus();
                return;
            }

            if (EntryPassword.Text == null)
            {
                //await this.DisplayAlert(null, "กรุณาระบุรหัสผ่าน", null, "ตกลง");
                EntryPassword.PlaceholderColor = Color.FromHex("#ffb3ba");
                EntryPassword.Placeholder      = "กรุณาระบุรหัสผ่าน";
                EntryPassword.Focus();
                return;
            }

            btnLogin.IsEnabled = false;
            //Cloud database
            //Register data to firebase also
            RegUserJson user = await apiRequestHelper.RequestLoginUserAsync(EntryUser.Text, EntryPassword.Text);

            if (user != null & user.UserName == EntryUser.Text)
            {
                var dbpath  = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), "UserDatabase.db");
                var db      = new SQLiteConnection(dbpath);
                var reguser = db.GetTableInfo("RegUserTable");
                if (reguser.Count == 0)
                {
                    db.CreateTable <RegUserTable>();

                    var item = new RegUserTable()
                    {
                        UserName    = user.UserName,
                        Password    = user.Password,
                        Email       = user.Email,
                        PhoneNumber = user.PhoneNumber,
                    };

                    db.Insert(item);
                }
                else
                {
                    var item = db.Table <RegUserTable>().Where(u => u.UserName.Equals(user.UserName)).FirstOrDefault();

                    if (item == null)
                    {
                        var data = new RegUserTable()
                        {
                            UserName    = user.UserName,
                            Password    = user.Password,
                            Email       = user.Email,
                            PhoneNumber = user.PhoneNumber,
                        };
                        db.Insert(data);
                    }
                }
                RootProfileObject profileData = await apiRequestHelper.RequestProfileAsync(user.UserName);

                if (profileData != null && profileData.Data != null && profileData.Data.Count > 0)
                {
                    List <ProfileJson> Data = profileData.Data;
                    if (Data.Count > 0)
                    {
                        ProfileJson json = Data.First <ProfileJson>();

                        var userprofile = db.GetTableInfo("ProfileTable");
                        if (userprofile.Count == 0)
                        {
                            db.CreateTable <ProfileTable>();
                            var profile = new ProfileTable()
                            {
                                UserName    = json.UserName,
                                FirstName   = json.FirstName,
                                LastName    = json.LastName,
                                Gender      = (json.Gender == null ? "" : json.Gender),
                                DateOfBirth = (json.DateOfBirth == null ? "" : json.DateOfBirth),
                                Address1    = json.Address1 == null? "" : json.Address1,
                                Address2    = json.Address2 == null ? "" : json.Address2,
                                Address3    = json.Address3 == null ? "" : json.Address3,
                                Email       = json.Email,
                                PhoneNumber = json.PhoneNumber,

                                CreateDate = DateTime.Now,
                                UpdateDate = DateTime.Now,
                            };

                            db.Insert(profile);
                        }
                        else
                        {
                            var item = db.Table <ProfileTable>().Where(u => u.UserName.Equals(user.UserName)).FirstOrDefault();

                            if (item == null)
                            {
                                var profile = new ProfileTable()
                                {
                                    UserName    = json.UserName,
                                    FirstName   = json.FirstName,
                                    LastName    = json.LastName,
                                    Gender      = (json.Gender == null ? "" : json.Gender),
                                    DateOfBirth = (json.DateOfBirth == null ? "" : json.DateOfBirth),
                                    Address1    = json.Address1 == null ? "" : json.Address1,
                                    Address2    = json.Address2 == null ? "" : json.Address2,
                                    Address3    = json.Address3 == null ? "" : json.Address3,
                                    Email       = json.Email,
                                    PhoneNumber = json.PhoneNumber,

                                    CreateDate = DateTime.Now,
                                    UpdateDate = DateTime.Now,
                                };

                                db.Insert(profile);
                            }
                        }
                    }
                }

                ///////////////////

                Device.StartTimer(TimeSpan.FromSeconds(0.1), () => {
                    btnLogin.IsEnabled = true;

                    Toast.MakeText(context, "Login Successfull", ToastLength.Short).Show();
                    Application.Current.Properties.Add("USER_NAME", EntryUser.Text);
                    App.Current.MainPage = new MainPage();
                    return(false);
                });
            }
            else
            {
                Device.BeginInvokeOnMainThread(async() =>
                {
                    var result2 = await this.DisplayAlert(null, "ข้อผิดพลาด! ไม่พบข้อมูลผู้ใช้งาน\nกรุณาตรวจสอบชื่อผู้ใช้งานและรหัสผ่าน", null, "ตกลง");

                    if (!result2)
                    {
                        btnLogin.IsEnabled = true;
                        EntryUser.Focus();
                    }
                });
            }

            //End of Cloud database


            //Local database

            /*
             * var dbpath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), "UserDatabase.db");
             * var db = new SQLiteConnection(dbpath);
             * db.CreateTable<RegUserTable>();
             * var myquery = db.Table<RegUserTable>().Where(u => u.UserName.Equals(EntryUser.Text) && u.Password.Equals(EntryPassword.Text)).FirstOrDefault();
             *
             * if (myquery != null)
             * {
             *  Application.Current.Properties.Add("USER_NAME", myquery.UserName);
             *  App.Current.MainPage = new MainPage();
             * }
             * else
             * {
             *  Device.BeginInvokeOnMainThread(async () => {
             *      if(EntryUser.Text == null)
             *      {
             *          //await this.DisplayAlert(null, "กรุณาระบุชื่อผู้ใช้งาน", null, "ตกลง");
             *          EntryUser.PlaceholderColor = Color.FromHex("#ffb3ba");
             *          EntryUser.Placeholder = "กรุณาระบุชื่อผู้ใช้งาน";
             *          EntryUser.Focus();
             *          return;
             *      }
             *
             *      if (EntryPassword.Text == null)
             *      {
             *          //await this.DisplayAlert(null, "กรุณาระบุรหัสผ่าน", null, "ตกลง");
             *          EntryPassword.PlaceholderColor = Color.FromHex("#ffb3ba");
             *          EntryPassword.Placeholder = "กรุณาระบุรหัสผ่าน";
             *          EntryPassword.Focus();
             *          return;
             *      }
             *
             *      var result = await this.DisplayAlert(null, "ข้อผิดพลาด! ไม่พบข้อมูลผู้ใช้งาน\nกรุณาตรวจสอบชื่อผู้ใช้งานและรหัสผ่าน", null, "ตกลง");
             *
             *      if (!result)
             *      {
             *          EntryUser.Focus();
             *      }
             *  });
             *
             * }
             */
            //End of Local database
        }
Exemplo n.º 14
0
        private async void Principal_M(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(EntryCorreo.Text))
            {
                await DisplayAlert("Error", "Debe ingresar una dirección de correo electrónico.", "Ok");

                EntryCorreo.Focus();
                return;
            }

            if (!emailValidator.IsValid)
            {
                await DisplayAlert("Error", "Debe ingresar una dirección de correo electrónico válida.", "Ok");

                EntryCorreo.Focus();
                return;
            }

            if (string.IsNullOrEmpty(EntryPassword.Text))
            {
                await DisplayAlert("Error", "Debe ingresar su contraseña.", "Ok");

                EntryPassword.Focus();
                return;
            }

            this.IsBusy       = true;
            overlay.IsVisible = true;

            var response = await _Client.GetAsync(url + EntryCorreo.Text + "/" + EntryPassword.Text);

            var code = response.IsSuccessStatusCode;

            System.Diagnostics.Debug.WriteLine(code);

            if (code != false)
            {
                var content = await _Client.GetStringAsync(url + EntryCorreo.Text + "/" + EntryPassword.Text);

                var get = JsonConvert.DeserializeObject <List <modelo.User> >(content);

                App.UserNombre = get[0].Nombre;
                App.UserCorreo = get[0].Correo;
                App.UserId     = get[0].id;
                App.Admin      = get[0].Admin;

                await DisplayAlert("Login Correcto", "Logueado.", "Ok");

                this.IsBusy       = false;
                overlay.IsVisible = false;

                if (App.Admin == 1)
                {
                    await Navigation.PushAsync(new paginasAdmin.MenuPrincipalAdmin());
                }
                else
                {
                    await Navigation.PushAsync(new paginas.MenuPrincipal());
                }
            }
            else
            {
                await DisplayAlert("Error Logueando", "Correo o Contraseña incorrectos o no existen.", "Ok");

                this.IsBusy       = false;
                overlay.IsVisible = false;
            }
        }