From 5ff65fc1a1a019fac11c69062a9c5fc093cd93d3 Mon Sep 17 00:00:00 2001 From: Elham Rababah Date: Mon, 8 Jun 2020 11:47:20 +0300 Subject: [PATCH] improve login form --- lib/widgets/auth/login_form.dart | 12 ++-- lib/widgets/auth/verfiy_account.dart | 90 +++++++++++++++++----------- 2 files changed, 62 insertions(+), 40 deletions(-) diff --git a/lib/widgets/auth/login_form.dart b/lib/widgets/auth/login_form.dart index ccee038f..b93bfafa 100644 --- a/lib/widgets/auth/login_form.dart +++ b/lib/widgets/auth/login_form.dart @@ -23,6 +23,7 @@ Helpers helpers = Helpers(); class LoginForm extends StatefulWidget with DrAppToastMsg { LoginForm({this.changeLoadingStata}); + final Function changeLoadingStata; @override @@ -85,7 +86,7 @@ class _LoginFormState extends State { return null; }, onSaved: (value) { - userInfo.UserID = value; + userInfo.UserID = value.trim(); }, onFieldSubmitted: (_) { FocusScope.of(context).requestFocus(focusPass); @@ -184,9 +185,9 @@ class _LoginFormState extends State { ); } -/* - *@author: Elham Rababah - *@Date:20/4/2020 +/* + *@author: Elham Rababah + *@Date:20/4/2020 *@param: context, hint, asset *@return: InputDecoration *@desc: decorate input feilds @@ -337,6 +338,7 @@ class _LoginFormState extends State { userInfo.ProjectID = projectsList[index]["ID"]; projectIdController.text = projectsList[index]['Name']; }); - FocusScope.of(context).requestFocus(focusProject); + + primaryFocus.unfocus(); } } diff --git a/lib/widgets/auth/verfiy_account.dart b/lib/widgets/auth/verfiy_account.dart index 0ebbeab4..9a4ad85c 100644 --- a/lib/widgets/auth/verfiy_account.dart +++ b/lib/widgets/auth/verfiy_account.dart @@ -21,7 +21,9 @@ Helpers helpers = Helpers(); class VerifyAccount extends StatefulWidget { VerifyAccount({this.changeLoadingStata}); + final Function changeLoadingStata; + @override _VerifyAccountState createState() => _VerifyAccountState(); } @@ -37,8 +39,9 @@ class _VerifyAccountState extends State { Future _loggedUserFuture; var _loggedUser; AuthProvider authProv; - bool _isInit =true; + bool _isInit = true; var model; + @override void initState() { super.initState(); @@ -93,25 +96,30 @@ class _VerifyAccountState extends State { MainAxisAlignment.spaceAround, children: [ Container( - width: SizeConfig.realScreenWidth * 0.20, - child: TextFormField( - textInputAction: TextInputAction.next, - style: buildTextStyle(), - maxLength: 1, - textAlign: TextAlign.center, - keyboardType: TextInputType.number, - decoration: - buildInputDecoration(context), - onSaved: (val) { - verifyAccountFormValue['digit1'] = - val; - }, - validator: validateCodeDigit, - onFieldSubmitted: (_) { + width: SizeConfig.realScreenWidth * 0.20, + child: TextFormField( + textInputAction: TextInputAction.next, + style: buildTextStyle(), + maxLength: 1, + textAlign: TextAlign.center, + keyboardType: TextInputType.number, + decoration: buildInputDecoration(context), + onSaved: (val) { + verifyAccountFormValue['digit1'] = val; + }, + validator: validateCodeDigit, + onFieldSubmitted: (_) { + FocusScope.of(context) + .requestFocus(focusD2); + }, + onChanged: (val) { + if (val.length == 1) { FocusScope.of(context) .requestFocus(focusD2); - }, - )), + } + }, + ), + ), Container( width: SizeConfig.realScreenWidth * 0.20, child: TextFormField( @@ -131,6 +139,12 @@ class _VerifyAccountState extends State { FocusScope.of(context) .requestFocus(focusD3); }, + onChanged: (val) { + if (val.length == 1) { + FocusScope.of(context) + .requestFocus(focusD3); + } + }, validator: validateCodeDigit), ), Container( @@ -152,6 +166,12 @@ class _VerifyAccountState extends State { FocusScope.of(context) .requestFocus(focusD4); }, + onChanged: (val) { + if (val.length == 1) { + FocusScope.of(context) + .requestFocus(focusD4); + } + }, validator: validateCodeDigit)), Container( width: SizeConfig.realScreenWidth * 0.20, @@ -214,10 +234,10 @@ class _VerifyAccountState extends State { }); } -/* - *@author: Elham Rababah - *@Date:19/4/2020 - *@param: +/* + *@author: Elham Rababah + *@Date:19/4/2020 + *@param: *@return: *@desc: change the style for the input field */ @@ -234,9 +254,9 @@ class _VerifyAccountState extends State { return null; } -/* - *@author: Elham Rababah - *@Date:28/4/2020 +/* + *@author: Elham Rababah + *@Date:28/4/2020 *@param: context *@return:InputDecoration *@desc: buildInputDecoration @@ -255,10 +275,10 @@ class _VerifyAccountState extends State { )); } -/* - *@author: Elham Rababah - *@Date:28/4/2020 - *@param: +/* + *@author: Elham Rababah + *@Date:28/4/2020 + *@param: *@return: RichText *@desc: buildText */ @@ -283,9 +303,9 @@ class _VerifyAccountState extends State { ); } -/* - *@author: Elham Rababah - *@Date:15/4/2020 +/* + *@author: Elham Rababah + *@Date:15/4/2020 *@param: authProv *@return: *@desc: verify Account func call sendActivationCodeByOtpNotificationType service @@ -349,8 +369,8 @@ class _VerifyAccountState extends State { } } - /* - *@author: Elham Rababah + /* + *@author: Elham Rababah *@Date:17/5/2020 *@param: Map profile, Function changeLoadingStata *@return: @@ -385,7 +405,7 @@ class _VerifyAccountState extends State { }); } - /* + /* *@author: Elham Rababah *@Date:17/5/2020 *@param: ClinicModel clinicInfo, Function changeLoadingStata