public void RegisterLayout(List <UserModel> users) { NavigationPage.SetHasNavigationBar(this, false); //Label lblRegisterName = new Label { Text = "Name", HorizontalOptions = LayoutOptions.Start, TextColor = Color.White, WidthRequest = 70, HeightRequest = 30 }; Image imgBack = new Image { Source = "Home3.ico", HorizontalOptions = LayoutOptions.CenterAndExpand, HeightRequest = 100, WidthRequest = 50 }; StackLayout sRegisterImage = new StackLayout { Children = { imgBack }, Orientation = StackOrientation.Horizontal, Padding = new Thickness(0, 0, 0, 0) }; Label lblRegister = new Label { Text = "Register", FontSize = 30, HorizontalOptions = LayoutOptions.CenterAndExpand, TextColor = Color.Black, FontAttributes = FontAttributes.Bold }; StackLayout sRegisterText = new StackLayout { Children = { lblRegister }, Orientation = StackOrientation.Horizontal, Padding = new Thickness(0, 0, 0, 10) }; registerName = new CustomEntryForLogin { Placeholder = "Name", HorizontalOptions = LayoutOptions.FillAndExpand }; StackLayout sRegisterName = new StackLayout { Children = { registerName }, Orientation = StackOrientation.Horizontal, Padding = new Thickness(0, 0, 0, 8) }; //Label lblRegisterMobile = new Label { Text = "Mobile", HorizontalOptions = LayoutOptions.Start, TextColor = Color.White, WidthRequest = 70, HeightRequest = 30 }; registerMobile = new CustomEntryForLogin { Placeholder = "Mobile", HorizontalOptions = LayoutOptions.FillAndExpand }; registerMobile.Behaviors.Add(new NumberValidationBehavior()); StackLayout sRegisterMoble = new StackLayout { Children = { registerMobile }, Orientation = StackOrientation.Horizontal, Padding = new Thickness(0, 0, 0, 8) }; //Label lblRegisterEmail = new Label { Text = "Email", HorizontalOptions = LayoutOptions.Start, TextColor = Color.White, WidthRequest = 70, HeightRequest = 30 }; registerEmail = new CustomEntryForLogin { Placeholder = "Email", HorizontalOptions = LayoutOptions.FillAndExpand }; registerEmail.Behaviors.Add(new EmailValidatorBehavior()); StackLayout sRegisterEmail = new StackLayout { Children = { registerEmail }, Orientation = StackOrientation.Horizontal, Padding = new Thickness(0, 0, 0, 8) }; //Label lblRegisterPassword = new Label { Text = "Password", HorizontalOptions = LayoutOptions.Start, TextColor = Color.White, WidthRequest = 70, HeightRequest = 30 }; registerPassword = new CustomEntryForLogin { IsPassword = true, Placeholder = "Password", HorizontalOptions = LayoutOptions.FillAndExpand }; //registerPassword.Behaviors.Add(new PasswordValidationBehavior()); StackLayout sRegisterPassword = new StackLayout { Children = { registerPassword }, Orientation = StackOrientation.Horizontal, Padding = new Thickness(0, 0, 0, 8) }; //Label lblRegisterConfirmPassword = new Label { Text = "Confirm Password", HorizontalOptions = LayoutOptions.Start, TextColor = Color.White, WidthRequest = 70, HeightRequest = 30 }; registerConfirmPassword = new CustomEntryForLogin { IsPassword = true, Placeholder = "Confirm Password", HorizontalOptions = LayoutOptions.FillAndExpand }; StackLayout sRegisterConfirmPassword = new StackLayout { Children = { registerConfirmPassword }, Orientation = StackOrientation.Horizontal, Padding = new Thickness(0, 0, 0, 8) }; //Label lblRegisterButton = new Label { Text = "", HorizontalOptions = LayoutOptions.Start, TextColor = Color.White, WidthRequest = 70, HeightRequest = 30 }; Button btnRegister = new Button { Text = "Register", HorizontalOptions = LayoutOptions.FillAndExpand, BackgroundColor = Color.FromHex("4690FB"), TextColor = Color.White, BorderRadius = 10, WidthRequest = 150, HeightRequest = 40, FontAttributes = FontAttributes.Bold }; //btnRegister.Behaviors.Add(new ButtonBehaviour()); StackLayout sRegisterButton = new StackLayout { Children = { btnRegister }, Orientation = StackOrientation.Horizontal, Padding = new Thickness(0, 0, 0, 8) }; Label lblForResponse = new Label { Text = "", HorizontalOptions = LayoutOptions.StartAndExpand, TextColor = Color.Red }; StackLayout sLblForResponse = new StackLayout { Children = { lblForResponse }, Orientation = StackOrientation.Horizontal, Padding = new Thickness(0, 0, 0, 8) }; Button btnRegisterAlreadyHaveAccountButton = new Button { Text = "Already have an account", HorizontalOptions = LayoutOptions.FillAndExpand, BackgroundColor = Color.Transparent, TextColor = Color.FromHex("4690FB"), HeightRequest = 40, FontAttributes = FontAttributes.None }; StackLayout sRegisterAlreadyHaveAccountButton = new StackLayout { Children = { btnRegisterAlreadyHaveAccountButton }, Orientation = StackOrientation.Horizontal, Padding = new Thickness(0, 15, 0, 8) }; StackLayout sRegister = new StackLayout { Children = { sRegisterImage, sRegisterText, sRegisterName, sRegisterMoble, sRegisterEmail, sRegisterPassword, sRegisterConfirmPassword, sRegisterButton, sLblForResponse, sRegisterAlreadyHaveAccountButton }, HorizontalOptions = LayoutOptions.FillAndExpand, VerticalOptions = LayoutOptions.FillAndExpand, Padding = new Thickness(20, 10, 20, 0), BackgroundColor = Color.White }; ScrollView svMyProfile = new ScrollView { Content = sRegister }; Content = svMyProfile; UserModel userModel = new UserModel(); btnRegisterAlreadyHaveAccountButton.Clicked += (object sender, EventArgs e) => { Device.BeginInvokeOnMainThread(async() => { await Navigation.PushAsync(new Login()); }); }; btnRegister.Clicked += (object sender, EventArgs e) => { if (Validate()) { userModel.FirstName = registerName.Text; userModel.MiddleName = registerName.Text; userModel.LastName = registerName.Text; userModel.Gender = 1; userModel.Mobile = registerMobile.Text; userModel.Email = registerEmail.Text; userModel.Password = registerPassword.Text; userModel.Address1 = registerName.Text; userModel.Address2 = registerName.Text; userModel.City = registerName.Text; userModel.StateId = 1; userModel.CountryId = 1; userModel.Pin = 1; userModel.BioData = registerName.Text; userModel.ProfileImage = registerName.Text; userModel.CreatedDate = DateTime.Now; userModel.ModifiedDate = DateTime.Now; userModel.UserType = 1; userModel.EmpId = 1; Device.BeginInvokeOnMainThread(async() => { var result = await Service.PostRegister(userModel); int i = 0; foreach (var item in users) { if (item.Email.Contains(userModel.Email)) { i++; } } if (i > 0) { lblForResponse.Text = "Email address is already in use"; } else { lblForResponse.Text = "Registration successfull"; lblForResponse.TextColor = Color.Green; registerName.Text = string.Empty; registerMobile.Text = string.Empty; registerEmail.Text = string.Empty; registerPassword.Text = string.Empty; registerConfirmPassword.Text = string.Empty; } }); } ; }; }
public void LoginLayout() { NavigationPage.SetHasNavigationBar(this, false); Image imgBack = new Image { Source = "Home3.ico", HorizontalOptions = LayoutOptions.CenterAndExpand, HeightRequest = 200, WidthRequest = 150 }; StackLayout sLoginImage = new StackLayout { Children = { imgBack }, Orientation = StackOrientation.Horizontal, Padding = new Thickness(0, 0, 0, 20) }; Label lblSignIn = new Label { Text = "Log In", FontSize = 30, HorizontalOptions = LayoutOptions.CenterAndExpand, TextColor = Color.Black, FontAttributes = FontAttributes.Bold }; StackLayout sLoginText = new StackLayout { Children = { lblSignIn }, Orientation = StackOrientation.Horizontal, Padding = new Thickness(0, 0, 0, 40) }; loginId = new CustomEntryForLogin { Placeholder = "ID", HorizontalOptions = LayoutOptions.FillAndExpand, BackgroundColor = Color.Red, TextColor = Color.White, AnchorX = 50 }; loginId.Behaviors.Add(new EmailValidatorBehavior()); StackLayout sLoginId = new StackLayout { Children = { loginId }, Orientation = StackOrientation.Horizontal, Padding = new Thickness(2, 0, 2, 8) }; loginPassword = new CustomEntryForLogin { IsPassword = true, Placeholder = "Password", HorizontalOptions = LayoutOptions.FillAndExpand, BackgroundColor = Color.FromHex("A9A9A9"), TextColor = Color.White }; StackLayout sLoginPassword = new StackLayout { Children = { loginPassword }, Orientation = StackOrientation.Horizontal, Padding = new Thickness(2, 0, 2, 8) }; Label lblLoginButton = new Label { Text = "", HorizontalOptions = LayoutOptions.Start, TextColor = Color.White, WidthRequest = 70, HeightRequest = 30 }; Button btnLogin = new Button { Text = "Login", HorizontalOptions = LayoutOptions.FillAndExpand, BackgroundColor = Color.FromHex("4690FB"), TextColor = Color.White, BorderRadius = 10, WidthRequest = 150, HeightRequest = 40, FontAttributes = FontAttributes.Bold }; StackLayout sLoginButton = new StackLayout { Children = { btnLogin }, Orientation = StackOrientation.Horizontal, Padding = new Thickness(2, 0, 2, 8) }; Label lblForResponse = new Label { Text = "", HorizontalOptions = LayoutOptions.StartAndExpand, TextColor = Color.Red }; StackLayout sLblForResponse = new StackLayout { Children = { lblForResponse }, Orientation = StackOrientation.Horizontal, Padding = new Thickness(0, 0, 0, 8) }; Button btnLoginForgotPassword = new Button { Text = "Register here", HorizontalOptions = LayoutOptions.CenterAndExpand, BackgroundColor = Color.Transparent, TextColor = Color.FromHex("4690FB"), BorderRadius = 10, HeightRequest = 40, FontAttributes = FontAttributes.None }; StackLayout sLoginForgotPassword = new StackLayout { Children = { btnLoginForgotPassword }, Orientation = StackOrientation.Horizontal, Padding = new Thickness(2, 30, 2, 8) }; StackLayout slLogin = new StackLayout { Children = { sLoginImage, sLoginText, sLoginId, sLoginPassword, sLoginButton, sLblForResponse, sLoginForgotPassword }, HorizontalOptions = LayoutOptions.FillAndExpand, VerticalOptions = LayoutOptions.FillAndExpand, Padding = new Thickness(20, 10, 20, 0), BackgroundColor = Color.White }; ScrollView svMyProfile = new ScrollView { Content = slLogin }; Content = svMyProfile; btnLoginForgotPassword.Clicked += (object sender, EventArgs e) => { Device.BeginInvokeOnMainThread(async() => { await Navigation.PushModalAsync(new Register()); }); }; btnLogin.Clicked += (object sender, EventArgs e) => { if (Validate()) { try { Device.BeginInvokeOnMainThread(async() => { var result = await Service.GetLogin(loginId.Text, loginPassword.Text); if (result != null && !string.IsNullOrEmpty(result)) { UserModel response = JsonConvert.DeserializeObject <UserModel>(result); if (response.Email == loginId.Text) { ACTContext.userId = response.Id; ACTContext.isLogin = true; //await Navigation.PushAsync(new Status()); await Navigation.PushModalAsync(App.StatusPage()); //if (ACTContext.menuItemNumber == 3) //{ // await Navigation.PushAsync(new WorkExperience()); //} //else if (ACTContext.menuItemNumber == 4) //{ // await Navigation.PushAsync(new EducationDetails()); //} //else if (ACTContext.menuItemNumber == 5) //{ // await Navigation.PushAsync(new InterviewDetails()); //} //else if (ACTContext.menuItemNumber == 6) //{ // await Navigation.PushAsync(new InterviewMatrix()); //} //else if (ACTContext.menuItemNumber == 7) //{ // await Navigation.PushAsync(new UploadDocuments()); //} //else if (ACTContext.menuItemNumber == 8) //{ // await Navigation.PushAsync(new TestExam()); //} } else { lblForResponse.Text = "Login failed"; } } else { lblForResponse.Text = "Please enter valid username and password"; } }); } catch (Exception ex) { lblForResponse.Text = "Login failed"; } } }; }
public void RegisterLayout(UserModel users) { NavigationPage.SetHasNavigationBar(this, false); //Label lblRegisterName = new Label { Text = "Name", HorizontalOptions = LayoutOptions.Start, TextColor = Color.White, WidthRequest = 70, HeightRequest = 30 }; Image imgBack = new Image { Source = "Home3.ico", HorizontalOptions = LayoutOptions.CenterAndExpand, HeightRequest = 100, WidthRequest = 50 }; StackLayout sRegisterImage = new StackLayout { Children = { imgBack }, Orientation = StackOrientation.Horizontal, Padding = new Thickness(0, 0, 0, 0) }; Label lblRegister = new Label { Text = "Change Password", FontSize = 30, HorizontalOptions = LayoutOptions.CenterAndExpand, TextColor = Color.Black, FontAttributes = FontAttributes.Bold }; StackLayout sRegisterText = new StackLayout { Children = { lblRegister }, Orientation = StackOrientation.Horizontal, Padding = new Thickness(0, 0, 0, 10) }; oldPwd = new CustomEntryForLogin { IsPassword = true, Placeholder = "Password", HorizontalOptions = LayoutOptions.FillAndExpand }; //registerPassword.Behaviors.Add(new PasswordValidationBehavior()); StackLayout oldRegisterPassword = new StackLayout { Children = { oldPwd }, Orientation = StackOrientation.Horizontal, Padding = new Thickness(0, 0, 0, 8) }; //Label lblRegisterPassword = new Label { Text = "Password", HorizontalOptions = LayoutOptions.Start, TextColor = Color.White, WidthRequest = 70, HeightRequest = 30 }; registerPassword = new CustomEntryForLogin { IsPassword = true, Placeholder = "Password", HorizontalOptions = LayoutOptions.FillAndExpand }; //registerPassword.Behaviors.Add(new PasswordValidationBehavior()); StackLayout sRegisterPassword = new StackLayout { Children = { registerPassword }, Orientation = StackOrientation.Horizontal, Padding = new Thickness(0, 0, 0, 8) }; //Label lblRegisterConfirmPassword = new Label { Text = "Confirm Password", HorizontalOptions = LayoutOptions.Start, TextColor = Color.White, WidthRequest = 70, HeightRequest = 30 }; registerConfirmPassword = new CustomEntryForLogin { IsPassword = true, Placeholder = "Confirm Password", HorizontalOptions = LayoutOptions.FillAndExpand }; StackLayout sRegisterConfirmPassword = new StackLayout { Children = { registerConfirmPassword }, Orientation = StackOrientation.Horizontal, Padding = new Thickness(0, 0, 0, 8) }; //Label lblRegisterButton = new Label { Text = "", HorizontalOptions = LayoutOptions.Start, TextColor = Color.White, WidthRequest = 70, HeightRequest = 30 }; Button btnRegister = new Button { Text = "Register", HorizontalOptions = LayoutOptions.FillAndExpand, BackgroundColor = Color.FromHex("4690FB"), TextColor = Color.White, BorderRadius = 10, WidthRequest = 150, HeightRequest = 40, FontAttributes = FontAttributes.Bold }; //btnRegister.Behaviors.Add(new ButtonBehaviour()); StackLayout sRegisterButton = new StackLayout { Children = { btnRegister }, Orientation = StackOrientation.Horizontal, Padding = new Thickness(0, 0, 0, 8) }; Label lblForResponse = new Label { Text = "", HorizontalOptions = LayoutOptions.StartAndExpand, TextColor = Color.Red }; StackLayout sLblForResponse = new StackLayout { Children = { lblForResponse }, Orientation = StackOrientation.Horizontal, Padding = new Thickness(0, 0, 0, 8) }; StackLayout sRegister = new StackLayout { Children = { sRegisterImage, sRegisterText, oldRegisterPassword, sRegisterPassword, sRegisterConfirmPassword, sRegisterButton, sLblForResponse }, HorizontalOptions = LayoutOptions.FillAndExpand, VerticalOptions = LayoutOptions.FillAndExpand, Padding = new Thickness(20, 10, 20, 0), BackgroundColor = Color.White }; ScrollView svMyProfile = new ScrollView { Content = sRegister }; Content = svMyProfile; UserModel userModel = new UserModel(); //btnRegisterAlreadyHaveAccountButton.Clicked += (object sender, EventArgs e) => { // Device.BeginInvokeOnMainThread(async () => // { // await Navigation.PushAsync(new Login()); // }); //}; btnRegister.Clicked += (object sender, EventArgs e) => { if (Validate()) { userModel.Id = ACTContext.userId; userModel.Password = registerPassword.Text; Device.BeginInvokeOnMainThread(async() => { var result = await Service.PostChangePwd(userModel); int i = 0; //foreach (var item in users) //{ if (users.Email.Contains(userModel.Email)) { i++; } //} if (i > 0) { lblForResponse.Text = "Password Change Failed"; } else { lblForResponse.Text = "Password Changed"; lblForResponse.TextColor = Color.Green; registerPassword.Text = string.Empty; registerConfirmPassword.Text = string.Empty; } }); } ; }; }