public override Widget build(int i, float animationValue, Widget widget) { float v = Unities._getValue(values, animationValue, i); return(Transform.rotate( degree: v, child: widget )); }
public override Widget build(int i, float animationValue, Widget widget) { Offset s = Unities._getOffsetValue(values, animationValue, i); return(Transform.translate( offset: s, child: widget )); }
private async void Register() { bool isValidateName = Unities.ValidateName(FirstName); if (!isValidateName) { FirstName = ""; } bool isValidateLastName = Unities.ValidateName(LastName); if (!isValidateLastName) { LastName = ""; } bool isValidateDate = Unities.ValidateStringDateFormat(BirthDate); if (!isValidateDate) { BirthDate = ""; } bool isValidateEmail = Unities.CheckEmailFormat(Email); if (!isValidateEmail) { Email = ""; } if (!string.IsNullOrEmpty(MobileNumber)) { MobileNumber = Regex.Replace(MobileNumber, @"[^\d]", ""); } bool isValidatePhoneNumber = Unities.ValidateStringMobile(MobileNumber); if (!isValidatePhoneNumber) { MobileNumber = ""; } if (isValidateName && isValidateLastName && isValidateDate && isValidateEmail && isValidatePhoneNumber) { RegisterCommand register = new RegisterCommand { BirthDate = DateTime.ParseExact(BirthDate, "dd/MM/yyyy", null), Email = Email, FirstName = FirstName, LastName = LastName, Pin = Pin, MobileNumber = MobileNumber, Gender = Gender }; SetPinForAuthViewModel authViewModel = new SetPinForAuthViewModel(register); await Application.Current.MainPage.Navigation.PushAsync(new PinPage(authViewModel)); } else { await PopupNavigation.PushAsync(new Error(new ErrorViewModel("กรอกข้อมูลไม่ถูกต้อง", (int)EW_Enumerations.EW_ErrorTypeEnum.Warning))); } }
public override Widget build(int i, float animationValue, Widget widget) { float v = Unities._getValue(values, animationValue, i); return(new Opacity( opacity: v, child: widget )); }
public LoginByPinViewModel() { title = ""; image = "icon_PIN"; blackDetail = "ใส่รหัสผ่าน"; grayDetail = "ใส่รหัสผ่านของคุณ"; referenceText = ""; referenceVisible = false; orangeText = "ลืมรหัสผ่าน"; orangeVisible = true; warningText = ""; warningVisible = false; backVisible = false; pin = ""; OrangeTextTab = new Command(GoToForgotPasswordPage); InputPin = new Command <string>(LoginByPin); try { email = SecureStorage.GetAsync("Email").Result; bool checkFingerPrint = Convert.ToBoolean(SecureStorage.GetAsync("IsFingerprintEnabled").Result); if (checkFingerPrint) { fingerTabVisible = true; Fingerprint = new Command(LoginByFingerprint); } else { fingerTabVisible = false; } bool isExistEmail = Unities.CheckEmailFormat(email); if (!isExistEmail) { ForceLogout(); } } catch (Exception e) { Console.WriteLine("Get Email And Fingerprint in LoginViewModel : {0}", e); ForceLogout(); } try { countLogin = Int32.Parse(SecureStorage.GetAsync("CountLogin").Result); } catch (Exception e) { countLogin = 0; Console.WriteLine("countLogin in LoginViewModel : {0}", e); } }
private async void Edit() { if (IsEditMode) { bool isValidateName = Unities.ValidateName(FirstName); bool isValidateLastName = Unities.ValidateName(LastName); bool isValidateDate = Unities.ValidateStringDateFormat(BirthDate); bool isValidateEmail = Unities.CheckEmailFormat(Email); bool isValidatePhoneNum = Unities.ValidateStringMobile(MobileNumber); if (isValidateName && isValidateLastName && isValidateDate && isValidateEmail && isValidatePhoneNum) { UpdateUserCommand updateUserCommand = new UpdateUserCommand { BitrhDate = DateTime.ParseExact(BirthDate, "dd/MM/yyyy", null), Email = Email, FirstName = FirstName, LastName = LastName, MobileNumber = MobileNumber, Gender = Gender }; var editResult = await _userService.UpdateUser(updateUserCommand); bool isError = editResult.IsError; if (isError) { await PopupNavigation.PushAsync(new Error(new ErrorViewModel("Error", (int)EW_Enumerations.EW_ErrorTypeEnum.Warning))); } else { //TODO: Show Completed Popup StoreValue(updateUserCommand); IsEditMode = false; ShowEditButton = true; await PopupNavigation.PushAsync(new SavedProfile()); Application.Current.MainPage.Navigation.PushAsync(new EditProfilePage()); } } else { await PopupNavigation.PushAsync(new Error(new ErrorViewModel("กรอกข้อมูลไม่ถูกต้อง", (int)EW_Enumerations.EW_ErrorTypeEnum.Warning))); } } else { IsEditMode = true; ShowEditButton = false; } }
private async void SignIn() { IsProcess = true; bool isEmail = Unities.CheckEmailFormat(Email); if (isEmail) { ResultServiceModel <CheckEmailViewModel> result = await _authService.SignIn(Email); if (result.IsError || result.Model == null) { ErrorViewModel errorView = new ErrorViewModel("ไม่สามารถเชื่อมต่อกับระบบได้"); IsProcess = false; await PopupNavigation.Instance.PushAsync(new Error(errorView)); } else { if (result.Model.Role != 0) { ErrorViewModel errorView = new ErrorViewModel("กรุณาใช้แอพพลิเคชั่นสำหรับผู้ค้าหรือแอดมิน"); IsProcess = false; await PopupNavigation.Instance.PushAsync(new Error(errorView)); return; } App.Email = Email; if (result.Model.IsExist == true) { IsProcess = false; var status = Status.LastPage.Login; await Application.Current.MainPage.Navigation.PushAsync(new PinPage(new OtpRegisViewModel(Email, result.Model.RefNumber, status))); } else { IsProcess = false; var status = Status.LastPage.Register; await Application.Current.MainPage.Navigation.PushAsync(new PinPage(new OtpRegisViewModel(Email, result.Model.RefNumber, status))); } } } else { ErrorViewModel errorView = new ErrorViewModel("โปรดกรอก Username เป็น format Email", (int)EW_Enumerations.EW_ErrorTypeEnum.Warning); IsProcess = false; await PopupNavigation.Instance.PushAsync(new Error(errorView)); } }
public async void SentOtpAgain() { bool isExistEmail = Unities.CheckEmailFormat(email); if (isExistEmail) { var signInData = await _authService.SignIn(email); if (signInData != null && !signInData.IsError) { Status.LastPage lastPage; if (signInData.Model.IsExist) { lastPage = Status.LastPage.Login; } else { lastPage = Status.LastPage.Register; } OtpRegisViewModel otpRegis = new OtpRegisViewModel(email, signInData.Model.RefNumber, lastPage); await Application.Current.MainPage.Navigation.PushAsync(new PinPage(otpRegis)); } else { WarningText = "ไม่สามารถเชื่อมต่อได้"; WarningVisible = true; try { Vibration.Vibrate(); var duration = TimeSpan.FromSeconds(1); Vibration.Vibrate(duration); } catch (FeatureNotSupportedException ex) { } catch (Exception ex) { } } } else { await Application.Current.MainPage.Navigation.PopToRootAsync(); } }
public override Widget _buildItem(int i, int realIndex, float animationValue) { float s = Unities._getValue(scales, animationValue, i); float f = Unities._getValue(offsetsX, animationValue, i); float fy = Unities._getValue(offsetsY, animationValue, i); float o = Unities._getValue(opacity, animationValue, i); float a = Unities._getValue(rotates, animationValue, i); Alignment alignment = widget.scrollDirection == Axis.horizontal ? Alignment.bottomCenter : Alignment.centerLeft; return(new Opacity( opacity: o, child: Transform.rotate( degree: a / 180.0f, child: Transform.translate( key: new ValueKey <int>(_currentIndex + i), offset: new Offset(f, fy), child: Transform.scale( scale: s, alignment: alignment, child: new SizedBox( width: widget.itemWidth, height: widget.itemHeight, child: widget.itemBuilder(context, realIndex) ) ) ) ) )); }
public ChangePasswordViewModel() { title = "เปลี่ยนรหัสผ่าน"; image = "icon_PIN"; blackDetail = "ใส่รหัสผ่าน"; grayDetail = "ใส่รหัสผ่านของคุณ"; referenceText = ""; referenceVisible = false; orangeText = "ลืมรหัสผ่าน"; orangeVisible = true; warningText = ""; warningVisible = false; backVisible = true; fingerTabVisible = false; OrangeTextTab = new Command(GoToForgotPasswordPage); InputPin = new Command <string>(InputPinMethod); GoBack = new Command(BackPage); pin = ""; oldPin = ""; newPin = ""; repeatNewPin = ""; email = App.Email; bool isExistEmail = Unities.CheckEmailFormat(email); if (!isExistEmail) { ForceLogout(); } try { countLogin = Int32.Parse(SecureStorage.GetAsync("CountLogin").Result); } catch (Exception e) { countLogin = 0; Console.WriteLine("countLogin in ChangePasswordViewModel : {0}", e); } }
public async void SentOtpAgain() { bool isExistEmail = Unities.CheckEmailFormat(email); if (isExistEmail) { var checkForgotData = await _pinService.CheckForgotPin(birthDate, email); if (checkForgotData != null && !checkForgotData.IsError) { OtpForgotPassViewModel otpForgotPass = new OtpForgotPassViewModel(email, checkForgotData.Model.RefNumber, birthDate); await Application.Current.MainPage.Navigation.PushAsync(new PinPage(otpForgotPass)); } else { WarningText = "ไม่สามารถเชื่อมต่อได้"; WarningVisible = true; try { Vibration.Vibrate(); var duration = TimeSpan.FromSeconds(1); Vibration.Vibrate(duration); } catch (FeatureNotSupportedException ex) { } catch (Exception ex) { } } } else { await Application.Current.MainPage.Navigation.PopToRootAsync(); } }
public override Widget build(int i, float animationValue, Widget widget) { float s = Unities._getValue(values, animationValue, i); return(Transform.scale(scale: s, child: widget)); }
private async void CheckPin() { IsProcess = true; DateTime birthDate = new DateTime(); error = null; int errorType = 0; try { var inputDateTime = DateTime.ParseExact(BirthDate, "dd/MM/yyyy", null); birthDate = Convert.ToDateTime(inputDateTime); } catch (Exception e) { error = "Invalid BirthDate format is\n Example : 25/12/2562"; } bool checkEmailFormat = false; if (!string.IsNullOrEmpty(Email)) { checkEmailFormat = Unities.CheckEmailFormat(Email); } if (!checkEmailFormat) { error += "\n Invalid Email Format"; } if (!string.IsNullOrEmpty(error)) { IsProcess = false; ErrorViewModel errorView = new ErrorViewModel(error, errorType); await PopupNavigation.Instance.PushAsync(new Error(errorView)); } else { var resultCaller = await _pinService.CheckForgotPin(birthDate, Email); if (resultCaller == null || resultCaller.Model == null || string.IsNullOrEmpty(resultCaller.Model.RefNumber)) { error = "ขออภัย! ไม่พบอีเมลล์ที่กรอกในระบบ"; } else if (resultCaller.IsError) { error = "ขออภัย! ไม่สามารถเชื่อมต่อได้"; errorType = 1; } else { IsProcess = false; string resultRefOtp = resultCaller.Model.RefNumber; await PopupNavigation.Instance.PopAllAsync(); await Application.Current.MainPage.Navigation.PushAsync(new PinPage(new OtpForgotPassViewModel(Email, resultRefOtp, birthDate))); } if (!string.IsNullOrEmpty(error)) { IsProcess = false; ErrorViewModel errorView = new ErrorViewModel(error, errorType); await PopupNavigation.Instance.PushAsync(new Error(errorView)); } } }
public async void LoginByPin(string value) { WarningText = ""; WarningVisible = false; if (value == "Delete") { if (pin.Length > 0) { pin = pin.Remove(pin.Length - 1); int countPin = pin.Length; HintColorChange(countPin); } } else { bool isExistvalue = Unities.CheckDigitaAndLength(value, 1); if (!isExistvalue) { WarningText = "ค่าที่ใส่ไม่ใช่ตัวเลข"; WarningVisible = true; try { Vibration.Vibrate(); var duration = TimeSpan.FromSeconds(1); Vibration.Vibrate(duration); } catch (FeatureNotSupportedException ex) { } catch (Exception ex) { } } pin += value; int countPin = pin.Length; HintColorChange(countPin); if (countPin == 6) { var loginPinData = await _pinService.LoginByPin(pin, email); if (loginPinData != null && !loginPinData.IsError && loginPinData.Model != null) { if (loginPinData.Model.IsLogin) { try { await SecureStorage.SetAsync("CountLogin", "0"); var refreshToken = await SecureStorage.GetAsync("RefreshToken");; var tokenData = await _authService.GetTokenByRefreshToken(email, refreshToken); if (tokenData != null || !tokenData.IsError) { if (tokenData.Model == null || tokenData.Model.Token == null) { ErrorViewModel errorViewModel = new ErrorViewModel("กรุณาเข้าสู่ระบบอีกครั้ง", (int)EW_Enumerations.EW_ErrorTypeEnum.Error, ForceLogoutForErrorPopup); await PopupNavigation.Instance.PushAsync(new Error(errorViewModel)); } else { await SecureStorage.SetAsync("Token", tokenData.Model.Token); App.Account = await SecureStorage.GetAsync("Account"); App.Email = await SecureStorage.GetAsync("Email"); App.FirstName = await SecureStorage.GetAsync("FirstName"); App.LastName = await SecureStorage.GetAsync("LastName"); string preBirthDate = await SecureStorage.GetAsync("BirthDate"); try { App.BirthDate = DateTime.Parse(preBirthDate); } catch (Exception) { } App.MobileNumber = await SecureStorage.GetAsync("MobileNumber"); int gender = 0; int.TryParse(await SecureStorage.GetAsync("Gender"), out gender); App.Gender = (EWalletV2.Api.ViewModels.EW_Enumerations.EW_GenderEnum)gender; Application.Current.MainPage = new NavigationPage(new UserTabbedPage()); } } else { pin = ""; countPin = pin.Length; HintColorChange(countPin); WarningText = "ไม่สามารถเชื่อมต่อได้"; WarningVisible = true; try { Vibration.Vibrate(); var duration = TimeSpan.FromSeconds(1); Vibration.Vibrate(duration); } catch (FeatureNotSupportedException ex) { } catch (Exception ex) { } } } catch (Exception e) { ErrorViewModel errorViewModel = new ErrorViewModel("โทรศัพท์ของท่านไม่สามารถใช้งานแอพพลิเคชั่นนี้ได้", (int)EW_Enumerations.EW_ErrorTypeEnum.Warning, CloseApp); await PopupNavigation.Instance.PushAsync(new Error(errorViewModel)); } } else { pin = ""; countPin = pin.Length; HintColorChange(countPin); WarningText = "รหัสผ่านไม่ถูกต้อง"; WarningVisible = true; try { Vibration.Vibrate(); var duration = TimeSpan.FromSeconds(1); Vibration.Vibrate(duration); } catch (FeatureNotSupportedException ex) { } catch (Exception ex) { } countLogin++; await SecureStorage.SetAsync("CountLogin", countLogin.ToString()); if (countLogin >= 5) { ForceLogout(); } } } else { pin = ""; countPin = pin.Length; HintColorChange(countPin); WarningText = "ไม่สามารถเชื่อมต่อได้"; WarningVisible = true; try { Vibration.Vibrate(); var duration = TimeSpan.FromSeconds(1); Vibration.Vibrate(duration); } catch (FeatureNotSupportedException ex) { } catch (Exception ex) { } } } if (countPin > 6) { pin = pin.Substring(0, 5); HintColorChange(pin.Length); } } }
public async void InputPinMethod(string value) { WarningText = ""; WarningVisible = false; if (value == "Delete") { if (pin.Length > 0) { pin = pin.Remove(pin.Length - 1); int countPin = pin.Length; HintColorChange(countPin); } } else { bool isExistvalue = Unities.CheckDigitaAndLength(value, 1); if (!isExistvalue) { WarningText = "ค่าที่ใส่ไม่ใช่ตัวเลข"; WarningVisible = true; try { Vibration.Vibrate(); var duration = TimeSpan.FromSeconds(1); Vibration.Vibrate(duration); } catch (FeatureNotSupportedException ex) { } catch (Exception ex) { } } pin += value; int countPin = pin.Length; HintColorChange(countPin); if (countPin == 6) { if (oldPin != "" && newPin != "") { repeatNewPin = pin; if (newPin == repeatNewPin) { var updateData = await _pinService.UpdatePin(newPin, oldPin, email); if (updateData != null && !updateData.IsError) { await PopupNavigation.Instance.PushAsync(new ChangePasswordSuccess()); await Application.Current.MainPage.Navigation.PopAsync(); } } else { pin = ""; countPin = pin.Length; HintColorChange(countPin); WarningText = "รหัสผ่านทั้ง 2 ครั้งไม่ตรงกัน"; WarningVisible = true; try { Vibration.Vibrate(); var duration = TimeSpan.FromSeconds(1); Vibration.Vibrate(duration); } catch (FeatureNotSupportedException ex) { } catch (Exception ex) { } } } else if (oldPin != "") { ChangeDataRepeatNewPin(); } else { var loginPinData = await _pinService.LoginByPin(pin, email); if (loginPinData != null && !loginPinData.IsError && loginPinData.Model != null) { if (loginPinData.Model.IsLogin) { await SecureStorage.SetAsync("CountLogin", "0"); ChangeDataNewPin(); } else { pin = ""; countPin = pin.Length; HintColorChange(countPin); WarningText = "รหัสผ่านไม่ถูกต้อง"; WarningVisible = true; try { Vibration.Vibrate(); var duration = TimeSpan.FromSeconds(1); Vibration.Vibrate(duration); } catch (FeatureNotSupportedException ex) { } catch (Exception ex) { } countLogin++; await SecureStorage.SetAsync("CountLogin", countLogin.ToString()); if (countLogin >= 5) { ForceLogout(); } } } else { pin = ""; countPin = pin.Length; HintColorChange(countPin); WarningText = "ไม่สามารถเชื่อมต่อได้"; WarningVisible = true; try { Vibration.Vibrate(); var duration = TimeSpan.FromSeconds(1); Vibration.Vibrate(duration); } catch (FeatureNotSupportedException ex) { } catch (Exception ex) { } } } } if (countPin > 6) { pin = pin.Substring(0, 5); } } }
public async void CheckOtp(string value) { WarningText = ""; WarningVisible = false; if (value == "Delete") { if (pin.Length > 0) { pin = pin.Remove(pin.Length - 1); int countPin = pin.Length; HintColorChange(countPin); } } else { bool isExistvalue = Unities.CheckDigitaAndLength(value, 1); if (!isExistvalue) { WarningText = "ค่าที่ใส่ไม่ใช่ตัวเลข"; WarningVisible = true; try { Vibration.Vibrate(); var duration = TimeSpan.FromSeconds(1); Vibration.Vibrate(duration); } catch (FeatureNotSupportedException ex) { } catch (Exception ex) { } } pin += value; int countPin = pin.Length; HintColorChange(countPin); if (countPin == 6) { var checkOtpData = await _authService.CheckOtp(email, pin, reference); if (checkOtpData != null && !checkOtpData.IsError) { if (checkOtpData.Model != null && checkOtpData.Model.IsValidateOtp) { if (checkProcess == Status.LastPage.Login) { SetPinForAuthViewModel setPinForAuth = new SetPinForAuthViewModel(email); await Application.Current.MainPage.Navigation.PushAsync(new PinPage(setPinForAuth)); } else if (checkProcess == Status.LastPage.Register) { await Application.Current.MainPage.Navigation.PushAsync(new RegisterPage()); } else { await Application.Current.MainPage.Navigation.PopToRootAsync(); } } else { pin = ""; countPin = pin.Length; HintColorChange(countPin); WarningText = "OTP ไม่ถูกต้องหรือหมดอายุ"; WarningVisible = true; try { Vibration.Vibrate(); var duration = TimeSpan.FromSeconds(1); Vibration.Vibrate(duration); } catch (FeatureNotSupportedException ex) { } catch (Exception ex) { } } } else { pin = ""; countPin = pin.Length; HintColorChange(countPin); WarningText = "ไม่สามารถเชื่อมต่อได้"; WarningVisible = true; try { Vibration.Vibrate(); var duration = TimeSpan.FromSeconds(1); Vibration.Vibrate(duration); } catch (FeatureNotSupportedException ex) { } catch (Exception ex) { } } } if (countPin > 6) { pin = pin.Substring(0, 5); } } }
public async void InputPinMethod(string value) { WarningText = ""; WarningVisible = false; if (value == "Delete") { if (pin.Length > 0) { pin = pin.Remove(pin.Length - 1); int countPin = pin.Length; HintColorChange(countPin); } } else { bool isExistvalue = Unities.CheckDigitaAndLength(value, 1); if (!isExistvalue) { WarningText = "ค่าที่ใส่ไม่ใช่ตัวเลข"; WarningVisible = true; try { Vibration.Vibrate(); var duration = TimeSpan.FromSeconds(1); Vibration.Vibrate(duration); } catch (FeatureNotSupportedException ex) { } catch (Exception ex) { } } pin += value; int countPin = pin.Length; HintColorChange(countPin); if (countPin == 6) { if (lastPage == Status.LastPage.Login) { if (repeatPin == "") { ChangeDataJoint(); } else { if (pin == repeatPin) { await Login(); } else { pin = ""; countPin = pin.Length; HintColorChange(countPin); WarningText = "รหัสผ่านทั้ง 2 ครั้งไม่ตรงกัน"; WarningVisible = true; try { Vibration.Vibrate(); var duration = TimeSpan.FromSeconds(1); Vibration.Vibrate(duration); } catch (FeatureNotSupportedException ex) { } catch (Exception ex) { } } } } else if (lastPage == Status.LastPage.Register) { if (repeatPin == "") { ChangeDataJoint(); } else { if (pin == repeatPin) { register.Pin = pin; await Register(); } else { pin = ""; countPin = pin.Length; HintColorChange(countPin); WarningText = "รหัสผ่านทั้ง 2 ครั้งไม่ตรงกัน"; WarningVisible = true; try { Vibration.Vibrate(); var duration = TimeSpan.FromSeconds(1); Vibration.Vibrate(duration); } catch (FeatureNotSupportedException ex) { } catch (Exception ex) { } } } } else { await Application.Current.MainPage.Navigation.PopToRootAsync(); } } if (countPin > 6) { pin = pin.Substring(0, 5); } } }